On Mon, Oct 21, 2024 at 04:54:08PM +0300, Jani Nikula wrote: > Facilitate using display->platform.haswell and > display->platform.haswell_ult etc. for identifying platforms and > subplatforms. > > Merge the platform and subplatform bitmaps together, and check that > there's no overlap. > > v4: > - Lower case, s/is/platform/ > > v3: > - Fix sanity check on display->is after merging subplatform members > > v2: > - Use bitmap ops > - Add some sanity checks with warnings > > Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> > --- > .../gpu/drm/i915/display/intel_display_core.h | 3 ++ > .../drm/i915/display/intel_display_device.c | 35 +++++++++++++++++-- > 2 files changed, 36 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h > index 45697af25fa9..45b7c6900adc 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_core.h > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h > @@ -284,6 +284,9 @@ struct intel_display { > /* drm device backpointer */ > struct drm_device *drm; > > + /* Platform (and subplatform, if any) identification */ > + struct intel_display_platforms platform; > + > /* Display functions */ > struct { > /* Top level crtc-ish functions */ > diff --git a/drivers/gpu/drm/i915/display/intel_display_device.c b/drivers/gpu/drm/i915/display/intel_display_device.c > index 0e835f714bf5..c124df204166 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_device.c > +++ b/drivers/gpu/drm/i915/display/intel_display_device.c > @@ -1525,6 +1525,25 @@ static enum intel_step get_pre_gmdid_step(struct intel_display *display, > return step; > } > > +/* Size of the entire bitmap, not the number of platforms */ > +static unsigned int display_platforms_num_bits(void) > +{ > + return sizeof(((struct intel_display_platforms *)0)->bitmap) * BITS_PER_BYTE; > +} > + > +/* Number of platform bits set */ > +static unsigned int display_platforms_weight(const struct intel_display_platforms *p) > +{ > + return bitmap_weight(p->bitmap, display_platforms_num_bits()); > +} > + > +/* Merge the subplatform information from src to dst */ > +static void display_platforms_or(struct intel_display_platforms *dst, > + const struct intel_display_platforms *src) > +{ > + bitmap_or(dst->bitmap, dst->bitmap, src->bitmap, display_platforms_num_bits()); > +} > + > void intel_display_device_probe(struct drm_i915_private *i915) > { > struct intel_display *display = &i915->display; > @@ -1564,13 +1583,25 @@ void intel_display_device_probe(struct drm_i915_private *i915) > &DISPLAY_INFO(i915)->__runtime_defaults, > sizeof(*DISPLAY_RUNTIME_INFO(i915))); > > - drm_WARN_ON(&i915->drm, !desc->platform || !desc->name); > + drm_WARN_ON(&i915->drm, !desc->platform || !desc->name || > + !display_platforms_weight(&desc->platforms)); > DISPLAY_RUNTIME_INFO(i915)->platform = desc->platform; > > + display->platform = desc->platforms; > + > subdesc = find_subplatform_desc(pdev, desc); > if (subdesc) { > - drm_WARN_ON(&i915->drm, !subdesc->subplatform || !subdesc->name); > + drm_WARN_ON(&i915->drm, !subdesc->subplatform || !subdesc->name || > + !display_platforms_weight(&subdesc->platforms)); > DISPLAY_RUNTIME_INFO(i915)->subplatform = subdesc->subplatform; > + > + display_platforms_or(&display->platform, &subdesc->platforms); > + > + /* Ensure platform and subplatform are distinct */ > + drm_WARN_ON(&i915->drm, > + display_platforms_weight(&display->platform) != > + display_platforms_weight(&desc->platforms) + > + display_platforms_weight(&subdesc->platforms)); > } > > if (ip_ver.ver || ip_ver.rel || ip_ver.step) { > -- > 2.39.5 >