[Intel-gfx] [PATCH 2/4] drm/i915: Generalize pci quirks

Ville Syrjälä ville.syrjala at linux.intel.com
Mon Feb 25 13:38:00 UTC 2019


On Mon, Feb 25, 2019 at 03:28:18PM +0200, Jani Nikula wrote:
> On Mon, 25 Feb 2019, Jani Nikula <jani.nikula at linux.intel.com> wrote:
> > On Fri, 22 Feb 2019, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
> >> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> >>
> >> Add support for multiple independent pci quirk tables.
> >> I want to reuse the quirk table approach for some
> >> watermark quirks but I prefer to keep the details in
> >> one place rather than spreading them all over.
> >>
> >> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> >
> > Reviewed-by: Jani Nikula <jani.nikula at intel.com>
> 
> Hmm. Not to block the series, but this got me thinking. See
> e.g. QUIRK_BACKLIGHT_PRESENT or QUIRK_INVERT_BRIGHTNESS. Should we
> localize those to their own quirk tables in intel_panel.c now?

Might be nice.

However we seem to have a sole DMI quirk for some backlight
stuff. That would need to be handled somehow as well.

> 
> What if intel_apply_pci_quirks() returned an OR of the return values of
> the hooks. In a few cases we could nuke the use of dev_priv->quirks in
> favor of more localized quirks. The former backlight quirk need not be
> saved at all, it's a one time check, and the latter could be saved in
> the backlight struct.
> 
> Something for the future, perhaps.
> 
> BR,
> Jani.
> 
> 
> >
> >> ---
> >>  drivers/gpu/drm/i915/intel_drv.h    |  9 +++++++++
> >>  drivers/gpu/drm/i915/intel_quirks.c | 28 +++++++++++++++-------------
> >>  2 files changed, 24 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> >> index 81ec73e4a083..8924b43d6e99 100644
> >> --- a/drivers/gpu/drm/i915/intel_drv.h
> >> +++ b/drivers/gpu/drm/i915/intel_drv.h
> >> @@ -2187,7 +2187,16 @@ int intel_psr_wait_for_idle(const struct intel_crtc_state *new_crtc_state,
> >>  bool intel_psr_enabled(struct intel_dp *intel_dp);
> >>  
> >>  /* intel_quirks.c */
> >> +struct intel_pci_quirk {
> >> +	int device;
> >> +	int subsystem_vendor;
> >> +	int subsystem_device;
> >> +	void (*hook)(struct drm_i915_private *i915);
> >> +};
> >> +
> >>  void intel_init_quirks(struct drm_i915_private *dev_priv);
> >> +void intel_apply_pci_quirks(struct drm_i915_private *i915,
> >> +			    const struct intel_pci_quirk *quirks);
> >>  
> >>  /* intel_runtime_pm.c */
> >>  void intel_runtime_pm_init_early(struct drm_i915_private *dev_priv);
> >> diff --git a/drivers/gpu/drm/i915/intel_quirks.c b/drivers/gpu/drm/i915/intel_quirks.c
> >> index ec2b0fc92b8b..e073510553a6 100644
> >> --- a/drivers/gpu/drm/i915/intel_quirks.c
> >> +++ b/drivers/gpu/drm/i915/intel_quirks.c
> >> @@ -52,13 +52,6 @@ static void quirk_increase_ddi_disabled_time(struct drm_i915_private *i915)
> >>  	DRM_INFO("Applying Increase DDI Disabled quirk\n");
> >>  }
> >>  
> >> -struct intel_quirk {
> >> -	int device;
> >> -	int subsystem_vendor;
> >> -	int subsystem_device;
> >> -	void (*hook)(struct drm_i915_private *i915);
> >> -};
> >> -
> >>  /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
> >>  struct intel_dmi_quirk {
> >>  	void (*hook)(struct drm_i915_private *i915);
> >> @@ -87,7 +80,7 @@ static const struct intel_dmi_quirk intel_dmi_quirks[] = {
> >>  	},
> >>  };
> >>  
> >> -static struct intel_quirk intel_quirks[] = {
> >> +static const struct intel_pci_quirk intel_pci_quirks[] = {
> >>  	/* Lenovo U160 cannot use SSC on LVDS */
> >>  	{ 0x0046, 0x17aa, 0x3920, quirk_ssc_force_disable },
> >>  
> >> @@ -145,16 +138,17 @@ static struct intel_quirk intel_quirks[] = {
> >>  	/* ASRock ITX*/
> >>  	{ 0x3185, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
> >>  	{ 0x3184, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
> >> +
> >> +	{}
> >>  };
> >>  
> >> -void intel_init_quirks(struct drm_i915_private *i915)
> >> +void intel_apply_pci_quirks(struct drm_i915_private *i915,
> >> +			    const struct intel_pci_quirk *quirks)
> >>  {
> >>  	struct pci_dev *d = i915->drm.pdev;
> >> -	int i;
> >> -
> >> -	for (i = 0; i < ARRAY_SIZE(intel_quirks); i++) {
> >> -		struct intel_quirk *q = &intel_quirks[i];
> >> +	const struct intel_pci_quirk *q;
> >>  
> >> +	for (q = quirks; q->device; q++) {
> >>  		if (d->device == q->device &&
> >>  		    (d->subsystem_vendor == q->subsystem_vendor ||
> >>  		     q->subsystem_vendor == PCI_ANY_ID) &&
> >> @@ -162,6 +156,14 @@ void intel_init_quirks(struct drm_i915_private *i915)
> >>  		     q->subsystem_device == PCI_ANY_ID))
> >>  			q->hook(i915);
> >>  	}
> >> +}
> >> +
> >> +void intel_init_quirks(struct drm_i915_private *i915)
> >> +{
> >> +	int i;
> >> +
> >> +	intel_apply_pci_quirks(i915, intel_pci_quirks);
> >> +
> >>  	for (i = 0; i < ARRAY_SIZE(intel_dmi_quirks); i++) {
> >>  		if (dmi_check_system(*intel_dmi_quirks[i].dmi_id_list) != 0)
> >>  			intel_dmi_quirks[i].hook(i915);
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center

-- 
Ville Syrjälä
Intel


More information about the Intel-gfx mailing list