Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4462492rwb; Tue, 6 Sep 2022 07:54:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6iGETTDSP6uVNSDgcxNde4Gh84+hPuHM0L3EBWpZ5Rt60mw7HJDBXby71LcBPZ0isNCax4 X-Received: by 2002:a17:907:9627:b0:741:8d57:f335 with SMTP id gb39-20020a170907962700b007418d57f335mr29806878ejc.7.1662476064868; Tue, 06 Sep 2022 07:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662476064; cv=none; d=google.com; s=arc-20160816; b=C8Ev1NCqL1+UDpSzRp5wvi+bZAbojIs3B3rn3bMZkw7XgdRk+EpTe0B7h1hLlMj6Mi KxXsmokhVzaAPfJiMLDmSwRtKmdBy3V3NjKy4akoOkAp8MaQ3XY7bp4Z53j83ioEdYqP sa4jLzlOpUn29M5QUKgEv8pYj1YH6NzyTDqt7xkqCjzBJNhUHjzMk/eIZCEnej5wBHFv RtLRxWgQ/HHS8/DHg/oZEVxuixkbL1ViGspE84FPt2uAA6lSialdYA255JqAVCjbOSSz Yb2BlJPKWVGU2WA75OwhC5K/4ElzgK6aY8tNX6jYroTQ6GptWOiKtRXW+TxHjKyVp+bb q8Dg== 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=dbhuKV2ChjIsqAPjFaY/3tjddq+3iviwZu641vE6p5w=; b=s4CVjpwj8l4jgMEzKk837iSOoOGZcN6ZjWlREhmC/lPNLKqGoapv2MdUXsXdBXmfGC 9PH1p7ynUG29Rkr9sFo9cenOduNC2Q1KMimcdoUAK8FqMqrQ9xrq+pO5ub4JILcmI4m4 j0cJSHrLgQfLGsWB2vJt4V+VvieFLOL9HBwVkbZ/iaIpxgr+3AhjqbSfAuVXGhm4sUga ud+b5/gqO677UKLKt2weAbEeEd7s0yR/M8RJ+6v0KcqS+XFOjy/IzaemzH986RE+ioOv bRxt7kuSoBUEmXyPH8//bJJgMkumr/TOmcIk96A6EKkZuAqgPjjIk4Ob2MnaAtwujBcq fW/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=09DGB3Tt; 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 gs41-20020a1709072d2900b00734b96e0c80si11044019ejc.690.2022.09.06.07.53.41; Tue, 06 Sep 2022 07:54:24 -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=09DGB3Tt; 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 S233076AbiIFOQA (ORCPT + 99 others); Tue, 6 Sep 2022 10:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241575AbiIFONj (ORCPT ); Tue, 6 Sep 2022 10:13:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E3D87084; Tue, 6 Sep 2022 06:48:15 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CAEFA6154B; Tue, 6 Sep 2022 13:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAC7AC433C1; Tue, 6 Sep 2022 13:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662472022; bh=avoFJpQIsTZtMHJdbgIcBdihFDoRXRpQVYeQWJ31r34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=09DGB3Tt6JLTmOdR0W34tKSO87xVXPh0QEUHQ5moksiIbSnE0Tu1RRyB9stEFI1Xj XCykweziQsBRGUxQMs0jC52oierAj96XdK1kAkiboQmQANzLXpCum8PM+h+slyMMTU kos3i6RFx4hT4NL5+IZ5URf7jTyciI2irre//8zU= 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.19 120/155] usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles Date: Tue, 6 Sep 2022 15:31:08 +0200 Message-Id: <20220906132834.522494089@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@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 @@ -99,8 +99,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)