linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: liulongfang <liulongfang@huawei.com>
Cc: mathias.nyman@intel.com, stern@rowland.harvard.edu,
	liudongdong3@huawei.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, kong.kongxinwei@hisilicon.com,
	yisen.zhuang@huawei.com
Subject: Re: [RFC PATCH] USB:XHCI:skip hub registration
Date: Fri, 16 Apr 2021 07:16:32 +0200	[thread overview]
Message-ID: <YHkdsMR7E2Dr7QTc@kroah.com> (raw)
In-Reply-To: <973a4759-4464-e59e-f84b-15672503e290@huawei.com>

On Fri, Apr 16, 2021 at 10:43:34AM +0800, liulongfang wrote:
> On 2021/4/15 20:34, Greg KH wrote:
> > On Thu, Apr 15, 2021 at 08:22:38PM +0800, Longfang Liu wrote:
> >> When the number of ports on the USB hub is 0, skip the registration
> >> operation of the USB hub.
> > 
> > That's crazy.  Why not fix the hardware?  How has this hub passed the
> > USB certification process?
> > 
> >> The current Kunpeng930's XHCI hardware controller is defective. The number
> >> of ports on its USB3.0 bus controller is 0, and the number of ports on
> >> the USB2.0 bus controller is 1.
> >>
> >> In order to solve this problem that the USB3.0 controller does not have
> >> a port which causes the registration of the hub to fail, this patch passes
> >> the defect information by adding flags in the quirks of xhci and usb_hcd,
> >> and finally skips the registration process of the hub directly according
> >> to the results of these flags when the hub is initialized.
> >>
> >> Signed-off-by: Longfang Liu <liulongfang@huawei.com>
> >> ---
> >>  drivers/usb/core/hub.c      | 6 ++++++
> >>  drivers/usb/host/xhci-pci.c | 4 ++++
> >>  drivers/usb/host/xhci.c     | 5 +++++
> >>  drivers/usb/host/xhci.h     | 1 +
> >>  include/linux/usb/hcd.h     | 1 +
> >>  5 files changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> >> index b1e14be..2d6869d 100644
> >> --- a/drivers/usb/core/hub.c
> >> +++ b/drivers/usb/core/hub.c
> >> @@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
> >>  	struct usb_host_interface *desc;
> >>  	struct usb_device *hdev;
> >>  	struct usb_hub *hub;
> >> +	struct usb_hcd *hcd;
> >>  
> >>  	desc = intf->cur_altsetting;
> >>  	hdev = interface_to_usbdev(intf);
> >> +	hcd = bus_to_hcd(hdev->bus);
> >> +	if (hcd->usb3_no_port) {
> >> +		dev_warn(&intf->dev, "USB hub has no port\n");
> >> +		return -ENODEV;
> >> +	}
> >>  
> >>  	/*
> >>  	 * Set default autosuspend delay as 0 to speedup bus suspend,
> >> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> >> index ef513c2..63b89a4 100644
> >> --- a/drivers/usb/host/xhci-pci.c
> >> +++ b/drivers/usb/host/xhci-pci.c
> >> @@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
> >>  	if (xhci->quirks & XHCI_RESET_ON_RESUME)
> >>  		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
> >>  				"QUIRK: Resetting on resume");
> >> +
> >> +	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
> >> +	    pdev->device == 0xa23c)
> >> +		xhci->quirks |= XHCI_USB3_NOPORT;
> > 
> > Can't we just detect this normally that there are no ports for this
> > device?  Why is the device lying about how many ports it has such that
> > we have to "override" this?
> > 
> 
> The hub driver will check the port number in prob(). If there is no port,
> the driver will report an error log. But we hope this defective device
> does not print error log.

Defective devices deserve to have errors sent to the error log,
otherwise how will people know to tell the companies to fix them?

Again, this device can not pass USB certification, so there's not much
we should do to work around that, right?

thanks,

greg k-h

  reply	other threads:[~2021-04-16  5:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 12:22 [RFC PATCH] USB:XHCI:skip hub registration Longfang Liu
2021-04-15 12:34 ` Greg KH
2021-04-16  2:43   ` liulongfang
2021-04-16  5:16     ` Greg KH [this message]
2021-04-15 14:43 ` Alan Stern
2021-04-16  2:03   ` liulongfang
2021-04-16 15:20     ` Alan Stern
2021-04-17  3:11       ` liulongfang
2021-04-17  6:48       ` liulongfang
2021-04-17 15:31         ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YHkdsMR7E2Dr7QTc@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=liudongdong3@huawei.com \
    --cc=liulongfang@huawei.com \
    --cc=mathias.nyman@intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).