Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4469545rwb; Tue, 6 Sep 2022 08:00:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR5r84IqiPc78y10GNSqpKsGGutUUoKN1AlGiIJUPspowBWZfmjEYatIubsbA37hFhfpM6Sh X-Received: by 2002:a17:907:3188:b0:741:4bf7:ec1a with SMTP id xe8-20020a170907318800b007414bf7ec1amr33861503ejb.448.1662476441263; Tue, 06 Sep 2022 08:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662476441; cv=none; d=google.com; s=arc-20160816; b=S1hx6n2PNIty3v1j7hT0oYHCiETOcVoMDH1SSQD6ODqZLN/Rv17ZWdN3sbKX8VB//4 hhCW7nKYxU7+eksv4mSqOEOp6mEmin+0c7Z+U1DLFOzdo9zNyx6bGNkOTBuOtlOW+O6O APhSY3M/J7bNajwrdrbEW1k9pXymanPiifcoFCg1H1ret/G7/8k7h9O+QhLEkBp4vW8p RIbaeHJXmZlwbz0UB3dzDhkH70Z2PZXgqk+pPyRQJGRXmOyaA/rLrbwOov5UxC0eMmn9 k2RC6++mlS/03Yzk5pl20mfzAJJKSNadJ0ZcPruf4YkG0PES5i3TPQd8JCKzFJ42TmNv 4wJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TpGe28YMLb+MMp5998ZqJEu5VxEkQlc6RqDbAEOryBI=; b=qllvah4Dp8csvwW+SDXuyqcpcAl++Mr2BZIx0W/4D4C1YxV0IYY44CZJWpGyC7M35F n3OcZfwh3k/HyyKuI9uBdBZwkyCT8YSaUDjkeLs8lzL6Njb0Fpnt8cQxyVcxGm/sjE9X hkNojAyI2klnrsm3+W/jRl1Eauj5XMDJ8Yijj6YYExy2o+Ro18FvqCaRAZWyi1Yur2js 33CxW0S4rRzYgkoxQFAfll6gfFenCgJbQt8BJz+V8wMbYsMtqaA2ePZGm+R7yJA3qxUr ++FNIqR46HXiGQT8Km/9lvfktlSlxvuaWqjE2TaTr5wlxep8KGndNRC58UeuBlzAETnl 777A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MlzPyB5u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb2-20020a1709071c8200b0072b3b8d31f8si9858028ejc.63.2022.09.06.08.00.15; Tue, 06 Sep 2022 08:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MlzPyB5u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233468AbiIFNmK (ORCPT + 99 others); Tue, 6 Sep 2022 09:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233371AbiIFNkn (ORCPT ); Tue, 6 Sep 2022 09:40:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EA0A7B790; Tue, 6 Sep 2022 06:37:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BF17DB816A0; Tue, 6 Sep 2022 13:36:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F2C4C433D7; Tue, 6 Sep 2022 13:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471360; bh=4i5sYG49tf9dNz8KHpFIUCVSBk6MKdxITrMG9BQRhAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlzPyB5ubxp+Gz/ZWyId053Kxi7c3nGcldE7Iq8R/sCiJcc/kUZMi9N41St//ZUx7 eJBcb3OW8+9VQLvymr9sHeQjZ4rOJYuyHpqhFP0vlLEJv5814Y/vNq1W2CxTtKrI4T +e/Az7RXX4GD14Exw9OuZ5hobgnCl5dl4gVYQCNU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Ranquet , Heikki Krogerus , Pablo Sun , Macpaul Lin Subject: [PATCH 5.10 56/80] usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles Date: Tue, 6 Sep 2022 15:30:53 +0200 Message-Id: <20220906132819.395576458@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Sun commit c1e5c2f0cb8a22ec2e14af92afc7006491bebabb upstream. Fix incorrect pin assignment values when connecting to a monitor with Type-C receptacle instead of a plug. According to specification, an UFP_D receptacle's pin assignment should came from the UFP_D pin assignments field (bit 23:16), while an UFP_D plug's assignments are described in the DFP_D pin assignments (bit 15:8) during Mode Discovery. For example the LG 27 UL850-W is a monitor with Type-C receptacle. The monitor responds to MODE DISCOVERY command with following DisplayPort Capability flag: dp->alt->vdo=0x140045 The existing logic only take cares of UPF_D plug case, and would take the bit 15:8 for this 0x140045 case. This results in an non-existing pin assignment 0x0 in dp_altmode_configure. To fix this problem a new set of macros are introduced to take plug/receptacle differences into consideration. Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode") Cc: stable@vger.kernel.org Co-developed-by: Pablo Sun Co-developed-by: Macpaul Lin Reviewed-by: Guillaume Ranquet Reviewed-by: Heikki Krogerus Signed-off-by: Pablo Sun Signed-off-by: Macpaul Lin Link: https://lore.kernel.org/r/20220804034803.19486-1-macpaul.lin@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/altmodes/displayport.c | 4 ++-- include/linux/usb/typec_dp.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -88,8 +88,8 @@ static int dp_altmode_configure(struct d case DP_STATUS_CON_UFP_D: case DP_STATUS_CON_BOTH: /* NOTE: First acting as DP source */ conf |= DP_CONF_UFP_U_AS_UFP_D; - pin_assign = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo) & - DP_CAP_UFP_D_PIN_ASSIGN(dp->port->vdo); + pin_assign = DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo) & + DP_CAP_PIN_ASSIGN_DFP_D(dp->port->vdo); break; default: break; --- a/include/linux/usb/typec_dp.h +++ b/include/linux/usb/typec_dp.h @@ -73,6 +73,11 @@ enum { #define DP_CAP_USB BIT(7) #define DP_CAP_DFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(15, 8)) >> 8) #define DP_CAP_UFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(23, 16)) >> 16) +/* Get pin assignment taking plug & receptacle into consideration */ +#define DP_CAP_PIN_ASSIGN_UFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_)) +#define DP_CAP_PIN_ASSIGN_DFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_)) /* DisplayPort Status Update VDO bits */ #define DP_STATUS_CONNECTION(_status_) ((_status_) & 3)