Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp62103imn; Wed, 3 Aug 2022 19:44:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vh9iCd10h9yvztpzw8qW1nEYPCVnvwVV50ruYxRw9LzzeMPkzipvTdqzQrbXtlskxiVqhc X-Received: by 2002:a05:6402:3881:b0:43a:691f:8e3b with SMTP id fd1-20020a056402388100b0043a691f8e3bmr28131531edb.217.1659581074848; Wed, 03 Aug 2022 19:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659581074; cv=none; d=google.com; s=arc-20160816; b=RnQZgEeNDFru400NPMxMe3e7QcIlblzUCIuSxr/lE4k76yT48o0M/Yvw+fP1r307Uw eL2+LQKztRUQioDNKLlFEEH3ZahpBuZQ1QjVbh8h20kbTZlr5KAX2YrUC+4rZPETizy3 nMHr1G9Knq1lpgwNqdQVVVZZI3wYtzTbwxl1OK/jIt6QN28wHbRMvpbudOtIhslGOzyG 7X0q2ErFASMyowfpGqbNYdMwKbxM7Kd56DUYS2obQoc+R/T58yP+uQH8YbqIk2zd4pCP Mq7JUf2FZ+rOn9JnTCX0w1XPbDf4FC96heEZfGnTYfrB20MaqNG6zt6ZwiEePsxOp13n 8K9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=JV37hBY3bLNZYQs+9XiGt0a6pECWVBS/ZPRB8OihWFw=; b=DkKJmpJC3YP/OdEyNOedNVvsIgCT/Iyul4ZRY86SY4Q7CRCsgIQr+QWq3xiUzrMt4Z Ti+bm2CbMm8tQaOTHHOQL8r94F/2OSWbs+WyOCohKVwdwYQvzBgZaQ7ajhxmFNQ0GeC5 vfG1gb/JLVQcNV3Wdj5Jmk5elQ2tDWcrm7iZ/+hNVWcgojRpgwnsx3Pwtlfy0jtAWwXb iiwgMP6IC3/jmeAPtCuCwXO4NhArsYhqeedsQuAbeZD45yC2omzxvmijbC7wWj6XtvC0 FFsB3CeblRgqIhTuem9ffHmeyYZBHm3kb+EzSC9/1MyXONQi9CWk+5fls0u50h29nbv1 tfSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=VkQaXp98; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc22-20020a1709071c1600b0072b66c5cdf0si3931260ejc.481.2022.08.03.19.44.09; Wed, 03 Aug 2022 19:44:34 -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=@mediatek.com header.s=dk header.b=VkQaXp98; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236716AbiHDCmQ (ORCPT + 99 others); Wed, 3 Aug 2022 22:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbiHDCmO (ORCPT ); Wed, 3 Aug 2022 22:42:14 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D16AD20F7D; Wed, 3 Aug 2022 19:42:12 -0700 (PDT) X-UUID: f059efa0ad804c9aa6a30b0054188cdb-20220804 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:CC:To:Subject; bh=JV37hBY3bLNZYQs+9XiGt0a6pECWVBS/ZPRB8OihWFw=; b=VkQaXp98I8c3ozZhA0cbosYAshO20cXeK0Axw95AcmYAq44H9MzPssD4XaULWTJ9R9wnO7CqJLOVM2RGFh3NZcS8xxX0wWb8wSvsb1Vi0xcLq3LLyZf5SMHvD1Zz1XC3Kr3CGPY8kudqpSKHttQZtO00sok20Z0VOnNSPQuXLwA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:860e4a0b-f073-4a67-84c9-a32514bd52b3,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:0f94e32,CLOUDID:283a3625-a982-4824-82d2-9da3b6056c2a,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: f059efa0ad804c9aa6a30b0054188cdb-20220804 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1110431861; Thu, 04 Aug 2022 10:42:07 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 4 Aug 2022 10:42:06 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 4 Aug 2022 10:42:06 +0800 Subject: Re: [PATCH] usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles To: Heikki Krogerus CC: Greg Kroah-Hartman , Matthias Brugger , , , , , Bear Wang , Pablo Sun , Mediatek WSD Upstream , Macpaul Lin , References: <20220727110503.5260-1-macpaul.lin@mediatek.com> From: Macpaul Lin Message-ID: <09f8d925-7d11-d101-8a12-8df858e74057@mediatek.com> Date: Thu, 4 Aug 2022 10:42:05 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY 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 On 8/2/22 3:28 PM, Heikki Krogerus wrote: > Hi guys, > > On Wed, Jul 27, 2022 at 07:05:03PM +0800, Macpaul Lin wrote: >> From: Pablo Sun >> >> From: Pablo Sun > > Looks like there's something wrong with the formating of the patch > here? The duplicated line will be removed in patch v2. >> 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. >> >> Co-developed-by: Pablo Sun >> Signed-off-by: Pablo Sun >> Co-developed-by: Macpaul Lin >> Signed-off-by: Macpaul Lin >> Reviewed-by: Guillaume Ranquet >> Cc: stable@vger.kernel.org > > If this is a fix, then you need to have the "Fixes" tag that tells > which commit the patch is fixing. Thanks for the review. Will add "Fixes" tag and "Reviewed-by" tags in patch v2. >> --- >> drivers/usb/typec/altmodes/displayport.c | 4 ++-- >> include/linux/usb/typec_dp.h | 5 +++++ >> 2 files changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c >> index 9360ca177c7d..8dd0e505ef99 100644 >> --- a/drivers/usb/typec/altmodes/displayport.c >> +++ b/drivers/usb/typec/altmodes/displayport.c >> @@ -98,8 +98,8 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con) >> 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; >> diff --git a/include/linux/usb/typec_dp.h b/include/linux/usb/typec_dp.h >> index cfb916cccd31..8d09c2f0a9b8 100644 >> --- 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) >> -- >> 2.18.0 > > thanks, > Thanks. Macpaul Lin