Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp8347653pxu; Sun, 27 Dec 2020 03:25:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwz4oKnvlggYlYNmzr/aVkpYvPjXsji9NDD4bC5lVTBRZO9YrhNLLxwwRnVVFdMT4PwCA9n X-Received: by 2002:aa7:c358:: with SMTP id j24mr38717751edr.265.1609068347079; Sun, 27 Dec 2020 03:25:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609068347; cv=none; d=google.com; s=arc-20160816; b=Rg8pOj3Y0UCA/NKN6lD/e/wIK2KzBChxNoHMF3L8f/4mjk44zKz3xnC79VPZG0PanQ kd7f1DQBANFpjL6yc0E7/L1y4vHl7bR9eNPKkycD8HSBUA+zAaNGgAfMKa8FKY8sYGDN 1JcTiRExvKuwal2hbCSXFZVGPqAkDLHNxQjrHcXr+ycggPMNuHviwUHCM+WL1aOXOuia J/u7jdCek9VElzCTaHMKJlBXcAhHyE3i80wxcELdBF/x8MKICqGbqdf3BjFmxXtgMyZS XxRf+caI+lgxH2iNUzmPez0hsb/vNwKUFksAk5Y2E6Pxwx2G4aT4/+XVqNKrniwGN2fe Md8Q== 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=NlbdLRZu3sxJfgl+DbjuBHBfD/zxEG0Yzt0rT61WHvw=; b=WtexfWrG37m2yOT996yH0t+xY9ZQwZVY5dyM0eIAI5ep7H1RXWJPSlx2OkNli+sKJB mOLvd5eQF9xLQFhdXgCRXLDoEnpPuW3wD4DBuvKp1rJC5VRZOWHv5B0VG1cT/ZRb2XSk kdWA8lCY6ScI1fSOIPQ4AmauYXr1FDxW4rMGWAou5FWn9CeUXshsque+nAyl+u5ov7K4 NQQJz4Mz93zpqAxgNmJP7KCoc9NM1wS5nPYcx7lF50/3uIHUzOpojoivIxmgHLwKVRcU t3Lt6VuSWl4uQSBZOkiGqGM2KAP97xCBuHYx12TyPL4qFVckWkNgolAytprxT12RSeiH yjdg== 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 s23si19097056eds.566.2020.12.27.03.25.17; Sun, 27 Dec 2020 03:25:47 -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 S1726167AbgL0LXU (ORCPT + 99 others); Sun, 27 Dec 2020 06:23:20 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:43973 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgL0LXT (ORCPT ); Sun, 27 Dec 2020 06:23:19 -0500 Received: from aptenodytes (lns-bzn-59-82-252-129-67.adsl.proxad.net [82.252.129.67]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id F2D05200002; Sun, 27 Dec 2020 11:22:35 +0000 (UTC) Date: Sun, 27 Dec 2020 12:22:34 +0100 From: Paul Kocialkowski To: Hamish Martin Cc: stern@rowland.harvard.edu, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] usb: ohci: Default to per-port over-current protection Message-ID: References: <20200910212512.16670-1-hamish.martin@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Smv2TijY037QtWlE" Content-Disposition: inline In-Reply-To: <20200910212512.16670-1-hamish.martin@alliedtelesis.co.nz> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Smv2TijY037QtWlE Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri 11 Sep 20, 09:25, Hamish Martin wrote: > Some integrated OHCI controller hubs do not expose all ports of the hub > to pins on the SoC. In some cases the unconnected ports generate > spurious over-current events. For example the Broadcom 56060/Ranger 2 SoC > contains a nominally 3 port hub but only the first port is wired. >=20 > Default behaviour for ohci-platform driver is to use global over-current > protection mode (AKA "ganged"). This leads to the spurious over-current > events affecting all ports in the hub. >=20 > We now alter the default to use per-port over-current protection. This specific patch lead to breaking OHCI on my mom's laptop (whom was about to buy a new one thinking the hardware had failed). I get no OHCI interrupt= at all and no USB 1 device is ever detected. I haven't really found a reasonable explanation about why that is, but here are some notes I was able to collect: - The issue showed up on 5.8,18 and 5.9.15, which don't include the patch from this series that sets distrust_firmware =3D false; This results in t= he NPS bit being set via OHCI_QUIRK_HUB_POWER. - Adding val &=3D ~RH_A_PSM; (as was done before this change) solves the is= sue which is weird because the bit is supposed to be inactive when NPS is set; - Setting ohci_hcd.distrust_firmware=3D0 in the cmdline results in not sett= ing the NPS bit and also solves the issue; - The initial value of the register at function entry is 0x1001104 (PSM bit is set, NPS is unset); - The OHCI controller is the following: 00:03.0 USB controller: Silicon Integrated Systems [SiS] USB 1.1 Controller= (rev 0f) (prog-if 10 [OHCI]) Subsystem: ASUSTeK Computer Inc. Device 1aa7 Does that make any sense to you? I really wonder what a proper fix could be and here are some suggestions: - Adding a specific quirk to clear the PSM bit for this hardware which seem= s to consider the bit regardless of NPS; - Adding the patch that sets distrust_firmware =3D false to stable branches; What do you think? Cheers, Paul > This patch results in the following configuration changes depending > on quirks: > - For quirk OHCI_QUIRK_SUPERIO no changes. These systems remain set up > for ganged power switching and no over-current protection. > - For quirk OHCI_QUIRK_AMD756 or OHCI_QUIRK_HUB_POWER power switching > remains at none, while over-current protection is now guaranteed to be > set to per-port rather than the previous behaviour where it was either > none or global over-current protection depending on the value at > function entry. >=20 > Suggested-by: Alan Stern > Signed-off-by: Hamish Martin > --- >=20 > Notes: > Changes in v2: > - remove clearing of RH_A_PSM in OHCI_QUIRK_HUB_POWER block. >=20 > drivers/usb/host/ohci-hcd.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c > index dd37e77dae00..2845ea328a06 100644 > --- a/drivers/usb/host/ohci-hcd.c > +++ b/drivers/usb/host/ohci-hcd.c > @@ -673,20 +673,24 @@ static int ohci_run (struct ohci_hcd *ohci) > =20 > /* handle root hub init quirks ... */ > val =3D roothub_a (ohci); > - val &=3D ~(RH_A_PSM | RH_A_OCPM); > + /* Configure for per-port over-current protection by default */ > + val &=3D ~RH_A_NOCP; > + val |=3D RH_A_OCPM; > if (ohci->flags & OHCI_QUIRK_SUPERIO) { > - /* NSC 87560 and maybe others */ > + /* NSC 87560 and maybe others. > + * Ganged power switching, no over-current protection. > + */ > val |=3D RH_A_NOCP; > - val &=3D ~(RH_A_POTPGT | RH_A_NPS); > - ohci_writel (ohci, val, &ohci->regs->roothub.a); > + val &=3D ~(RH_A_POTPGT | RH_A_NPS | RH_A_PSM | RH_A_OCPM); > } else if ((ohci->flags & OHCI_QUIRK_AMD756) || > (ohci->flags & OHCI_QUIRK_HUB_POWER)) { > /* hub power always on; required for AMD-756 and some > - * Mac platforms. ganged overcurrent reporting, if any. > + * Mac platforms. > */ > val |=3D RH_A_NPS; > - ohci_writel (ohci, val, &ohci->regs->roothub.a); > } > + ohci_writel(ohci, val, &ohci->regs->roothub.a); > + > ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status); > ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM, > &ohci->regs->roothub.b); > --=20 > 2.28.0 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --Smv2TijY037QtWlE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAl/obnoACgkQ3cLmz3+f v9H38Qf/bak2ehuKVY7Ky7MD+Yo2z98TvUwbvJMz4t6ncISe+LaeOfCjnVEiw0Gp TUZA2OUDR9pTFuPg7KwYzOGGvRR2DV+b3YDNOawTs2enzC62ToFldHGUuezdL/kN Zatg86b4vECQDldjqKNmVP7Z8ttu31RXzdOBi0CVZNNz94m+ytsA5d966G43iVmB /bLz5kQ+j9MDQulx+IUQcALDUAEoIG9hGoqPNN8/Ci/Xex1ul3N2giRxk2SQk0hB n4V/1Nwif4TWUdwHnH7WI4JWGey7+rTODDR4uxDfedzL6+dgHeXuIX2aSA0LbcQu m9fcSb1m6aXjK2f8VQoPajo3wUY2KQ== =khjv -----END PGP SIGNATURE----- --Smv2TijY037QtWlE--