Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1335035imi; Sat, 23 Jul 2022 02:43:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tZM7M4vp80X57ZvU6jSqYLWoDIPbJqblYkjJZ09Goe/mE2OE++cKx+10HuREZuCo+VIHmw X-Received: by 2002:a17:907:7349:b0:72d:a080:f8b0 with SMTP id dq9-20020a170907734900b0072da080f8b0mr2900243ejc.389.1658569428495; Sat, 23 Jul 2022 02:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658569428; cv=none; d=google.com; s=arc-20160816; b=OWQIDoT+vu+t3wx9sBfLBoHRhiXkS5iDZpu2cUFZTj9V1x/20kpMCjHV9/l5b+pAV+ EP+gDdLI4E13pM3I9AihYlpNsGSj5VFCaIk3C2TiDwD+wf0f6OGb9UC0WEzcAw/WofQ3 DwuTEd2PswQxaqTGV6IV1+lZnBuykBAqXefA3A3ZGMJ/ePKJi6zryuu2Cc9RkMeb5qR7 t9ghfCjFev/ECQTxrnj0RuLqQR6B/YOnYMzxJLlSNtZLqqSZ1ku2VKYMpHYbIwR/IBBs aaveL/UPp2+P1Egzt9laUggvEnVHf2guoronhwe7E1Bf1yfuObm4lR8O//vi9SrkPMUA JdgQ== 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:dkim-signature; bh=b5bVCXbhcTNR+CnLs7ny3yPTp0L+ij1nEc/4tgkbSmw=; b=VJDzY5A824GkzXhnqHzuLI/kfywfeB406UqJUAzBfjTxtjnkY+EaNuBvbowxrTd3hQ CMolTo5FoD4CXpFToek46udV8tcn05Hc7GbQrXa9o3a3irefcIGpSqq4mApkLA/t5gby 4ccHjzZEVzLnS2LCVznfWXwazfefzPYenYE11BZWOl3TmH6hQBYLaZ1li3UkeN5TMFLW LUiPILpg28f+qzQRs0F03ndRdx27xvZR5Q1NBNdyDK9uWK712rB/rKB8IA8yRcq9/srt 5VLZexKiwtYzOQSW4uysySW6GvKO6Lfpea3nRLmbBTUqH6/fjm0/NH81Cl870v60YmoT zP2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RSM2Fvxp; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020a05640242d400b0043bc342ffa9si10580604edc.133.2022.07.23.02.43.23; Sat, 23 Jul 2022 02:43:48 -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=RSM2Fvxp; 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 S237249AbiGWJby (ORCPT + 99 others); Sat, 23 Jul 2022 05:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbiGWJbx (ORCPT ); Sat, 23 Jul 2022 05:31:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B7C012632; Sat, 23 Jul 2022 02:31:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id 26B39B827CC; Sat, 23 Jul 2022 09:31:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FCE5C341C0; Sat, 23 Jul 2022 09:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658568709; bh=nOYpDiEuiMsa/dvvzuJwWwhhNMgzATPrg+9e85VUeiM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RSM2Fvxp5zpJU3r95P2oTb3eBcNbZAzQK9K5SspVyMFqktjSBC2F2cemyDKXiB+Eb EkMP1qaZf2o7hFR8X1i5Jnru7Oscr52T7thwEguc/FnPNki7O+Rsr7QHdPoMRUm0Ag TNDaW3tH0+LJPJ3Z8dChKatg+IKdHmnMAmuzlj9Q= Date: Sat, 23 Jul 2022 11:31:40 +0200 From: Greg KH To: xy521521 Cc: stern@rowland.harvard.edu, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, EdisonZhang@zhaoxin.com, PeterWu@zhaoxin.com, cobechen@zhaoxin.com, wugaoquan@kylinos.cn, Hongyu Xie Subject: Re: [PATCH -next] usb: ehci: Read CMD_RUN instead of STS_HALT in ehci_halt with ZX-200 Message-ID: References: <20220723073805.23491-1-xy521521@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220723073805.23491-1-xy521521@gmail.com> X-Spam-Status: No, score=-7.8 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 On Sat, Jul 23, 2022 at 03:38:05PM +0800, xy521521 wrote: > From: Hongyu Xie > > Forcing HC to halt state is ensured by reading STS_HALT field in USBSTS > register every microsecond(2ms in total) after clearing CMD_RUN filed in > USBCMD register during initialization. > > But sometimes the STS_HALT field in USBSTS is not set during that 2ms, i.e > ehci_handshake returns -ETIMEDOUT. And host controller won't work after > that, so does the device attached on it. This was first found on a system > with ZX-200 HC on it. > > The interesting part is that if you ignore -ETIMEOUT returned from > ehci_handshak or read CMD_RUN instead and continue the initialization, the > HC works just fine. > > So read CMD_RUN instead. You do not define what a "ZX-200" is, please do so. This feels like a bug in the hardware, right? If so, why not make a new quirk flag for it and handle it that way as odds are it probably is in other devices based on this silicon. > > Signed-off-by: Hongyu Xie Is thie relevant for stable kernels? If so, how far back? > --- > drivers/usb/host/ehci-hcd.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c > index 684164fa9716..a935cfb79bcc 100644 > --- a/drivers/usb/host/ehci-hcd.c > +++ b/drivers/usb/host/ehci-hcd.c > @@ -181,6 +181,7 @@ static int tdi_in_host_mode (struct ehci_hcd *ehci) > static int ehci_halt (struct ehci_hcd *ehci) > { > u32 temp; > + struct pci_dev *pci_dev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); Wait, how do you know this is a PCI device? What happens when you run this on a ehci controller that is not a PCI device? How well did you test this change? > > spin_lock_irq(&ehci->lock); > > @@ -204,8 +205,14 @@ static int ehci_halt (struct ehci_hcd *ehci) > spin_unlock_irq(&ehci->lock); > synchronize_irq(ehci_to_hcd(ehci)->irq); > > - return ehci_handshake(ehci, &ehci->regs->status, > - STS_HALT, STS_HALT, 16 * 125); > + if (((pci_dev->vendor == PCI_VENDOR_ID_ZHAOXIN) && > + (pci_dev->device == 0x3104) && > + ((pci_dev->revision & 0xf0) == 0x90))) > + return ehci_handshake(ehci, &ehci->regs->command, CMD_RUN, > + 0, 16 * 125); What is the "0" here for? > + else No need for the else statement, checkpatch should have caught that, right? thanks, greg k-h