From patchwork Mon Oct 24 11:34:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp511799wru; Mon, 24 Oct 2022 08:26:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51pvlNHChmKdR65goS431ssJFNOhtLWL/N3RddrKvlhsvUT4DplooLORBwL5Pb8BFTBzwX X-Received: by 2002:a05:6402:3551:b0:45d:a52f:2d77 with SMTP id f17-20020a056402355100b0045da52f2d77mr32281708edd.67.1666625192936; Mon, 24 Oct 2022 08:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666625192; cv=none; d=google.com; s=arc-20160816; b=hRIXFCTgRQk6gFRBODU4MnKBzywztLVEf+pm1b5c8jXqtPZusivb4g9+uWq2Wl1Qz5 RJcnxusezZ2A78i1GbVVAvoFijKURPJ+OAZ7SXRRHNERoFti+2ZWuotWTfxROAMOD40B QEmwObLtwtt7pm9aL51KdE/fsGyOFdQj/vM8n3NcXuoW8m8ee+mCaMQw95sXImMrisd0 nVZ5ZVThieZFmx4p/6ba3YDw+r54FAZZJubXgQg+lS8R73OLD9X5k4ULhiQkrucm+rjP 0AjBcsNTJsoCWPNaPeR2Yf6H4NgVMBBmZHtd4aK3/avvzoNZW4NbmxN0S9ir7mPqlLSM bicw== 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=CYAM2bTAPsu5rjMP5kJ/zxzH+BYQWtrCk95gpRx8sqw=; b=GvpOW4qJ+2LkMWL2IjKMuTAZ07JCjeJ06kUgi+6/jzCUa1vbnHA4fXJxxUwgR521p7 h6lUmWmLVeUaAaAkWWZWpq12TOc2PHUndkoZfEJRUnAHSd85ivBQl1RjdDDp8E0JiVfO vdwnM8xXcMMbQLmAYoJR05Fzvrx3pTJQg1b7jOE7ooQO4LpJS33lQpOcDpdI0Q0xVjqe beYjL+t4MYH5XSxMfAdxPT3ahy2ZnzCaX3yMJ8qqg/Wgqrg6Udrw6ZVsNsqZZRPo8OfA 0b4SkY8eX/rsZdKZmi/SGtYvGQpNUk9l65s1MKcs9H7ImYE1v56d7hOYv55WUMm+usbh TSgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K+W5ffzW; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n20-20020a056402515400b004615937b174si40011edd.480.2022.10.24.08.26.08; Mon, 24 Oct 2022 08:26:32 -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=K+W5ffzW; 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 S233752AbiJXPAQ (ORCPT + 99 others); Mon, 24 Oct 2022 11:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbiJXO7g (ORCPT ); Mon, 24 Oct 2022 10:59:36 -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 D384C132249; Mon, 24 Oct 2022 06:37:00 -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 8CAEB61330; Mon, 24 Oct 2022 12:56:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B616C433C1; Mon, 24 Oct 2022 12:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666616178; bh=NF7v3Ni4t2EjxnCdZQDAN1XxUriaIun6viozetKWNXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+W5ffzWK4oQhVcHa5d0E6gCdBpzI5Xd8Rk6m4EbtzElpSCbYvwdb5iCFmSRrl2V0 3zLg62kmXm177BCjohC38OFeHta0OR+MMRxtrRRhS13VRNOupjowHe7RRISwPrNfp4 YVykW8fduhWEronXlC355GtwDqKG3dlCrDy/wnow= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Piyush Mehta , Sasha Levin Subject: [PATCH 5.15 499/530] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing termination error after resume bug Date: Mon, 24 Oct 2022 13:34:03 +0200 Message-Id: <20221024113107.635661787@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747583178233094703?= X-GMAIL-MSGID: =?utf-8?q?1747583178233094703?= From: Piyush Mehta [ Upstream commit 63d7f9810a38102cdb8cad214fac98682081e1a7 ] When configured in HOST mode, after issuing U3/L2 exit controller fails to send proper CRC checksum in CRC5 field. Because of this behavior Transaction Error is generated, resulting in reset and re-enumeration of usb device attached. Enabling chicken bit 10 of GUCTL1 will correct this problem. When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations, term, and xcvr signals after EOR. This option is to support certain legacy UTMI/ULPI PHYs. Added "snps,resume-hs-terminations" quirk to resolved the above issue. Signed-off-by: Piyush Mehta Link: https://lore.kernel.org/r/20220920052235.194272-3-piyush.mehta@amd.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/core.c | 17 +++++++++++++++++ drivers/usb/dwc3/core.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c32ca691bcc7..a2f3e56aba05 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1041,6 +1041,21 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); } + /* + * When configured in HOST mode, after issuing U3/L2 exit controller + * fails to send proper CRC checksum in CRC5 feild. Because of this + * behaviour Transaction Error is generated, resulting in reset and + * re-enumeration of usb device attached. All the termsel, xcvrsel, + * opmode becomes 0 during end of resume. Enabling bit 10 of GUCTL1 + * will correct this problem. This option is to support certain + * legacy ULPI PHYs. + */ + if (dwc->resume_hs_terminations) { + reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); + reg |= DWC3_GUCTL1_RESUME_OPMODE_HS_HOST; + dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); + } + if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) { reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); @@ -1383,6 +1398,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,dis-del-phy-power-chg-quirk"); dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev, "snps,dis-tx-ipgap-linecheck-quirk"); + dwc->resume_hs_terminations = device_property_read_bool(dev, + "snps,resume-hs-terminations"); dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev, "snps,parkmode-disable-ss-quirk"); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 077d03a33388..e82e4cbe4ec7 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -260,6 +260,7 @@ #define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28) #define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24) #define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17) +#define DWC3_GUCTL1_RESUME_OPMODE_HS_HOST BIT(10) /* Global Status Register */ #define DWC3_GSTS_OTG_IP BIT(10) @@ -1072,6 +1073,8 @@ struct dwc3_scratchpad_array { * change quirk. * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate * check during HS transmit. + * @resume-hs-terminations: Set if we enable quirk for fixing improper crc + * generation after resume from suspend. * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed * instances in park mode. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk @@ -1284,6 +1287,7 @@ struct dwc3 { unsigned dis_u2_freeclk_exists_quirk:1; unsigned dis_del_phy_power_chg_quirk:1; unsigned dis_tx_ipgap_linecheck_quirk:1; + unsigned resume_hs_terminations:1; unsigned parkmode_disable_ss_quirk:1; unsigned tx_de_emphasis_quirk:1;