[Intel-gfx] [PATCH 1/2] drm/i915: Canonicalize stolen memory calculations

Chris Wilson chris at chris-wilson.co.uk
Fri Apr 22 11:48:19 UTC 2016


On Fri, Apr 22, 2016 at 02:25:06PM +0300, Joonas Lahtinen wrote:
> Move the better constructs/comments from i915_gem_stolen.c to
> early-quirks.c and increase readability in preparation of only
> having one set of functions.
> 
> - intel_stolen_base -> gen3_stolen_base
> - use phys_addr_t instead of u32 for address for future proofing
> 
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala at intel.com>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at linux.intel.com>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>

Looks like a fairly mechanical change, so
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

>  static size_t __init i830_stolen_size(int num, int slot, int func)
>  {
> -	size_t stolen_size;
>  	u16 gmch_ctrl;
> +	u16 gms;
>  
>  	gmch_ctrl = read_pci_config_16(0, 0, 0, I830_GMCH_CTRL);
> -
> -	switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
> -	case I830_GMCH_GMS_STOLEN_512:
> -		stolen_size = KB(512);
> -		break;
> -	case I830_GMCH_GMS_STOLEN_1024:
> -		stolen_size = MB(1);
> -		break;
> -	case I830_GMCH_GMS_STOLEN_8192:
> -		stolen_size = MB(8);
> -		break;
> -	case I830_GMCH_GMS_LOCAL:
> -		/* local memory isn't part of the normal address space */
> -		stolen_size = 0;
> -		break;
> +	gms = gmch_ctrl & I830_GMCH_GMS_MASK;
> +
> +	switch (gms) {
> +	case I830_GMCH_GMS_STOLEN_512:	return KB(512);
> +	case I830_GMCH_GMS_STOLEN_1024:	return MB(1);
> +	case I830_GMCH_GMS_STOLEN_8192:	return MB(8);
> +	/* local memory isn't part of the normal address space */
> +	case I830_GMCH_GMS_LOCAL:	return 0;
>  	default:
> -		return 0;
> +		WARN(1, "Unknown register value!\n");

When adding a warn try to include the pertinent information:

WARN(1, "Unknown I830_GMCH_CTRL value: %x!\n", gms);
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list