diff mbox series

[3/7] drm/i915: Assert that device info bitmasks have enough bits

Message ID 20230511165534.10266-4-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Init DDI ports based on port_mask | expand

Commit Message

Ville Syrjälä May 11, 2023, 4:55 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Sprinkle in some BUILD_BUG_ON()s to make sure some of
the bitmasks used in the device info have enough bits.

Do we have a better place for this sort of stuff?

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_device_info.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Lucas De Marchi May 24, 2023, 3:48 p.m. UTC | #1
On Thu, May 11, 2023 at 07:55:30PM +0300, Ville Syrjälä wrote:
>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>Sprinkle in some BUILD_BUG_ON()s to make sure some of
>the bitmasks used in the device info have enough bits.
>
>Do we have a better place for this sort of stuff?

it's being moved to display/, so I'd say the intel_display_device_info.c
is a better place. What about using a static_assert() and leave them
near the top of the file?

Lucas De Marchi

>
>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>---
> drivers/gpu/drm/i915/intel_device_info.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
>index bb10e8e78a94..ce257446b712 100644
>--- a/drivers/gpu/drm/i915/intel_device_info.c
>+++ b/drivers/gpu/drm/i915/intel_device_info.c
>@@ -414,6 +414,10 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
> 	struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
> 	enum pipe pipe;
>
>+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->pipe_mask) < I915_MAX_PIPES);
>+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->cpu_transcoder_mask) < I915_MAX_TRANSCODERS);
>+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->port_mask) < I915_MAX_PORTS);
>+
> 	/* Wa_14011765242: adl-s A0,A1 */
> 	if (IS_ADLS_DISPLAY_STEP(dev_priv, STEP_A0, STEP_A2))
> 		for_each_pipe(dev_priv, pipe)
>-- 
>2.39.3
>
Jani Nikula May 25, 2023, 9:27 a.m. UTC | #2
On Wed, 24 May 2023, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
> On Thu, May 11, 2023 at 07:55:30PM +0300, Ville Syrjälä wrote:
>>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>
>>Sprinkle in some BUILD_BUG_ON()s to make sure some of
>>the bitmasks used in the device info have enough bits.
>>
>>Do we have a better place for this sort of stuff?
>
> it's being moved to display/, so I'd say the intel_display_device_info.c
> is a better place. What about using a static_assert() and leave them
> near the top of the file?

I'm afraid the whole series needs a rebase too.

BR,
Jani.

>
> Lucas De Marchi
>
>>
>>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>---
>> drivers/gpu/drm/i915/intel_device_info.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>>diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
>>index bb10e8e78a94..ce257446b712 100644
>>--- a/drivers/gpu/drm/i915/intel_device_info.c
>>+++ b/drivers/gpu/drm/i915/intel_device_info.c
>>@@ -414,6 +414,10 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
>> 	struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
>> 	enum pipe pipe;
>>
>>+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->pipe_mask) < I915_MAX_PIPES);
>>+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->cpu_transcoder_mask) < I915_MAX_TRANSCODERS);
>>+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->port_mask) < I915_MAX_PORTS);
>>+
>> 	/* Wa_14011765242: adl-s A0,A1 */
>> 	if (IS_ADLS_DISPLAY_STEP(dev_priv, STEP_A0, STEP_A2))
>> 		for_each_pipe(dev_priv, pipe)
>>-- 
>>2.39.3
>>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index bb10e8e78a94..ce257446b712 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -414,6 +414,10 @@  void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
 	struct intel_runtime_info *runtime = RUNTIME_INFO(dev_priv);
 	enum pipe pipe;
 
+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->pipe_mask) < I915_MAX_PIPES);
+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->cpu_transcoder_mask) < I915_MAX_TRANSCODERS);
+	BUILD_BUG_ON(BITS_PER_TYPE(runtime->port_mask) < I915_MAX_PORTS);
+
 	/* Wa_14011765242: adl-s A0,A1 */
 	if (IS_ADLS_DISPLAY_STEP(dev_priv, STEP_A0, STEP_A2))
 		for_each_pipe(dev_priv, pipe)