Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1276150pxb; Thu, 24 Mar 2022 16:41:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTB6LWe2lvlPSlnSaHdrDJsayTtbt7ShTDc5x37ajJ9nacgFTekPgnLBypGv3iE+f9/0x2 X-Received: by 2002:a17:903:110c:b0:14a:f110:84e1 with SMTP id n12-20020a170903110c00b0014af11084e1mr8363401plh.7.1648165284556; Thu, 24 Mar 2022 16:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648165284; cv=none; d=google.com; s=arc-20160816; b=zCXFTMb/LGiNKf4uvyNIH3MgFEIdQ/SootLJFvOK0nXaY0xdPUVDymQ9AmaiqMzyDH Xu1ToHbSQZWx5e32ekzl9YV6u7dMFvMD9dLBWtam+W0Bu2A04sGbGGOcLiL5Ta1Wbh2+ bzXx6I4CURNvJhvUUCxwSlaKl4LYm7GtxhaU5x02X1iV6kNgtQiFVH7dzx6t9eg0Malu 4B8llEVpXOa32zOmYxSauU96N5nsK9deTahyBIGArcYu6vaUH6fJ+DqZsP9JWvqybfqj 0F965SInjZaAk/c+Y/u+9+xDl5aNQgBX8EmbgWtpf1ok+kFoRSJmJy36m12vWUr5GFey rlZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=er+lT7xiEYYHfe7rlLMBy6wY3R1S4abhK+IlBsoNUqM=; b=HqBnvz+Fn/cMIzOugO5ZDQScqwk+qe3ws0r73mG8L1+pHC4XleIhoZTuwdvUd0x8xm K1TSrjrLE31B0XBzVmIE7xGEtnma5dFwI5wOUHHWPf3pVYMQg9CxqLLF+tZJIbJ+H8D5 BC6nqV2FKapjVDnD+O/6HAd+JUO2TO9lPaBwbx1buq/wPFcp71a2Jni6XH3XXgMaNQo6 w7UN2qSKm80xrNyKt3znZsnJvBppTG9sD92NevEuFFr7SIHuWu+JPKXxkR4FRNUbnz5Q D0InU/ZGsH/6RodNrLDrOBmqo5QQG15B0CfyDl5NT6lacIbAlvjnD5Y6fY+VwjdofLMk zsgg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a056a000a1400b004fa3a8dff84si1306212pfh.59.2022.03.24.16.41.10; Thu, 24 Mar 2022 16:41: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233148AbiCXP1v (ORCPT + 99 others); Thu, 24 Mar 2022 11:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240829AbiCXP1u (ORCPT ); Thu, 24 Mar 2022 11:27:50 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 6E80AA8EFF for ; Thu, 24 Mar 2022 08:26:18 -0700 (PDT) Received: (qmail 210494 invoked by uid 1000); 24 Mar 2022 11:26:17 -0400 Date: Thu, 24 Mar 2022 11:26:17 -0400 From: Alan Stern To: WeitaoWangoc Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, tonywwang@zhaoxin.com, weitaowang@zhaoxin.com, CobeChen@zhaoxin.com Subject: Re: [PATCH v2] USB:Fix ehci infinite suspend-resume loop issue in zhaoxin Message-ID: References: <20220324121735.3803-1-WeitaoWang-oc@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220324121735.3803-1-WeitaoWang-oc@zhaoxin.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Mar 24, 2022 at 08:17:35PM +0800, WeitaoWangoc wrote: > In zhaoxin platform, some ehci projects will latch a wakeup signal > internal when plug in a device on port during system S0. This wakeup > signal will turn on when ehci runtime suspend, which will trigger a > system control interrupt that will resume ehci back to D0. As no > device connect, ehci will be set to runtime suspend and turn on the > internal latched wakeup signal again. It will cause a suspend-resume > loop and generate system control interrupt continuously. > > Fixed this issue by clear wakeup signal latched in ehci internal when > ehci resume callback is called. > > Signed-off-by: Weitao Wang Acked-by: Alan Stern I'll submit the change to hcd-pci.c after the current merge window closes. Alan Stern > --- > v1->v2 > - Improve this patch with not to clear STS_PCD bit. > - Change a boolean flag name to make its meaning more obvious. > - Fix "tabs converted to spaces" issue. > > drivers/usb/host/ehci-hcd.c | 23 +++++++++++++++++++++++ > drivers/usb/host/ehci-pci.c | 4 ++++ > drivers/usb/host/ehci.h | 1 + > 3 files changed, 28 insertions(+) > > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c > index 3d82e0b853be..684164fa9716 100644 > --- a/drivers/usb/host/ehci-hcd.c > +++ b/drivers/usb/host/ehci-hcd.c > @@ -1103,6 +1103,26 @@ static void ehci_remove_device(struct usb_hcd *hcd, struct usb_device *udev) > > #ifdef CONFIG_PM > > +/* Clear wakeup signal locked in zhaoxin platform when device plug in. */ > +static void ehci_zx_wakeup_clear(struct ehci_hcd *ehci) > +{ > + u32 __iomem *reg = &ehci->regs->port_status[4]; > + u32 t1 = ehci_readl(ehci, reg); > + > + t1 &= (u32)~0xf0000; > + t1 |= PORT_TEST_FORCE; > + ehci_writel(ehci, t1, reg); > + t1 = ehci_readl(ehci, reg); > + msleep(1); > + t1 &= (u32)~0xf0000; > + ehci_writel(ehci, t1, reg); > + ehci_readl(ehci, reg); > + msleep(1); > + t1 = ehci_readl(ehci, reg); > + ehci_writel(ehci, t1 | PORT_CSC, reg); > + ehci_readl(ehci, reg); > +} > + > /* suspend/resume, section 4.3 */ > > /* These routines handle the generic parts of controller suspend/resume */ > @@ -1154,6 +1174,9 @@ int ehci_resume(struct usb_hcd *hcd, bool force_reset) > if (ehci->shutdown) > return 0; /* Controller is dead */ > > + if (ehci->zx_wakeup_clear_needed) > + ehci_zx_wakeup_clear(ehci); > + > /* > * If CF is still set and reset isn't forced > * then we maintained suspend power. > diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c > index e87cf3a00fa4..b11a6f82aee2 100644 > --- a/drivers/usb/host/ehci-pci.c > +++ b/drivers/usb/host/ehci-pci.c > @@ -222,6 +222,10 @@ static int ehci_pci_setup(struct usb_hcd *hcd) > ehci->has_synopsys_hc_bug = 1; > } > break; > + case PCI_VENDOR_ID_ZHAOXIN: > + if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x90) > + ehci->zx_wakeup_clear_needed = 1; > + break; > } > > /* optional debug port, normally in the first BAR */ > diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h > index fdd073cc053b..ad3f13a3eaf1 100644 > --- a/drivers/usb/host/ehci.h > +++ b/drivers/usb/host/ehci.h > @@ -220,6 +220,7 @@ struct ehci_hcd { /* one per controller */ > unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ > unsigned spurious_oc:1; > unsigned is_aspeed:1; > + unsigned zx_wakeup_clear_needed:1; > > /* required for usb32 quirk */ > #define OHCI_CTRL_HCFS (3 << 6) > -- > 2.32.0