Skip to contentSkip to conversation

xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

PATCH RESEND In review D Scott Phillips 3 participants 3 messages Mar 15, 2023 – Mar 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 xhci: also avoid the XHCI_ZERO_64B_REGS quirk with a passthrough iommu

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")
---
 drivers/usb/host/xhci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/host/xhci.c +5 -1
index 6183ce8574b1..bdb6dd819a3b 100644
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/iommu.h>
 #include <linux/iopoll.h>
 #include <linux/irq.h>
 #include <linux/log2.h>
@@ -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");
Signature · 1 line
2.39.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · 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")
	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#2 lore raw
Quoted 10 lines · Marc Zyngier
Quoted 8 lines · 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.

Quoted 6 lines
Quoted 2 lines
Fixes 12de0a35c996 ("xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers")
	M.

Thanks, adding to queue

-Mathias