drm/i915/cnp: Properly handle VBT ddc pin out of bounds.

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/6e3322c226f15bc1838007f5a75566f1482b8e40
Commit:     6e3322c226f15bc1838007f5a75566f1482b8e40
Parent:     f24c606c21a8cb6f75adc20edcd80b6d851991bf
Refname:    refs/heads/master
Author:     Rodrigo Vivi <[email protected]>
AuthorDate: Thu Jan 25 14:25:24 2018 -0800
Committer:  Rodrigo Vivi <[email protected]>
CommitDate: Tue Feb 6 11:41:41 2018 -0800

    drm/i915/cnp: Properly handle VBT ddc pin out of bounds.
    
    If the table result is out of bounds on the array map
    there is something really wrong with VBT pin so we don't
    return that vbt_pin, but only return 0 instead.
    
    This basically reverts commit 'a8e6f3888b05 ("drm/i915/cnp:
    Ignore VBT request for know invalid DDC pin.")'
    
    Also this properly fixes commit 9c3b2689d01f ("drm/i915/cnl:
    Map VBT DDC Pin to BSpec DDC Pin.")
    
    v2: Do in a way that we don't break other platforms. (Jani)
    
    v3: Keep debug message (Jani)
    
    v4: Don't mess with 0 mapping was noticed by Jani and
        addressed with a simple solution suggested by Lucas
        that makes this even simpler.
    
    Fixes: a8e6f3888b05 ("drm/i915/cnp: Ignore VBT request for know invalid DDC pin.")
    Fixes: 9c3b2689d01f ("drm/i915/cnl: Map VBT DDC Pin to BSpec DDC Pin.")
    Cc: Radhakrishna Sripada <[email protected]>
    Cc: Jani Nikula <[email protected]>
    Cc: Kai Heng Feng <[email protected]>
    Cc: Lucas De Marchi <[email protected]>
    Suggested-by: Lucas De Marchi <[email protected]>
    Signed-off-by: Rodrigo Vivi <[email protected]>
    Reviewed-by: Lucas De Marchi <[email protected]>
    Tested-by: Kai-Heng Feng <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 3393ce1ed8fc43dbdb83952facaf04e644ca1d54)
    Signed-off-by: Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/intel_bios.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 7c6391459d8f..4c42cc4b193b 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -1107,6 +1107,7 @@ static void sanitize_aux_ch(struct drm_i915_private *dev_priv,
 }
 
 static const u8 cnp_ddc_pin_map[] = {
+	[0] = 0, /* N/A */
 	[DDC_BUS_DDI_B] = GMBUS_PIN_1_BXT,
 	[DDC_BUS_DDI_C] = GMBUS_PIN_2_BXT,
 	[DDC_BUS_DDI_D] = GMBUS_PIN_4_CNP, /* sic */
@@ -1116,9 +1117,9 @@ 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)) {
-		if (vbt_pin > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map))
+		if (vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map)) {
 			return cnp_ddc_pin_map[vbt_pin];
-		if (vbt_pin > GMBUS_PIN_4_CNP) {
+		} else {
 			DRM_DEBUG_KMS("Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n", vbt_pin);
 			return 0;
 		}
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.