Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: give stolen_usable_size a more suitable home

Kick it out of i915_ggtt and keep it grouped with dsm and dsm_reserved,
where it makes the most sense.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171211151822.20953-9-matthew.auld@intel.com

authored by

Matthew Auld and committed by
Joonas Lahtinen
b1ace601 73ebd503

+16 -18
+12 -1
drivers/gpu/drm/i915/i915_drv.h
··· 2254 2254 /** 2255 2255 * Data Stolen Memory - aka "i915 stolen memory" gives us the start and 2256 2256 * end of stolen which we can optionally use to create GEM objects 2257 - * backed by stolen memory. Note that ggtt->stolen_usable_size tells us 2257 + * backed by stolen memory. Note that stolen_usable_size tells us 2258 2258 * exactly how much of this we are actually allowed to use, given that 2259 2259 * some portion of it is in fact reserved for use by hardware functions. 2260 2260 */ ··· 2263 2263 * Reseved portion of Data Stolen Memory 2264 2264 */ 2265 2265 struct resource dsm_reserved; 2266 + 2267 + /* 2268 + * Stolen memory is segmented in hardware with different portions 2269 + * offlimits to certain functions. 2270 + * 2271 + * The drm_mm is initialised to the total accessible range, as found 2272 + * from the PCI config. On Broadwell+, this is further restricted to 2273 + * avoid the first page! The upper end of stolen memory is reserved for 2274 + * hardware functions and similarly removed from the accessible range. 2275 + */ 2276 + u32 stolen_usable_size; /* Total size minus reserved ranges */ 2266 2277 2267 2278 void __iomem *regs; 2268 2279
-10
drivers/gpu/drm/i915/i915_gem_gtt.h
··· 373 373 struct resource gmadr; /* GMADR resource */ 374 374 u64 mappable_end; /* End offset that we can CPU map */ 375 375 376 - /* Stolen memory is segmented in hardware with different portions 377 - * offlimits to certain functions. 378 - * 379 - * The drm_mm is initialised to the total accessible range, as found 380 - * from the PCI config. On Broadwell+, this is further restricted to 381 - * avoid the first page! The upper end of stolen memory is reserved for 382 - * hardware functions and similarly removed from the accessible range. 383 - */ 384 - u32 stolen_usable_size; /* Total size minus reserved ranges */ 385 - 386 376 /** "Graphics Stolen Memory" holds the global PTEs */ 387 377 void __iomem *gsm; 388 378 void (*invalidate)(struct drm_i915_private *dev_priv);
+2 -3
drivers/gpu/drm/i915/i915_gem_stolen.c
··· 325 325 326 326 int i915_gem_init_stolen(struct drm_i915_private *dev_priv) 327 327 { 328 - struct i915_ggtt *ggtt = &dev_priv->ggtt; 329 328 dma_addr_t reserved_base, stolen_top; 330 329 u32 reserved_total, reserved_size; 331 330 u32 stolen_usable_start; ··· 415 416 if (INTEL_GEN(dev_priv) >= 8) 416 417 stolen_usable_start = 4096; 417 418 418 - ggtt->stolen_usable_size = 419 + dev_priv->stolen_usable_size = 419 420 resource_size(&dev_priv->dsm) - reserved_total - stolen_usable_start; 420 421 421 422 /* Basic memrange allocator for stolen space. */ 422 423 drm_mm_init(&dev_priv->mm.stolen, stolen_usable_start, 423 - ggtt->stolen_usable_size); 424 + dev_priv->stolen_usable_size); 424 425 425 426 return 0; 426 427 }
+1 -2
drivers/gpu/drm/i915/intel_display.c
··· 2639 2639 { 2640 2640 struct drm_device *dev = crtc->base.dev; 2641 2641 struct drm_i915_private *dev_priv = to_i915(dev); 2642 - struct i915_ggtt *ggtt = &dev_priv->ggtt; 2643 2642 struct drm_i915_gem_object *obj = NULL; 2644 2643 struct drm_mode_fb_cmd2 mode_cmd = { 0 }; 2645 2644 struct drm_framebuffer *fb = &plane_config->fb->base; ··· 2654 2655 /* If the FB is too big, just don't use it since fbdev is not very 2655 2656 * important and we should probably use that space with FBC or other 2656 2657 * features. */ 2657 - if (size_aligned * 2 > ggtt->stolen_usable_size) 2658 + if (size_aligned * 2 > dev_priv->stolen_usable_size) 2658 2659 return false; 2659 2660 2660 2661 mutex_lock(&dev->struct_mutex);
+1 -2
drivers/gpu/drm/i915/intel_fbdev.c
··· 115 115 struct drm_framebuffer *fb; 116 116 struct drm_device *dev = helper->dev; 117 117 struct drm_i915_private *dev_priv = to_i915(dev); 118 - struct i915_ggtt *ggtt = &dev_priv->ggtt; 119 118 struct drm_mode_fb_cmd2 mode_cmd = {}; 120 119 struct drm_i915_gem_object *obj; 121 120 int size, ret; ··· 138 139 * important and we should probably use that space with FBC or other 139 140 * features. */ 140 141 obj = NULL; 141 - if (size * 2 < ggtt->stolen_usable_size) 142 + if (size * 2 < dev_priv->stolen_usable_size) 142 143 obj = i915_gem_object_create_stolen(dev_priv, size); 143 144 if (obj == NULL) 144 145 obj = i915_gem_object_create(dev_priv, size);