Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp809657imm; Mon, 2 Jul 2018 23:50:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqd0j2kMXomznKMLEGLRLX1kWHlSXIhi3WQTkBMEhQMRgxQI5WfN621uv8U7/OfZ3ubagi X-Received: by 2002:a65:6699:: with SMTP id b25-v6mr24739013pgw.426.1530600640971; Mon, 02 Jul 2018 23:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530600640; cv=none; d=google.com; s=arc-20160816; b=lYMUoRJS5jbf0ZYyAYJuAko6oq0PDE7OOChtRkCgkkHu1525b6yBvuVxFNhkK/Vfpy t2D0mQYdFgBIG0T924Whl+96riNVTHnPjA2riJDlGirIKMmbEW86JI2Iz2yQaPc0JEHQ 5aHH5BXXJ5DIzKYFZKhStD1fIYCjllLOeWZQTI2C2uUxAw61LL+zPC1cUcHnZZy8KfrL hJ/x1zw85vENc+LHsfMW5uxjV5pCnOk39qmIYgfhR3SKGL6eipMPHp5j+wn7w2SavIFw jaNu2BF0+5/r61gVPCBVrG8taxYwGcnreHAMw1rv3Y9mJkMgYCIhGkCc/YICUxFYjiBL pHtQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=1LlpJ+T7eFULSHhRhByfISEUD7DNoktCxSc7seVaP84=; b=gb9nOnGIwXk8ZQMiz+GQc+64FjinT7VCAF5hatpy/XqrPCc3+39CUFvhodmI5D5QqP Biypo45YccjaNOOD5FF0JJ9PpNFBviG8L0+/bFNbTOWfZ1bfIMS1anYzDTqJXPARGg2y ijc9EbX8cAGwb9N96hdlzyHi5O1nude8vAi1J0WRV13zj58pPmWjzTFWydZEfrmoaEbo 1r6M+HOdycZziGws0g4frsiZGcX62ufXOb0ZIZMaqcG3KaYjLSFVNdrVs13ZHbeHJKiW tf1WVTm6VwJHHzdK/MN8uCIDgIIoD7YY8qUqKOWj3+XNPThMNo6WDQgZZJi40EgDeZhd aZVA== 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 h1-v6si427578pfn.285.2018.07.02.23.50.26; Mon, 02 Jul 2018 23:50:40 -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 S1753643AbeGCGto (ORCPT + 99 others); Tue, 3 Jul 2018 02:49:44 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:32907 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751760AbeGCGtm (ORCPT ); Tue, 3 Jul 2018 02:49:42 -0400 Received: from [192.168.0.3] (ip5f5aebd9.dynamic.kabel-deutschland.de [95.90.235.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 886D02012BA054; Tue, 3 Jul 2018 08:49:40 +0200 (CEST) Subject: Re: [PATCH] usb/host/pci-quirks: Only reset USB bus on NVIDIA devices To: Alan Stern Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Paul Menzel Message-ID: Date: Tue, 3 Jul 2018 08:49:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Alan, Thank you very much for looking into this issue. Am 02.07.2018 um 19:19 schrieb Alan Stern: > 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. > 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) Tested on ASRock E350M1 with GRUB as bootloader, and a mouse attached to the USB port. The mouse works under X. Kind regards, Paul