FreeBSD/sys/dev/drm2/radeon/r600.c
/**
 * r600_vram_gtt_location - try to find VRAM & GTT location
 * @rdev: radeon device structure holding all necessary informations
 * @mc: memory controller structure holding memory informations
 *
 * Function will place try to place VRAM at same place as in CPU (PCI)
 * address space as some GPU seems to have issue when we reprogram at
 * different address space.
 *
 * If there is not enough space to fit the unvisible VRAM after the
 * aperture then we limit the VRAM size to the aperture.
 *
 * If we are using AGP then place VRAM adjacent to AGP aperture are we need
 * them to be in one from GPU point of view so that we can program GPU to
 * catch access outside them (weird GPU policy see ??).
 *
 * This function will never fails, worst case are limiting VRAM or GTT.
 *
 * Note: GTT start, end, size should be initialized before calling this
 * function on AGP platform.
 */
try to find VRAM & GTT location
@rdev: radeon device structure holding all necessary informations
@mc: memory controller structure holding memory informations

Function will place try to place VRAM at same place as in CPU (PCI)
address space as some GPU seems to have issue when we reprogram at
different address space.

If there is not enough space to fit the unvisible VRAM after the
aperture then we limit the VRAM size to the aperture.

If we are using AGP then place VRAM adjacent to AGP aperture are we need
them to be in one from GPU point of view so that we can program GPU to
catch access outside them (weird GPU policy see ??).

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

GTT start, end, size should be initialized before calling this
function on AGP platform.
try to find VRAM & GTT location @rdev : radeon device structure holding all necessary informations @mc : memory controller structure holding memory informations Function will place try to place VRAM at same place as in CPU ( PCI ) address space as some GPU seems to have issue when we reprogram at different address space . If there is not enough space to fit the unvisible VRAM after the aperture then we limit the VRAM size to the aperture . If we are using AGP then place VRAM adjacent to AGP aperture are we need them to be in one from GPU point of view so that we can program GPU to catch access outside them ( weird GPU policy see ?? ) . This function will never fails worst case are limiting VRAM or GTT . GTT start end size should be initialized before calling this function on AGP platform .
static void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
{
	u64 size_bf, size_af;
	if (mc->mc_vram_size > 0xE0000000) {
		dev_warn(rdev->dev, "limiting VRAM\n");
		mc->real_vram_size = 0xE0000000;
		mc->mc_vram_size = 0xE0000000;
	}
	if (rdev->flags & RADEON_IS_AGP) {
		size_bf = mc->gtt_start;
		size_af = 0xFFFFFFFF - mc->gtt_end;
		if (size_bf > size_af) {
			if (mc->mc_vram_size > size_bf) {
				dev_warn(rdev->dev, "limiting VRAM\n");
				mc->real_vram_size = size_bf;
				mc->mc_vram_size = size_bf;
			}
			mc->vram_start = mc->gtt_start - mc->mc_vram_size;
		} else {
			if (mc->mc_vram_size > size_af) {
				dev_warn(rdev->dev, "limiting VRAM\n");
				mc->real_vram_size = size_af;
				mc->mc_vram_size = size_af;
			}
			mc->vram_start = mc->gtt_end + 1;
		}
		mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
		dev_info(rdev->dev, "VRAM: %juM 0x%08jX - 0x%08jX (%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);
	} else {
		u64 base = 0;
		if (rdev->flags & RADEON_IS_IGP) {
			base = RREG32(MC_VM_FB_LOCATION) & 0xFFFF;
			base <<= 24;
		}
		radeon_vram_location(rdev, &rdev->mc, base);
		rdev->mc.gtt_base_align = 0;
		radeon_gtt_location(rdev, mc);
	}
}
static void r600_vram_gtt_location ( struct radeon_device * rdev , struct radeon_mc * mc ) { u64 size_bf , size_af ; if ( mc -> mc_vram_size > 0xE0000000 ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> real_vram_size = 0xE0000000 ; mc -> mc_vram_size = 0xE0000000 ; } if ( rdev -> flags & RADEON_IS_AGP ) { size_bf = mc -> gtt_start ; size_af = 0xFFFFFFFF - mc -> gtt_end ; if ( size_bf > size_af ) { if ( mc -> mc_vram_size > size_bf ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> real_vram_size = size_bf ; mc -> mc_vram_size = size_bf ; } mc -> vram_start = mc -> gtt_start - mc -> mc_vram_size ; } else { if ( mc -> mc_vram_size > size_af ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> real_vram_size = size_af ; mc -> mc_vram_size = size_af ; } mc -> vram_start = mc -> gtt_end + 1 ; } mc -> vram_end = mc -> vram_start + mc -> mc_vram_size - 1 ; 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 ) ; } else { u64 base = 0 ; if ( rdev -> flags & RADEON_IS_IGP ) { base = RREG32 ( MC_VM_FB_LOCATION ) & 0xFFFF ; base <<= 24 ; } radeon_vram_location ( rdev , & rdev -> mc , base ) ; rdev -> mc . gtt_base_align = 0 ; radeon_gtt_location ( rdev , mc ) ; } }
r600_vram_gtt_location - try to find VRAM & GTT location
 @rdev: radeon device structure holding all necessary informations
 @mc: memory controller structure holding memory informations
r600_vram_gtt_location - try to find VRAM & GTT location @rdev : radeon device structure holding all necessary informations @mc : memory controller structure holding memory informations
/* leave room for at least 512M GTT */