FreeBSD/sys/dev/drm2/radeon/radeon_device.c
/**
 * radeon_vram_location - try to find VRAM location
 * @rdev: radeon device structure holding all necessary informations
 * @mc: memory controller structure holding memory informations
 * @base: base address at which to put VRAM
 *
 * Function will place try to place VRAM at base address provided
 * as parameter (which is so far either PCI aperture address or
 * for IGP TOM base address).
 *
 * If there is not enough space to fit the unvisible VRAM in the 32bits
 * address space then we limit the VRAM size to the aperture.
 *
 * If we are using AGP and if the AGP aperture doesn't allow us to have
 * room for all the VRAM than we restrict the VRAM to the PCI aperture
 * size and print a warning.
 *
 * This function will never fails, worst case are limiting VRAM.
 *
 * Note: GTT start, end, size should be initialized before calling this
 * function on AGP platform.
 *
 * Note: We don't explicitly enforce VRAM start to be aligned on VRAM size,
 * this shouldn't be a problem as we are using the PCI aperture as a reference.
 * Otherwise this would be needed for rv280, all r3xx, and all r4xx, but
 * not IGP.
 *
 * Note: we use mc_vram_size as on some board we need to program the mc to
 * cover the whole aperture even if VRAM size is inferior to aperture size
 * Novell bug 204882 + along with lots of ubuntu ones
 *
 * Note: when limiting vram it's safe to overwritte real_vram_size because
 * we are not in case where real_vram_size is inferior to mc_vram_size (ie
 * note afected by bogus hw of Novell bug 204882 + along with lots of ubuntu
 * ones)
 *
 * Note: IGP TOM addr should be the same as the aperture addr, we don't
 * explicitly check for that thought.
 *
 * FIXME: when reducing VRAM size align new size on power of 2.
 */
try to find VRAM location
@rdev: radeon device structure holding all necessary informations
@mc: memory controller structure holding memory informations
@base: base address at which to put VRAM

Function will place try to place VRAM at base address provided
as parameter (which is so far either PCI aperture address or
for IGP TOM base address).

If there is not enough space to fit the unvisible VRAM in the 32bits
address space then we limit the VRAM size to the aperture.

If we are using AGP and if the AGP aperture doesn't allow us to have
room for all the VRAM than we restrict the VRAM to the PCI aperture
size and print a warning.

This function will never fails, worst case are limiting VRAM.

GTT start, end, size should be initialized before calling this
function on AGP platform.

We don't explicitly enforce VRAM start to be aligned on VRAM size,
this shouldn't be a problem as we are using the PCI aperture as a reference.
Otherwise this would be needed for rv280, all r3xx, and all r4xx, but
not IGP.

we use mc_vram_size as on some board we need to program the mc to
cover the whole aperture even if VRAM size is inferior to aperture size
Novell bug 204882 + along with lots of ubuntu ones

when limiting vram it's safe to overwritte real_vram_size because
we are not in case where real_vram_size is inferior to mc_vram_size

IGP TOM addr should be the same as the aperture addr, we don't
explicitly check for that thought.

when reducing VRAM size align new size on power of 2.
try to find VRAM location @rdev : radeon device structure holding all necessary informations @mc : memory controller structure holding memory informations @base : base address at which to put VRAM Function will place try to place VRAM at base address provided as parameter ( which is so far either PCI aperture address or for IGP TOM base address ) . If there is not enough space to fit the unvisible VRAM in the 32bits address space then we limit the VRAM size to the aperture . If we are using AGP and if the AGP aperture doesn ' t allow us to have room for all the VRAM than we restrict the VRAM to the PCI aperture size and print a warning . This function will never fails worst case are limiting VRAM . GTT start end size should be initialized before calling this function on AGP platform . We don ' t explicitly enforce VRAM start to be aligned on VRAM size this shouldn ' t be a problem as we are using the PCI aperture as a reference . Otherwise this would be needed for rv280 all r3xx and all r4xx but not IGP . we use mc_vram_size as on some board we need to program the mc to cover the whole aperture even if VRAM size is inferior to aperture size Novell bug 204882 + along with lots of ubuntu ones when limiting vram it ' s safe to overwritte real_vram_size because we are not in case where real_vram_size is inferior to mc_vram_size IGP TOM addr should be the same as the aperture addr we don ' t explicitly check for that thought . when reducing VRAM size align new size on power of 2 .
void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base)
{
	uint64_t limit = (uint64_t)radeon_vram_limit << 20;
	mc->vram_start = base;
	if (mc->mc_vram_size > (0xFFFFFFFF - base + 1)) {
		dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n");
		mc->real_vram_size = mc->aper_size;
		mc->mc_vram_size = mc->aper_size;
	}
	mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
	if (rdev->flags & RADEON_IS_AGP && mc->vram_end > mc->gtt_start && mc->vram_start <= mc->gtt_end) {
		dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n");
		mc->real_vram_size = mc->aper_size;
		mc->mc_vram_size = mc->aper_size;
	}
	mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
	if (limit && limit < mc->real_vram_size)
		mc->real_vram_size = limit;
	dev_info(rdev->dev, "VRAM: %juM 0x%016jX - 0x%016jX (%juM used)\n",
			(uintmax_t)mc->mc_vram_size >> 20, (uintmax_t)mc->vram_start,
			(uintmax_t)mc->vram_end, (uintmax_t)mc->real_vram_size >> 20);
}
void radeon_vram_location ( struct radeon_device * rdev , struct radeon_mc * mc , u64 base ) { uint64_t limit = ( uint64_t ) radeon_vram_limit << 20 ; mc -> vram_start = base ; if ( mc -> mc_vram_size > ( 0xFFFFFFFF - base + 1 ) ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> real_vram_size = mc -> aper_size ; mc -> mc_vram_size = mc -> aper_size ; } mc -> vram_end = mc -> vram_start + mc -> mc_vram_size - 1 ; if ( rdev -> flags & RADEON_IS_AGP && mc -> vram_end > mc -> gtt_start && mc -> vram_start <= mc -> gtt_end ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> real_vram_size = mc -> aper_size ; mc -> mc_vram_size = mc -> aper_size ; } mc -> vram_end = mc -> vram_start + mc -> mc_vram_size - 1 ; if ( limit && limit < mc -> real_vram_size ) mc -> real_vram_size = limit ; dev_info ( rdev -> dev , " \n " , ( uintmax_t ) mc -> mc_vram_size >> 20 , ( uintmax_t ) mc -> vram_start , ( uintmax_t ) mc -> vram_end , ( uintmax_t ) mc -> real_vram_size >> 20 ) ; }
radeon_vram_location - try to find VRAM location
 @rdev: radeon device structure holding all necessary informations
 @mc: memory controller structure holding memory informations
 @base: base address at which to put VRAM
radeon_vram_location - try to find VRAM location @rdev : radeon device structure holding all necessary informations @mc : memory controller structure holding memory informations @base : base address at which to put VRAM