FreeBSD/sys/dev/drm2/radeon/radeon_device.c
/**
 * radeon_gtt_location - try to find GTT location
 * @rdev: radeon device structure holding all necessary informations
 * @mc: memory controller structure holding memory informations
 *
 * Function will place try to place GTT before or after VRAM.
 *
 * If GTT size is bigger than space left then we ajust GTT size.
 * Thus function will never fails.
 *
 * FIXME: when reducing GTT size align new size on power of 2.
 */
try to find GTT location
@rdev: radeon device structure holding all necessary informations
@mc: memory controller structure holding memory informations

Function will place try to place GTT before or after VRAM.

If GTT size is bigger than space left then we ajust GTT size.
Thus function will never fails.

when reducing GTT size align new size on power of 2.
try to find GTT location @rdev : radeon device structure holding all necessary informations @mc : memory controller structure holding memory informations Function will place try to place GTT before or after VRAM . If GTT size is bigger than space left then we ajust GTT size . Thus function will never fails . when reducing GTT size align new size on power of 2 .
void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
{
	u64 size_af, size_bf;
	size_af = ((0xFFFFFFFF - mc->vram_end) + mc->gtt_base_align) & ~mc->gtt_base_align;
	size_bf = mc->vram_start & ~mc->gtt_base_align;
	if (size_bf > size_af) {
		if (mc->gtt_size > size_bf) {
			dev_warn(rdev->dev, "limiting GTT\n");
			mc->gtt_size = size_bf;
		}
		mc->gtt_start = (mc->vram_start & ~mc->gtt_base_align) - mc->gtt_size;
	} else {
		if (mc->gtt_size > size_af) {
			dev_warn(rdev->dev, "limiting GTT\n");
			mc->gtt_size = size_af;
		}
		mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align;
	}
	mc->gtt_end = mc->gtt_start + mc->gtt_size - 1;
	dev_info(rdev->dev, "GTT: %juM 0x%016jX - 0x%016jX\n",
			(uintmax_t)mc->gtt_size >> 20, (uintmax_t)mc->gtt_start, (uintmax_t)mc->gtt_end);
}
void radeon_gtt_location ( struct radeon_device * rdev , struct radeon_mc * mc ) { u64 size_af , size_bf ; size_af = ( ( 0xFFFFFFFF - mc -> vram_end ) + mc -> gtt_base_align ) & ~ mc -> gtt_base_align ; size_bf = mc -> vram_start & ~ mc -> gtt_base_align ; if ( size_bf > size_af ) { if ( mc -> gtt_size > size_bf ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> gtt_size = size_bf ; } mc -> gtt_start = ( mc -> vram_start & ~ mc -> gtt_base_align ) - mc -> gtt_size ; } else { if ( mc -> gtt_size > size_af ) { dev_warn ( rdev -> dev , " \n " ) ; mc -> gtt_size = size_af ; } mc -> gtt_start = ( mc -> vram_end + 1 + mc -> gtt_base_align ) & ~ mc -> gtt_base_align ; } mc -> gtt_end = mc -> gtt_start + mc -> gtt_size - 1 ; dev_info ( rdev -> dev , " \n " , ( uintmax_t ) mc -> gtt_size >> 20 , ( uintmax_t ) mc -> gtt_start , ( uintmax_t ) mc -> gtt_end ) ; }
radeon_gtt_location - try to find GTT location
 @rdev: radeon device structure holding all necessary informations
 @mc: memory controller structure holding memory informations
radeon_gtt_location - try to find GTT location @rdev : radeon device structure holding all necessary informations @mc : memory controller structure holding memory informations