@@ -3437,14 +3437,18 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
xhci->mfwrap_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_mfwrap_timer, xhci);
memory_region_init(&xhci->mem, OBJECT(xhci), "xhci", LEN_REGS);
- memory_region_init_io(&xhci->mem_cap, OBJECT(xhci), &xhci_cap_ops, xhci,
- "capabilities", LEN_CAP);
- memory_region_init_io(&xhci->mem_oper, OBJECT(xhci), &xhci_oper_ops, xhci,
- "operational", 0x400);
- memory_region_init_io(&xhci->mem_runtime, OBJECT(xhci), &xhci_runtime_ops, xhci,
- "runtime", LEN_RUNTIME);
- memory_region_init_io(&xhci->mem_doorbell, OBJECT(xhci), &xhci_doorbell_ops, xhci,
- "doorbell", LEN_DOORBELL);
+ memory_region_init_io_with_dev(&xhci->mem_cap, OBJECT(xhci),
+ &xhci_cap_ops, xhci,
+ "capabilities", LEN_CAP, &dev->qdev);
+ memory_region_init_io_with_dev(&xhci->mem_oper, OBJECT(xhci),
+ &xhci_oper_ops, xhci,
+ "operational", 0x400, &dev->qdev);
+ memory_region_init_io_with_dev(&xhci->mem_runtime, OBJECT(xhci),
+ &xhci_runtime_ops, xhci,
+ "runtime", LEN_RUNTIME, &dev->qdev);
+ memory_region_init_io_with_dev(&xhci->mem_doorbell, OBJECT(xhci),
+ &xhci_doorbell_ops, xhci,
+ "doorbell", LEN_DOORBELL, &dev->qdev);
memory_region_add_subregion(&xhci->mem, 0, &xhci->mem_cap);
memory_region_add_subregion(&xhci->mem, OFF_OPER, &xhci->mem_oper);
@@ -3455,8 +3459,9 @@ static void usb_xhci_realize(struct PCIDevice *dev, Error **errp)
XHCIPort *port = &xhci->ports[i];
uint32_t offset = OFF_OPER + 0x400 + 0x10 * i;
port->xhci = xhci;
- memory_region_init_io(&port->mem, OBJECT(xhci), &xhci_port_ops, port,
- port->name, 0x10);
+ memory_region_init_io_with_dev(&port->mem, OBJECT(xhci),
+ &xhci_port_ops, port,
+ port->name, 0x10, &dev->qdev);
memory_region_add_subregion(&xhci->mem, offset, &port->mem);
}
This can avoid the DMA to MMIO issue here: https://bugs.launchpad.net/qemu/+bug/1891354 Signed-off-by: Li Qiang <liq3ea@163.com> --- hw/usb/hcd-xhci.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)