Message ID | 51D59C20.1070101@redhat.com |
---|---|
State | New |
Headers | show |
On 2013-07-04 18:00, Paolo Bonzini wrote: > Il 04/07/2013 17:51, Jan Kiszka ha scritto: >>>> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c >>>> index 16d6356..65e6680 100644 >>>> --- a/hw/usb/hcd-ehci.c >>>> +++ b/hw/usb/hcd-ehci.c >>>> @@ -1245,7 +1245,7 @@ static int ehci_init_transfer(EHCIPacket *p) >>>> 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, 5, p->queue->ehci->as); >>>> + qemu_sglist_init(&p->sgl, DEVICE(p->queue->ehci), 5, p->queue->ehci->as); >> I was just testing this from your current git tree, and it causes >> >> qemu/hw/usb/hcd-ehci.c:1248:ehci_init_transfer: Object 0x7f3eb39c6500 is >> not an instance of type device >> >> when booting a q35 machine (as it pulls in EHCI). The cast is obviously >> wrong, but I didn't spot yet what is required instead. > > EHCIState and AHCIDevice are not qdev structs. You need to go > through the bus to get the DeviceState. But I had fixed this once... > > /me checks > > Yes, I had fixed it at the same time I fixed Andreas's requested > BUS(). I thought I had fixed it _before_ posting this patch first. > > Pulling in the "Reviewed-by"s (as I just replied to the cover > letter) also pulled in the right version of the patch. So it > should be fixed _now_ in git (commit c7086b4a). > > I tested both AHCI and EHCI and they work. Yes, it's now fine here as well. Jan
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index bae484a..97eddec 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -650,6 +650,8 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset) int off_idx = -1; int off_pos = -1; int tbl_entry_size; + IDEBus *bus = &ad->port; + BusState *qbus = BUS(bus); if (!sglist_alloc_hint) { DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts); @@ -691,7 +693,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset) goto out; } - qemu_sglist_init(sglist, DEVICE(ad->hba), (sglist_alloc_hint - off_idx), + qemu_sglist_init(sglist, qbus->parent, (sglist_alloc_hint - off_idx), ad->hba->as); qemu_sglist_add(sglist, le64_to_cpu(tbl[off_idx].addr + off_pos), le32_to_cpu(tbl[off_idx].flags_size) + 1 - off_pos); diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index cdc932b..67e4b24 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1241,11 +1241,13 @@ 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, DEVICE(p->queue->ehci), 5, p->queue->ehci->as); + qemu_sglist_init(&p->sgl, qbus->parent, 5, p->queue->ehci->as); while (bytes > 0) { if (cpage > 4) {