diff mbox

drm/i915/cnp: Ignore VBT request for know invalid DDC pin.

Message ID 20180123174050.4261-1-rodrigo.vivi@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rodrigo Vivi Jan. 23, 2018, 5:40 p.m. UTC
Let's ignore VBT request if the pin is clearly wrong.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104139
Cc: Kai Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/i915/intel_bios.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Rodrigo Vivi Jan. 23, 2018, 11:19 p.m. UTC | #1
On Tue, Jan 23, 2018 at 05:40:50PM +0000, Rodrigo Vivi wrote:
> Let's ignore VBT request if the pin is clearly wrong.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104139
> Cc: Kai Heng Feng <kai.heng.feng@canonical.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
(f2f)
thanks

merged to dinq.

> ---
>  drivers/gpu/drm/i915/intel_bios.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> index b0668202dc7e..95f0b310d656 100644
> --- a/drivers/gpu/drm/i915/intel_bios.c
> +++ b/drivers/gpu/drm/i915/intel_bios.c
> @@ -1115,9 +1115,14 @@ static const u8 cnp_ddc_pin_map[] = {
>  
>  static u8 map_ddc_pin(struct drm_i915_private *dev_priv, u8 vbt_pin)
>  {
> -	if (HAS_PCH_CNP(dev_priv) &&
> -	    vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
> -		return cnp_ddc_pin_map[vbt_pin];
> +	if (HAS_PCH_CNP(dev_priv)) {
> +		if (vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
> +			return cnp_ddc_pin_map[vbt_pin];
> +		if (vbt_pin > GMBUS_PIN_4_CNP) {
> +			DRM_DEBUG_KMS("Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n", vbt_pin);
> +			return 0;
> +		}
> +	}
>  
>  	return vbt_pin;
>  }
> -- 
> 2.13.6
>
Kai-Heng Feng Jan. 24, 2018, 9:24 a.m. UTC | #2
Hi,

> On 24 Jan 2018, at 5:25 PM, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> A bit too fast IMO. The bug report doesn't include the vbt dump which
> you should *always* look at before making workarounds for vbt.

I didn’t have access to the machine in question until now, I can provide
VBT dump as well as i915_opregion requested by Ville.

But how do I make a VBT dump?

Kai-Heng 

> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
Jani Nikula Jan. 24, 2018, 9:25 a.m. UTC | #3
On Tue, 23 Jan 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote:
> On Tue, Jan 23, 2018 at 05:40:50PM +0000, Rodrigo Vivi wrote:
>> Let's ignore VBT request if the pin is clearly wrong.
>> 
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104139
>> Cc: Kai Heng Feng <kai.heng.feng@canonical.com>
>> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>
> Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> (f2f)
> thanks
>
> merged to dinq.

A bit too fast IMO. The bug report doesn't include the vbt dump which
you should *always* look at before making workarounds for vbt.

Also, see below.

>> ---
>>  drivers/gpu/drm/i915/intel_bios.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
>> index b0668202dc7e..95f0b310d656 100644
>> --- a/drivers/gpu/drm/i915/intel_bios.c
>> +++ b/drivers/gpu/drm/i915/intel_bios.c
>> @@ -1115,9 +1115,14 @@ static const u8 cnp_ddc_pin_map[] = {
>>  
>>  static u8 map_ddc_pin(struct drm_i915_private *dev_priv, u8 vbt_pin)
>>  {
>> -	if (HAS_PCH_CNP(dev_priv) &&
>> -	    vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
>> -		return cnp_ddc_pin_map[vbt_pin];
>> +	if (HAS_PCH_CNP(dev_priv)) {
>> +		if (vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
>> +			return cnp_ddc_pin_map[vbt_pin];
>> +		if (vbt_pin > GMBUS_PIN_4_CNP) {
>> +			DRM_DEBUG_KMS("Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n", vbt_pin);
>> +			return 0;
>> +		}

The original code was wrong in the sense that it would only do the
mapping if the provided vbt_pin was within bounds for CNP, and would
return the unmapped vbt_pin otherwise. Instead, I think you should
directly return 0 for out of bounds vbt_pin.

This change here is effectively the same, but more confusing. As if
there's a case where the vbt_pin can be both out of bounds, within CNP
pin limits, and should be returned unmapped. That can't happen, so
please make the code reflect that.

BR,
Jani.


>> +	}
>>  
>>  	return vbt_pin;
>>  }
>> -- 
>> 2.13.6
>> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula Jan. 24, 2018, 10:03 a.m. UTC | #4
On Wed, 24 Jan 2018, Kai Heng Feng <kai.heng.feng@canonical.com> wrote:
> Hi,
>
>> On 24 Jan 2018, at 5:25 PM, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>> A bit too fast IMO. The bug report doesn't include the vbt dump which
>> you should *always* look at before making workarounds for vbt.
>
> I didn’t have access to the machine in question until now, I can provide
> VBT dump as well as i915_opregion requested by Ville.
>
> But how do I make a VBT dump?

Copy /sys/kernel/debug/dri/0/i915_vbt

I don't think the opregion will be necessary, I think Ville asks for it
for the vbt, which on most platforms is contained in the opregion.

BR,
Jani.


>
> Kai-Heng 
>
>> 
>> -- 
>> Jani Nikula, Intel Open Source Technology Center
>
Kai-Heng Feng Jan. 24, 2018, 10:04 a.m. UTC | #5
> On 24 Jan 2018, at 6:03 PM, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> 
> On Wed, 24 Jan 2018, Kai Heng Feng <kai.heng.feng@canonical.com> wrote:
>> Hi,
>> 
>>> On 24 Jan 2018, at 5:25 PM, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>>> A bit too fast IMO. The bug report doesn't include the vbt dump which
>>> you should *always* look at before making workarounds for vbt.
>> 
>> I didn’t have access to the machine in question until now, I can provide
>> VBT dump as well as i915_opregion requested by Ville.
>> 
>> But how do I make a VBT dump?
> 
> Copy /sys/kernel/debug/dri/0/i915_vbt
> 
> I don't think the opregion will be necessary, I think Ville asks for it
> for the vbt, which on most platforms is contained in the opregion.
> 

Thanks for the tip.

Attached i915_vbt:
https://bugs.freedesktop.org/attachment.cgi?id=136935

Kai-Heng

> BR,
> Jani.
> 
> 
>> 
>> Kai-Heng 
>> 
>>> 
>>> -- 
>>> Jani Nikula, Intel Open Source Technology Center
>> 
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
Ville Syrjala Jan. 24, 2018, 1:30 p.m. UTC | #6
On Wed, Jan 24, 2018 at 12:03:12PM +0200, Jani Nikula wrote:
> On Wed, 24 Jan 2018, Kai Heng Feng <kai.heng.feng@canonical.com> wrote:
> > Hi,
> >
> >> On 24 Jan 2018, at 5:25 PM, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> >> A bit too fast IMO. The bug report doesn't include the vbt dump which
> >> you should *always* look at before making workarounds for vbt.
> >
> > I didn’t have access to the machine in question until now, I can provide
> > VBT dump as well as i915_opregion requested by Ville.
> >
> > But how do I make a VBT dump?
> 
> Copy /sys/kernel/debug/dri/0/i915_vbt
> 
> I don't think the opregion will be necessary, I think Ville asks for it
> for the vbt, which on most platforms is contained in the opregion.

Old habits...
Rodrigo Vivi Jan. 24, 2018, 6:34 p.m. UTC | #7
On Wed, Jan 24, 2018 at 09:25:06AM +0000, Jani Nikula wrote:
> On Tue, 23 Jan 2018, Rodrigo Vivi <rodrigo.vivi@intel.com> wrote:
> > On Tue, Jan 23, 2018 at 05:40:50PM +0000, Rodrigo Vivi wrote:
> >> Let's ignore VBT request if the pin is clearly wrong.
> >> 
> >> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104139
> >> Cc: Kai Heng Feng <kai.heng.feng@canonical.com>
> >> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> >
> > Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
> > (f2f)
> > thanks
> >
> > merged to dinq.
> 
> A bit too fast IMO. The bug report doesn't include the vbt dump which
> you should *always* look at before making workarounds for vbt.

my apologies. My biggest mistake was taking so long to reply to the
bug and taking so long to post the patch here. :(

I looked to the VBT now and it is really just this ddc pin for this
particular port wrong. Or should I look to something else?

What other kind of useful information would that bring to us
normally?

> 
> Also, see below.
> 
> >> ---
> >>  drivers/gpu/drm/i915/intel_bios.c | 11 ++++++++---
> >>  1 file changed, 8 insertions(+), 3 deletions(-)
> >> 
> >> diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
> >> index b0668202dc7e..95f0b310d656 100644
> >> --- a/drivers/gpu/drm/i915/intel_bios.c
> >> +++ b/drivers/gpu/drm/i915/intel_bios.c
> >> @@ -1115,9 +1115,14 @@ static const u8 cnp_ddc_pin_map[] = {
> >>  
> >>  static u8 map_ddc_pin(struct drm_i915_private *dev_priv, u8 vbt_pin)
> >>  {
> >> -	if (HAS_PCH_CNP(dev_priv) &&
> >> -	    vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
> >> -		return cnp_ddc_pin_map[vbt_pin];
> >> +	if (HAS_PCH_CNP(dev_priv)) {
> >> +		if (vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
> >> +			return cnp_ddc_pin_map[vbt_pin];
> >> +		if (vbt_pin > GMBUS_PIN_4_CNP) {
> >> +			DRM_DEBUG_KMS("Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n", vbt_pin);
> >> +			return 0;
> >> +		}
> 
> The original code was wrong in the sense that it would only do the
> mapping if the provided vbt_pin was within bounds for CNP, and would
> return the unmapped vbt_pin otherwise. Instead, I think you should
> directly return 0 for out of bounds vbt_pin.
> 
> This change here is effectively the same, but more confusing. As if
> there's a case where the vbt_pin can be both out of bounds, within CNP
> pin limits, and should be returned unmapped. That can't happen, so
> please make the code reflect that.

Yes. That's a great idea. Thanks for the suggestion.

Honestly, at first I assumed our behavior was something
like this so I couldn't believe we had the issue even with
the original mapping there. But when I did the last fix
I avoided changing the original behavior and messed things up. Sorry.

Thanks,
Rodrigo.

> 
> BR,
> Jani.
> 
> 
> >> +	}
> >>  
> >>  	return vbt_pin;
> >>  }
> >> -- 
> >> 2.13.6
> >> 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index b0668202dc7e..95f0b310d656 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -1115,9 +1115,14 @@  static const u8 cnp_ddc_pin_map[] = {
 
 static u8 map_ddc_pin(struct drm_i915_private *dev_priv, u8 vbt_pin)
 {
-	if (HAS_PCH_CNP(dev_priv) &&
-	    vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
-		return cnp_ddc_pin_map[vbt_pin];
+	if (HAS_PCH_CNP(dev_priv)) {
+		if (vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
+			return cnp_ddc_pin_map[vbt_pin];
+		if (vbt_pin > GMBUS_PIN_4_CNP) {
+			DRM_DEBUG_KMS("Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n", vbt_pin);
+			return 0;
+		}
+	}
 
 	return vbt_pin;
 }