From patchwork Thu Jan 25 18:07:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 10184577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0EA060388 for ; Thu, 25 Jan 2018 18:07:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFA50288B3 for ; Thu, 25 Jan 2018 18:07:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C44FD28A1C; Thu, 25 Jan 2018 18:07:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 595F2288B3 for ; Thu, 25 Jan 2018 18:07:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4259A6E3F1; Thu, 25 Jan 2018 18:07:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2BC76E3F1 for ; Thu, 25 Jan 2018 18:07:27 +0000 (UTC) Received: by mail-pg0-x244.google.com with SMTP id m136so5534628pga.12 for ; Thu, 25 Jan 2018 10:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jLBwnRAyvQx5gOS0Y7yZ3V0NZK9f30u5dRHtUh6iMsk=; b=kumwmIsmHKb4Vw9WWYeSB1LMEuQPSjai3M8WT60zz94bAN/u835Q/WZdM9kTcQ276T X/kPimnotsOYOScC9C7RRkAPtwPKE1oHOVeqxA/NReCanb4YjjwWBpriEJncJqezi0co LPj6eg/cJWLPb7G/xG56X8irtUCdrq+8+rrneD9iN/4NCcMIj3W+8Hz/iXsS/FEF/ORM QMnQVAEbzqFH9nrRQ74x0Nazjp8/BKiN2PMkpH/8yNy4DjXw5EwGrCcBNo3kYql9zIX9 NGoSdZANghftnEwoOO1KE9vJIiwedc+zBD2+/8EHZgDbLEmM04iqNAgAaMGz8CmEJWRU 6dXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=jLBwnRAyvQx5gOS0Y7yZ3V0NZK9f30u5dRHtUh6iMsk=; b=EOKw8ILbWTuWsQWzzHxk8v5mJdRcVoIrP3Uq+zdHmUaH/cINzE3ojskOkBwdmtA0IC oVFZRXUyhPRLBthOpZ9655V28Fkl6p2X2o1sysAYyV5QK9xHDHkiPUvaTGqFtc/GzWgJ h1bNShOEO/xip/+GjJWfToLqKILSMKDwDBHjxKMaom4VjhR6/zBAyOoB87Wb0FpRbHau tvnJ5skvQO1CR9Y79HCl56usnUlPPov6S2jn66bpvZBqht7J79RQmFngC+pmyWH0PyQq 7OrDFsaOgTMn8WNzbR4IpeHixUPNx8VIdGiqKe3xtlqrezr9PXzaEs5X2z/I/sRkntCd zJVg== X-Gm-Message-State: AKwxytehJ57XTUS2JzCvVMGQqPfi/B8+ygVXkr0ewTraQGUFPNZOADDE MaZyiV0bb8+F3hCsYCfvgJY= X-Google-Smtp-Source: AH8x224sXc7A5/gU0vjrPfk+Twq1RZJ0bqPVa+1n91LqkLu/xaIOV12MDzQM6PJB9lRjJ2DHIDiIiQ== X-Received: by 10.98.245.69 with SMTP id n66mr16677275pfh.137.1516903647048; Thu, 25 Jan 2018 10:07:27 -0800 (PST) Received: from ldmartin-desk.amr.corp.intel.com ([192.55.54.41]) by smtp.gmail.com with ESMTPSA id v9sm14997660pfj.88.2018.01.25.10.07.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jan 2018 10:07:26 -0800 (PST) Date: Thu, 25 Jan 2018 10:07:19 -0800 From: Lucas De Marchi To: Jani Nikula Message-ID: <20180125180718.GA10880@ldmartin-desk.amr.corp.intel.com> References: <87efmedkch.fsf@intel.com> <20180125154008.12535-1-rodrigo.vivi@intel.com> <87bmhidjgl.fsf@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87bmhidjgl.fsf@intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) Subject: Re: [Intel-gfx] [PATCH] drm/i915/cnp: Properly handle VBT ddc pin out of bounds. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, Kai Heng Feng , Rodrigo Vivi Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Jan 25, 2018 at 05:52:26PM +0200, Jani Nikula wrote: > On Thu, 25 Jan 2018, Rodrigo Vivi wrote: > > 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) > > > > 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 > > Cc: Jani Nikula > > Cc: Kai Heng Feng > > Signed-off-by: Rodrigo Vivi > > --- > > drivers/gpu/drm/i915/intel_bios.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c > > index 95f0b310d656..06526b17a011 100644 > > --- a/drivers/gpu/drm/i915/intel_bios.c > > +++ b/drivers/gpu/drm/i915/intel_bios.c > > @@ -1116,9 +1116,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 > 0 && vbt_pin < ARRAY_SIZE(cnp_ddc_pin_map)) { > > return cnp_ddc_pin_map[vbt_pin]; > > - if (vbt_pin > GMBUS_PIN_4_CNP) { > > + } else { > > You're going to hate me, but I just realized this will now complain > about vbt_pin == 0, which I guess is valid for N/A. > > Why are simple things so hard sometimes... :( > > else if (vbt_pin) ? vpt_pin is unsigned so we are just special-casing the vpt_pin == 0 already. What about stopping doing that by adding it to the array, like below (to be squashed) ------- ------- Lucas De Marchi diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index 06526b17a011..cf3f8f1ba6f7 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,7 +1117,7 @@ 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]; } else { DRM_DEBUG_KMS("Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n", vbt_pin);