Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp221876imm; Mon, 2 Jul 2018 10:21:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpceMX91nQkrojIKFlNuWn9O2DWgrrmZJcKffm3hw61IQmDNkwD5qJRXLs7FvojmiOIG3vcM X-Received: by 2002:a17:902:d807:: with SMTP id a7-v6mr17545803plz.214.1530552062422; Mon, 02 Jul 2018 10:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530552062; cv=none; d=google.com; s=arc-20160816; b=lKlK5yYTfxTmpveaRq9lQDtCu4ujzxgpO2f1PmVTQToaRLtLJvuXhmk5U9ly4DZOBT NcqhCYHYzXMQJNJpnkI0td2BUYNMRBXNyJjpuct7Gd8EdrJ8K1Tk1R41yfbdwrRyi3GZ pulA+keJSStIj/iH3AkBTB767QGpqntg/LNsBEWRdKJcjlLr/TW12FEM/EOTFvA60iO5 3EysMUC/TNQMpVamz2E7I65zGSnvtC7xphy0hPwvVpl1vAGYY3pERHQy/NG54Nf/C2Ih CnB68pXpzSzGhXyLODdvm14O+yCIVgNsBnTd/HwKFxtJq1k3d4v00MrYlS+ilw769Bx1 IjxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=/cqlMDeAygWTf0bIRe1oICyHZhwot8E45ebKHyh06OU=; b=tvNfCm2Eq1d3szTbnHrz21IsyCyfT70ikSfu/TDy/ZMxNc4UyzG/FvIe0Itee948I0 rXV094Jkl85y45eh8dAIEPdkqhLhgVF4dROAHfoXreWbZLrTgMFpqd4+KtVTKuMp3jFA GS4aTu61ebost6ag+/94QUlPHQzHiXPekE1U1huNIz4MByMu7hfJZBqbSBe6yZLnqdI4 Bly05vTNmPCOhMmDp3Pz4gKMfScRdJWtPQaeKwIVaIJUOs2g2hUmBV+IeG/hxqvjDKM0 GKf6zaRDQejtsrZm1lgW44Y+28RrOgjjZShDYcPalNly7EB4BkeMR3RiIU03YL+5HPgL J2Mg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e125-v6si11118864pgc.424.2018.07.02.10.20.47; Mon, 02 Jul 2018 10:21:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753048AbeGBRTr (ORCPT + 99 others); Mon, 2 Jul 2018 13:19:47 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:39506 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752445AbeGBRTq (ORCPT ); Mon, 2 Jul 2018 13:19:46 -0400 Received: (qmail 4343 invoked by uid 2102); 2 Jul 2018 13:19:45 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 2 Jul 2018 13:19:45 -0400 Date: Mon, 2 Jul 2018 13:19:45 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Paul Menzel cc: Greg Kroah-Hartman , , Subject: Re: [PATCH] usb/host/pci-quirks: Only reset USB bus on NVIDIA devices In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 Jul 2018, Alan Stern wrote: > > >> The problem is, that currently 100 ms sleep is over 10 % of the overall > > >> execution time of the Linux kernel here. So I really like to not sleep > > >> if it’s not needed. > > > > > > It would be nice to execute the probes in parallel; that would reduce > > > the total delay to 50 ms. However, that is the subject of a separate > > > discussion. > > > > > >>> Besides, doesn't it seem like a bad idea to reset the controller while > > >>> leaving devices on the USB bus in whatever state they happened to be? > > >> > > >> Yes, it’s probably not optimal. > > >> > > >> I wonder if the reset is needed, if the firmware has already initialized > > >> the device. > > > > > > The devices on the bus need to be reset, because the OS has no idea of > > > what they are and what the firmware has them doing. > > > > > > For example, the firmware may have assigned bus address 2 to a > > > keyboard. But the OS can initialize the devices in a different order, > > > and it might want to assign bus address 2 to a USB drive. Then you'd > > > have two devices trying to use the same address at the same time, which > > > would not be a good thing. > > > > Understood. > > > > So, what would be a way forward? Add a whitelist for boards or chipsets > > not needing the 50 ms delay? > > The 50-ms delay isn't for the board or the chipset; it is for the USB > devices that are plugged into the controller. It is required by the > USB spec, so we can't get rid of it. I may have been too hasty. The drivers for other types of USB host controllers do not perform a USB bus reset during startup, so maybe OHCI doesn't really need it either. We still need to put the controller into the correct state, but what happens to the bus shouldn't matter. This is because reinitializing the controller disables all its ports, and the only way to enable a port is by sending a reset signal through it. So the attached devices will end up getting reset one way or another, even if we don't do it explicitly during the handoff. Therefore in theory we should be okay without the 50-ms delay at all. And we might as well tell the controller to go into the USB_RESET even if it already is in that state; testing the current state is more effort than just doing setting it. Something like the patch below ought to work, although I wouldn't submit it for the -stable kernels since it doesn't fix a real bug. It's not clear why OHCI has both a USB_RESET state and a HostControllerReset command, especially since the command changes the state to USB_SUSPEND instead of USB_RESET. This is just one of several odd things in the OHCI specification. Alan Stern Index: usb-4.x/drivers/usb/host/pci-quirks.c =================================================================== --- usb-4.x.orig/drivers/usb/host/pci-quirks.c +++ usb-4.x/drivers/usb/host/pci-quirks.c @@ -783,15 +783,9 @@ static void quirk_usb_handoff_ohci(struc /* disable interrupts */ writel((u32) ~0, base + OHCI_INTRDISABLE); - /* Reset the USB bus, if the controller isn't already in RESET */ - if (control & OHCI_HCFS) { - /* Go into RESET, preserving RWC (and possibly IR) */ - writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); - readl(base + OHCI_CONTROL); - - /* drive bus reset for at least 50 ms (7.1.7.5) */ - msleep(50); - } + /* Go into the USB_RESET state, preserving RWC (and possibly IR) */ + writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); + readl(base + OHCI_CONTROL); /* software reset of the controller, preserving HcFmInterval */ if (!no_fminterval)