hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/usb/host/xhci.c
....@@ -9,6 +9,9 @@
99 */
1010
1111 #include <linux/pci.h>
12
+#ifndef __GENKSYMS__ /* ANDROID: KABI CRC preservation hack */
13
+#include <linux/iommu.h>
14
+#endif
1215 #include <linux/iopoll.h>
1316 #include <linux/irq.h>
1417 #include <linux/log2.h>
....@@ -223,6 +226,7 @@
223226 static void xhci_zero_64b_regs(struct xhci_hcd *xhci)
224227 {
225228 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
229
+ struct iommu_domain *domain;
226230 int err, i;
227231 u64 val;
228232 u32 intrs;
....@@ -241,7 +245,9 @@
241245 * an iommu. Doing anything when there is no iommu is definitely
242246 * unsafe...
243247 */
244
- if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !device_iommu_mapped(dev))
248
+ domain = iommu_get_domain_for_dev(dev);
249
+ if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !domain ||
250
+ domain->type == IOMMU_DOMAIN_IDENTITY)
245251 return;
246252
247253 xhci_info(xhci, "Zeroing 64bit base registers, expecting fault\n");
....@@ -692,6 +698,8 @@
692698 }
693699 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
694700 "Finished xhci_run for USB2 roothub");
701
+
702
+ set_bit(HCD_FLAG_DEFER_RH_REGISTER, &hcd->flags);
695703
696704 xhci_dbc_init(xhci);
697705
....@@ -1258,7 +1266,7 @@
12581266 * the first wake signalling failed, give it that chance.
12591267 */
12601268 pending_portevent = xhci_pending_portevent(xhci);
1261
- if (!pending_portevent) {
1269
+ if (!pending_portevent && !IS_ENABLED(CONFIG_ARCH_ROCKCHIP)) {
12621270 msleep(120);
12631271 pending_portevent = xhci_pending_portevent(xhci);
12641272 }
....@@ -3865,6 +3873,7 @@
38653873 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
38663874 struct xhci_virt_device *virt_dev;
38673875 struct xhci_slot_ctx *slot_ctx;
3876
+ unsigned long flags;
38683877 int i, ret;
38693878
38703879 /*
....@@ -3893,7 +3902,11 @@
38933902 }
38943903 virt_dev->udev = NULL;
38953904 xhci_disable_slot(xhci, udev->slot_id);
3905
+
3906
+ spin_lock_irqsave(&xhci->lock, flags);
38963907 xhci_free_virt_device(xhci, udev->slot_id);
3908
+ spin_unlock_irqrestore(&xhci->lock, flags);
3909
+
38973910 }
38983911
38993912 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)