Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp434856pxk; Wed, 9 Sep 2020 09:06:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPNXQNe9P8JlP5IlT3RUpFmyuoHta9MDiUrMJMP4e3Lo5hDw66JDxN6fuvBdh0iVUSCyMl X-Received: by 2002:a50:8e58:: with SMTP id 24mr4959392edx.226.1599667568643; Wed, 09 Sep 2020 09:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599667568; cv=none; d=google.com; s=arc-20160816; b=o9chTAgpxZY6ow9NGE0m8Udw0f287H+RfKcu92YkhY5nV8O8fmMdWrhsqBd1Iu6QGs OUlMCK6hie0dayfdQccJI7LmbGntXrRMIWHGQWU8tfeITlfh4BAhxnWFuv21uIjJ1wEa W9wI1aG2qnS59yZsZ49Czg3ayDvQsvW1MEcdguZPHsEvDJ8yBWiKxrRA2UKA59NChy5a DUDzOYMVbL2FLkpjSvXDsEDM3B+rXtCQLMb/TvzTgXX9VLiiNdqJBfNAGSc1uSeXQZRS +72pzzKIyz3F0TrMcNqKBJvjoOLQAV6blE3O7/+FIkSwbLQ8yf3XLYjrvD39rJiQkg5W TNpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=H4dky5Jx89tVX2yVdssfAU54dZygo06mFpsj6uqPegU=; b=j2zICNEOK67O/A9Hsa3o3HgcmoDKTW3t1lUlPjKtVbpp64NQwgrQrRvBsgDCs2xueW GdrneRaYEVYCgvVieXQ8NLE/m89vdlXR2L3vnLwZsQI9RbZ+d2DZdQj75NWmdpNoARHg z9EQBBS825TnU+E1OIkZV5+n/PiCq1/Qs1XR18din/lCvAKKV97BpcPPk5usuf++dZWu 5W/rfEcCU9oiN0CSG5LmZe9Q5sLfede/uawkferGXAMzD41F6sa8Ee7DlhGsdTLx9UG3 abzqDiOoWWE1uWpeVR4Et9og2kiO8voRuG4LvzgBTLYd7oGY7l/UuNCIkJ5Ai84eRHRV 0daw== 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 p2si1722438ejf.310.2020.09.09.09.05.44; Wed, 09 Sep 2020 09:06:08 -0700 (PDT) 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 S1730882AbgIIQEB (ORCPT + 99 others); Wed, 9 Sep 2020 12:04:01 -0400 Received: from netrider.rowland.org ([192.131.102.5]:57829 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730716AbgIIQDZ (ORCPT ); Wed, 9 Sep 2020 12:03:25 -0400 Received: (qmail 818232 invoked by uid 1000); 9 Sep 2020 10:05:47 -0400 Date: Wed, 9 Sep 2020 10:05:47 -0400 From: Alan Stern To: Hamish Martin Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: ohci: Default to per-port over-current protection Message-ID: <20200909140547.GB817244@rowland.harvard.edu> References: <20200909035734.22463-1-hamish.martin@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909035734.22463-1-hamish.martin@alliedtelesis.co.nz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 09, 2020 at 03:57:34PM +1200, 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. > > 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. > > We now alter the default to use per-port over-current protection. > > 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. How about changing the quirk name to something more meaningful, such as OHCI_QUIRK_GANGED_POWER_NO_OVERCURRENT? > - 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. Also consider renaming OHCI_QUIRK_HUB_POWER to something like OHCI_QUIRK_PORT_POWER_ALWAYS_ON. > Suggested-by: Alan Stern > Signed-off-by: Hamish Martin > --- > drivers/usb/host/ohci-hcd.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c > index dd37e77dae00..8ab81f6ab150 100644 > --- a/drivers/usb/host/ohci-hcd.c > +++ b/drivers/usb/host/ohci-hcd.c > @@ -673,20 +673,25 @@ static int ohci_run (struct ohci_hcd *ohci) > > /* handle root hub init quirks ... */ > val = roothub_a (ohci); > - val &= ~(RH_A_PSM | RH_A_OCPM); > + /* Configure for per-port over-current protection by default */ > + val &= ~RH_A_NOCP; > + val |= 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 |= RH_A_NOCP; > - val &= ~(RH_A_POTPGT | RH_A_NPS); > - ohci_writel (ohci, val, &ohci->regs->roothub.a); > + val &= ~(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 &= ~RH_A_PSM; > val |= RH_A_NPS; PSM is ignored when NPS is on. You needn't bother to set it. > - 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); You didn't actually change the default: distrust_firmware is still initialized to true. Alan Stern