[PATCH] drm/i915: use unsigned long for platform_mask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No reason to stick to u32 for platform mask if we can just use more bits
on 64 bit platforms.

$ size drivers/gpu/drm/i915/i915.ko*
   text	   data	    bss	    dec	    hex	filename
1884779	  41334	   5408	1931521	 1d7901	drivers/gpu/drm/i915/i915.ko
1886693	  41358	   5408	1933459	 1d8093	drivers/gpu/drm/i915/i915.ko.old

Now on 64 bits we have only one long as opposed to 2 u32:

$ pahole -C intel_runtime_info drivers/gpu/drm/i915/i915.ko
struct intel_runtime_info {
	long unsigned int          platform_mask[1];     /*     0     8 */
...
}

On 32 bits we still have the same thing as before:
$ size drivers/gpu/drm/i915/i915.ko*
   text	   data	    bss	    dec	    hex	filename
1489839	  32485	   2816	1525140	 174594	drivers/gpu/drm/i915/i915.ko
1489839	  32485	   2816	1525140	 174594	drivers/gpu/drm/i915/i915.ko.old

Besides reducing the code on x86-64 now the array size is automatically
calculated and we don't have to worry about extending it anymore.

Signed-off-by: Lucas De Marchi <lucas.demarchi@xxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_drv.h          | 4 ----
 drivers/gpu/drm/i915/intel_device_info.h | 8 ++++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0ab4826921f7..7845a825e810 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2309,10 +2309,6 @@ __platform_mask_index(const struct intel_runtime_info *info,
 	const unsigned int pbits =
 		BITS_PER_TYPE(info->platform_mask[0]) - INTEL_SUBPLATFORM_BITS;
 
-	/* Expand the platform_mask array if this fails. */
-	BUILD_BUG_ON(INTEL_MAX_PLATFORMS >
-		     pbits * ARRAY_SIZE(info->platform_mask));
-
 	return p / pbits;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_device_info.h b/drivers/gpu/drm/i915/intel_device_info.h
index 0e579f158016..637d97e8314e 100644
--- a/drivers/gpu/drm/i915/intel_device_info.h
+++ b/drivers/gpu/drm/i915/intel_device_info.h
@@ -214,11 +214,11 @@ struct intel_runtime_info {
 	 * Platform mask is used for optimizing or-ed IS_PLATFORM calls into
 	 * into single runtime conditionals, and also to provide groundwork
 	 * for future per platform, or per SKU build optimizations.
-	 *
-	 * Array can be extended when necessary if the corresponding
-	 * BUILD_BUG_ON is hit.
 	 */
-	u32 platform_mask[2];
+	unsigned long platform_mask[
+		DIV_ROUND_UP(INTEL_MAX_PLATFORMS,
+			     BITS_PER_TYPE(unsigned long)
+			     - INTEL_SUBPLATFORM_BITS)];
 
 	u16 device_id;
 
-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux