From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Crosthwaite" <peter.crosthwaite@xilinx.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH qom-next] usb/hcd-xhci: QOM parent field cleanup
Date: Sun, 30 Jun 2013 13:41:05 +0200 [thread overview]
Message-ID: <1372592465-17576-1-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <7a74619d53f723e8b6160c85642dd8933c8e99db.1372055322.git.peter.crosthwaite@xilinx.com>
Rename to parent_obj and fix any fallout.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/usb/hcd-xhci.c | 83 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 48 insertions(+), 35 deletions(-)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index bdbca67..765ee0e 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -443,7 +443,10 @@ typedef struct XHCIInterrupter {
} XHCIInterrupter;
struct XHCIState {
- PCIDevice pci_dev;
+ /*< private >*/
+ PCIDevice parent_obj;
+ /*< public >*/
+
USBBus bus;
qemu_irq irq;
MemoryRegion mem;
@@ -659,7 +662,7 @@ static inline void xhci_dma_read_u32s(XHCIState *xhci, dma_addr_t addr,
assert((len % sizeof(uint32_t)) == 0);
- pci_dma_read(&xhci->pci_dev, addr, buf, len);
+ pci_dma_read(PCI_DEVICE(xhci), addr, buf, len);
for (i = 0; i < (len / sizeof(uint32_t)); i++) {
buf[i] = le32_to_cpu(buf[i]);
@@ -677,7 +680,7 @@ static inline void xhci_dma_write_u32s(XHCIState *xhci, dma_addr_t addr,
for (i = 0; i < (len / sizeof(uint32_t)); i++) {
tmp[i] = cpu_to_le32(buf[i]);
}
- pci_dma_write(&xhci->pci_dev, addr, tmp, len);
+ pci_dma_write(PCI_DEVICE(xhci), addr, tmp, len);
}
static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport)
@@ -704,10 +707,11 @@ static XHCIPort *xhci_lookup_port(XHCIState *xhci, struct USBPort *uport)
static void xhci_intx_update(XHCIState *xhci)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
int level = 0;
- if (msix_enabled(&xhci->pci_dev) ||
- msi_enabled(&xhci->pci_dev)) {
+ if (msix_enabled(pci_dev) ||
+ msi_enabled(pci_dev)) {
return;
}
@@ -723,9 +727,10 @@ static void xhci_intx_update(XHCIState *xhci)
static void xhci_msix_update(XHCIState *xhci, int v)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
bool enabled;
- if (!msix_enabled(&xhci->pci_dev)) {
+ if (!msix_enabled(pci_dev)) {
return;
}
@@ -736,17 +741,19 @@ static void xhci_msix_update(XHCIState *xhci, int v)
if (enabled) {
trace_usb_xhci_irq_msix_use(v);
- msix_vector_use(&xhci->pci_dev, v);
+ msix_vector_use(pci_dev, v);
xhci->intr[v].msix_used = true;
} else {
trace_usb_xhci_irq_msix_unuse(v);
- msix_vector_unuse(&xhci->pci_dev, v);
+ msix_vector_unuse(pci_dev, v);
xhci->intr[v].msix_used = false;
}
}
static void xhci_intr_raise(XHCIState *xhci, int v)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
+
xhci->intr[v].erdp_low |= ERDP_EHB;
xhci->intr[v].iman |= IMAN_IP;
xhci->usbsts |= USBSTS_EINT;
@@ -759,15 +766,15 @@ static void xhci_intr_raise(XHCIState *xhci, int v)
return;
}
- if (msix_enabled(&xhci->pci_dev)) {
+ if (msix_enabled(pci_dev)) {
trace_usb_xhci_irq_msix(v);
- msix_notify(&xhci->pci_dev, v);
+ msix_notify(pci_dev, v);
return;
}
- if (msi_enabled(&xhci->pci_dev)) {
+ if (msi_enabled(pci_dev)) {
trace_usb_xhci_irq_msi(v);
- msi_notify(&xhci->pci_dev, v);
+ msi_notify(pci_dev, v);
return;
}
@@ -790,6 +797,7 @@ static void xhci_die(XHCIState *xhci)
static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
XHCIInterrupter *intr = &xhci->intr[v];
XHCITRB ev_trb;
dma_addr_t addr;
@@ -808,7 +816,7 @@ static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v)
ev_trb.status, ev_trb.control);
addr = intr->er_start + TRB_SIZE*intr->er_ep_idx;
- pci_dma_write(&xhci->pci_dev, addr, &ev_trb, TRB_SIZE);
+ pci_dma_write(pci_dev, addr, &ev_trb, TRB_SIZE);
intr->er_ep_idx++;
if (intr->er_ep_idx >= intr->er_size) {
@@ -955,9 +963,11 @@ static void xhci_ring_init(XHCIState *xhci, XHCIRing *ring,
static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRing *ring, XHCITRB *trb,
dma_addr_t *addr)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
+
while (1) {
TRBType type;
- pci_dma_read(&xhci->pci_dev, ring->dequeue, trb, TRB_SIZE);
+ pci_dma_read(pci_dev, ring->dequeue, trb, TRB_SIZE);
trb->addr = ring->dequeue;
trb->ccs = ring->ccs;
le64_to_cpus(&trb->parameter);
@@ -990,6 +1000,7 @@ static TRBType xhci_ring_fetch(XHCIState *xhci, XHCIRing *ring, XHCITRB *trb,
static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
XHCITRB trb;
int length = 0;
dma_addr_t dequeue = ring->dequeue;
@@ -999,7 +1010,7 @@ static int xhci_ring_chain_length(XHCIState *xhci, const XHCIRing *ring)
while (1) {
TRBType type;
- pci_dma_read(&xhci->pci_dev, dequeue, &trb, TRB_SIZE);
+ pci_dma_read(pci_dev, dequeue, &trb, TRB_SIZE);
le64_to_cpus(&trb.parameter);
le32_to_cpus(&trb.status);
le32_to_cpus(&trb.control);
@@ -1051,7 +1062,7 @@ static void xhci_er_reset(XHCIState *xhci, int v)
return;
}
dma_addr_t erstba = xhci_addr64(intr->erstba_low, intr->erstba_high);
- pci_dma_read(&xhci->pci_dev, erstba, &seg, sizeof(seg));
+ pci_dma_read(PCI_DEVICE(xhci), erstba, &seg, sizeof(seg));
le32_to_cpus(&seg.addr_low);
le32_to_cpus(&seg.addr_high);
le32_to_cpus(&seg.size);
@@ -1526,7 +1537,7 @@ static int xhci_xfer_create_sgl(XHCITransfer *xfer, int in_xfer)
int i;
xfer->int_req = false;
- pci_dma_sglist_init(&xfer->sgl, &xhci->pci_dev, xfer->trb_count);
+ pci_dma_sglist_init(&xfer->sgl, PCI_DEVICE(xhci), xfer->trb_count);
for (i = 0; i < xfer->trb_count; i++) {
XHCITRB *trb = &xfer->trbs[i];
dma_addr_t addr;
@@ -2111,7 +2122,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
assert(slotid >= 1 && slotid <= xhci->numslots);
dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high);
- poctx = ldq_le_pci_dma(&xhci->pci_dev, dcbaap + 8*slotid);
+ poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid);
ictx = xhci_mask64(pictx);
octx = xhci_mask64(poctx);
@@ -2432,7 +2443,7 @@ static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
/* TODO: actually implement real values here */
bw_ctx[0] = 0;
memset(&bw_ctx[1], 80, xhci->numports); /* 80% */
- pci_dma_write(&xhci->pci_dev, ctx, bw_ctx, sizeof(bw_ctx));
+ pci_dma_write(PCI_DEVICE(xhci), ctx, bw_ctx, sizeof(bw_ctx));
return CC_SUCCESS;
}
@@ -2455,11 +2466,12 @@ static uint32_t xhci_nec_challenge(uint32_t hi, uint32_t lo)
static void xhci_via_challenge(XHCIState *xhci, uint64_t addr)
{
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
uint32_t buf[8];
uint32_t obuf[8];
dma_addr_t paddr = xhci_mask64(addr);
- pci_dma_read(&xhci->pci_dev, paddr, &buf, 32);
+ pci_dma_read(pci_dev, paddr, &buf, 32);
memcpy(obuf, buf, sizeof(obuf));
@@ -2475,7 +2487,7 @@ static void xhci_via_challenge(XHCIState *xhci, uint64_t addr)
obuf[7] = obuf[2] ^ obuf[3] ^ 0x65866593;
}
- pci_dma_write(&xhci->pci_dev, paddr, &obuf, 32);
+ pci_dma_write(pci_dev, paddr, &obuf, 32);
}
static void xhci_process_commands(XHCIState *xhci)
@@ -3322,10 +3334,10 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
XHCIState *xhci = XHCI(dev);
- xhci->pci_dev.config[PCI_CLASS_PROG] = 0x30; /* xHCI */
- xhci->pci_dev.config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
- xhci->pci_dev.config[PCI_CACHE_LINE_SIZE] = 0x10;
- xhci->pci_dev.config[0x60] = 0x30; /* release number */
+ dev->config[PCI_CLASS_PROG] = 0x30; /* xHCI */
+ dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin 1 */
+ dev->config[PCI_CACHE_LINE_SIZE] = 0x10;
+ dev->config[0x60] = 0x30; /* release number */
usb_xhci_init(xhci);
@@ -3347,7 +3359,7 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
xhci->mfwrap_timer = qemu_new_timer_ns(vm_clock, xhci_mfwrap_timer, xhci);
- xhci->irq = xhci->pci_dev.irq[0];
+ xhci->irq = dev->irq[0];
memory_region_init(&xhci->mem, "xhci", LEN_REGS);
memory_region_init_io(&xhci->mem_cap, &xhci_cap_ops, xhci,
@@ -3373,18 +3385,18 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
memory_region_add_subregion(&xhci->mem, offset, &port->mem);
}
- pci_register_bar(&xhci->pci_dev, 0,
+ pci_register_bar(dev, 0,
PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64,
&xhci->mem);
- ret = pcie_endpoint_cap_init(&xhci->pci_dev, 0xa0);
+ ret = pcie_endpoint_cap_init(dev, 0xa0);
assert(ret >= 0);
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI)) {
- msi_init(&xhci->pci_dev, 0x70, xhci->numintrs, true, false);
+ msi_init(dev, 0x70, xhci->numintrs, true, false);
}
if (xhci->flags & (1 << XHCI_FLAG_USE_MSI_X)) {
- msix_init(&xhci->pci_dev, xhci->numintrs,
+ msix_init(dev, xhci->numintrs,
&xhci->mem, 0, OFF_MSIX_TABLE,
&xhci->mem, 0, OFF_MSIX_PBA,
0x90);
@@ -3396,6 +3408,7 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
static int usb_xhci_post_load(void *opaque, int version_id)
{
XHCIState *xhci = opaque;
+ PCIDevice *pci_dev = PCI_DEVICE(xhci);
XHCISlot *slot;
XHCIEPContext *epctx;
dma_addr_t dcbaap, pctx;
@@ -3411,7 +3424,7 @@ static int usb_xhci_post_load(void *opaque, int version_id)
continue;
}
slot->ctx =
- xhci_mask64(ldq_le_pci_dma(&xhci->pci_dev, dcbaap + 8*slotid));
+ xhci_mask64(ldq_le_pci_dma(pci_dev, dcbaap + 8 * slotid));
xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx));
slot->uport = xhci_lookup_uport(xhci, slot_ctx);
assert(slot->uport && slot->uport->dev);
@@ -3436,9 +3449,9 @@ static int usb_xhci_post_load(void *opaque, int version_id)
for (intr = 0; intr < xhci->numintrs; intr++) {
if (xhci->intr[intr].msix_used) {
- msix_vector_use(&xhci->pci_dev, intr);
+ msix_vector_use(pci_dev, intr);
} else {
- msix_vector_unuse(&xhci->pci_dev, intr);
+ msix_vector_unuse(pci_dev, intr);
}
}
@@ -3531,8 +3544,8 @@ static const VMStateDescription vmstate_xhci = {
.version_id = 1,
.post_load = usb_xhci_post_load,
.fields = (VMStateField[]) {
- VMSTATE_PCIE_DEVICE(pci_dev, XHCIState),
- VMSTATE_MSIX(pci_dev, XHCIState),
+ VMSTATE_PCIE_DEVICE(parent_obj, XHCIState),
+ VMSTATE_MSIX(parent_obj, XHCIState),
VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,
vmstate_xhci_port, XHCIPort),
--
1.8.1.4
next prev parent reply other threads:[~2013-06-30 11:41 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 6:49 [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land peter.crosthwaite
2013-06-24 6:50 ` [Qemu-devel] [PATCH v2 01/30] net/e1000: QOM Upcast Sweep peter.crosthwaite
2013-06-30 10:59 ` [Qemu-devel] [PATCH qom-next] net/e1000: QOM parent field cleanup Andreas Färber
2013-06-24 6:51 ` [Qemu-devel] [PATCH v2 02/30] net/rtl8139: QOM Upcast Sweep peter.crosthwaite
2013-06-30 11:16 ` [Qemu-devel] [PATCH qom-next] net/rtl8139: QOM parent field cleanup Andreas Färber
2013-06-24 6:52 ` [Qemu-devel] [PATCH v2 03/30] net/pcnet-pci: QOM Upcast Sweep peter.crosthwaite
2013-06-30 7:34 ` Andreas Färber
2013-06-30 11:24 ` Andreas Färber
2013-07-22 17:17 ` Andreas Färber
2013-06-24 6:52 ` [Qemu-devel] [PATCH v2 04/30] usb/hcd-xhci: " peter.crosthwaite
2013-06-30 7:44 ` Andreas Färber
2013-06-30 11:41 ` Andreas Färber [this message]
2013-06-24 6:53 ` [Qemu-devel] [PATCH v2 05/30] scsi/lsi53c895a: " peter.crosthwaite
2013-06-30 7:51 ` Andreas Färber
2013-06-30 11:54 ` [Qemu-devel] [PATCH qom-next] scsi/lsi53c895a: QOM parent field cleanup Andreas Färber
2013-06-24 6:54 ` [Qemu-devel] [PATCH v2 06/30] scsi/megasas: QOM Upcast Sweep peter.crosthwaite
2013-06-30 12:04 ` [Qemu-devel] [PATCH qom-next] scsi/megasas: QOM parent field cleanup Andreas Färber
2013-06-24 6:55 ` [Qemu-devel] [PATCH v2 07/30] scsi/esp-pci: QOM Upcast Sweep peter.crosthwaite
2013-06-30 12:11 ` [Qemu-devel] [PATCH qom-next] scsi/esp-pci: QOM parent field cleanup Andreas Färber
2013-06-24 6:55 ` [Qemu-devel] [PATCH v2 08/30] ide/ich: QOM Upcast Sweep peter.crosthwaite
2013-06-30 8:21 ` Andreas Färber
2013-06-30 23:36 ` Alexander Graf
2013-07-01 10:03 ` Andreas Färber
2013-07-01 10:10 ` Alexander Graf
2013-06-30 12:20 ` [Qemu-devel] [PATCH qom-next] ide/ich: QOM parent field cleanup Andreas Färber
2013-06-24 6:56 ` [Qemu-devel] [PATCH v2 09/30] ide/piix: QOM casting sweep peter.crosthwaite
2013-06-30 8:25 ` Andreas Färber
2013-07-22 16:20 ` Andreas Färber
2013-07-22 15:58 ` [Qemu-devel] [PATCH qom-next] ide: Introduce abstract QOM type for PCIIDEState Andreas Färber
2013-07-24 23:28 ` Andreas Färber
2013-06-24 6:57 ` [Qemu-devel] [PATCH v2 10/30] acpi/piix4: QOM Upcast Sweep peter.crosthwaite
2013-06-30 12:41 ` [Qemu-devel] [PATCH qom-next] acpi/piix4: QOM parent field cleanup Andreas Färber
2013-06-24 6:58 ` [Qemu-devel] [PATCH v2 11/30] misc/pci-testdev: QOM Upcast Sweep peter.crosthwaite
2013-06-30 12:49 ` Andreas Färber
2013-06-30 12:50 ` [Qemu-devel] [PATCH qom-next] misc/pci-testdev: QOM parent field cleanup Andreas Färber
2013-06-24 6:58 ` [Qemu-devel] [PATCH v2 12/30] virtio/vmware_vga: QOM casting sweep peter.crosthwaite
2013-06-30 8:41 ` Andreas Färber
2013-06-30 13:02 ` [Qemu-devel] [PATCH qom-next] display/vmware_vga: QOM parent field cleanup Andreas Färber
2013-06-24 6:59 ` [Qemu-devel] [PATCH v2 13/30] misc/ivshmem: QOM Upcast Sweep peter.crosthwaite
2013-06-30 9:18 ` Andreas Färber
2013-06-30 13:15 ` Andreas Färber
2013-06-30 13:16 ` [Qemu-devel] [PATCH qom-next] misc/ivshmem: QOM parent field cleanup Andreas Färber
2013-06-24 7:00 ` [Qemu-devel] [PATCH v2 14/30] xen/xen_platform: QOM casting sweep peter.crosthwaite
2013-06-30 9:32 ` Andreas Färber
2013-06-30 13:23 ` [Qemu-devel] [PATCH qom-next] xen/xen_platform: QOM parent field cleanup Andreas Färber
2013-06-24 7:00 ` [Qemu-devel] [PATCH v2 15/30] isa/*: QOM casting sweep peter.crosthwaite
2013-06-24 7:01 ` [Qemu-devel] [PATCH v2 16/30] pci/*: " peter.crosthwaite
2013-06-30 8:05 ` Andreas Färber
2013-06-24 7:02 ` [Qemu-devel] [PATCH v2 17/30] pci-bridge/pci_bridge_dev: Don't use DO_UPCAST peter.crosthwaite
2013-06-24 7:03 ` [Qemu-devel] [PATCH v2 18/30] pci-bridge/*: substitute ->qdev casts with DEVICE() peter.crosthwaite
2013-06-24 7:03 ` [Qemu-devel] [PATCH v2 19/30] pci/pci_bridge: " peter.crosthwaite
2013-06-24 7:04 ` [Qemu-devel] [PATCH v2 20/30] misc/vfio: " peter.crosthwaite
2013-06-24 7:05 ` [Qemu-devel] [PATCH v2 21/30] net/eepro100: " peter.crosthwaite
2013-06-24 7:06 ` [Qemu-devel] [PATCH v2 22/30] net/ne2000: " peter.crosthwaite
2013-06-24 7:06 ` [Qemu-devel] [PATCH v2 23/30] usb/*: " peter.crosthwaite
2013-06-24 7:07 ` [Qemu-devel] [PATCH v2 24/30] watchdog/wdt_i6300esb: " peter.crosthwaite
2013-06-24 7:08 ` [Qemu-devel] [PATCH v2 25/30] scsi/vmw_pvscsi: " peter.crosthwaite
2013-06-24 7:09 ` [Qemu-devel] [PATCH v2 26/30] i2c/smbus_ich9: " peter.crosthwaite
2013-06-24 7:09 ` [Qemu-devel] [PATCH v2 27/30] ide/cmd646: " peter.crosthwaite
2013-06-24 7:10 ` [Qemu-devel] [PATCH v2 28/30] ide/via: " peter.crosthwaite
2013-06-24 7:11 ` [Qemu-devel] [PATCH v2 29/30] pci-host/*: " peter.crosthwaite
2013-06-24 7:12 ` [Qemu-devel] [PATCH v2 30/30] i386/*: " peter.crosthwaite
2013-06-30 10:44 ` [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land -- ANN: qom-next revived Andreas Färber
2013-06-30 15:09 ` [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land Andreas Färber
2013-07-01 4:33 ` [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land -- ANN: qom-next revived Peter Crosthwaite
2013-07-01 4:50 ` Peter Crosthwaite
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372592465-17576-1-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=kraxel@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).