Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp781085pxy; Wed, 5 May 2021 13:50:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5prqOnPFkrJqiKO5BWLk3OI+jwcf6Qdg84pmHtlLruod2fRiKC4E5mXCqHsgghix0+W0G X-Received: by 2002:aa7:9104:0:b029:279:e897:2825 with SMTP id 4-20020aa791040000b0290279e8972825mr851558pfh.51.1620247804497; Wed, 05 May 2021 13:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620247804; cv=none; d=google.com; s=arc-20160816; b=aGfqZ9fTMSLZf0rKSzbMh2hmLZnKIgqm/G3xlUlqaIy2ygIK8DkBnO4u1+xIyE/lOh 2Yw9HFEYOXILk7TbnJpZwnbCiseUmVMQpf5Xxxpj/DE8hq0NVXuXJwUJw3FhhrdsaAOq FUv51TsMbm8xAECadcNEYyfH41lAgWUyHa73Tqkzq6rZ5ZsPZr13PZa1/gwp49/u2sgS MtmlPlqD1Do/35o+sXvTmyG4QdA22iJLqsPWNNxlNjgVlMD4GMo7kbYPvc31zwUPgm7A ghISEIqfr3AqiCBDYhjDmSpPYEv2SCWJFfAmeXs9kjH0A0h/TDj/LHtOuub7mGDsLNsd U7IQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4KGB6jNFqbzdXlOx4iSjW7D9bRWdq+1hSzausQqh6AA=; b=rRxUj5va87gfqn1qLH0GkzKw6TTdpYHB44Tev7js3ehs8PwI85UZhDY4hXSxxQoyQ2 si+oR3QMojgbyA8+FEySdc3ZAJh6ZBzEdnVjj8aHNWvEhMHECzxteNT4yhIKb2a4bu12 edkeRaSt5J5etz9taFX5HaVx5rLIZR14sp2mZp4u3agTqBbaUuHE3bUI646jd6g8nKw9 c1Gz9TX9ikCelDctY0Z6V7NLm/CAXtzbZ0d0anJOIxa1MC53AsahlfcatssK0LHGsZGS drK9jtAqXEAhv92ZWLwoO6vP9ngU6DDnxb+bVQU72jjzXG+Ae1Ve92oc+9RFZMJxnrvO VSeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dx4Vx3IS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si328852pjs.80.2021.05.05.13.49.50; Wed, 05 May 2021 13:50:04 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dx4Vx3IS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbhEEPyS (ORCPT + 99 others); Wed, 5 May 2021 11:54:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:33446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbhEEPyR (ORCPT ); Wed, 5 May 2021 11:54:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D0D36102A; Wed, 5 May 2021 15:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620230000; bh=1IqzisQrKCry3zuhlGVA9DAmUDQ6Lmyb/6eDqrrSd5A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dx4Vx3IS7EQcYaI8hG4qSa186pMuWLX3Zz+TG0xQGg+LusDjgZX4XbZFoucHcH6NW /c9qZlJdrYfBnLVLOpkSHXENA7+mGKZrB9BEXTMfY8/n9pLgfuJBIApNulxwvN2aOr JR1X0dcND9r4Pja/BEeQ8ETM6ONpPq3jF1ZHr0X0= Date: Wed, 5 May 2021 17:53:18 +0200 From: Greg Kroah-Hartman To: Bjorn Helgaas Cc: Paul Menzel , linux-usb@vger.kernel.org, LKML , Mathias Nyman , linux-pci@vger.kernel.org Subject: Re: `quirk_usb_handoff_xhci` takes 60 ms with ASM1042 Message-ID: References: <20210505154741.GA1304534@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210505154741.GA1304534@bjorn-Precision-5520> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 05, 2021 at 10:47:41AM -0500, Bjorn Helgaas wrote: > On Wed, May 05, 2021 at 02:31:56PM +0200, Greg Kroah-Hartman wrote: > > On Wed, May 05, 2021 at 02:15:26PM +0200, Paul Menzel wrote: > > > Am 05.05.21 um 10:33 schrieb Greg Kroah-Hartman: > > > > On Wed, May 05, 2021 at 10:27:52AM +0200, Paul Menzel wrote: > > > > > Am 05.05.21 um 10:11 schrieb Greg Kroah-Hartman: > > > > > > > If the driver is built as a module, there should not be any "hot > > > > > > path" here as the module is loaded async when the device is > > > > > > discovered, right? > > > > > obj-$(CONFIG_USB_PCI) += pci-quirks.o > > > > > > > > > > So all quirks are run independently of the USB “variant” > > > > > (UHCI, OHCI, EHCI, xHCI). > > > > > > > > > > Indeed, this driver is built into the Linux kernel. > > > > > > > > > > $ grep USB_PCI .config > > > > > CONFIG_USB_PCI=y > > > > > > > > > > So, should `pci-quirks.c` be split up to have more fine > > > > > grained control? > > > > > > > > What control do you need here? > > > > > > Good question, as I do not know the USB spec. I’d say, disabling certain > > > quirks, or just run them, when the actual driver is loaded. > > > > This is not a "quirk", it is part of how USB works. > > I agree, this doesn't look like a "quirk" in the sense of working > around a hardware defect; the handoff is just a normal part of > operating the device. But can you elaborate on why it must be done > this way? > > I'm looking at the xHCI r1.2 spec, sec 4.22.1. It talks about the > handoff synchronization process and says the OS driver shall use the > defined protocol to request ownership before it uses the device. But > AFAICT there's no specific "early-startup" requirement. > > quirk_usb_handoff_xhci() is in drivers/usb/host/pci-quirks.c, which is > always built statically and the quirk runs during device enumeration, > even if the xhcd driver itself is a module. It looks like we run the > quirk even if we never load the xhcd driver. > > Why can't we just do the handoff in the xhcd driver probe? I think, if we don't do the handoff, then the BIOS/firmware tries to send the OS fake keyboard/mouse commands, and Linux isn't ready for that as we didn't allow hotplug PS/2 stuff. But I could be wrong, it's been a long time since we did that logic. Someone could try to change this and see :) > > > > Try changing your BIOS settings to not have "legacy" USB support > > > > in it, that could cause this transition to go faster, at the > > > > expense of not being able to use a USB device before Linux > > > > boots. > > > > > > The firmware of the Asus F2A85-M PRO allows to disable *legacy* > > > USB support for only the ASMedia ASM1042. And, thank you for the > > > suggestion, it helped. `quirk_usb_early_handoff()` does not show > > > up in the logs now, meaning it’s below 50 ms. And it is well > > > below: less than one millisecond. > > > > > > [ 0.308343] pci 0000:00:15.1: PCI->APIC IRQ transform: INT A -> IRQ > > > 16 > > > [ 0.308359] pci 0000:03:00.0: PCI->APIC IRQ transform: INT A -> IRQ > > > 17 > > > [ 0.308376] pci 0000:03:00.0: hc_init reached > > > [ 0.308380] pci 0000:03:00.0: second handshake done > > > [ 0.308384] pci 0000:03:00.0: third handshake done > > > [ 0.308395] PCI: CLS 64 bytes, default 64 > > > […] > > > [ 0.401722] Run /lib/systemd/systemd as init process > > > > Nice! > > > > Go blame your bios vendor now :) > > So the answer is "to make Linux boot faster, flip this BIOS switch > which means your USB devices no longer work while in BIOS"? > > I can see why this helps (BIOS never claims the xHCI, so OS can > immediately claim ownership), but it seems like a sub-optimal user > experience. Welcome to UEFI :) thanks, greg k-h