ehci: save device pointer in EHCIState
PATCH v2 1/1 ehci: save device pointer in EHCIState
We'll need a pointer to the actual pci/sysbus device, stick a pointer to it into the EHCIState struct.
https://bugzilla.redhat.com/show_bug.cgi?id=1005495
Signed-off-by Gerd Hoffmann <[email protected]>
--- hw/usb/hcd-ehci.c | 7 +++---- hw/usb/hcd-ehci.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)
hw/usb/hcd-ehci.c +3 -4
@@ -1241,13 +1241,11 @@ static int ehci_init_transfer(EHCIPacket *p) {uint32_t cpage, offset, bytes, plen;dma_addr_t page; -USBBus *bus = &p->queue->ehci->bus; -BusState *qbus =BUS (bus); cpage =get_field (p->qtd.token,QTD_TOKEN_CPAGE ); bytes =get_field (p->qtd.token,QTD_TOKEN_TBYTES ); offset = p->qtd.bufptr[0 ] & ~QTD_BUFPTR_MASK ; -qemu_sglist_init (&p->sgl, qbus->parent,5 , p->queue->ehci->as); +qemu_sglist_init (&p->sgl, p->queue->ehci->device,5 , p->queue->ehci->as);while (bytes >0 ) {if (cpage >4 ) {
@@ -1486,7 +1484,7 @@ static int ehci_process_itd(EHCIState *ehci,return -1 ; } -qemu_sglist_init (&ehci->isgl,DEVICE (ehci),2 , ehci->as); +qemu_sglist_init (&ehci->isgl, ehci->device,2 , ehci->as);if (off + len >4096 ) {/* transfer crosses page border */ uint32_t len2 = off + len -4096 ;
@@ -2529,6 +2527,7 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) s->frame_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , ehci_frame_timer, s); s->async_bh =qemu_bh_new (ehci_frame_timer, s); + s->device = dev;qemu_register_reset (ehci_reset, s);qemu_add_vm_change_state_handler (usb_ehci_vm_state_change, s);
hw/usb/hcd-ehci.h +1 -0
@@ -255,6 +255,7 @@ typedef QTAILQ_HEAD(EHCIQueueHead, EHCIQueue) EHCIQueueHead;struct EHCIState {USBBus bus; +DeviceState *device;qemu_irq irq;MemoryRegion mem;AddressSpace *as;
Signature · 1 line
1.8.3.1
Hi,
Quoted 4 lines · Gerd Hoffmann
We'll need a pointer to the actual pci/sysbus device, stick a pointer to it into the EHCIState struct.
Looks good, note you've forgotten to add qemu-stable, I've done so now.
Acked-by Hans de Goede <[email protected]>
Regards,
Hans
Quoted 56 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/hcd-ehci.c | 7 +++---- hw/usb/hcd-ehci.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)hw/usb/hcd-ehci.c +3
-4@@ -1241,13 +1241,11 @@ static int ehci_init_transfer(EHCIPacket *p) {uint32_t cpage, offset, bytes, plen;dma_addr_t page; -USBBus *bus = &p->queue->ehci->bus; -BusState *qbus =BUS (bus); cpage =get_field (p->qtd.token,QTD_TOKEN_CPAGE ); bytes =get_field (p->qtd.token,QTD_TOKEN_TBYTES ); offset = p->qtd.bufptr[0 ] & ~QTD_BUFPTR_MASK ; -qemu_sglist_init (&p->sgl, qbus->parent,5 , p->queue->ehci->as); +qemu_sglist_init (&p->sgl, p->queue->ehci->device,5 , p->queue->ehci->as);while (bytes >0 ) {if (cpage >4 ) {@@ -1486,7 +1484,7 @@ static int ehci_process_itd(EHCIState *ehci,return -1 ; } -qemu_sglist_init (&ehci->isgl,DEVICE (ehci),2 , ehci->as); +qemu_sglist_init (&ehci->isgl, ehci->device,2 , ehci->as);if (off + len >4096 ) {/* transfer crosses page border */ uint32_t len2 = off + len -4096 ;@@ -2529,6 +2527,7 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) s->frame_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , ehci_frame_timer, s); s->async_bh =qemu_bh_new (ehci_frame_timer, s); + s->device = dev;qemu_register_reset (ehci_reset, s);qemu_add_vm_change_state_handler (usb_ehci_vm_state_change, s);hw/usb/hcd-ehci.h +1
-0@@ -255,6 +255,7 @@ typedef QTAILQ_HEAD(EHCIQueueHead, EHCIQueue) EHCIQueueHead;struct EHCIState {USBBus bus; +DeviceState *device;qemu_irq irq;MemoryRegion mem;AddressSpace *as;