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

drm/i915: Use fixed-sized types for stolen

Stolen memory is a hardware resource of known size, so use an accurate
fixed integer type rather than the ambiguous variable size_t. This was
motivated by the next patch spotting inconsistencies in our types.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170106152013.24684-3-chris@chris-wilson.co.uk

+30 -23
+4 -2
drivers/char/agp/intel-gtt.c
··· 1420 1420 } 1421 1421 EXPORT_SYMBOL(intel_gmch_probe); 1422 1422 1423 - void intel_gtt_get(u64 *gtt_total, size_t *stolen_size, 1424 - phys_addr_t *mappable_base, u64 *mappable_end) 1423 + void intel_gtt_get(u64 *gtt_total, 1424 + u32 *stolen_size, 1425 + phys_addr_t *mappable_base, 1426 + u64 *mappable_end) 1425 1427 { 1426 1428 *gtt_total = intel_private.gtt_total_entries << PAGE_SHIFT; 1427 1429 *stolen_size = intel_private.stolen_size;
+5 -3
drivers/gpu/drm/i915/i915_gem_gtt.c
··· 3139 3139 return -EIO; 3140 3140 } 3141 3141 3142 - intel_gtt_get(&ggtt->base.total, &ggtt->stolen_size, 3143 - &ggtt->mappable_base, &ggtt->mappable_end); 3142 + intel_gtt_get(&ggtt->base.total, 3143 + &ggtt->stolen_size, 3144 + &ggtt->mappable_base, 3145 + &ggtt->mappable_end); 3144 3146 3145 3147 ggtt->do_idle_maps = needs_idle_maps(dev_priv); 3146 3148 ggtt->base.insert_page = i915_ggtt_insert_page; ··· 3207 3205 DRM_INFO("Memory usable by graphics device = %lluM\n", 3208 3206 ggtt->base.total >> 20); 3209 3207 DRM_DEBUG_DRIVER("GMADR size = %lldM\n", ggtt->mappable_end >> 20); 3210 - DRM_DEBUG_DRIVER("GTT stolen size = %zdM\n", ggtt->stolen_size >> 20); 3208 + DRM_DEBUG_DRIVER("GTT stolen size = %uM\n", ggtt->stolen_size >> 20); 3211 3209 #ifdef CONFIG_INTEL_IOMMU 3212 3210 if (intel_iommu_gfx_mapped) 3213 3211 DRM_INFO("VT-d active for gfx access\n");
+7 -6
drivers/gpu/drm/i915/i915_gem_gtt.h
··· 315 315 struct i915_address_space base; 316 316 struct io_mapping mappable; /* Mapping to our CPU mappable region */ 317 317 318 + phys_addr_t mappable_base; /* PA of our GMADR */ 319 + u64 mappable_end; /* End offset that we can CPU map */ 320 + 318 321 /* Stolen memory is segmented in hardware with different portions 319 322 * offlimits to certain functions. 320 323 * ··· 326 323 * avoid the first page! The upper end of stolen memory is reserved for 327 324 * hardware functions and similarly removed from the accessible range. 328 325 */ 329 - size_t stolen_size; /* Total size of stolen memory */ 330 - size_t stolen_usable_size; /* Total size minus reserved ranges */ 331 - size_t stolen_reserved_base; 332 - size_t stolen_reserved_size; 333 - u64 mappable_end; /* End offset that we can CPU map */ 334 - phys_addr_t mappable_base; /* PA of our GMADR */ 326 + u32 stolen_size; /* Total size of stolen memory */ 327 + u32 stolen_usable_size; /* Total size minus reserved ranges */ 328 + u32 stolen_reserved_base; 329 + u32 stolen_reserved_size; 335 330 336 331 /** "Graphics Stolen Memory" holds the global PTEs */ 337 332 void __iomem *gsm;
+10 -10
drivers/gpu/drm/i915/i915_gem_stolen.c
··· 281 281 } 282 282 283 283 static void g4x_get_stolen_reserved(struct drm_i915_private *dev_priv, 284 - phys_addr_t *base, unsigned long *size) 284 + phys_addr_t *base, u32 *size) 285 285 { 286 286 struct i915_ggtt *ggtt = &dev_priv->ggtt; 287 287 uint32_t reg_val = I915_READ(IS_GM45(dev_priv) ? ··· 304 304 } 305 305 306 306 static void gen6_get_stolen_reserved(struct drm_i915_private *dev_priv, 307 - phys_addr_t *base, unsigned long *size) 307 + phys_addr_t *base, u32 *size) 308 308 { 309 309 uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 310 310 ··· 330 330 } 331 331 332 332 static void gen7_get_stolen_reserved(struct drm_i915_private *dev_priv, 333 - phys_addr_t *base, unsigned long *size) 333 + phys_addr_t *base, u32 *size) 334 334 { 335 335 uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 336 336 ··· 350 350 } 351 351 352 352 static void chv_get_stolen_reserved(struct drm_i915_private *dev_priv, 353 - phys_addr_t *base, unsigned long *size) 353 + phys_addr_t *base, u32 *size) 354 354 { 355 355 uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); 356 356 ··· 376 376 } 377 377 378 378 static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv, 379 - phys_addr_t *base, unsigned long *size) 379 + phys_addr_t *base, u32 *size) 380 380 { 381 381 struct i915_ggtt *ggtt = &dev_priv->ggtt; 382 382 uint32_t reg_val = I915_READ(GEN6_STOLEN_RESERVED); ··· 400 400 { 401 401 struct i915_ggtt *ggtt = &dev_priv->ggtt; 402 402 phys_addr_t reserved_base, stolen_top; 403 - unsigned long reserved_total, reserved_size; 404 - unsigned long stolen_usable_start; 403 + u32 reserved_total, reserved_size; 404 + u32 stolen_usable_start; 405 405 406 406 mutex_init(&dev_priv->mm.stolen_lock); 407 407 ··· 478 478 * memory, so just consider the start. */ 479 479 reserved_total = stolen_top - reserved_base; 480 480 481 - DRM_DEBUG_KMS("Memory reserved for graphics device: %zuK, usable: %luK\n", 481 + DRM_DEBUG_KMS("Memory reserved for graphics device: %uK, usable: %uK\n", 482 482 ggtt->stolen_size >> 10, 483 483 (ggtt->stolen_size - reserved_total) >> 10); 484 484 ··· 487 487 if (INTEL_GEN(dev_priv) >= 8) 488 488 stolen_usable_start = 4096; 489 489 490 - ggtt->stolen_usable_size = ggtt->stolen_size - reserved_total - 491 - stolen_usable_start; 490 + ggtt->stolen_usable_size = 491 + ggtt->stolen_size - reserved_total - stolen_usable_start; 492 492 493 493 /* Basic memrange allocator for stolen space. */ 494 494 drm_mm_init(&dev_priv->mm.stolen, stolen_usable_start,
+4 -2
include/drm/intel-gtt.h
··· 3 3 #ifndef _DRM_INTEL_GTT_H 4 4 #define _DRM_INTEL_GTT_H 5 5 6 - void intel_gtt_get(u64 *gtt_total, size_t *stolen_size, 7 - phys_addr_t *mappable_base, u64 *mappable_end); 6 + void intel_gtt_get(u64 *gtt_total, 7 + u32 *stolen_size, 8 + phys_addr_t *mappable_base, 9 + u64 *mappable_end); 8 10 9 11 int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, 10 12 struct agp_bridge_data *bridge);