Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1159536pxu; Fri, 27 Nov 2020 00:48:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXGQJhqPWGlsULmozx4KdKvQEyeY3lv1PpRYXdwQXx17TWsnR118P9G6iasWJj9ORPe1PO X-Received: by 2002:a50:d757:: with SMTP id i23mr6519607edj.116.1606466907112; Fri, 27 Nov 2020 00:48:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466907; cv=none; d=google.com; s=arc-20160816; b=jRqqQpEa/xXXuajZjUhG4DQOcko1poFqmgGCDSDucw6dOjJKmLM3BFwQdb8UUMOwl3 Rxv9E0ed15LIOnu/ke4mRG0ldq6p+yKuZsyRAAx0YksEmRVPJEf9/eHPLSi4GpbxtHQk yXKFEuc4CMnat6ae4SE4va3oxozHwR3EspwkFqYRgiBJ94L1E/9bi+rGT0jBDXyGProE 0J3PLKH7yoi/AzKKklaBV09yR8aL/oeMbWgJWWglBYmC32WQo9mSIJSZBgCQCAnyW5hd HO3R1sKTWkFXSeR8xghkie7K5Yiss7zA8bY4HQEgtuoN1guv0tCj/yMS2gXLtGGWqDR1 cB8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=2fJ4d0XNd04E7yfBCsPAVKD5WshCWHn/bndAVS1csts=; b=cS1tfigUR45bpe8UUTwtC2sF7yHJ7bcMVJ3nYaHupgbY5Z/Plp6jo48s46r6gUTgHe j6KKSTF2R90TyF4lCt+L98LQDaCGel0pQb7UkQO+yDX9fK5QgT6rZvvTIuboUH4kuHsi anSMuoG5pvFM4YLzEQ0wwHg0/n4NNRkWJAdHOqFLI3SIkADMDZolqC/SrZhsant5CJCo GaupSWw4GWrqxM9WNWkDC0AVNiCZbpqH1iGNrmH7LCk3kaQ4L1eZSFHBtX6KOm12CB7W krb3NQLM1U70bPcSXLBzlJwmTVvw1kSl3feKaPdJRgdyJtKzYWpP/uREzCKmTbKChTcx j75A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si4634227edj.71.2020.11.27.00.48.04; Fri, 27 Nov 2020 00:48:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392228AbgK0C3L (ORCPT + 99 others); Thu, 26 Nov 2020 21:29:11 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8043 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbgK0C3L (ORCPT ); Thu, 26 Nov 2020 21:29:11 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Chz8G0fB9zhhvK; Fri, 27 Nov 2020 10:28:46 +0800 (CST) Received: from [10.67.102.118] (10.67.102.118) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Fri, 27 Nov 2020 10:29:03 +0800 Subject: Re: [PATCH] USB:ehci:fix an interrupt calltrace error To: Alan Stern CC: , , References: <1606361673-573-1-git-send-email-liulongfang@huawei.com> <20201126160830.GA827745@rowland.harvard.edu> From: liulongfang Message-ID: <96b4d366-c94c-9708-da12-5693bf16b716@huawei.com> Date: Fri, 27 Nov 2020 10:29:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20201126160830.GA827745@rowland.harvard.edu> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.118] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/11/27 0:08, Alan Stern Wrote: > On Thu, Nov 26, 2020 at 11:34:33AM +0800, Longfang Liu wrote: >> The system goes to suspend when using USB audio player. This causes >> the USB device continuous send interrupt signal to system, When the >> number of interrupts exceeds 100000, the system will forcibly close >> the interrupts and output a calltrace error. > > This description is very confusing. USB devices do not send interrupt > signals to the host. Do you mean that the device sends a wakeup > request? Or do you mean something else? The irq type is IRQ_NONE??It's counted in the note_interrupt function. From the analysis of the driver code, that are indeed interrupt signals. > >> When the system goes to suspend, the last interrupt is reported to >> the driver. At this time, the system has set the state to suspend. >> This causes the last interrupt to not be processed by the system and >> not clear the interrupt state flag. This uncleared interrupt flag >> constantly triggers new interrupt event. This causing the driver to >> receive more than 100,000 interrupts, which causes the system to >> forcibly close the interrupt report and report the calltrace error. > > If the driver receives an interrupt, it is supposed to process the event > even if the host controller is suspended. And when ehci_irq() runs, it > clears the bits that are set in the USBSYS register. When the host controller is suspended, the ehci_suspend() will clear the HCD_FLAG_HW_ACCESSIBLE, and then usb_hcd_irq() will return IRQ_NONE directly without calling ehci_irq(). > > Why is your system getting interrupts? That is, which bits are set in > the USBSTS register? BIT(5) and BIT(3) are setted, STS_IAA and STS_FLR. > >> so, when the driver goes to sleep and changes the system state to >> suspend, the interrupt flag needs to be cleared. >> >> Signed-off-by: Longfang Liu >> --- >> drivers/usb/host/ehci-hub.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c >> index ce0eaf7..5b13825 100644 >> --- a/drivers/usb/host/ehci-hub.c >> +++ b/drivers/usb/host/ehci-hub.c >> @@ -348,6 +348,11 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) >> >> /* Any IAA cycle that started before the suspend is now invalid */ >> end_iaa_cycle(ehci); >> + >> + /* clear interrupt status */ >> + if (ehci->has_synopsys_hc_bug) >> + ehci_writel(ehci, INTR_MASK | STS_FLR, &ehci->regs->status); > > This is a very strange place to add your new code -- right in the middle > of the IAA and unlink handling. Why not put it in a more reasonable > place?After the IAA is processed, clear the STS_IAA interrupt state flag. > > Also, the patch description does not mention has_synopsys_hc_bug. The > meaning of this flag has no connection with the interrupt status > register, so why do you use it here? Because of our USB IP comes from Synopsys, and the uncleared flage is also caused by special hardware design, in addition, we have not tested other manufacturers' USB controllers.We don??t know if other manufacturers?? designs have this problem, so this modification is only limited to this kind of design. > >> + >> ehci_handle_start_intr_unlinks(ehci); >> ehci_handle_intr_unlinks(ehci); >> end_free_itds(ehci); > > Alan Stern > . > Thanks, Longfang Liu