From patchwork Thu Mar 30 14:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 669387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E19BC6FD1D for ; Thu, 30 Mar 2023 14:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232493AbjC3OaF (ORCPT ); Thu, 30 Mar 2023 10:30:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232251AbjC3OaD (ORCPT ); Thu, 30 Mar 2023 10:30:03 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D25351732 for ; Thu, 30 Mar 2023 07:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680186601; x=1711722601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MMDAVcDFo6/QQcdlj3DTrQwtZPY9SuZ1TBG0sLiBIQo=; b=Pn+/8EaaiXnaedD6MOPIiu7soJ7Kj/meGbbnzq2LoEWvelFR2E3VB+Cc f0o0BCaRY+lkrhS5J8obyWbxjc53PpjwzLie00MoxxAh3gYgRvi7BzOut Iv6/qadxkg1aBCdWcN8BVaPuHhIrrGn6nbgT0M+94To8CFGGYzoHkQX+V bcK+KuqUmHImbUyUw4y86XKugNOykIIDtOvzDA/ls+tTouPNuF8U2W0i4 Z/YooLWBIknXG/HBQGd2FtMSOYtjTpdZ+C2EQ4uddY3g0jpOUYyU6jLPp dVUIk4puM3fTk08Mgrdi+WuS5f30soZoR4dLWYt+BXhkys/l+/8HVUJU6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="406172553" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="406172553" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 07:29:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="774021093" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="774021093" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by FMSMGA003.fm.intel.com with ESMTP; 30 Mar 2023 07:29:47 -0700 From: Mathias Nyman To: Cc: , D Scott Phillips , Marc Zyngier , Mathias Nyman Subject: [PATCH 1/3] xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu Date: Thu, 30 Mar 2023 17:30:54 +0300 Message-Id: <20230330143056.1390020-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230330143056.1390020-1-mathias.nyman@linux.intel.com> References: <20230330143056.1390020-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: D Scott Phillips Previously the quirk was skipped when no iommu was present. The same rationale for skipping the quirk also applies in the iommu.passthrough=1 case. Skip applying the XHCI_ZERO_64B_REGS quirk if the device's iommu domain is passthrough. Fixes: 12de0a35c996 ("xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers") Signed-off-by: D Scott Phillips Acked-by: Marc Zyngier Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6183ce8574b1..bdb6dd819a3b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -228,6 +229,7 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us) static void xhci_zero_64b_regs(struct xhci_hcd *xhci) { struct device *dev = xhci_to_hcd(xhci)->self.sysdev; + struct iommu_domain *domain; int err, i; u64 val; u32 intrs; @@ -246,7 +248,9 @@ static void xhci_zero_64b_regs(struct xhci_hcd *xhci) * an iommu. Doing anything when there is no iommu is definitely * unsafe... */ - if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !device_iommu_mapped(dev)) + domain = iommu_get_domain_for_dev(dev); + if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !domain || + domain->type == IOMMU_DOMAIN_IDENTITY) return; xhci_info(xhci, "Zeroing 64bit base registers, expecting fault\n"); From patchwork Thu Mar 30 14:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 668821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA3D3C6FD1D for ; Thu, 30 Mar 2023 14:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbjC3OaB (ORCPT ); Thu, 30 Mar 2023 10:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbjC3OaA (ORCPT ); Thu, 30 Mar 2023 10:30:00 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBB2710DD for ; Thu, 30 Mar 2023 07:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680186600; x=1711722600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oMmY+b1g2KGoiAZvCSckQgQ9KZLKSzt0B0nSDdMkzJ8=; b=Zc01aqSvnOxfq6ecK/qecst65JF06XviZ21pL8+nw7fbhS9GTStVZqC4 ZkgEfIGyc7iYkRcLM1RA9C2IEBuUn9hGsPoOjFaLvuNgnG4sR9jak/hDV 4N/LcgIyaPv24AkIZDZxFLmoEYhIMT/o6rx1XVgnY3UHyqStvyQR8ifjQ BuqNG35OvTN/Vqj+nK8wPoGGGDDwno0rTLctkYQpZgU3meGbsB5+iVyMP wPNrBvNimDyqbmN7QTN/4hoAjvU+UqOkqi1c1dEqLP5IRsCNjMlh+XBjA QI8HgQhcJUwHAW1ccU0VtEr86ei+G3+QNN/wXNP8be5pjnoVJN3T5V15x w==; X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="406172536" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="406172536" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 07:29:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="774021094" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="774021094" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by FMSMGA003.fm.intel.com with ESMTP; 30 Mar 2023 07:29:49 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 2/3] Revert "usb: xhci-pci: Set PROBE_PREFER_ASYNCHRONOUS" Date: Thu, 30 Mar 2023 17:30:55 +0300 Message-Id: <20230330143056.1390020-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230330143056.1390020-1-mathias.nyman@linux.intel.com> References: <20230330143056.1390020-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This reverts commit 4c2604a9a6899bab195edbee35fc8d64ce1444aa. Asynch probe caused regression in a setup with both Renesas and Intel xHC controllers. Devices connected to the Renesas disconnected shortly after boot. With Asynch probe the busnumbers got interleaved. xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 1 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 2 xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 3 xhci_hcd 0000:04:00.0: new USB bus registered, assigned bus number 4 Reason why this commit causes regression is still unknown, but revert it while debugging the issue. Link: https://lore.kernel.org/linux-usb/20230307132120.5897c5af@deangelis.fenrir.org.uk Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index fb988e4ea924..6db07ca419c3 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -771,12 +771,11 @@ static struct pci_driver xhci_pci_driver = { /* suspend and resume implemented later */ .shutdown = usb_hcd_pci_shutdown, - .driver = { #ifdef CONFIG_PM - .pm = &usb_hcd_pci_pm_ops, -#endif - .probe_type = PROBE_PREFER_ASYNCHRONOUS, + .driver = { + .pm = &usb_hcd_pci_pm_ops }, +#endif }; static int __init xhci_pci_init(void) From patchwork Thu Mar 30 14:30:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 669388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B9E9C761AF for ; Thu, 30 Mar 2023 14:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232303AbjC3OaD (ORCPT ); Thu, 30 Mar 2023 10:30:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232345AbjC3OaB (ORCPT ); Thu, 30 Mar 2023 10:30:01 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8037B3; Thu, 30 Mar 2023 07:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680186600; x=1711722600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hTiUmnEecxYNtA9xQHIkvXv5NkPp0vGZ3pfAXPcUgus=; b=HFYilgzsqPUMFc4LkPAdAGNqlH/afgyPIL4baBDpFcNE1v93eFeh95g4 T294+63ha4hUIxUzUvP9LoZ3SfazabDpu1FWnrh3IH1UEYcodyvFurBHN XS+fwIDC1+BCqpLqppsqRyuTqVBEU3G7YImIVs59flWme1DQKOp8nV/eG P03g9PQK6+sV2OeVWyT/PpanSPCjWymYNBOhXtWE11shUsPVxUbeTGz9t 06VSXt1MQeVVpyTYVqI9nKcej/HFyFFwvklOs8KTM+ktSyuNzTIrJxXKG RDsl+gntx6EYOZutWoc1jvvagKTnum8VuNa6fGKMtwXzqSznee0NBrejS Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="406172544" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="406172544" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 07:29:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="774021097" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="774021097" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by FMSMGA003.fm.intel.com with ESMTP; 30 Mar 2023 07:29:50 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman , Mirsad Goran Todorovac , Stable@vger.kernel.org Subject: [PATCH 3/3] xhci: Free the command allocated for setting LPM if we return early Date: Thu, 30 Mar 2023 17:30:56 +0300 Message-Id: <20230330143056.1390020-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230330143056.1390020-1-mathias.nyman@linux.intel.com> References: <20230330143056.1390020-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The command allocated to set exit latency LPM values need to be freed in case the command is never queued. This would be the case if there is no change in exit latency values, or device is missing. Reported-by: Mirsad Goran Todorovac Link: https://lore.kernel.org/linux-usb/24263902-c9b3-ce29-237b-1c3d6918f4fe@alu.unizg.hr Tested-by: Mirsad Goran Todorovac Fixes: 5c2a380a5aa8 ("xhci: Allocate separate command structures for each LPM command") Cc: Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index bdb6dd819a3b..6307bae9cddf 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4442,6 +4442,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, if (!virt_dev || max_exit_latency == virt_dev->current_mel) { spin_unlock_irqrestore(&xhci->lock, flags); + xhci_free_command(xhci, command); return 0; }