Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12703519rwd; Fri, 23 Jun 2023 09:28:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IuoeaXJjqNBNtmP+sYz+pNuTIXbO1PVhiR0GuVvAYbBEJEU+B5AzB939xilBk/9rPnyPz X-Received: by 2002:a17:902:7443:b0:1b5:edd:e3c7 with SMTP id e3-20020a170902744300b001b50edde3c7mr18072292plt.16.1687537722121; Fri, 23 Jun 2023 09:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687537722; cv=none; d=google.com; s=arc-20160816; b=U8JJKhPskTw7GQFmNt2K4B3bC2Lj4tz/6VmKp3g6GoH16a5HB5A9goOoQUNIDvRniw t+Fjl174RAjE/r1TJ04I9h6kgG8E/5zLmnpjcASdrHBwqNguN3YQd3AtLG5sClTbC8m6 dItJrvED54Cg8EEJHh/i6HDvQR6IzMttAA8Qjve0LFosLbuuWdpRSY62gDgj50kfGrKo TXqOBiAsC0AUB7N0d+XCKiJgB86aogvdbO44XeXRBKEmPByu0WhOSf8tilP6f/qRu5K+ MkzJLoYSVcjBAVHtXVDbokkOV6tftd1BNdLypDem3IE1Iwa78wzW7jIQUzTBcqfHyY6J G2Lg== 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=5rCYlP4kFPAMN7WB17oqHf+XfYdw0abL7v5T3kZCENA=; b=VPLHHVizSH9Z3BSox/WwUVYYXR8Un/EUPbpQxGBrq6hJIArpN2lPjp/h7tdgcAvB9O 4GQSPNXTI6D/sZRju8rpLE5kAlTyw9A5LZwVm+mNS3LSYXn2wXVL+Z60yVeZnd0cvJXf m0ZGxISndLiQRgeAEnMMVMj/KBLP/p6JUrU5Zvis4VWtZMK+MCBYOCwKP76eZ/0CBQDR tcUmUqt3dbmpjJDpdJAiVqRf+NOt4dPoL7sfL3nU58Vvxzt4NpOPOrP9wCZ73nrillbX X6inu+3q9dBaWFWsSqUq0DY8Kst8zrWzTx+eH/FGpARJRhlydk/SXQiLBG+8y2NNrwJq wRzg== 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 ka12-20020a170903334c00b001ae0691dfdbsi8283073plb.158.2023.06.23.09.28.30; Fri, 23 Jun 2023 09:28:42 -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 S232123AbjFWPw4 (ORCPT + 99 others); Fri, 23 Jun 2023 11:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbjFWPwz (ORCPT ); Fri, 23 Jun 2023 11:52:55 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id DE2092129 for ; Fri, 23 Jun 2023 08:52:53 -0700 (PDT) Received: (qmail 754247 invoked by uid 1000); 23 Jun 2023 11:52:53 -0400 Date: Fri, 23 Jun 2023 11:52:53 -0400 From: Alan Stern To: Guiting Shen Cc: gregkh@linuxfoundation.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@microchip.com, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume Message-ID: <9c702495-a839-43ea-85b7-1c0a0c54ec73@rowland.harvard.edu> References: <20230622025739.13934-1-aarongt.shen@gmail.com> <4cf867a9-3c78-403a-aaeb-91f6cf099a3d@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Fri, Jun 23, 2023 at 11:44:04AM +0800, Guiting Shen wrote: > > > On Thu,Jun 22,2023 at 22:29:43PM GMT+8, Alan Stern wrote: > > On Thu, Jun 22, 2023 at 10:57:39AM +0800, Guiting Shen wrote: > > > The ohci_hcd_at91_drv_suspend() sets ohci->rh_state to OHCI_RH_HALTED when > > > suspend which will let the ohci_irq() skip the interrupt after resume. And > > > nobody to handle this interrupt. > > > > > > Set the ohci->rh_state to OHCI_RH_SUSPEND instead of OHCI_RH_HALTED when > > > suspend to fix it. > > > > > > Signed-off-by: Guiting Shen > > > --- > > > drivers/usb/host/ohci-at91.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c > > > index b9ce8d80f20b..7a970e573668 100644 > > > --- a/drivers/usb/host/ohci-at91.c > > > +++ b/drivers/usb/host/ohci-at91.c > > > @@ -645,7 +645,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev) > > > * REVISIT: some boards will be able to turn VBUS off... > > > */ > > > if (!ohci_at91->wakeup) { > > > - ohci->rh_state = OHCI_RH_HALTED; > > > + ohci->rh_state = OHCI_RH_SUSPENDED; > > > > It looks like this change ignores the comment immediately above it > > (just before the start of this hunk). > > > > If you want to find a way to handle IRQs better after the controller > > resumes, maybe you should change the resume routine instead of the > > suspend routine. > > > > Alan Stern > > The comment which was added with commit-id 0365ee0a8f745 may be outdated > because ohci_suspend() and ohci_at91_port_suspend() is used to suspend > instead of setting ohci->rh_state to OHCI_RH_HALTED. The comment says nothing about ohci->rh_state; it talks about the integrated transceivers and the 48 MHz clock. I don't see why you would think the comment is outdated. > What's more, I found that only ohci-at91 driver to set the ohci->rh_state > which may be unnessory because the ohci_suspend() disable irq emission and > mark HW unaccessible and ohci_at91_port_suspend() suspend the controller. > > Is it really need to set ohci->rh_state in ohci_hcd_at91_drv_suspend()? > > It maybe confused to set ohci->rh_state to OHCI_RH_SUSPEND in resume > routine. I'm not really sure what that assignment was intended to accomplish, but maybe it was meant to force a reset when the controller resumes. You could get the same result by leaving ohci->rh_state set to OHCI_RH_SUSPENDED but changing ohci_hcd_at91_drv_resume(). Instead of calling ohci_resume(hcd, false), have it call: ohci_resume(hcd, !ohci_at91->wakeup); That way, if the wakeup flag is clear and the clock was stopped, ohci_resume() will call ohci_usb_reset(). You should also add a comment explaining the reason. I can't test this because I don't have the AT91 hardware. Alan Stern