PCI: Cleanup legacy casts in device land
v2 cover PCI: Cleanup legacy casts in device land
From: Peter Crosthwaite <[email protected]>
There are a number of different cast implementations from various stages of QEMU development out in device model land. This series cleans up the ones involving TYPE_PCI_DEVICE to consistently use proper QOM casts for both up and down casts.
Some were easy, some needed QOM cast macros which are added as appropriate.
Following the recent discussion RE performance consequences of QOM casts, im interested in any reports of possible performance regressions here, although I am hoping that Anthony current efforts to improve QOM casting efficiency make this a non-issue.
Changed since V1:
Removed hunks which macroified VMSD names
Dropped virtio/virtio.pci patch
Rebased
Peter Crosthwaite (30):
net/e1000: QOM Upcast Sweep
net/rtl8139: QOM Upcast Sweep
net/pcnet-pci: QOM Upcast Sweep
usb/hcd-xhci: QOM Upcast Sweep
scsi/lsi53c895a: QOM Upcast Sweep
scsi/megasas: QOM Upcast Sweep
scsi/esp-pci: QOM Upcast Sweep
ide/ich: QOM Upcast Sweep
ide/piix: QOM casting sweep
acpi/piix4: QOM Upcast Sweep
misc/pci-testdev: QOM Upcast Sweep virtio/vmware_vga: QOM casting sweep
misc/ivshmem: QOM Upcast Sweep
xen/xen_platform: QOM casting sweep
isa/*: QOM casting sweep
pci/*: QOM casting sweep pci-bridge/pci_bridge_dev: Don't use DO_UPCAST pci-bridge/*: substitute ->qdev casts with DEVICE() pci/pci_bridge: substitute ->qdev casts with DEVICE() misc/vfio: substitute ->qdev casts with DEVICE() net/eepro100: substitute ->qdev casts with DEVICE() net/ne2000: substitute ->qdev casts with DEVICE() usb/*: substitute ->qdev casts with DEVICE() watchdog/wdt_i6300esb: substitute ->qdev casts with DEVICE() scsi/vmw_pvscsi: substitute ->qdev casts with DEVICE() i2c/smbus_ich9: substitute ->qdev casts with DEVICE() ide/cmd646: substitute ->qdev casts with DEVICE() ide/via: substitute ->qdev casts with DEVICE() pci-host/*: substitute ->qdev casts with DEVICE() i386/*: substitute ->qdev casts with DEVICE()
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- hw/display/vmware_vga.c | 13 ++++++++----- hw/i2c/smbus_ich9.c | 2 +- hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 3 ++- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.h | 5 +++++ hw/ide/cmd646.c | 8 ++++---- hw/ide/ich.c | 10 +++++----- hw/ide/piix.c | 8 ++++---- hw/ide/via.c | 4 ++-- hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/misc/ivshmem.c | 18 +++++++++++------- hw/misc/pci-testdev.c | 11 ++++++++--- hw/misc/vfio.c | 4 ++-- hw/net/e1000.c | 18 ++++++++++++------ hw/net/eepro100.c | 14 ++++++++------ hw/net/ne2000.c | 6 ++++-- hw/net/pcnet-pci.c | 14 +++++++++----- hw/net/rtl8139.c | 26 ++++++++++++++++++-------- hw/pci-bridge/dec.c | 2 +- hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pci_bridge.c | 7 ++++--- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- hw/scsi/esp-pci.c | 14 +++++++++----- hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- hw/scsi/megasas.c | 15 ++++++++++----- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 19 +++++++++++++------ hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 45 files changed, 258 insertions(+), 177 deletions(-)
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 1/30 net/e1000: QOM Upcast Sweep
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/net/e1000.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
hw/net/e1000.c +12 -6
@@ -138,6 +138,11 @@ typedef struct E1000State_st {uint32_t compat_flags; } E1000State; +#define TYPE_E1000 "e1000" + +#define E1000 (obj) \ + OBJECT_CHECK(E1000State, (obj), TYPE_E1000) +#define defreg (x) x = (E1000_##x>>2)enum { defreg(CTRL), defreg(EECD), defreg(EERD), defreg(GPRC),
@@ -1296,7 +1301,7 @@ e1000_cleanup(NetClientState *nc)static void pci_e1000_uninit (PCIDevice *dev) { -E1000State *d =DO_UPCAST (E1000State, dev, dev); +E1000State *d =E1000 (dev);qemu_del_timer (d->autoneg_timer);qemu_free_timer (d->autoneg_timer);
@@ -1316,7 +1321,8 @@ static NetClientInfo net_e1000_info = {static int pci_e1000_init (PCIDevice *pci_dev) { -E1000State *d =DO_UPCAST (E1000State, dev, pci_dev); +DeviceState *dev =DEVICE (pci_dev); +E1000State *d =E1000 (pci_dev);uint8_t *pci_conf;uint16_t checksum =0 ;int i;
@@ -1347,11 +1353,11 @@ static int pci_e1000_init(PCIDevice *pci_dev) d->eeprom_data[EEPROM_CHECKSUM_REG ] = checksum; d->nic =qemu_new_nic (&net_e1000_info, &d->conf, -object_get_typename (OBJECT (d)), d->dev.qdev.id, d); +object_get_typename (OBJECT (d)), dev->id, d);qemu_format_nic_info_str (qemu_get_queue (d->nic), macaddr); -add_boot_device_path (d->conf.bootindex, &pci_dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (d->conf.bootindex, dev,"/ethernet-phy@0" ); d->autoneg_timer =qemu_new_timer_ms (vm_clock, e1000_autoneg_timer, d);
@@ -1360,7 +1366,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)static void qdev_e1000_reset (DeviceState *dev) { -E1000State *d =DO_UPCAST (E1000State, dev.qdev, dev); +E1000State *d =E1000 (dev);e1000_reset (d); }
@@ -1390,7 +1396,7 @@ static void e1000_class_init(ObjectClass *klass, void *data) }static const TypeInfo e1000_info = { - .name ="e1000" , + .name =TYPE_E1000 , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (E1000State), .class_init = e1000_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 1/1 net/e1000: QOM parent field cleanup
Rename to parent_obj and fix any remaining fallout.
--- hw/net/e1000.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
hw/net/e1000.c +22 -13
@@ -85,7 +85,10 @@ enum { }; typedef struct E1000State_st { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + NICState *nic; NICConf conf; MemoryRegion mmio;
@@ -245,6 +248,8 @@ static const uint32_t mac_reg_init[] = {static void set_interrupt_cause (E1000State *s,int index,uint32_t val) { +PCIDevice *d =PCI_DEVICE (s); +if (val && (E1000_DEVID >=E1000_DEV_ID_82547EI_MOBILE )) {/* Only for 8257x */ val |=E1000_ICR_INT_ASSERTED ;
@@ -261,7 +266,7 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val)*/ s->mac_reg[ICS ] = val; -qemu_set_irq (s->dev.irq[0 ], (s->mac_reg[IMS ] & s->mac_reg[ICR ]) !=0 ); +qemu_set_irq (d->irq[0 ], (s->mac_reg[IMS ] & s->mac_reg[ICR ]) !=0 ); } static void
@@ -558,6 +563,7 @@ xmit_seg(E1000State *s)static void process_tx_desc (E1000State *s,struct e1000_tx_desc *dp) { +PCIDevice *d =PCI_DEVICE (s);uint32_t txd_lower =le32_to_cpu (dp->lower.data);uint32_t dtype = txd_lower & (E1000_TXD_CMD_DEXT |E1000_TXD_DTYP_D );unsigned int split_size = txd_lower &0xffff , bytes, sz, op;
@@ -616,7 +622,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) bytes = msh - tp->size; bytes =MIN (sizeof (tp->data) - tp->size, bytes); -pci_dma_read (&s->dev, addr, tp->data + tp->size, bytes); +pci_dma_read (d, addr, tp->data + tp->size, bytes);if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)memmove (tp->header, tp->data, hdr); tp->size = sz;
@@ -632,7 +638,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)DBGOUT (TXERR ,"TCP segmentation error\n" ); }else { split_size =MIN (sizeof (tp->data) - tp->size, split_size); -pci_dma_read (&s->dev, addr, tp->data + tp->size, split_size); +pci_dma_read (d, addr, tp->data + tp->size, split_size); tp->size += split_size; }
@@ -650,6 +656,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)static uint32_t txdesc_writeback (E1000State *s,dma_addr_t base,struct e1000_tx_desc *dp) { +PCIDevice *d =PCI_DEVICE (s);uint32_t txd_upper, txd_lower =le32_to_cpu (dp->lower.data);if (!(txd_lower & (E1000_TXD_CMD_RS |E1000_TXD_CMD_RPS )))
@@ -657,7 +664,7 @@ txdesc_writeback(E1000State *s, dma_addr_t base, struct e1000_tx_desc *dp) txd_upper = (le32_to_cpu (dp->upper.data) |E1000_TXD_STAT_DD ) & ~(E1000_TXD_STAT_EC |E1000_TXD_STAT_LC |E1000_TXD_STAT_TU ); dp->upper.data =cpu_to_le32 (txd_upper); -pci_dma_write (&s->dev, base + ((char *)&dp->upper - (char *)dp), +pci_dma_write (d, base + ((char *)&dp->upper - (char *)dp), &dp->upper,sizeof (dp->upper));return E1000_ICR_TXDW ; }
@@ -673,6 +680,7 @@ static uint64_t tx_desc_base(E1000State *s)static void start_xmit (E1000State *s) { +PCIDevice *d =PCI_DEVICE (s);dma_addr_t base;struct e1000_tx_desc desc;uint32_t tdh_start = s->mac_reg[TDH ], cause =E1000_ICS_TXQE ;
@@ -685,7 +693,7 @@ start_xmit(E1000State *s)while (s->mac_reg[TDH ] != s->mac_reg[TDT ]) { base =tx_desc_base (s) +sizeof (struct e1000_tx_desc ) * s->mac_reg[TDH ]; -pci_dma_read (&s->dev, base, &desc,sizeof (desc)); +pci_dma_read (d, base, &desc,sizeof (desc)); DBGOUT(TX, "index %d: %p : %x %x\n", s->mac_reg[TDH], (void *)(intptr_t)desc.buffer_addr, desc.lower.data,
@@ -818,6 +826,7 @@ static ssize_t e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) {E1000State *s =qemu_get_nic_opaque (nc); +PCIDevice *d =PCI_DEVICE (s);struct e1000_rx_desc desc;dma_addr_t base;unsigned int n, rdt;
@@ -877,7 +886,7 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) desc_size = s->rxbuf_size; } base =rx_desc_base (s) +sizeof (desc) * s->mac_reg[RDH ]; -pci_dma_read (&s->dev, base, &desc,sizeof (desc)); +pci_dma_read (d, base, &desc,sizeof (desc)); desc.special = vlan_special; desc.status |= (vlan_status |E1000_RXD_STAT_DD );if (desc.buffer_addr) {
@@ -886,7 +895,7 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)if (copy_size > s->rxbuf_size) { copy_size = s->rxbuf_size; } -pci_dma_write (&s->dev,le64_to_cpu (desc.buffer_addr), +pci_dma_write (d,le64_to_cpu (desc.buffer_addr), buf + desc_offset + vlan_offset, copy_size); } desc_offset += desc_size;
@@ -901,7 +910,7 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) }else {// as per intel docs; skip descriptors with null buf addr DBGOUT (RX ,"Null RX descriptor!!\n" ); } -pci_dma_write (&s->dev, base, &desc,sizeof (desc)); +pci_dma_write (d, base, &desc,sizeof (desc));if (++s->mac_reg[RDH ] *sizeof (desc) >= s->mac_reg[RDLEN ]) s->mac_reg[RDH ] =0 ;
@@ -1187,7 +1196,7 @@ static const VMStateDescription vmstate_e1000 = { .pre_save = e1000_pre_save, .post_load = e1000_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, E1000State), +VMSTATE_PCI_DEVICE (parent_obj, E1000State),VMSTATE_UNUSED_TEST (is_version_1,4 ),/* was instance id */ VMSTATE_UNUSED (4 ),/* Was mmio_base. */ VMSTATE_UINT32 (rxbuf_size, E1000State),
@@ -1328,7 +1337,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)int i;uint8_t *macaddr; - pci_conf = d->dev.config; + pci_conf = pci_dev->config;/* TODO: RST# value should be 0, PCI spec 6.2.4 */ pci_conf[PCI_CACHE_LINE_SIZE ] =0x10 ;
@@ -1337,9 +1346,9 @@ static int pci_e1000_init(PCIDevice *pci_dev)e1000_mmio_setup (d); -pci_register_bar (&d->dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &d->mmio); +pci_register_bar (pci_dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &d->mmio); -pci_register_bar (&d->dev,1 ,PCI_BASE_ADDRESS_SPACE_IO , &d->io); +pci_register_bar (pci_dev,1 ,PCI_BASE_ADDRESS_SPACE_IO , &d->io);memmove (d->eeprom_data, e1000_eeprom_template,sizeof e1000_eeprom_template);
Signature · 1 line
1.8.1.4
PATCH v2 2/30 net/rtl8139: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/net/rtl8139.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
hw/net/rtl8139.c +18 -8
@@ -92,6 +92,11 @@ static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...) }#endif +#define TYPE_RTL8139 "rtl8139" + +#define RTL8139 (obj) \ + OBJECT_CHECK(RTL8139State, (obj), TYPE_RTL8139) +/* Symbolic offsets to registers. */ enum RTL8139_registers {MAC0 =0 ,/* Ethernet hardware address. */
@@ -1197,7 +1202,7 @@ static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize)static void rtl8139_reset (DeviceState *d) { -RTL8139State *s =container_of (d, RTL8139State, dev.qdev); +RTL8139State *s =RTL8139 (d);int i;/* restore MAC address */
@@ -1364,6 +1369,8 @@ static const VMStateDescription vmstate_tally_counters = {static void rtl8139_ChipCmd_write (RTL8139State *s,uint32_t val) { +DeviceState *d =DEVICE (s); + val &=0xff ;DPRINTF ("ChipCmd write val=0x%08x\n" , val);
@@ -1371,7 +1378,7 @@ static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)if (val & CmdReset) {DPRINTF ("ChipCmd reset\n" ); -rtl8139_reset (&s->dev.qdev); +rtl8139_reset (d); }if (val & CmdRxEnb) {
@@ -1525,6 +1532,8 @@ static uint32_t rtl8139_BasicModeStatus_read(RTL8139State *s)static void rtl8139_Cfg9346_write (RTL8139State *s,uint32_t val) { +DeviceState *d =DEVICE (s); + val &=0xff ;DPRINTF ("Cfg9346 write val=0x%02x\n" , val);
@@ -1544,7 +1553,7 @@ static void rtl8139_Cfg9346_write(RTL8139State *s, uint32_t val) }else if (opmode ==0x40 ) {/* Reset. */ val =0 ; -rtl8139_reset (&s->dev.qdev); +rtl8139_reset (d); } s->Cfg9346 = val;
@@ -3439,7 +3448,7 @@ static void rtl8139_cleanup(NetClientState *nc)static void pci_rtl8139_uninit (PCIDevice *dev) { -RTL8139State *s =DO_UPCAST (RTL8139State, dev, dev); +RTL8139State *s =RTL8139 (dev);memory_region_destroy (&s->bar_io);memory_region_destroy (&s->bar_mem);
@@ -3477,7 +3486,8 @@ static NetClientInfo net_rtl8139_info = {static int pci_rtl8139_init (PCIDevice *dev) { -RTL8139State * s =DO_UPCAST (RTL8139State, dev, dev); +RTL8139State *s =RTL8139 (dev); +DeviceState *d =DEVICE (dev);uint8_t *pci_conf; pci_conf = s->dev.config;
@@ -3505,7 +3515,7 @@ static int pci_rtl8139_init(PCIDevice *dev) s->eeprom.contents[9 ] = s->conf.macaddr.a[4 ] | s->conf.macaddr.a[5 ] <<8 ; s->nic =qemu_new_nic (&net_rtl8139_info, &s->conf, -object_get_typename (OBJECT (dev)), dev->qdev.id, s); +object_get_typename (OBJECT (dev)), d->id, s);qemu_format_nic_info_str (qemu_get_queue (s->nic), s->conf.macaddr.a); s->cplus_txbuffer =NULL ;
@@ -3516,7 +3526,7 @@ static int pci_rtl8139_init(PCIDevice *dev) s->timer =qemu_new_timer_ns (vm_clock, rtl8139_timer, s);rtl8139_set_next_tctr_time (s,qemu_get_clock_ns (vm_clock)); -add_boot_device_path (s->conf.bootindex, &dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (s->conf.bootindex, d,"/ethernet-phy@0" );return 0 ; }
@@ -3544,7 +3554,7 @@ static void rtl8139_class_init(ObjectClass *klass, void *data) }static const TypeInfo rtl8139_info = { - .name ="rtl8139" , + .name =TYPE_RTL8139 , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (RTL8139State), .class_init = rtl8139_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 1/1 net/rtl8139: QOM parent field cleanup
Rename to parent_obj and fix any remaining fallout.
--- hw/net/rtl8139.c | 88 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 39 deletions(-)
hw/net/rtl8139.c +49 -39
@@ -433,7 +433,10 @@ typedef struct RTL8139TallyCountersstatic void RTL8139TallyCounters_clear (RTL8139TallyCounters * counters); typedef struct RTL8139State { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + uint8_t phys[8]; /* mac address */ uint8_t mult[8]; /* multicast mask array */
@@ -706,13 +709,14 @@ static void prom9346_set_wire(RTL8139State *s, int eecs, int eesk, int eedi)static void rtl8139_update_irq (RTL8139State *s) { +PCIDevice *d =PCI_DEVICE (s);int isr; isr = (s->IntrStatus & s->IntrMask) &0xffff ;DPRINTF ("Set IRQ to %d (%04x %04x)\n" , isr ?1 :0 , s->IntrStatus, s->IntrMask); -qemu_set_irq (s->dev.irq[0 ], (isr !=0 )); +qemu_set_irq (d->irq[0 ], (isr !=0 )); }static int rtl8139_RxWrap (RTL8139State *s)
@@ -743,6 +747,8 @@ static int rtl8139_cp_transmitter_enabled(RTL8139State *s)static void rtl8139_write_buffer (RTL8139State *s,const void *buf,int size) { +PCIDevice *d =PCI_DEVICE (s); +if (s->RxBufAddr + size > s->RxBufferSize) {int wrapped =MOD2 (s->RxBufAddr + size, s->RxBufferSize);
@@ -754,14 +760,14 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)if (size > wrapped) { -pci_dma_write (&s->dev, s->RxBuf + s->RxBufAddr, +pci_dma_write (d, s->RxBuf + s->RxBufAddr, buf, size-wrapped); }/* reset buffer pointer */ s->RxBufAddr =0 ; -pci_dma_write (&s->dev, s->RxBuf + s->RxBufAddr, +pci_dma_write (d, s->RxBuf + s->RxBufAddr, buf + (size-wrapped), wrapped); s->RxBufAddr = wrapped;
@@ -771,7 +777,7 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size) }/* non-wrapping path or overwrapping enabled */ -pci_dma_write (&s->dev, s->RxBuf + s->RxBufAddr, buf, size); +pci_dma_write (d, s->RxBuf + s->RxBufAddr, buf, size); s->RxBufAddr += size; }
@@ -814,6 +820,7 @@ static int rtl8139_can_receive(NetClientState *nc)static ssize_t rtl8139_do_receive (NetClientState *nc,const uint8_t *buf,size_t size_,int do_interrupt) {RTL8139State *s =qemu_get_nic_opaque (nc); +PCIDevice *d =PCI_DEVICE (s);/* size is the length of the buffer passed to the driver */ int size = size_;const uint8_t *dot1q_buf =NULL ;
@@ -978,13 +985,13 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_tuint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; -pci_dma_read (&s->dev, cplus_rx_ring_desc, &val,4 ); +pci_dma_read (d, cplus_rx_ring_desc, &val,4 ); rxdw0 =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_rx_ring_desc+4 , &val,4 ); +pci_dma_read (d, cplus_rx_ring_desc+4 , &val,4 ); rxdw1 =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_rx_ring_desc+8 , &val,4 ); +pci_dma_read (d, cplus_rx_ring_desc+8 , &val,4 ); rxbufLO =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_rx_ring_desc+12 , &val,4 ); +pci_dma_read (d, cplus_rx_ring_desc+12 , &val,4 ); rxbufHI =le32_to_cpu (val); DPRINTF("+++ C+ mode RX descriptor %d %08x %08x %08x %08x\n",
@@ -1052,12 +1059,12 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t/* receive/copy to target memory */ if (dot1q_buf) { -pci_dma_write (&s->dev, rx_addr, buf,2 *ETHER_ADDR_LEN ); -pci_dma_write (&s->dev, rx_addr +2 *ETHER_ADDR_LEN , +pci_dma_write (d, rx_addr, buf,2 *ETHER_ADDR_LEN ); +pci_dma_write (d, rx_addr +2 *ETHER_ADDR_LEN , buf +2 *ETHER_ADDR_LEN +VLAN_HLEN , size -2 *ETHER_ADDR_LEN ); }else { -pci_dma_write (&s->dev, rx_addr, buf, size); +pci_dma_write (d, rx_addr, buf, size); }if (s->CpCmd & CPlusRxChkSum)
@@ -1067,7 +1074,7 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t/* write checksum */ val =cpu_to_le32 (crc32 (0 , buf, size_)); -pci_dma_write (&s->dev, rx_addr+size, (uint8_t *)&val,4 ); +pci_dma_write (d, rx_addr+size, (uint8_t *)&val,4 );/* first segment of received packet flag */ #define CP_RX_STATUS_FS (1<<29)
@@ -1113,9 +1120,9 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t/* update ring data */ val =cpu_to_le32 (rxdw0); -pci_dma_write (&s->dev, cplus_rx_ring_desc, (uint8_t *)&val,4 ); +pci_dma_write (d, cplus_rx_ring_desc, (uint8_t *)&val,4 ); val =cpu_to_le32 (rxdw1); -pci_dma_write (&s->dev, cplus_rx_ring_desc+4 , (uint8_t *)&val,4 ); +pci_dma_write (d, cplus_rx_ring_desc+4 , (uint8_t *)&val,4 );/* update tally counter */ ++s->tally_counters.RxOk;
@@ -1298,49 +1305,50 @@ static void RTL8139TallyCounters_clear(RTL8139TallyCounters* counters)static void RTL8139TallyCounters_dma_write (RTL8139State *s,dma_addr_t tc_addr) { +PCIDevice *d =PCI_DEVICE (s);RTL8139TallyCounters *tally_counters = &s->tally_counters;uint16_t val16;uint32_t val32;uint64_t val64; val64 =cpu_to_le64 (tally_counters->TxOk); -pci_dma_write (&s->dev, tc_addr +0 , (uint8_t *)&val64,8 ); +pci_dma_write (d, tc_addr +0 , (uint8_t *)&val64,8 ); val64 =cpu_to_le64 (tally_counters->RxOk); -pci_dma_write (&s->dev, tc_addr +8 , (uint8_t *)&val64,8 ); +pci_dma_write (d, tc_addr +8 , (uint8_t *)&val64,8 ); val64 =cpu_to_le64 (tally_counters->TxERR); -pci_dma_write (&s->dev, tc_addr +16 , (uint8_t *)&val64,8 ); +pci_dma_write (d, tc_addr +16 , (uint8_t *)&val64,8 ); val32 =cpu_to_le32 (tally_counters->RxERR); -pci_dma_write (&s->dev, tc_addr +24 , (uint8_t *)&val32,4 ); +pci_dma_write (d, tc_addr +24 , (uint8_t *)&val32,4 ); val16 =cpu_to_le16 (tally_counters->MissPkt); -pci_dma_write (&s->dev, tc_addr +28 , (uint8_t *)&val16,2 ); +pci_dma_write (d, tc_addr +28 , (uint8_t *)&val16,2 ); val16 =cpu_to_le16 (tally_counters->FAE); -pci_dma_write (&s->dev, tc_addr +30 , (uint8_t *)&val16,2 ); +pci_dma_write (d, tc_addr +30 , (uint8_t *)&val16,2 ); val32 =cpu_to_le32 (tally_counters->Tx1Col); -pci_dma_write (&s->dev, tc_addr +32 , (uint8_t *)&val32,4 ); +pci_dma_write (d, tc_addr +32 , (uint8_t *)&val32,4 ); val32 =cpu_to_le32 (tally_counters->TxMCol); -pci_dma_write (&s->dev, tc_addr +36 , (uint8_t *)&val32,4 ); +pci_dma_write (d, tc_addr +36 , (uint8_t *)&val32,4 ); val64 =cpu_to_le64 (tally_counters->RxOkPhy); -pci_dma_write (&s->dev, tc_addr +40 , (uint8_t *)&val64,8 ); +pci_dma_write (d, tc_addr +40 , (uint8_t *)&val64,8 ); val64 =cpu_to_le64 (tally_counters->RxOkBrd); -pci_dma_write (&s->dev, tc_addr +48 , (uint8_t *)&val64,8 ); +pci_dma_write (d, tc_addr +48 , (uint8_t *)&val64,8 ); val32 =cpu_to_le32 (tally_counters->RxOkMul); -pci_dma_write (&s->dev, tc_addr +56 , (uint8_t *)&val32,4 ); +pci_dma_write (d, tc_addr +56 , (uint8_t *)&val32,4 ); val16 =cpu_to_le16 (tally_counters->TxAbt); -pci_dma_write (&s->dev, tc_addr +60 , (uint8_t *)&val16,2 ); +pci_dma_write (d, tc_addr +60 , (uint8_t *)&val16,2 ); val16 =cpu_to_le16 (tally_counters->TxUndrn); -pci_dma_write (&s->dev, tc_addr +62 , (uint8_t *)&val16,2 ); +pci_dma_write (d, tc_addr +62 , (uint8_t *)&val16,2 ); }/* Loads values of tally counters from VM state file */
@@ -1830,13 +1838,14 @@ static int rtl8139_transmit_one(RTL8139State *s, int descriptor)DPRINTF ("+++ transmitting from descriptor %d\n" , descriptor); +PCIDevice *d =PCI_DEVICE (s);int txsize = s->TxStatus[descriptor] &0x1fff ;uint8_t txbuffer[0x2000 ];DPRINTF ("+++ transmit reading %d bytes from host memory at 0x%08x\n" , txsize, s->TxAddr[descriptor]); -pci_dma_read (&s->dev, s->TxAddr[descriptor], txbuffer, txsize); +pci_dma_read (d, s->TxAddr[descriptor], txbuffer, txsize);/* Mark descriptor as transferred */ s->TxStatus[descriptor] |= TxHostOwns;
@@ -1955,6 +1964,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)return 0 ; } +PCIDevice *d =PCI_DEVICE (s);int descriptor = s->currCPlusTxDesc;dma_addr_t cplus_tx_ring_desc =rtl8139_addr64 (s->TxAddr[0 ], s->TxAddr[1 ]);
@@ -1968,13 +1978,13 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)uint32_t val, txdw0,txdw1,txbufLO,txbufHI; -pci_dma_read (&s->dev, cplus_tx_ring_desc, (uint8_t *)&val,4 ); +pci_dma_read (d, cplus_tx_ring_desc, (uint8_t *)&val,4 ); txdw0 =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_tx_ring_desc+4 , (uint8_t *)&val,4 ); +pci_dma_read (d, cplus_tx_ring_desc+4 , (uint8_t *)&val,4 ); txdw1 =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_tx_ring_desc+8 , (uint8_t *)&val,4 ); +pci_dma_read (d, cplus_tx_ring_desc+8 , (uint8_t *)&val,4 ); txbufLO =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_tx_ring_desc+12 , (uint8_t *)&val,4 ); +pci_dma_read (d, cplus_tx_ring_desc+12 , (uint8_t *)&val,4 ); txbufHI =le32_to_cpu (val); DPRINTF("+++ C+ mode TX descriptor %d %08x %08x %08x %08x\n", descriptor,
@@ -2081,7 +2091,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)DMA_ADDR_FMT " to offset %d\n" , txsize, tx_addr, s->cplus_txbuffer_offset); -pci_dma_read (&s->dev, tx_addr, +pci_dma_read (d, tx_addr, s->cplus_txbuffer + s->cplus_txbuffer_offset, txsize); s->cplus_txbuffer_offset += txsize;
@@ -2109,7 +2119,7 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)/* update ring data */ val =cpu_to_le32 (txdw0); -pci_dma_write (&s->dev, cplus_tx_ring_desc, (uint8_t *)&val,4 ); +pci_dma_write (d, cplus_tx_ring_desc, (uint8_t *)&val,4 );/* Now decide if descriptor being processed is holding the last segment of packet */ if (txdw0 &CP_TX_LS )
@@ -3282,7 +3292,7 @@ static const VMStateDescription vmstate_rtl8139 = { .post_load = rtl8139_post_load, .pre_save = rtl8139_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, RTL8139State), +VMSTATE_PCI_DEVICE (parent_obj, RTL8139State),VMSTATE_PARTIAL_BUFFER (phys, RTL8139State,6 ),VMSTATE_BUFFER (mult, RTL8139State),VMSTATE_UINT32_ARRAY (TxStatus, RTL8139State,4 ),
@@ -3490,7 +3500,7 @@ static int pci_rtl8139_init(PCIDevice *dev)DeviceState *d =DEVICE (dev);uint8_t *pci_conf; - pci_conf = s->dev.config; + pci_conf = dev->config; pci_conf[PCI_INTERRUPT_PIN ] =1 ;/* interrupt pin A */ /* TODO: start of capability list, but no capability * list bit in status register, and offset 0xdc seems unused. */
@@ -3498,8 +3508,8 @@ static int pci_rtl8139_init(PCIDevice *dev)memory_region_init_io (&s->bar_io, &rtl8139_io_ops, s,"rtl8139" ,0x100 );memory_region_init_io (&s->bar_mem, &rtl8139_mmio_ops, s,"rtl8139" ,0x100 ); -pci_register_bar (&s->dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->bar_io); -pci_register_bar (&s->dev,1 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->bar_mem); +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->bar_io); +pci_register_bar (dev,1 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->bar_mem);qemu_macaddr_default_if_unset (&s->conf.macaddr);
Signature · 1 line
1.8.1.4
PATCH v2 3/30 net/pcnet-pci: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/net/pcnet-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/net/pcnet-pci.c +9 -5
@@ -43,6 +43,10 @@//#define PCNET_DEBUG_TMD //#define PCNET_DEBUG_MATCH +#define TYPE_PCI_PC_NET "pcnet" + +#define PCI_PC_NET (obj) \ + OBJECT_CHECK(PCIPCNetState, (obj), TYPE_PCI_PC_NET) typedef struct { PCIDevice pci_dev;
@@ -273,7 +277,7 @@ static void pci_pcnet_cleanup(NetClientState *nc)static void pci_pcnet_uninit (PCIDevice *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);memory_region_destroy (&d->state.mmio);memory_region_destroy (&d->io_bar);
@@ -293,7 +297,7 @@ static NetClientInfo net_pci_pcnet_info = {static int pci_pcnet_init (PCIDevice *pci_dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, pci_dev); +PCIPCNetState *d =PCI_PC_NET (pci_dev);PCNetState *s = &d->state;uint8_t *pci_conf;
@@ -329,12 +333,12 @@ static int pci_pcnet_init(PCIDevice *pci_dev) s->phys_mem_write = pci_physical_memory_write; s->dma_opaque = pci_dev; -return pcnet_common_init (&pci_dev->qdev, s, &net_pci_pcnet_info); +return pcnet_common_init (DEVICE (pci_dev), s, &net_pci_pcnet_info); }static void pci_reset (DeviceState *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev.qdev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);pcnet_h_reset (&d->state); }
@@ -362,7 +366,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data) }static const TypeInfo pcnet_info = { - .name ="pcnet" , + .name =TYPE_PCI_PC_NET , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIPCNetState), .class_init = pcnet_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 03/30] net/pcnet-pci: QOM Upcast Sweep
Am 24.06.2013 08:52, schrieb [email protected]:
Quoted 16 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/net/pcnet-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)hw/net/pcnet-pci.c +0
-0
hw/net/pcnet-pci.c line 46
Quoted 4 lines
hw/net/pcnet-pci.c +1
-0@@ -43,6 +43,10 @@//#define PCNET_DEBUG_TMD //#define PCNET_DEBUG_MATCH +#define TYPE_PCI_PC_NET "pcnet"
I'm wondering whether we should rename this PCNET rather than PC_NET, but I'm queuing it as is. Thanks,
Andreas
Quoted 49 lines
hw/net/pcnet-pci.c +8
-5+ +#define PCI_PC_NET (obj) \ + OBJECT_CHECK(PCIPCNetState, (obj), TYPE_PCI_PC_NET) typedef struct { PCIDevice pci_dev;@@ -273,7 +277,7 @@ static void pci_pcnet_cleanup(NetClientState *nc)static void pci_pcnet_uninit (PCIDevice *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);memory_region_destroy (&d->state.mmio);memory_region_destroy (&d->io_bar);@@ -293,7 +297,7 @@ static NetClientInfo net_pci_pcnet_info = {static int pci_pcnet_init (PCIDevice *pci_dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, pci_dev); +PCIPCNetState *d =PCI_PC_NET (pci_dev);PCNetState *s = &d->state;uint8_t *pci_conf;@@ -329,12 +333,12 @@ static int pci_pcnet_init(PCIDevice *pci_dev) s->phys_mem_write = pci_physical_memory_write; s->dma_opaque = pci_dev; -return pcnet_common_init (&pci_dev->qdev, s, &net_pci_pcnet_info); +return pcnet_common_init (DEVICE (pci_dev), s, &net_pci_pcnet_info); }static void pci_reset (DeviceState *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev.qdev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);pcnet_h_reset (&d->state); }@@ -362,7 +366,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data) }static const TypeInfo pcnet_info = { - .name ="pcnet" , + .name =TYPE_PCI_PC_NET , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIPCNetState), .class_init = pcnet_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 03/30] net/pcnet-pci: QOM Upcast Sweep
Am 30.06.2013 09:34, schrieb Andreas Färber:
Quoted 20 lines
Am 24.06.2013 08:52, schrieb [email protected]:
Quoted 19 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/net/pcnet-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)hw/net/pcnet-pci.c +0
-0@@ -43,6 +43,10 @@//#define PCNET_DEBUG_TMD //#define PCNET_DEBUG_MATCH
Quoted 4 lines
hw/net/pcnet-pci.c line 46
Quoted 1 line
hw/net/pcnet-pci.c +1
-0+#define TYPE_PCI_PC_NET "pcnet"I'm wondering whether we should rename this PCNET rather than
PC_NET, but I'm queuing it as is. Thanks,
Squashing the following.
Andreas
hw/net/pcnet-pci.c +5 -2
@@ -49,7 +49,10 @@ OBJECT_CHECK(PCIPCNetState, (obj), TYPE_PCI_PC_NET)typedef struct { -PCIDevice pci_dev; +/*< private >*/ +PCIDevice parent_obj; +/*< public >*/ +PCNetState state;MemoryRegion io_bar; }PCIPCNetState ;
@@ -240,7 +243,7 @@ static const VMStateDescription vmstate_pci_pcnet = { .minimum_version_id = 2, .minimum_version_id_old =2 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci_dev, PCIPCNetState), +VMSTATE_PCI_DEVICE (parent_obj, PCIPCNetState),VMSTATE_STRUCT (state, PCIPCNetState,0 , vmstate_pcnet, PCNetState),VMSTATE_END_OF_LIST () }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 03/30] net/pcnet-pci: QOM Upcast Sweep
In reply to Andreas FärberAm 30.06.2013 09:34, schrieb Andreas Färber:
Quoted 20 lines
Am 24.06.2013 08:52, schrieb [email protected]:
Quoted 19 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/net/pcnet-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)hw/net/pcnet-pci.c +0
-0@@ -43,6 +43,10 @@//#define PCNET_DEBUG_TMD //#define PCNET_DEBUG_MATCH
Quoted 4 lines
hw/net/pcnet-pci.c line 46
Quoted 1 line
hw/net/pcnet-pci.c +1
-0+#define TYPE_PCI_PC_NET "pcnet"I'm wondering whether we should rename this PCNET rather than
PC_NET, but I'm queuing it as is. Thanks,
In light of the MP_TIMER vs. MPTIMER discussion elsewhere I'm changing both patches, i.e. TYPE_PCI_PCNET and PCI_PCNET() here, in line with pcnet_ prefix.
Andreas
Quoted 51 lines
Quoted 49 lines
hw/net/pcnet-pci.c +8
-5+ +#define PCI_PC_NET (obj) \ + OBJECT_CHECK(PCIPCNetState, (obj), TYPE_PCI_PC_NET) typedef struct { PCIDevice pci_dev;@@ -273,7 +277,7 @@ static void pci_pcnet_cleanup(NetClientState *nc)static void pci_pcnet_uninit (PCIDevice *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);memory_region_destroy (&d->state.mmio);memory_region_destroy (&d->io_bar);@@ -293,7 +297,7 @@ static NetClientInfo net_pci_pcnet_info = {static int pci_pcnet_init (PCIDevice *pci_dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, pci_dev); +PCIPCNetState *d =PCI_PC_NET (pci_dev);PCNetState *s = &d->state;uint8_t *pci_conf;@@ -329,12 +333,12 @@ static int pci_pcnet_init(PCIDevice *pci_dev) s->phys_mem_write = pci_physical_memory_write; s->dma_opaque = pci_dev; -return pcnet_common_init (&pci_dev->qdev, s, &net_pci_pcnet_info); +return pcnet_common_init (DEVICE (pci_dev), s, &net_pci_pcnet_info); }static void pci_reset (DeviceState *dev) { -PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev.qdev, dev); +PCIPCNetState *d =PCI_PC_NET (dev);pcnet_h_reset (&d->state); }@@ -362,7 +366,7 @@ static void pcnet_class_init(ObjectClass *klass, void *data) }static const TypeInfo pcnet_info = { - .name ="pcnet" , + .name =TYPE_PCI_PC_NET , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIPCNetState), .class_init = pcnet_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH v2 4/30 usb/hcd-xhci: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/usb/hcd-xhci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
hw/usb/hcd-xhci.c +13 -6
@@ -482,6 +482,11 @@ struct XHCIState {XHCIRing cmd_ring; }; +#define TYPE_XHCI "nec-usb-xhci" + +#define XHCI (obj) \ + OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI) + typedef struct XHCIEvRingSeg { uint32_t addr_low; uint32_t addr_high;
@@ -2681,7 +2686,7 @@ static void xhci_port_reset(XHCIPort *port)static void xhci_reset (DeviceState *dev) { -XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev.qdev, dev); +XHCIState *xhci =XHCI (dev);int i;trace_usb_xhci_reset ();
@@ -2926,6 +2931,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, uint64_t val, unsigned size) {XHCIState *xhci = ptr; +DeviceState *d =DEVICE (ptr);trace_usb_xhci_oper_write (reg, val);
@@ -2939,7 +2945,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, xhci->usbcmd = val &0xc0f ;xhci_mfwrap_update (xhci);if (val &USBCMD_HCRST ) { -xhci_reset (&xhci->pci_dev.qdev); +xhci_reset (d); }xhci_intx_update (xhci);break ;
@@ -3267,6 +3273,7 @@ static USBBusOps xhci_bus_ops = {static void usb_xhci_init (XHCIState *xhci,DeviceState *dev) { +DeviceState *d =DEVICE (xhci);XHCIPort *port;int i, usbports, speedmask;
@@ -3281,7 +3288,7 @@ static void usb_xhci_init(XHCIState *xhci, DeviceState *dev) usbports =MAX (xhci->numports_2, xhci->numports_3); xhci->numports = xhci->numports_2 + xhci->numports_3; -usb_bus_new (&xhci->bus, &xhci_bus_ops, &xhci->pci_dev.qdev); +usb_bus_new (&xhci->bus, &xhci_bus_ops, d);for (i =0 ; i < usbports; i++) { speedmask =0 ;
@@ -3313,14 +3320,14 @@ static int usb_xhci_initfn(struct PCIDevice *dev) {int i, ret; -XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev, 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 */ -usb_xhci_init (xhci, &dev->qdev); +usb_xhci_init (xhci,DEVICE (dev));if (xhci->numintrs >MAXINTRS ) { xhci->numintrs =MAXINTRS ;
@@ -3581,7 +3588,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) }static const TypeInfo xhci_info = { - .name ="nec-usb-xhci" , + .name =TYPE_XHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (XHCIState), .class_init = xhci_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 04/30] usb/hcd-xhci: QOM Upcast Sweep
Am 24.06.2013 08:52, schrieb [email protected]:
Quoted 54 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/usb/hcd-xhci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)hw/usb/hcd-xhci.c +8
-2@@ -482,6 +482,11 @@ struct XHCIState {XHCIRing cmd_ring; }; +#define TYPE_XHCI "nec-usb-xhci" + +#define XHCI (obj) \ + OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI) + typedef struct XHCIEvRingSeg { uint32_t addr_low; uint32_t addr_high;@@ -2681,7 +2686,7 @@ static void xhci_port_reset(XHCIPort *port)static void xhci_reset (DeviceState *dev) { -XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev.qdev, dev); +XHCIState *xhci =XHCI (dev);int i;trace_usb_xhci_reset ();@@ -2926,6 +2931,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, uint64_t val, unsigned size) {XHCIState *xhci = ptr; +DeviceState *d =DEVICE (ptr);trace_usb_xhci_oper_write (reg, val);@@ -2939,7 +2945,7 @@ static void xhci_oper_write(void *ptr, hwaddr reg, xhci->usbcmd = val &0xc0f ;xhci_mfwrap_update (xhci);if (val &USBCMD_HCRST ) { -xhci_reset (&xhci->pci_dev.qdev); +xhci_reset (d); }xhci_intx_update (xhci);break ;
hw/usb/hcd-xhci.c static USBBusOps xhci_bus_ops = { · line 3276
Quoted 4 lines
hw/usb/hcd-xhci.c +1
-0@@ -3267,6 +3273,7 @@ static USBBusOps xhci_bus_ops = {static void usb_xhci_init (XHCIState *xhci,DeviceState *dev) { +DeviceState *d =DEVICE (xhci);
This is duplicating the dev argument. I'll drop that and rename your variable to dev instead:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Thanks,
Andreas
Quoted 39 lines
hw/usb/hcd-xhci.c +4
-4XHCIPort *port;int i, usbports, speedmask;@@ -3281,7 +3288,7 @@ static void usb_xhci_init(XHCIState *xhci, DeviceState *dev) usbports =MAX (xhci->numports_2, xhci->numports_3); xhci->numports = xhci->numports_2 + xhci->numports_3; -usb_bus_new (&xhci->bus, &xhci_bus_ops, &xhci->pci_dev.qdev); +usb_bus_new (&xhci->bus, &xhci_bus_ops, d);for (i =0 ; i < usbports; i++) { speedmask =0 ;@@ -3313,14 +3320,14 @@ static int usb_xhci_initfn(struct PCIDevice *dev) {int i, ret; -XHCIState *xhci =DO_UPCAST (XHCIState, pci_dev, 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 */ -usb_xhci_init (xhci, &dev->qdev); +usb_xhci_init (xhci,DEVICE (dev));if (xhci->numintrs >MAXINTRS ) { xhci->numintrs =MAXINTRS ;@@ -3581,7 +3588,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) }static const TypeInfo xhci_info = { - .name ="nec-usb-xhci" , + .name =TYPE_XHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (XHCIState), .class_init = xhci_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 usb/hcd-xhci: QOM parent field cleanup
In reply to [email protected]Rename to parent_obj and fix any fallout.
--- hw/usb/hcd-xhci.c | 83 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 35 deletions(-)
hw/usb/hcd-xhci.c +48 -35
@@ -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),
Signature · 1 line
1.8.1.4
PATCH v2 5/30 scsi/lsi53c895a: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
hw/scsi/lsi53c895a.c +16 -10
@@ -275,6 +275,11 @@ typedef struct {uint32_t script_ram[2048 ]; } LSIState; +#define TYPE_LSI53C895A "lsi53c895a" + +#define LSI53C895A (obj) \ + OBJECT_CHECK(LSIState, (obj), TYPE_LSI53C895A) +static inline int lsi_irq_on_rsl (LSIState *s) {return (s->sien0 &LSI_SIST0_RSL ) && (s->scid &LSI_SCID_RRE );
@@ -653,7 +658,7 @@ static void lsi_request_free(LSIState *s, lsi_request *p)static void lsi_request_cancelled (SCSIRequest *req) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);lsi_request *p = req->hba_private; req->hba_private =NULL ;
@@ -692,7 +697,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req, uint32_t len)/* Callback to indicate that the SCSI layer has completed a command. */ static void lsi_command_complete (SCSIRequest *req,uint32_t status,size_t resid) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);int out; out = (s->sstat1 &PHASE_MASK ) ==PHASE_DO ;
@@ -717,7 +722,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid/* Callback to indicate that the SCSI layer has completed a transfer. */ static void lsi_transfer_data (SCSIRequest *req,uint32_t len) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);int out;assert (req->hba_private);
@@ -1726,7 +1731,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)lsi_execute_script (s); }if (val &LSI_ISTAT0_SRST ) { -qdev_reset_all (&s->dev.qdev); +qdev_reset_all (DEVICE (s)); }break ;case 0x16 :/* MBOX0 */
@@ -1960,7 +1965,7 @@ static const MemoryRegionOps lsi_io_ops = {static void lsi_scsi_reset (DeviceState *dev) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, dev); +LSIState *s =LSI53C895A (dev);lsi_soft_reset (s); }
@@ -2061,7 +2066,7 @@ static const VMStateDescription vmstate_lsi_scsi = {static void lsi_scsi_uninit (PCIDevice *d) { -LSIState *s =DO_UPCAST (LSIState, dev, d); +LSIState *s =LSI53C895A (d);memory_region_destroy (&s->mmio_io);memory_region_destroy (&s->ram_io);
@@ -2080,7 +2085,8 @@ static const struct SCSIBusInfo lsi_scsi_info = {static int lsi_scsi_init (PCIDevice *dev) { -LSIState *s =DO_UPCAST (LSIState, dev, dev); +LSIState *s =LSI53C895A (dev); +DeviceState *d =DEVICE (dev);uint8_t *pci_conf; pci_conf = s->dev.config;
@@ -2099,8 +2105,8 @@ static int lsi_scsi_init(PCIDevice *dev)pci_register_bar (&s->dev,2 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ram_io);QTAILQ_INIT (&s->queue); -scsi_bus_new (&s->bus, &dev->qdev, &lsi_scsi_info,NULL ); -if (!dev->qdev.hotplugged) { +scsi_bus_new (&s->bus, d, &lsi_scsi_info,NULL ); +if (!d->hotplugged) {return scsi_bus_legacy_handle_cmdline (&s->bus); }return 0 ;
@@ -2122,7 +2128,7 @@ static void lsi_class_init(ObjectClass *klass, void *data) }static const TypeInfo lsi_info = { - .name ="lsi53c895a" , + .name =TYPE_LSI53C895A , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (LSIState), .class_init = lsi_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 05/30] scsi/lsi53c895a: QOM Upcast Sweep
Am 24.06.2013 08:53, schrieb [email protected]:
Quoted 28 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)hw/scsi/lsi53c895a.c +5
-0@@ -275,6 +275,11 @@ typedef struct {uint32_t script_ram[2048 ]; } LSIState; +#define TYPE_LSI53C895A "lsi53c895a" + +#define LSI53C895A (obj) \ + OBJECT_CHECK(LSIState, (obj), TYPE_LSI53C895A) +static inline int lsi_irq_on_rsl (LSIState *s) {return (s->sien0 &LSI_SIST0_RSL ) && (s->scid &LSI_SCID_RRE );
hw/scsi/lsi53c895a.c static void lsi_request_free(LSIState *s, lsi_request *p) · line 661
Quoted 5 lines
hw/scsi/lsi53c895a.c +1
-1@@ -653,7 +658,7 @@ static void lsi_request_free(LSIState *s, lsi_request *p)static void lsi_request_cancelled (SCSIRequest *req) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);
We should be using BUS() in place of ->qbus, but since you're pretty cleanly separating things in your series, we can do that as a follow-up. Thanks, queued on qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
Quoted 79 lines
hw/scsi/lsi53c895a.c +10
-9lsi_request *p = req->hba_private; req->hba_private =NULL ;@@ -692,7 +697,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req, uint32_t len)/* Callback to indicate that the SCSI layer has completed a command. */ static void lsi_command_complete (SCSIRequest *req,uint32_t status,size_t resid) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);int out; out = (s->sstat1 &PHASE_MASK ) ==PHASE_DO ;@@ -717,7 +722,7 @@ static void lsi_command_complete(SCSIRequest *req, uint32_t status, size_t resid/* Callback to indicate that the SCSI layer has completed a transfer. */ static void lsi_transfer_data (SCSIRequest *req,uint32_t len) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, req->bus->qbus.parent); +LSIState *s =LSI53C895A (req->bus->qbus.parent);int out;assert (req->hba_private);@@ -1726,7 +1731,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)lsi_execute_script (s); }if (val &LSI_ISTAT0_SRST ) { -qdev_reset_all (&s->dev.qdev); +qdev_reset_all (DEVICE (s)); }break ;case 0x16 :/* MBOX0 */ @@ -1960,7 +1965,7 @@ static const MemoryRegionOps lsi_io_ops = {static void lsi_scsi_reset (DeviceState *dev) { -LSIState *s =DO_UPCAST (LSIState, dev.qdev, dev); +LSIState *s =LSI53C895A (dev);lsi_soft_reset (s); }@@ -2061,7 +2066,7 @@ static const VMStateDescription vmstate_lsi_scsi = {static void lsi_scsi_uninit (PCIDevice *d) { -LSIState *s =DO_UPCAST (LSIState, dev, d); +LSIState *s =LSI53C895A (d);memory_region_destroy (&s->mmio_io);memory_region_destroy (&s->ram_io);@@ -2080,7 +2085,8 @@ static const struct SCSIBusInfo lsi_scsi_info = {static int lsi_scsi_init (PCIDevice *dev) { -LSIState *s =DO_UPCAST (LSIState, dev, dev); +LSIState *s =LSI53C895A (dev); +DeviceState *d =DEVICE (dev);uint8_t *pci_conf; pci_conf = s->dev.config;@@ -2099,8 +2105,8 @@ static int lsi_scsi_init(PCIDevice *dev)pci_register_bar (&s->dev,2 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ram_io);QTAILQ_INIT (&s->queue); -scsi_bus_new (&s->bus, &dev->qdev, &lsi_scsi_info,NULL ); -if (!dev->qdev.hotplugged) { +scsi_bus_new (&s->bus, d, &lsi_scsi_info,NULL ); +if (!d->hotplugged) {return scsi_bus_legacy_handle_cmdline (&s->bus); }return 0 ;@@ -2122,7 +2128,7 @@ static void lsi_class_init(ObjectClass *klass, void *data) }static const TypeInfo lsi_info = { - .name ="lsi53c895a" , + .name =TYPE_LSI53C895A , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (LSIState), .class_init = lsi_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 scsi/lsi53c895a: QOM parent field cleanup
In reply to [email protected]Rename to parent_obj and fix any fallout.
--- hw/scsi/lsi53c895a.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-)
hw/scsi/lsi53c895a.c +27 -19
@@ -184,7 +184,10 @@ typedef struct lsi_request { } lsi_request; typedef struct { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + MemoryRegion mmio_io; MemoryRegion ram_io; MemoryRegion io_io;
@@ -387,7 +390,7 @@ static inline uint32_t read_dword(LSIState *s, uint32_t addr) {uint32_t buf; -pci_dma_read (&s->dev, addr, &buf,4 ); +pci_dma_read (PCI_DEVICE (s), addr, &buf,4 );return cpu_to_le32 (buf); }
@@ -398,6 +401,7 @@ static void lsi_stop_script(LSIState *s)static void lsi_update_irq (LSIState *s) { +PCIDevice *d =PCI_DEVICE (s);int level;static int last_level;lsi_request *p;
@@ -429,7 +433,7 @@ static void lsi_update_irq(LSIState *s) level, s->dstat, s->sist1, s->sist0); last_level = level; } -qemu_set_irq (s->dev.irq[0 ], level); +qemu_set_irq (d->irq[0 ], level);if (!level &&lsi_irq_on_rsl (s) && !(s->scntl1 &LSI_SCNTL1_CON )) { DPRINTF("Handled IRQs & disconnected, looking for pending "
@@ -525,6 +529,7 @@ static void lsi_bad_selection(LSIState *s, uint32_t id)/* Initiate a SCSI layer data transfer. */ static void lsi_do_dma (LSIState *s,int out) { +PCIDevice *pci_dev;uint32_t count;dma_addr_t addr;SCSIDevice *dev;
@@ -536,6 +541,7 @@ static void lsi_do_dma(LSIState *s, int out)return ; } + pci_dev =PCI_DEVICE (s); dev = s->current->req->dev;assert (dev);
@@ -561,9 +567,9 @@ static void lsi_do_dma(LSIState *s, int out) }/* ??? Set SFBR to first data byte. */ if (out) { -pci_dma_read (&s->dev, addr, s->current->dma_buf, count); +pci_dma_read (pci_dev, addr, s->current->dma_buf, count); }else { -pci_dma_write (&s->dev, addr, s->current->dma_buf, count); +pci_dma_write (pci_dev, addr, s->current->dma_buf, count); } s->current->dma_len -= count;if (s->current->dma_len ==0 ) {
@@ -758,7 +764,7 @@ static void lsi_do_command(LSIState *s)DPRINTF ("Send command len=%d\n" , s->dbc);if (s->dbc >16 ) s->dbc =16 ; -pci_dma_read (&s->dev, s->dnad, buf, s->dbc); +pci_dma_read (PCI_DEVICE (s), s->dnad, buf, s->dbc); s->sfbr = buf[0 ]; s->command_complete =0 ;
@@ -809,7 +815,7 @@ static void lsi_do_status(LSIState *s) s->dbc =1 ; status = s->status; s->sfbr = status; -pci_dma_write (&s->dev, s->dnad, &status,1 ); +pci_dma_write (PCI_DEVICE (s), s->dnad, &status,1 );lsi_set_phase (s,PHASE_MI ); s->msg_action =1 ;lsi_add_msg_byte (s,0 );/* COMMAND COMPLETE */
@@ -823,7 +829,7 @@ static void lsi_do_msgin(LSIState *s) len = s->msg_len;if (len > s->dbc) len = s->dbc; -pci_dma_write (&s->dev, s->dnad, s->msg, len); +pci_dma_write (PCI_DEVICE (s), s->dnad, s->msg, len);/* Linux drivers rely on the last byte being in the SIDL. */ s->sidl = s->msg[len -1 ]; s->msg_len -= len;
@@ -855,7 +861,7 @@ static void lsi_do_msgin(LSIState *s)static uint8_t lsi_get_msgbyte (LSIState *s) {uint8_t data; -pci_dma_read (&s->dev, s->dnad, &data,1 ); +pci_dma_read (PCI_DEVICE (s), s->dnad, &data,1 ); s->dnad++; s->dbc--;return data;
@@ -1001,14 +1007,15 @@ static inline int32_t sxt24(int32_t n)#define LSI_BUF_SIZE 4096static void lsi_memcpy (LSIState *s,uint32_t dest,uint32_t src,int count) { +PCIDevice *d =PCI_DEVICE (s);int n;uint8_t buf[LSI_BUF_SIZE ];DPRINTF ("memcpy dest 0x%08x src 0x%08x count %d\n" , dest, src, count);while (count) { n = (count >LSI_BUF_SIZE ) ?LSI_BUF_SIZE : count; -pci_dma_read (&s->dev, src, buf, n); -pci_dma_write (&s->dev, dest, buf, n); +pci_dma_read (d, src, buf, n); +pci_dma_write (d, dest, buf, n); src += n; dest += n; count -= n;
@@ -1034,6 +1041,7 @@ static void lsi_wait_reselect(LSIState *s)static void lsi_execute_script (LSIState *s) { +PCIDevice *pci_dev =PCI_DEVICE (s);uint32_t insn;uint32_t addr, addr_high;int opcode;
@@ -1076,7 +1084,7 @@ again:/* 32-bit Table indirect */ offset =sxt24 (addr); -pci_dma_read (&s->dev, s->dsa + offset, buf,8 ); +pci_dma_read (pci_dev, s->dsa + offset, buf,8 );/* byte count is stored in bits 0:23 only */ s->dbc =cpu_to_le32 (buf[0 ]) &0xffffff ; s->rbc = s->dbc;
@@ -1435,7 +1443,7 @@ again: n = (insn &7 ); reg = (insn >>16 ) &0xff ;if (insn & (1 <<24 )) { -pci_dma_read (&s->dev, addr, data, n); +pci_dma_read (pci_dev, addr, data, n);DPRINTF ("Load reg 0x%x size %d addr 0x%08x = %08x\n" , reg, n, addr, *(int *)data);for (i =0 ; i < n; i++) {
@@ -1446,7 +1454,7 @@ again:for (i =0 ; i < n; i++) { data[i] =lsi_reg_readb (s, reg + i); } -pci_dma_write (&s->dev, addr, data, n); +pci_dma_write (pci_dev, addr, data, n); } } }
@@ -1988,7 +1996,7 @@ static const VMStateDescription vmstate_lsi_scsi = { .minimum_version_id_old = 0, .pre_save = lsi_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, LSIState), +VMSTATE_PCI_DEVICE (parent_obj, LSIState),VMSTATE_INT32 (carry, LSIState),VMSTATE_INT32 (status, LSIState),
@@ -2089,7 +2097,7 @@ static int lsi_scsi_init(PCIDevice *dev)DeviceState *d =DEVICE (dev);uint8_t *pci_conf; - pci_conf = s->dev.config; + pci_conf = dev->config;/* PCI latency timer = 255 */ pci_conf[PCI_LATENCY_TIMER ] =0xff ;
@@ -2100,9 +2108,9 @@ static int lsi_scsi_init(PCIDevice *dev)memory_region_init_io (&s->ram_io, &lsi_ram_ops, s,"lsi-ram" ,0x2000 );memory_region_init_io (&s->io_io, &lsi_io_ops, s,"lsi-io" ,256 ); -pci_register_bar (&s->dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->io_io); -pci_register_bar (&s->dev,1 ,0 , &s->mmio_io); -pci_register_bar (&s->dev,2 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ram_io); +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->io_io); +pci_register_bar (dev,1 ,0 , &s->mmio_io); +pci_register_bar (dev,2 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ram_io);QTAILQ_INIT (&s->queue);scsi_bus_new (&s->bus, d, &lsi_scsi_info,NULL );
Signature · 1 line
1.8.1.4
PATCH v2 6/30 scsi/megasas: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/scsi/megasas.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
hw/scsi/megasas.c +10 -5
@@ -108,6 +108,11 @@ typedef struct MegasasState {SCSIBus bus; } MegasasState; +#define TYPE_MEGASAS "megasas" + +#define MEGASAS (obj) \ + OBJECT_CHECK(MegasasState, (obj), TYPE_MEGASAS) +#define MEGASAS_INTR_DISABLED_MASK 0xFFFFFFFFstatic bool megasas_intr_enabled (MegasasState *s)
@@ -2039,7 +2044,7 @@ static void megasas_soft_reset(MegasasState *s)static void megasas_scsi_reset (DeviceState *dev) { -MegasasState *s =DO_UPCAST (MegasasState, dev.qdev, dev); +MegasasState *s =MEGASAS (dev);megasas_soft_reset (s); }
@@ -2064,7 +2069,7 @@ static const VMStateDescription vmstate_megasas = {static void megasas_scsi_uninit (PCIDevice *d) { -MegasasState *s =DO_UPCAST (MegasasState, dev, d); +MegasasState *s =MEGASAS (d);#ifdef USE_MSIX msix_uninit (&s->dev, &s->mmio_io);
@@ -2087,7 +2092,7 @@ static const struct SCSIBusInfo megasas_scsi_info = {static int megasas_scsi_init (PCIDevice *dev) { -MegasasState *s =DO_UPCAST (MegasasState, dev, dev); +MegasasState *s =MEGASAS (dev);uint8_t *pci_conf;int i, bar_type;
@@ -2158,7 +2163,7 @@ static int megasas_scsi_init(PCIDevice *dev) s->frames[i].state = s; } -scsi_bus_new (&s->bus, &dev->qdev, &megasas_scsi_info,NULL ); +scsi_bus_new (&s->bus,DEVICE (dev), &megasas_scsi_info,NULL );scsi_bus_legacy_handle_cmdline (&s->bus);return 0 ; }
@@ -2198,7 +2203,7 @@ static void megasas_class_init(ObjectClass *oc, void *data) }static const TypeInfo megasas_info = { - .name ="megasas" , + .name =TYPE_MEGASAS , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (MegasasState), .class_init = megasas_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 1/1 scsi/megasas: QOM parent field cleanup
Rename to parent_obj and fix any fallout.
--- hw/scsi/megasas.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-)
hw/scsi/megasas.c +26 -20
@@ -70,7 +70,10 @@ typedef struct MegasasCmd { } MegasasCmd; typedef struct MegasasState { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + MemoryRegion mmio_io; MemoryRegion port_io; MemoryRegion queue_io;
@@ -237,7 +240,7 @@ static int megasas_map_sgl(MegasasState *s, MegasasCmd *cmd, union mfi_sgl *sgl) MEGASAS_MAX_SGE);return iov_count; } -pci_dma_sglist_init (&cmd->qsg, &s->dev, iov_count); +pci_dma_sglist_init (&cmd->qsg,PCI_DEVICE (s), iov_count);for (i =0 ; i < iov_count; i++) {dma_addr_t iov_pa, iov_size_p;
@@ -498,6 +501,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s,static void megasas_complete_frame (MegasasState *s,uint64_t context) { +PCIDevice *pci_dev =PCI_DEVICE (s);int tail, queue_offset;/* Decrement busy count */
@@ -526,12 +530,12 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context)/* Notify HBA */ s->doorbell++;if (s->doorbell ==1 ) { -if (msix_enabled (&s->dev)) { +if (msix_enabled (pci_dev)) {trace_megasas_msix_raise (0 ); -msix_notify (&s->dev,0 ); +msix_notify (pci_dev,0 ); }else {trace_megasas_irq_raise (); -qemu_irq_raise (s->dev.irq[0 ]); +qemu_irq_raise (pci_dev->irq[0 ]); } } }else {
@@ -633,7 +637,7 @@ static int megasas_map_dcmd(MegasasState *s, MegasasCmd *cmd) } iov_pa =megasas_sgl_get_addr (cmd, &cmd->frame->dcmd.sgl); iov_size =megasas_sgl_get_len (cmd, &cmd->frame->dcmd.sgl); -pci_dma_sglist_init (&cmd->qsg, &s->dev,1 ); +pci_dma_sglist_init (&cmd->qsg,PCI_DEVICE (s),1 );qemu_sglist_add (&cmd->qsg, iov_pa, iov_size); cmd->iov_size = iov_size;return cmd->iov_size;
@@ -660,6 +664,7 @@ static void megasas_finish_dcmd(MegasasCmd *cmd, uint32_t iov_size)static int megasas_ctrl_get_info (MegasasState *s,MegasasCmd *cmd) { +PCIDevice *pci_dev =PCI_DEVICE (s);struct mfi_ctrl_info info;size_t dcmd_size =sizeof (info);BusChild *kid;
@@ -710,11 +715,11 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)memcpy (info.image_component[0 ].build_date, __DATE__,11 );memcpy (info.image_component[0 ].build_time, __TIME__,8 ); info.image_component_count =1 ; -if (s->dev.has_rom) { +if (pci_dev->has_rom) {uint8_t biosver[32 ];uint8_t *ptr; - ptr =memory_region_get_ram_ptr (&s->dev.rom); + ptr =memory_region_get_ram_ptr (&pci_dev->rom);memcpy (biosver, ptr +0x41 ,31 );memcpy (info.image_component[1 ].name,"BIOS" ,4 ); memcpy(info.image_component[1].version, biosver,
@@ -1905,6 +1910,7 @@ static void megasas_mmio_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) {MegasasState *s = opaque; +PCIDevice *pci_dev =PCI_DEVICE (s);uint64_t frame_addr;uint32_t frame_count;int i;
@@ -1928,9 +1934,9 @@ static void megasas_mmio_write(void *opaque, hwaddr addr,break ;case MFI_OMSK : s->intr_mask = val; -if (!megasas_intr_enabled (s) && !msix_enabled (&s->dev)) { +if (!megasas_intr_enabled (s) && !msix_enabled (pci_dev)) {trace_megasas_irq_lower (); -qemu_irq_lower (s->dev.irq[0 ]); +qemu_irq_lower (pci_dev->irq[0 ]); }if (megasas_intr_enabled (s)) {trace_megasas_intr_enabled ();
@@ -1944,9 +1950,9 @@ static void megasas_mmio_write(void *opaque, hwaddr addr,/* Update reply queue pointer */ trace_megasas_qf_update (s->reply_queue_head, s->busy);stl_le_phys (s->producer_pa, s->reply_queue_head); -if (!msix_enabled (&s->dev)) { +if (!msix_enabled (pci_dev)) {trace_megasas_irq_lower (); -qemu_irq_lower (s->dev.irq[0 ]); +qemu_irq_lower (pci_dev->irq[0 ]); } }break ;
@@ -2055,7 +2061,7 @@ static const VMStateDescription vmstate_megasas = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, MegasasState), +VMSTATE_PCI_DEVICE (parent_obj, MegasasState),VMSTATE_INT32 (fw_state, MegasasState),VMSTATE_INT32 (intr_mask, MegasasState),
@@ -2072,7 +2078,7 @@ static void megasas_scsi_uninit(PCIDevice *d)MegasasState *s =MEGASAS (d);#ifdef USE_MSIX -msix_uninit (&s->dev, &s->mmio_io); +msix_uninit (d, &s->mmio_io);#endif memory_region_destroy (&s->mmio_io);memory_region_destroy (&s->port_io);
@@ -2096,7 +2102,7 @@ static int megasas_scsi_init(PCIDevice *dev)uint8_t *pci_conf;int i, bar_type; - pci_conf = s->dev.config; + pci_conf = dev->config;/* PCI latency timer = 0 */ pci_conf[PCI_LATENCY_TIMER ] =0 ;
@@ -2113,7 +2119,7 @@ static int megasas_scsi_init(PCIDevice *dev)#ifdef USE_MSIX /* MSI-X support is currently broken */ if (megasas_use_msix (s) && -msix_init (&s->dev,15 , &s->mmio_io,0 ,0x2000 )) { +msix_init (dev,15 , &s->mmio_io,0 ,0x2000 )) { s->flags &= ~MEGASAS_MASK_USE_MSIX ; }#else
@@ -2121,12 +2127,12 @@ static int megasas_scsi_init(PCIDevice *dev)#endif bar_type =PCI_BASE_ADDRESS_SPACE_MEMORY |PCI_BASE_ADDRESS_MEM_TYPE_64 ; -pci_register_bar (&s->dev,0 , bar_type, &s->mmio_io); -pci_register_bar (&s->dev,2 ,PCI_BASE_ADDRESS_SPACE_IO , &s->port_io); -pci_register_bar (&s->dev,3 , bar_type, &s->queue_io); +pci_register_bar (dev,0 , bar_type, &s->mmio_io); +pci_register_bar (dev,2 ,PCI_BASE_ADDRESS_SPACE_IO , &s->port_io); +pci_register_bar (dev,3 , bar_type, &s->queue_io);if (megasas_use_msix (s)) { -msix_vector_use (&s->dev,0 ); +msix_vector_use (dev,0 ); }if (!s->sas_addr) {
Signature · 1 line
1.8.1.4
PATCH v2 7/30 scsi/esp-pci: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/scsi/esp-pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
hw/scsi/esp-pci.c +9 -5
@@ -31,6 +31,9 @@#define TYPE_AM53C974_DEVICE "am53c974" +#define PCI_ESP (obj) \ + OBJECT_CHECK(PCIESPState, (obj), TYPE_AM53C974_DEVICE) +#define DMA_CMD 0x0#define DMA_STC 0x1#define DMA_SPA 0x2
@@ -288,7 +291,7 @@ static const MemoryRegionOps esp_pci_io_ops = {static void esp_pci_hard_reset (DeviceState *dev) { -PCIESPState *pci =DO_UPCAST (PCIESPState, dev.qdev, dev); +PCIESPState *pci =PCI_ESP (dev);esp_hard_reset (&pci->esp); pci->dma_regs[DMA_CMD ] &= ~(DMA_CMD_DIR |DMA_CMD_INTE_D |DMA_CMD_INTE_P |DMA_CMD_MDL |DMA_CMD_DIAG |DMA_CMD_MASK );
@@ -336,7 +339,8 @@ static const struct SCSIBusInfo esp_pci_scsi_info = {static int esp_pci_scsi_init (PCIDevice *dev) { -PCIESPState *pci =DO_UPCAST (PCIESPState, dev, dev); +PCIESPState *pci =PCI_ESP (dev); +DeviceState *d =DEVICE (dev);ESPState *s = &pci->esp;uint8_t *pci_conf;
@@ -354,8 +358,8 @@ static int esp_pci_scsi_init(PCIDevice *dev)pci_register_bar (&pci->dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &pci->io); s->irq = pci->dev.irq[0 ]; -scsi_bus_new (&s->bus, &dev->qdev, &esp_pci_scsi_info,NULL ); -if (!dev->qdev.hotplugged) { +scsi_bus_new (&s->bus, d, &esp_pci_scsi_info,NULL ); +if (!d->hotplugged) {return scsi_bus_legacy_handle_cmdline (&s->bus); }return 0 ;
@@ -363,7 +367,7 @@ static int esp_pci_scsi_init(PCIDevice *dev)static void esp_pci_scsi_uninit (PCIDevice *d) { -PCIESPState *pci =DO_UPCAST (PCIESPState, dev, d); +PCIESPState *pci =PCI_ESP (d);memory_region_destroy (&pci->io); }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 1/1 scsi/esp-pci: QOM parent field cleanup
Rename to parent_obj and fix any fallout.
--- hw/scsi/esp-pci.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
hw/scsi/esp-pci.c +9 -6
@@ -60,7 +60,10 @@#define SBAC_STATUS 0x1000 typedef struct PCIESPState { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + MemoryRegion io; uint32_t dma_regs[8]; uint32_t sbac;
@@ -260,7 +263,7 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, len = pci->dma_regs[DMA_WBC ]; } -pci_dma_rw (&pci->dev, addr, buf, len, dir); +pci_dma_rw (PCI_DEVICE (pci), addr, buf, len, dir);/* update status registers */ pci->dma_regs[DMA_WBC ] -= len;
@@ -309,7 +312,7 @@ static const VMStateDescription vmstate_esp_pci_scsi = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIESPState), +VMSTATE_PCI_DEVICE (parent_obj, PCIESPState),VMSTATE_BUFFER_UNSAFE (dma_regs, PCIESPState,0 ,8 *sizeof (uint32_t )),VMSTATE_STRUCT (esp, PCIESPState,0 , vmstate_esp, ESPState),VMSTATE_END_OF_LIST ()
@@ -344,7 +347,7 @@ static int esp_pci_scsi_init(PCIDevice *dev)ESPState *s = &pci->esp;uint8_t *pci_conf; - pci_conf = pci->dev.config; + pci_conf = dev->config;/* Interrupt pin A */ pci_conf[PCI_INTERRUPT_PIN ] =0x01 ;
@@ -355,8 +358,8 @@ static int esp_pci_scsi_init(PCIDevice *dev) s->chip_id =TCHI_AM53C974 ;memory_region_init_io (&pci->io, &esp_pci_io_ops, pci,"esp-io" ,0x80 ); -pci_register_bar (&pci->dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &pci->io); - s->irq = pci->dev.irq[0 ]; +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &pci->io); + s->irq = dev->irq[0 ];scsi_bus_new (&s->bus, d, &esp_pci_scsi_info,NULL );if (!d->hotplugged) {
Signature · 1 line
1.8.1.4
PATCH v2 8/30 ide/ich: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/ide/ahci.h | 5 +++++ hw/ide/ich.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
hw/ide/ahci.h +5 -0
@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {AHCIState ahci; } AHCIPCIState; +#define TYPE_ICH_AHCI "ich9-ahci" + +#define ICH_AHCI (obj) \ + OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI) +extern const VMStateDescription vmstate_ahci;#define VMSTATE_AHCI (_field, _state) { \
hw/ide/ich.c +5 -5
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ich9_ahci = {static void pci_ich9_reset (DeviceState *dev) { - struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev); +struct AHCIPCIState *d =ICH_AHCI (dev);ahci_reset (&d->ahci); }
@@ -102,9 +102,9 @@ static int pci_ich9_ahci_init(PCIDevice *dev)struct AHCIPCIState *d;int sata_cap_offset;uint8_t *sata_cap; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev); -ahci_init (&d->ahci, &dev->qdev,pci_get_address_space (dev),6 ); +ahci_init (&d->ahci,DEVICE (dev),pci_get_address_space (dev),6 );pci_config_set_prog_interface (d->card.config,AHCI_PROGMODE_MAJOR_REV_1 );
@@ -141,7 +141,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)static void pci_ich9_uninit (PCIDevice *dev) {struct AHCIPCIState *d; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev);msi_uninit (dev);ahci_uninit (&d->ahci);
@@ -163,7 +163,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) }static const TypeInfo ich_ahci_info = { - .name ="ich9-ahci" , + .name =TYPE_ICH_AHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (AHCIPCIState), .class_init = ich_ahci_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Andreas Färber
AppliedRe: [Qemu-devel] [PATCH v2 08/30] ide/ich: QOM Upcast Sweep
Am 24.06.2013 08:55, schrieb [email protected]:
Quoted 17 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/ide/ahci.h | 5 +++++ hw/ide/ich.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-)hw/ide/ahci.h +0
-0
hw/ide/ahci.h typedef struct AHCIPCIState { · line 308
Quoted 4 lines
hw/ide/ahci.h +1
-0@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {AHCIState ahci; } AHCIPCIState; +#define TYPE_ICH_AHCI "ich9-ahci"
Let's be as precise as for the LSI SCSI HBA and name this ICH9. :)
hw/ide/ahci.h typedef struct AHCIPCIState { · line 311
Quoted 3 lines
hw/ide/ahci.h +3
-0+ +#define ICH_AHCI (obj) \ + OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI)
Wondering if this is specific to ICH(9)? Alex? Leaving it as is for now, renaming is an easy follow-up.
Quoted 9 lines
hw/ide/ahci.h +1
-0+extern const VMStateDescription vmstate_ahci;#define VMSTATE_AHCI (_field, _state) { \hw/ide/ich.c +0
-0
hw/ide/ich.c static const VMStateDescription vmstate_ich9_ahci = { · line 95
Quoted 5 lines
hw/ide/ich.c +1
-1@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ich9_ahci = {static void pci_ich9_reset (DeviceState *dev) { - struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev); +struct AHCIPCIState *d =ICH_AHCI (dev);
Let's drop the "struct" while touching the line.
Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
Quoted 34 lines
hw/ide/ich.c +4
-4ahci_reset (&d->ahci); }@@ -102,9 +102,9 @@ static int pci_ich9_ahci_init(PCIDevice *dev)struct AHCIPCIState *d;int sata_cap_offset;uint8_t *sata_cap; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev); -ahci_init (&d->ahci, &dev->qdev,pci_get_address_space (dev),6 ); +ahci_init (&d->ahci,DEVICE (dev),pci_get_address_space (dev),6 );pci_config_set_prog_interface (d->card.config,AHCI_PROGMODE_MAJOR_REV_1 );@@ -141,7 +141,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)static void pci_ich9_uninit (PCIDevice *dev) {struct AHCIPCIState *d; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev);msi_uninit (dev);ahci_uninit (&d->ahci);@@ -163,7 +163,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) }static const TypeInfo ich_ahci_info = { - .name ="ich9-ahci" , + .name =TYPE_ICH_AHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (AHCIPCIState), .class_init = ich_ahci_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 08/30] ide/ich: QOM Upcast Sweep
Quoted 21 lines · Andreas Färber
Am 24.06.2013 08:55, schrieb [email protected]:
Quoted 20 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/ide/ahci.h| 5 +++++hw/ide/ich.c| 10 +++++-----2 files changed, 10 insertions(+), 5 deletions(-)hw/ide/ahci.h +0
-0@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {AHCIState ahci; } AHCIPCIState;
Quoted 3 lines
hw/ide/ahci.h typedef struct AHCIPCIState { · line 308
Quoted 1 line
hw/ide/ahci.h +1
-0+#define TYPE_ICH_AHCI "ich9-ahci"Let's be as precise as for the LSI SCSI HBA and name this ICH9. :)
No, please. ICH9 is a controller hub. This device really is only about the AHCI part of it.
Quoted 7 lines
hw/ide/ahci.h typedef struct AHCIPCIState { · line 311
Quoted 4 lines
hw/ide/ahci.h +3
-0+ +#define ICH_AHCI (obj) \ + OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI)Wondering if this is specific to ICH(9)? Alex? Leaving it as is for now, renaming is an easy follow-up.
This is not an ICH9 device. It's an ICH9-AHCI device. And for that the check looks sane from what I can tell.
Alex
Quoted 62 lines
Quoted 10 lines
hw/ide/ahci.h +1
-0+extern const VMStateDescription vmstate_ahci;#define VMSTATE_AHCI (_field, _state) { \hw/ide/ich.c +0
-0hw/ide/ich.c static const VMStateDescription vmstate_ich9_ahci = { · line 95
Quoted 5 lines
hw/ide/ich.c +1
-1@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ich9_ahci = {static void pci_ich9_reset (DeviceState *dev) { - struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev); +struct AHCIPCIState *d =ICH_AHCI (dev);Let's drop the "struct" while touching the line.
Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-nextAndreas
Quoted 34 lines
hw/ide/ich.c +4
-4ahci_reset (&d->ahci); }@@ -102,9 +102,9 @@ static int pci_ich9_ahci_init(PCIDevice *dev)struct AHCIPCIState *d;int sata_cap_offset;uint8_t *sata_cap; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev); -ahci_init (&d->ahci, &dev->qdev,pci_get_address_space (dev),6 ); +ahci_init (&d->ahci,DEVICE (dev),pci_get_address_space (dev),6 );pci_config_set_prog_interface (d->card.config,AHCI_PROGMODE_MAJOR_REV_1 );@@ -141,7 +141,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)static void pci_ich9_uninit (PCIDevice *dev) {struct AHCIPCIState *d; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev);msi_uninit (dev);ahci_uninit (&d->ahci);@@ -163,7 +163,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) }static const TypeInfo ich_ahci_info = { - .name ="ich9-ahci" , + .name =TYPE_ICH_AHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (AHCIPCIState), .class_init = ich_ahci_class_init,Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 08/30] ide/ich: QOM Upcast Sweep
Am 01.07.2013 01:36, schrieb Alexander Graf:
Quoted 31 lines · Andreas Färber
Quoted 22 lines
Am 24.06.2013 08:55, schrieb [email protected]:
Quoted 20 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/ide/ahci.h| 5 +++++hw/ide/ich.c| 10 +++++-----2 files changed, 10 insertions(+), 5 deletions(-)hw/ide/ahci.h +0
-0@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {AHCIState ahci; } AHCIPCIState;Quoted 3 lines
hw/ide/ahci.h typedef struct AHCIPCIState { · line 308
Quoted 1 line
hw/ide/ahci.h +1
-0+#define TYPE_ICH_AHCI "ich9-ahci"Let's be as precise as for the LSI SCSI HBA and name this ICH9. :)
No, please. ICH9 is a controller hub. This device really is only about the AHCI part of it.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
hw/ide/ahci.h typedef struct AHCIPCIState { · line 311
Quoted 3 lines
hw/ide/ahci.h +3
-0+ +#define ICH_AHCI (obj) \ + OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI)Wondering if this is specific to ICH(9)? Alex? Leaving it as is for now, renaming is an easy follow-up.
This is not an ICH9 device. It's an ICH9-AHCI device. And for that the check looks sane from what I can tell.
I don't see how either of your answers relate to my question? Maybe you were just tired? ;)
So as you can see above, the type is called ich9-ahci, therefore I have done s/TYPE_ICH_AHCI/TYPE_ICH9_AHCI/g, and I still don't see anything wrong with it, Peter just ack'ed it. There's a link to the modified patch below to verify.
What does a controller hub vs. AHCI have to do with ICH vs. ICH9?
The implied question really is, how specific is AHCIPCIState to ich9-ahci (its sole user AFAICS)? Would an ich6-ahci or ich10-ahci use the same struct or not? Is it even specific to ICH? If not, we might want to name the cast macro after the struct PCI_AHCI() rather than ICH_AHCI(). Compare EHCI where we have a base struct and one derived class having its own extended state/class structs.
Andreas
Quoted 62 lines
Quoted 61 lines
Quoted 9 lines
hw/ide/ahci.h +1
-0+extern const VMStateDescription vmstate_ahci;#define VMSTATE_AHCI (_field, _state) { \hw/ide/ich.c +0
-0hw/ide/ich.c static const VMStateDescription vmstate_ich9_ahci = { · line 95
Quoted 5 lines
hw/ide/ich.c +1
-1@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ich9_ahci = {static void pci_ich9_reset (DeviceState *dev) { - struct AHCIPCIState *d = DO_UPCAST(struct AHCIPCIState, card.qdev, dev); +struct AHCIPCIState *d =ICH_AHCI (dev);Let's drop the "struct" while touching the line.
Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-nextAndreas
Quoted 34 lines
hw/ide/ich.c +4
-4ahci_reset (&d->ahci); }@@ -102,9 +102,9 @@ static int pci_ich9_ahci_init(PCIDevice *dev)struct AHCIPCIState *d;int sata_cap_offset;uint8_t *sata_cap; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev); -ahci_init (&d->ahci, &dev->qdev,pci_get_address_space (dev),6 ); +ahci_init (&d->ahci,DEVICE (dev),pci_get_address_space (dev),6 );pci_config_set_prog_interface (d->card.config,AHCI_PROGMODE_MAJOR_REV_1 );@@ -141,7 +141,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev)static void pci_ich9_uninit (PCIDevice *dev) {struct AHCIPCIState *d; - d = DO_UPCAST(struct AHCIPCIState, card, dev); + d =ICH_AHCI (dev);msi_uninit (dev);ahci_uninit (&d->ahci);@@ -163,7 +163,7 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) }static const TypeInfo ich_ahci_info = { - .name ="ich9-ahci" , + .name =TYPE_ICH_AHCI , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (AHCIPCIState), .class_init = ich_ahci_class_init,Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 08/30] ide/ich: QOM Upcast Sweep
Quoted 39 lines · Andreas Färber
Am 01.07.2013 01:36, schrieb Alexander Graf:
Quoted 38 lines · Andreas Färber
Quoted 22 lines
Am 24.06.2013 08:55, schrieb [email protected]:
Quoted 20 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/ide/ahci.h| 5 +++++hw/ide/ich.c| 10 +++++-----2 files changed, 10 insertions(+), 5 deletions(-)hw/ide/ahci.h +0
-0@@ -305,6 +305,11 @@ typedef struct AHCIPCIState {AHCIState ahci; } AHCIPCIState;Quoted 3 lines
hw/ide/ahci.h typedef struct AHCIPCIState { · line 308
Quoted 1 line
hw/ide/ahci.h +1
-0+#define TYPE_ICH_AHCI "ich9-ahci"Let's be as precise as for the LSI SCSI HBA and name this ICH9. :)
No, please. ICH9 is a controller hub. This device really is only about the AHCI part of it.
Quoted 7 lines
hw/ide/ahci.h typedef struct AHCIPCIState { · line 311
Quoted 4 lines
hw/ide/ahci.h +3
-0+ +#define ICH_AHCI (obj) \ + OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH_AHCI)Wondering if this is specific to ICH(9)? Alex? Leaving it as is for now, renaming is an easy follow-up.
Quoted 4 lines
Quoted 1 line
This is not an ICH9 device. It's an ICH9-AHCI device. And for that the check looks sane from what I can tell.
I don't see how either of your answers relate to my question? Maybe you were just tired? ;)
Ah, sorry. I thought you wanted to just name it "ICH" instead of "ich9-ahci".
Quoted 7 lines
So as you can see above, the type is called ich9-ahci, therefore I have done s/TYPE_ICH_AHCI/TYPE_ICH9_AHCI/g, and I still don't see anything wrong with it, Peter just ack'ed it. There's a link to the modified patch below to verify.
What does a controller hub vs. AHCI have to do with ICH vs. ICH9?
Quoted 6 lines
The implied question really is, how specific is AHCIPCIState to ich9-ahci (its sole user AFAICS)? Would an ich6-ahci or ich10-ahci use the same struct or not? Is it even specific to ICH? If not, we might want to name the cast macro after the struct
PCI_AHCI()rather thanICH_AHCI(). Compare EHCI where we have a base struct and one derived class having its own extended state/class structs.
ich9-ahci is-a pci-ahci is-a ahci makes sense I would say. Different controllers can have different numbers of connectors, but apart from that they should look pretty similar.
Alex
PATCH 1/1 ide/ich: QOM parent field cleanup
In reply to [email protected]Rename to parent_obj and fix any fallout.
--- hw/ide/ahci.c | 11 ++++++----- hw/ide/ahci.h | 5 ++++- hw/ide/ich.c | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 17 deletions(-)
hw/ide/ahci.c +6 -5
@@ -117,12 +117,13 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset)static void ahci_irq_raise (AHCIState *s,AHCIDevice *dev) { -struct AHCIPCIState *d =container_of (s, AHCIPCIState, ahci); +AHCIPCIState *d =container_of (s, AHCIPCIState, ahci); +PCIDevice *pci_dev =PCI_DEVICE (d);DPRINTF (0 ,"raise irq\n" ); -if (msi_enabled (&d->card)) { -msi_notify (&d->card,0 ); +if (msi_enabled (pci_dev)) { +msi_notify (pci_dev,0 ); }else {qemu_irq_raise (s->irq); }
@@ -130,11 +131,11 @@ static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev)static void ahci_irq_lower (AHCIState *s,AHCIDevice *dev) { -struct AHCIPCIState *d =container_of (s, AHCIPCIState, ahci); +AHCIPCIState *d =container_of (s, AHCIPCIState, ahci);DPRINTF (0 ,"lower irq\n" ); -if (!msi_enabled (&d->card)) { +if (!msi_enabled (PCI_DEVICE (d))) {qemu_irq_lower (s->irq); } }
hw/ide/ahci.h +4 -1
@@ -301,7 +301,10 @@ typedef struct AHCIState { } AHCIState;typedef struct AHCIPCIState { -PCIDevice card; +/*< private >*/ +PCIDevice parent_obj; +/*< public >*/ +AHCIState ahci; }AHCIPCIState ;
hw/ide/ich.c +11 -11
@@ -84,7 +84,7 @@ static const VMStateDescription vmstate_ich9_ahci = { .unmigratable = 1, /* Still buggy under I/O load */ .version_id = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (card, AHCIPCIState), +VMSTATE_PCI_DEVICE (parent_obj, AHCIPCIState),VMSTATE_AHCI (ahci, AHCIPCIState),VMSTATE_END_OF_LIST () },
@@ -106,30 +106,30 @@ static int pci_ich9_ahci_init(PCIDevice *dev)ahci_init (&d->ahci,DEVICE (dev),pci_get_address_space (dev),6 ); -pci_config_set_prog_interface (d->card.config,AHCI_PROGMODE_MAJOR_REV_1 ); +pci_config_set_prog_interface (dev->config,AHCI_PROGMODE_MAJOR_REV_1 ); - d->card.config[PCI_CACHE_LINE_SIZE ] =0x08 ;/* Cache line size */ - d->card.config[PCI_LATENCY_TIMER ] =0x00 ;/* Latency timer */ -pci_config_set_interrupt_pin (d->card.config,1 ); + dev->config[PCI_CACHE_LINE_SIZE ] =0x08 ;/* Cache line size */ + dev->config[PCI_LATENCY_TIMER ] =0x00 ;/* Latency timer */ +pci_config_set_interrupt_pin (dev->config,1 );/* XXX Software should program this register */ - d->card.config[0x90 ] =1 <<6 ;/* Address Map Register - AHCI mode */ + dev->config[0x90 ] =1 <<6 ;/* Address Map Register - AHCI mode */ msi_init (dev,0x50 ,1 , true, false); - d->ahci.irq = d->card.irq[0 ]; + d->ahci.irq = dev->irq[0 ]; -pci_register_bar (&d->card,ICH9_IDP_BAR ,PCI_BASE_ADDRESS_SPACE_IO , +pci_register_bar (dev,ICH9_IDP_BAR ,PCI_BASE_ADDRESS_SPACE_IO , &d->ahci.idp); -pci_register_bar (&d->card,ICH9_MEM_BAR ,PCI_BASE_ADDRESS_SPACE_MEMORY , +pci_register_bar (dev,ICH9_MEM_BAR ,PCI_BASE_ADDRESS_SPACE_MEMORY , &d->ahci.mem); - sata_cap_offset =pci_add_capability (&d->card,PCI_CAP_ID_SATA , + sata_cap_offset =pci_add_capability (dev,PCI_CAP_ID_SATA ,ICH9_SATA_CAP_OFFSET ,SATA_CAP_SIZE );if (sata_cap_offset <0 ) {return sata_cap_offset; } - sata_cap = d->card.config + sata_cap_offset; + sata_cap = dev->config + sata_cap_offset;pci_set_word (sata_cap +SATA_CAP_REV ,0x10 );pci_set_long (sata_cap +SATA_CAP_BAR , (ICH9_IDP_BAR +0x4 ) | (ICH9_IDP_INDEX_LOG2 <<4 ));
Signature · 1 line
1.8.1.4
PATCH v2 9/30 ide/piix: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usage of DO_UPCAST and direct -> style upcasting.
---
hw/ide/piix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ide/piix.c +4 -4
@@ -135,7 +135,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));
@@ -159,7 +159,7 @@ static int pci_piix_ide_initfn(PCIDevice *dev)bmdma_setup_bar (d);pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);pci_piix_init_ports (d);
@@ -173,7 +173,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)DriveInfo *di;int i =0 ; - pci_dev =DO_UPCAST (PCIDevice, qdev, dev); + pci_dev =PCI_DEVICE (dev); pci_ide =DO_UPCAST (PCIIDEState, dev, pci_dev);for (; i <3 ; i++) {
@@ -188,7 +188,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)drive_put_ref (di); } } -qdev_reset_all (&(pci_ide->dev.qdev)); +qdev_reset_all (DEVICE (dev));return 0 ; }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 09/30] ide/piix: QOM casting sweep
Am 24.06.2013 08:56, schrieb [email protected]:
Quoted 34 lines
From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usage of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/ide/piix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/ide/piix.c +2
-2@@ -135,7 +135,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));@@ -159,7 +159,7 @@ static int pci_piix_ide_initfn(PCIDevice *dev)bmdma_setup_bar (d);pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);pci_piix_init_ports (d);
hw/ide/piix.c static int pci_piix3_xen_ide_unplug(DeviceState *dev) · line 177
Quoted 6 lines
hw/ide/piix.c +1
-1@@ -173,7 +173,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)DriveInfo *di;int i =0 ; - pci_dev =DO_UPCAST (PCIDevice, qdev, dev); + pci_dev =PCI_DEVICE (dev); pci_ide =DO_UPCAST (PCIIDEState, dev, pci_dev);
This misses the actual type. Any reason for that?
Andreas
Quoted 12 lines
hw/ide/piix.c +1
-1for (; i <3 ; i++) {@@ -188,7 +188,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)drive_put_ref (di); } } -qdev_reset_all (&(pci_ide->dev.qdev)); +qdev_reset_all (DEVICE (dev));return 0 ; }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 09/30] ide/piix: QOM casting sweep
Am 30.06.2013 10:25, schrieb Andreas Färber:
Quoted 38 lines
Am 24.06.2013 08:56, schrieb [email protected]:
Quoted 37 lines
From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usage of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/ide/piix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/ide/piix.c +2
-2@@ -135,7 +135,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));@@ -159,7 +159,7 @@ static int pci_piix_ide_initfn(PCIDevice *dev)bmdma_setup_bar (d);pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);pci_piix_init_ports (d);@@ -173,7 +173,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)DriveInfo *di;int i =0 ;
Quoted 5 lines
hw/ide/piix.c static int pci_piix3_xen_ide_unplug(DeviceState *dev) · line 177
Quoted 3 lines
hw/ide/piix.c +1
-1- pci_dev =DO_UPCAST (PCIDevice, qdev, dev); + pci_dev =PCI_DEVICE (dev); pci_ide =DO_UPCAST (PCIIDEState, dev, pci_dev);This misses the actual type. Any reason for that?
Found the answer myself: PCIIDEState was more involved since it was used by multiple types, so picked up this patch and posted a follow-up.
Andreas
Quoted 11 lines
Quoted 11 lines
hw/ide/piix.c +1
-1for (; i <3 ; i++) {@@ -188,7 +188,7 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)drive_put_ref (di); } } -qdev_reset_all (&(pci_ide->dev.qdev)); +qdev_reset_all (DEVICE (dev));return 0 ; }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 ide: Introduce abstract QOM type for PCIIDEState
In reply to [email protected]Needed for QOM casts.
--- hw/ide/cmd646.c | 62 ++++++++++++++++++++++++++++++--------------------------- hw/ide/pci.c | 30 +++++++++++++++++++++------- hw/ide/pci.h | 8 +++++++- hw/ide/piix.c | 24 ++++++++++------------ hw/ide/via.c | 18 ++++++++--------- 5 files changed, 82 insertions(+), 60 deletions(-)
hw/ide/cmd646.c +33 -29
@@ -127,7 +127,7 @@ static uint64_t bmdma_read(void *opaque, hwaddr addr, unsigned size) {BMDMAState *bm = opaque; -PCIIDEState *pci_dev = bm->pci_dev; +PCIDevice *pci_dev =PCI_DEVICE (bm->pci_dev);uint32_t val;if (size !=1 ) {
@@ -139,16 +139,16 @@ static uint64_t bmdma_read(void *opaque, hwaddr addr, val = bm->cmd;break ;case 1 : - val = pci_dev->dev.config[MRDMODE ]; + val = pci_dev->config[MRDMODE ];break ;case 2 : val = bm->status;break ;case 3 : -if (bm == &pci_dev->bmdma[0 ]) { - val = pci_dev->dev.config[UDIDETCR0 ]; +if (bm == &bm->pci_dev->bmdma[0 ]) { + val = pci_dev->config[UDIDETCR0 ]; }else { - val = pci_dev->dev.config[UDIDETCR1 ]; + val = pci_dev->config[UDIDETCR1 ]; }break ;default :
@@ -165,7 +165,7 @@ static void bmdma_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) {BMDMAState *bm = opaque; -PCIIDEState *pci_dev = bm->pci_dev; +PCIDevice *pci_dev =PCI_DEVICE (bm->pci_dev);if (size !=1 ) {return ;
@@ -179,18 +179,19 @@ static void bmdma_write(void *opaque, hwaddr addr,bmdma_cmd_writeb (bm, val);break ;case 1 : - pci_dev->dev.config[MRDMODE ] = - (pci_dev->dev.config[MRDMODE ] & ~0x30 ) | (val &0x30 ); -cmd646_update_irq (pci_dev); + pci_dev->config[MRDMODE ] = + (pci_dev->config[MRDMODE ] & ~0x30 ) | (val &0x30 ); +cmd646_update_irq (bm->pci_dev);break ;case 2 : bm->status = (val &0x60 ) | (bm->status &1 ) | (bm->status & ~val &0x06 );break ;case 3 : -if (bm == &pci_dev->bmdma[0 ]) - pci_dev->dev.config[UDIDETCR0 ] = val; -else - pci_dev->dev.config[UDIDETCR1 ] = val; +if (bm == &bm->pci_dev->bmdma[0 ]) { + pci_dev->config[UDIDETCR0 ] = val; + }else { + pci_dev->config[UDIDETCR1 ] = val; + }break ; } }
@@ -222,25 +223,29 @@ static void bmdma_setup_bar(PCIIDEState *d)registers */ static void cmd646_update_irq (PCIIDEState *d) { +PCIDevice *pd =PCI_DEVICE (d);int pci_level; - pci_level = ((d->dev.config[MRDMODE ] &MRDMODE_INTR_CH0 ) && - !(d->dev.config[MRDMODE ] &MRDMODE_BLK_CH0 )) || - ((d->dev.config[MRDMODE ] &MRDMODE_INTR_CH1 ) && - !(d->dev.config[MRDMODE ] &MRDMODE_BLK_CH1 )); -qemu_set_irq (d->dev.irq[0 ], pci_level); + + pci_level = ((pd->config[MRDMODE ] &MRDMODE_INTR_CH0 ) && + !(pd->config[MRDMODE ] &MRDMODE_BLK_CH0 )) || + ((pd->config[MRDMODE ] &MRDMODE_INTR_CH1 ) && + !(pd->config[MRDMODE ] &MRDMODE_BLK_CH1 )); +qemu_set_irq (pd->irq[0 ], pci_level); }/* the PCI irq level is the logical OR of the two channels */ static void cmd646_set_irq (void *opaque,int channel,int level) {PCIIDEState *d = opaque; +PCIDevice *pd =PCI_DEVICE (d);int irq_mask; irq_mask =MRDMODE_INTR_CH0 << channel; -if (level) - d->dev.config[MRDMODE ] |= irq_mask; -else - d->dev.config[MRDMODE ] &= ~irq_mask; +if (level) { + pd->config[MRDMODE ] |= irq_mask; + }else { + pd->config[MRDMODE ] &= ~irq_mask; + }cmd646_update_irq (d); }
@@ -257,8 +262,8 @@ static void cmd646_reset(void *opaque)/* CMD646 PCI IDE controller */ static int pci_cmd646_ide_initfn (PCIDevice *dev) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); -uint8_t *pci_conf = d->dev.config; +PCIIDEState *d =PCI_IDE (dev); +uint8_t *pci_conf = dev->config;qemu_irq *irq;int i;
@@ -284,7 +289,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) irq =qemu_allocate_irqs (cmd646_set_irq, d,2 );for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (dev), i,2 );ide_init2 (&d->bus[i], irq[i]);bmdma_init (&d->bus[i], &d->bmdma[i], d);
@@ -293,14 +298,14 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) &d->bmdma[i].dma); } -vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);qemu_register_reset (cmd646_reset, d);return 0 ; }static void pci_cmd646_ide_exitfn (PCIDevice *dev) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); +PCIIDEState *d =PCI_IDE (dev);unsigned i;for (i =0 ; i <2 ; ++i) {
@@ -347,8 +352,7 @@ static void cmd646_ide_class_init(ObjectClass *klass, void *data)static const TypeInfo cmd646_ide_info = { .name ="cmd646-ide" , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (PCIIDEState), + .parent =TYPE_PCI_IDE , .class_init = cmd646_ide_class_init, };
hw/ide/pci.c +23 -7
@@ -56,13 +56,14 @@ static int bmdma_prepare_buf(IDEDMA *dma, int is_write) {BMDMAState *bm =DO_UPCAST (BMDMAState, dma, dma);IDEState *s =bmdma_active_if (bm); +PCIDevice *pci_dev =PCI_DEVICE (bm->pci_dev);struct {uint32_t addr;uint32_t size; } prd;int l, len; -pci_dma_sglist_init (&s->sg, &bm->pci_dev->dev, +pci_dma_sglist_init (&s->sg, pci_dev, s->nsector / (BMDMA_PAGE_SIZE /512 ) +1 ); s->io_buffer_size =0 ;for (;;) {
@@ -71,7 +72,7 @@ static int bmdma_prepare_buf(IDEDMA *dma, int is_write)if (bm->cur_prd_last || (bm->cur_addr - bm->addr) >=BMDMA_PAGE_SIZE )return s->io_buffer_size !=0 ; -pci_dma_read (&bm->pci_dev->dev, bm->cur_addr, &prd,8 ); +pci_dma_read (pci_dev, bm->cur_addr, &prd,8 ); bm->cur_addr +=8 ; prd.addr =le32_to_cpu (prd.addr); prd.size =le32_to_cpu (prd.size);
@@ -98,6 +99,7 @@ static int bmdma_rw_buf(IDEDMA *dma, int is_write) {BMDMAState *bm =DO_UPCAST (BMDMAState, dma, dma);IDEState *s =bmdma_active_if (bm); +PCIDevice *pci_dev =PCI_DEVICE (bm->pci_dev);struct {uint32_t addr;uint32_t size;
@@ -113,7 +115,7 @@ static int bmdma_rw_buf(IDEDMA *dma, int is_write)if (bm->cur_prd_last || (bm->cur_addr - bm->addr) >=BMDMA_PAGE_SIZE )return 0 ; -pci_dma_read (&bm->pci_dev->dev, bm->cur_addr, &prd,8 ); +pci_dma_read (pci_dev, bm->cur_addr, &prd,8 ); bm->cur_addr +=8 ; prd.addr =le32_to_cpu (prd.addr); prd.size =le32_to_cpu (prd.size);
@@ -128,10 +130,10 @@ static int bmdma_rw_buf(IDEDMA *dma, int is_write) l = bm->cur_prd_len;if (l >0 ) {if (is_write) { -pci_dma_write (&bm->pci_dev->dev, bm->cur_prd_addr, +pci_dma_write (pci_dev, bm->cur_prd_addr, s->io_buffer + s->io_buffer_index, l); }else { -pci_dma_read (&bm->pci_dev->dev, bm->cur_prd_addr, +pci_dma_read (pci_dev, bm->cur_prd_addr, s->io_buffer + s->io_buffer_index, l); } bm->cur_prd_addr += l;
@@ -480,7 +482,7 @@ const VMStateDescription vmstate_ide_pci = { .minimum_version_id_old = 0, .post_load = ide_pci_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIIDEState), +VMSTATE_PCI_DEVICE (parent_obj, PCIIDEState),VMSTATE_STRUCT_ARRAY (bmdma, PCIIDEState,2 ,0 , vmstate_bmdma, BMDMAState),VMSTATE_IDE_BUS_ARRAY (bus, PCIIDEState,2 ),
@@ -492,7 +494,7 @@ const VMStateDescription vmstate_ide_pci = {void pci_ide_create_devs (PCIDevice *dev,DriveInfo **hd_table) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); +PCIIDEState *d =PCI_IDE (dev);static const int bus[4 ] = {0 ,0 ,1 ,1 };static const int unit[4 ] = {0 ,1 ,0 ,1 };int i;
@@ -531,3 +533,17 @@ void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d) bus->irq = *irq; bm->pci_dev = d; } + +static const TypeInfo pci_ide_type_info = { + .name =TYPE_PCI_IDE , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (PCIIDEState), + .abstract = true, +}; + +static void pci_ide_register_types (void ) +{ +type_register_static (&pci_ide_type_info); +} + +type_init (pci_ide_register_types)
hw/ide/pci.h +7 -1
@@ -37,8 +37,14 @@ typedef struct CMD646BAR {struct PCIIDEState *pci_dev; }CMD646BAR ; +#define TYPE_PCI_IDE "pci-ide" +#define PCI_IDE (obj) OBJECT_CHECK(PCIIDEState, (obj), TYPE_PCI_IDE) + typedef struct PCIIDEState { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + IDEBus bus[2]; BMDMAState bmdma[2]; uint32_t secondary; /* used only for cmd646 */
hw/ide/piix.c +10 -14
@@ -106,7 +106,8 @@ static void bmdma_setup_bar(PCIIDEState *d)static void piix3_reset (void *opaque) {PCIIDEState *d = opaque; -uint8_t *pci_conf = d->dev.config; +PCIDevice *pd =PCI_DEVICE (d); +uint8_t *pci_conf = pd->config;int i;for (i =0 ; i <2 ; i++) {
@@ -149,15 +150,15 @@ static void pci_piix_init_ports(PCIIDEState *d) {static int pci_piix_ide_initfn (PCIDevice *dev) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); -uint8_t *pci_conf = d->dev.config; +PCIIDEState *d =PCI_IDE (dev); +uint8_t *pci_conf = dev->config; pci_conf[PCI_CLASS_PROG ] =0x80 ;// legacy ATA mode qemu_register_reset (piix3_reset, d);bmdma_setup_bar (d); -pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); +pci_register_bar (dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar);vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);
@@ -168,13 +169,11 @@ static int pci_piix_ide_initfn(PCIDevice *dev)static int pci_piix3_xen_ide_unplug (DeviceState *dev) { -PCIDevice *pci_dev;PCIIDEState *pci_ide;DriveInfo *di;int i =0 ; - pci_dev =PCI_DEVICE (dev); - pci_ide =DO_UPCAST (PCIIDEState, dev, pci_dev); + pci_ide =PCI_IDE (dev);for (; i <3 ; i++) { di =drive_get_by_index (IF_IDE , i);
@@ -203,7 +202,7 @@ PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)static void pci_piix_ide_exitfn (PCIDevice *dev) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); +PCIIDEState *d =PCI_IDE (dev);unsigned i;for (i =0 ; i <2 ; ++i) {
@@ -253,8 +252,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)static const TypeInfo piix3_ide_info = { .name ="piix3-ide" , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (PCIIDEState), + .parent =TYPE_PCI_IDE , .class_init = piix3_ide_class_init, };
@@ -273,8 +271,7 @@ static void piix3_ide_xen_class_init(ObjectClass *klass, void *data)static const TypeInfo piix3_ide_xen_info = { .name ="piix3-ide-xen" , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (PCIIDEState), + .parent =TYPE_PCI_IDE , .class_init = piix3_ide_xen_class_init, };
@@ -294,8 +291,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)static const TypeInfo piix4_ide_info = { .name ="piix4-ide" , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (PCIIDEState), + .parent =TYPE_PCI_IDE , .class_init = piix4_ide_class_init, };
hw/ide/via.c +9 -9
@@ -108,7 +108,8 @@ static void bmdma_setup_bar(PCIIDEState *d)static void via_reset (void *opaque) {PCIIDEState *d = opaque; -uint8_t *pci_conf = d->dev.config; +PCIDevice *pd =PCI_DEVICE (d); +uint8_t *pci_conf = pd->config;int i;for (i =0 ; i <2 ; i++) {
@@ -158,7 +159,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));
@@ -173,17 +174,17 @@ static void vt82c686b_init_ports(PCIIDEState *d) {/* via ide func */ static int vt82c686b_ide_initfn (PCIDevice *dev) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); -uint8_t *pci_conf = d->dev.config; +PCIIDEState *d =PCI_IDE (dev); +uint8_t *pci_conf = dev->config;pci_config_set_prog_interface (pci_conf,0x8a );/* legacy ATA mode */ pci_set_long (pci_conf +PCI_CAPABILITY_LIST ,0x000000c0 );qemu_register_reset (via_reset, d);bmdma_setup_bar (d); -pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); +pci_register_bar (dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);vt82c686b_init_ports (d);
@@ -192,7 +193,7 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)static void vt82c686b_ide_exitfn (PCIDevice *dev) { -PCIIDEState *d =DO_UPCAST (PCIIDEState, dev, dev); +PCIIDEState *d =PCI_IDE (dev);unsigned i;for (i =0 ; i <2 ; ++i) {
@@ -228,8 +229,7 @@ static void via_ide_class_init(ObjectClass *klass, void *data)static const TypeInfo via_ide_info = { .name ="via-ide" , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (PCIIDEState), + .parent =TYPE_PCI_IDE , .class_init = via_ide_class_init, };
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-next] ide: Introduce abstract QOM type for PCIIDEState
Am 22.07.2013 17:58, schrieb Andreas Färber:
Quoted 10 lines
Needed for QOM casts.
Signed-off-by Andreas Färber <[email protected]>--- hw/ide/cmd646.c | 62 ++++++++++++++++++++++++++++++--------------------------- hw/ide/pci.c | 30 +++++++++++++++++++++------- hw/ide/pci.h | 8 +++++++- hw/ide/piix.c | 24 ++++++++++------------ hw/ide/via.c | 18 ++++++++--------- 5 files changed, 82 insertions(+), 60 deletions(-)
Since time is running away and there were no objections so far, applied this to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH v2 10/30 acpi/piix4: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +17 -14
@@ -96,6 +96,11 @@ typedef struct PIIX4PMState {Notifier cpu_added_notifier; } PIIX4PMState; +#define TYPE_PIIX4_PM "PIIX4_PM" + +#define PIIX4_PM (obj) \ + OBJECT_CHECK(PIIX4PMState, (obj), TYPE_PIIX4_PM) +static void piix4_acpi_system_hot_add_init (MemoryRegion *parent,PCIBus *bus,PIIX4PMState *s);
@@ -300,7 +305,7 @@ static const VMStateDescription vmstate_acpi = {static void acpi_piix_eject_slot (PIIX4PMState *s,unsigned slots) {BusChild *kid, *next; -BusState *bus =qdev_get_parent_bus (&s->dev.qdev); +BusState *bus =qdev_get_parent_bus (DEVICE (s));int slot =ffs (slots) -1 ;bool slot_free = true;
@@ -326,8 +331,7 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots)static void piix4_update_hotplug (PIIX4PMState *s) { -PCIDevice *dev = &s->dev; -BusState *bus =qdev_get_parent_bus (&dev->qdev); +BusState *bus =qdev_get_parent_bus (DEVICE (s));BusChild *kid, *next;/* Execute any pending removes during reset */
@@ -395,7 +399,7 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)static int piix4_pm_initfn (PCIDevice *dev) { -PIIX4PMState *s =DO_UPCAST (PIIX4PMState, dev, dev); +PIIX4PMState *s =PIIX4_PM (dev);uint8_t *pci_conf; pci_conf = s->dev.config;
@@ -418,7 +422,7 @@ static int piix4_pm_initfn(PCIDevice *dev) pci_conf[0x90 ] = s->smb_io_base |1 ; pci_conf[0x91 ] = s->smb_io_base >>8 ; pci_conf[0xd2 ] =0x09 ; -pm_smbus_init (&s->dev.qdev, &s->smb); +pm_smbus_init (DEVICE (dev), &s->smb);memory_region_set_enabled (&s->smb.io, pci_conf[0xd2 ] &1 );memory_region_add_subregion (pci_address_space_io (dev), s->smb_io_base, &s->smb.io);
@@ -449,18 +453,18 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq smi_irq, int kvm_enabled, FWCfgState *fw_cfg) { - PCIDevice *dev; + DeviceState *dev;PIIX4PMState *s; - dev =pci_create (bus, devfn,"PIIX4_PM" ); -qdev_prop_set_uint32 (&dev->qdev,"smb_io_base" , smb_io_base); + dev =DEVICE (pci_create (bus, devfn,TYPE_PIIX4_PM )); +qdev_prop_set_uint32 (dev,"smb_io_base" , smb_io_base); - s =DO_UPCAST (PIIX4PMState, dev, dev); + s =PIIX4_PM (dev); s->irq = sci_irq; s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled; -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (dev);if (fw_cfg) {uint8_t suspend[6 ] = {128 ,0 ,0 ,129 ,128 ,128 };
@@ -500,7 +504,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) }static const TypeInfo piix4_pm_info = { - .name ="PIIX4_PM" , + .name =TYPE_PIIX4_PM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PIIX4PMState), .class_init = piix4_pm_class_init,
@@ -678,7 +682,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, PCI_HOTPLUG_SIZE);memory_region_add_subregion (parent,PCI_HOTPLUG_ADDR , &s->io_pci); -pci_bus_hotplug (bus, piix4_device_hotplug, &s->dev.qdev); +pci_bus_hotplug (bus, piix4_device_hotplug,DEVICE (s));qemu_for_each_cpu (piix4_init_cpu_status, &s->gpe_cpu); memory_region_init_io(&s->io_cpu, &cpu_hotplug_ops, s, "apci-cpu-hotplug",
@@ -704,8 +708,7 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, PCIHotplugState state) {int slot =PCI_SLOT (dev->devfn); -PIIX4PMState *s =DO_UPCAST (PIIX4PMState, dev, -PCI_DEVICE (qdev)); +PIIX4PMState *s =PIIX4_PM (qdev);/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH 1/1 acpi/piix4: QOM parent field cleanup
Rename to parent_obj and fix any fallout.
--- hw/acpi/piix4.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
hw/acpi/piix4.c +19 -11
@@ -64,7 +64,9 @@ typedef struct CPUStatus { } CPUStatus; typedef struct PIIX4PMState { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ MemoryRegion io; MemoryRegion io_gpe;
@@ -135,11 +137,12 @@ static void pm_tmr_timer(ACPIREGS *ar)static void apm_ctrl_changed (uint32_t val,void *arg) {PIIX4PMState *s = arg; +PCIDevice *d =PCI_DEVICE (s);/* ACPI specs 3.0, 4.7.2.5 */ acpi_pm1_cnt_update (&s->ar, val ==ACPI_ENABLE , val ==ACPI_DISABLE ); -if (s->dev.config[0x5b ] & (1 <<1 )) { +if (d->config[0x5b ] & (1 <<1 )) {if (s->smi_irq) {qemu_irq_raise (s->smi_irq); }
@@ -148,24 +151,27 @@ static void apm_ctrl_changed(uint32_t val, void *arg)static void pm_io_space_update (PIIX4PMState *s) { +PCIDevice *d =PCI_DEVICE (s);uint32_t pm_io_base; - pm_io_base =le32_to_cpu (*(uint32_t *)(s->dev.config +0x40 )); + pm_io_base =le32_to_cpu (*(uint32_t *)(d->config +0x40 )); pm_io_base &=0xffc0 ;memory_region_transaction_begin (); -memory_region_set_enabled (&s->io, s->dev.config[0x80 ] &1 ); +memory_region_set_enabled (&s->io, d->config[0x80 ] &1 );memory_region_set_address (&s->io, pm_io_base);memory_region_transaction_commit (); }static void smbus_io_space_update (PIIX4PMState *s) { - s->smb_io_base =le32_to_cpu (*(uint32_t *)(s->dev.config +0x90 )); +PCIDevice *d =PCI_DEVICE (s); + + s->smb_io_base =le32_to_cpu (*(uint32_t *)(d->config +0x90 )); s->smb_io_base &=0xffc0 ;memory_region_transaction_begin (); -memory_region_set_enabled (&s->smb.io, s->dev.config[0xd2 ] &1 ); +memory_region_set_enabled (&s->smb.io, d->config[0xd2 ] &1 );memory_region_set_address (&s->smb.io, s->smb_io_base);memory_region_transaction_commit (); }
@@ -244,7 +250,7 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)int ret, i;uint16_t temp; - ret =pci_device_load (&s->dev, f); + ret =pci_device_load (PCI_DEVICE (s), f);if (ret <0 ) {return ret; }
@@ -288,7 +294,7 @@ static const VMStateDescription vmstate_acpi = { .load_state_old = acpi_load_old, .post_load = vmstate_acpi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PIIX4PMState), +VMSTATE_PCI_DEVICE (parent_obj, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.evt.sts, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.evt.en, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.cnt.cnt, PIIX4PMState),
@@ -359,7 +365,8 @@ static void piix4_update_hotplug(PIIX4PMState *s)static void piix4_reset (void *opaque) {PIIX4PMState *s = opaque; -uint8_t *pci_conf = s->dev.config; +PCIDevice *d =PCI_DEVICE (s); +uint8_t *pci_conf = d->config; pci_conf[0x58 ] =0 ; pci_conf[0x59 ] =0 ;
@@ -387,9 +394,10 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque)static void piix4_pm_machine_ready (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, machine_ready); +PCIDevice *d =PCI_DEVICE (s);uint8_t *pci_conf; - pci_conf = s->dev.config; + pci_conf = d->config; pci_conf[0x5f ] = (isa_is_ioport_assigned (0x378 ) ?0x80 :0 ) |0x10 ; pci_conf[0x63 ] =0x60 ; pci_conf[0x67] = (isa_is_ioport_assigned(0x3f8) ? 0x08 : 0) |
@@ -402,7 +410,7 @@ static int piix4_pm_initfn(PCIDevice *dev)PIIX4PMState *s =PIIX4_PM (dev);uint8_t *pci_conf; - pci_conf = s->dev.config; + pci_conf = dev->config; pci_conf[0x06 ] =0x80 ; pci_conf[0x07 ] =0x02 ; pci_conf[0x09 ] =0x00 ;
Signature · 1 line
1.8.1.4
PATCH v2 11/30 misc/pci-testdev: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/misc/pci-testdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/misc/pci-testdev.c +8 -3
@@ -83,6 +83,11 @@ typedef struct PCITestDevState {int current; } PCITestDevState; +#define TYPE_PCI_TEST_DEV "pci-testdev" + +#define PCI_TEST_DEV (obj) \ + OBJECT_CHECK(PCITestDevState, (obj), TYPE_PCI_TEST_DEV) +#define IOTEST_IS_MEM (i) (strcmp(IOTEST_TYPE(i), "portio"))#define IOTEST_REGION (d, i) (IOTEST_IS_MEM(i) ? &(d)->mmio : &(d)->portio)#define IOTEST_SIZE (i) (IOTEST_IS_MEM(i) ? IOTEST_MEMSIZE : IOTEST_IOSIZE)
@@ -274,7 +279,7 @@ static int pci_testdev_init(PCIDevice *pci_dev)static void pci_testdev_uninit (PCIDevice *dev) { -PCITestDevState *d =DO_UPCAST (PCITestDevState, dev, dev); +PCITestDevState *d =PCI_TEST_DEV (dev);int i;pci_testdev_reset (d);
@@ -291,7 +296,7 @@ pci_testdev_uninit(PCIDevice *dev)static void qdev_pci_testdev_reset (DeviceState *dev) { -PCITestDevState *d =DO_UPCAST (PCITestDevState, dev.qdev, dev); +PCITestDevState *d =PCI_TEST_DEV (dev);pci_testdev_reset (d); }
@@ -311,7 +316,7 @@ static void pci_testdev_class_init(ObjectClass *klass, void *data) }static const TypeInfo pci_testdev_info = { - .name ="pci-testdev" , + .name =TYPE_PCI_TEST_DEV , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCITestDevState), .class_init = pci_testdev_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 11/30] misc/pci-testdev: QOM Upcast Sweep
Am 24.06.2013 08:58, schrieb [email protected]:
Quoted 10 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/misc/pci-testdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Missed one DO_UPCAST(), fixing up.
Andreas
hw/misc/pci-testdev.c +1 -1
@@ -232,7 +232,7 @@ static const MemoryRegionOps pci_testdev_pio_ops = {static int pci_testdev_init (PCIDevice *pci_dev) { -PCITestDevState *d =DO_UPCAST (PCITestDevState, dev, pci_dev); +PCITestDevState *d =PCI_TEST_DEV (pci_dev);uint8_t *pci_conf;char *name;int r, i;
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 misc/pci-testdev: QOM parent field cleanup
In reply to [email protected]Rename to parent_obj and fix any fallout.
--- hw/misc/pci-testdev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/misc/pci-testdev.c +7 -4
@@ -76,7 +76,10 @@ enum {#define IOTEST_ACCESS_WIDTH (sizeof(uint8_t)) typedef struct PCITestDevState { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + MemoryRegion mmio; MemoryRegion portio; IOTest *tests;
@@ -237,7 +240,7 @@ static int pci_testdev_init(PCIDevice *pci_dev)char *name;int r, i; - pci_conf = d->dev.config; + pci_conf = pci_dev->config; pci_conf[PCI_INTERRUPT_PIN ] =0 ;/* no interrupt pin */
@@ -245,8 +248,8 @@ static int pci_testdev_init(PCIDevice *pci_dev) "pci-testdev-mmio", IOTEST_MEMSIZE * 2);memory_region_init_io (&d->portio, &pci_testdev_pio_ops, d,"pci-testdev-portio" ,IOTEST_IOSIZE *2 ); -pci_register_bar (&d->dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &d->mmio); -pci_register_bar (&d->dev,1 ,PCI_BASE_ADDRESS_SPACE_IO , &d->portio); +pci_register_bar (pci_dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &d->mmio); +pci_register_bar (pci_dev,1 ,PCI_BASE_ADDRESS_SPACE_IO , &d->portio); d->current =-1 ; d->tests =g_malloc0 (IOTEST_MAX *sizeof *d->tests);
Signature · 1 line
1.8.1.4
PATCH v2 12/30 virtio/vmware_vga: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style casting.
---
hw/display/vmware_vga.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/display/vmware_vga.c +8 -5
@@ -81,6 +81,11 @@ struct vmsvga_state_s {int redraw_fifo_first, redraw_fifo_last; }; +#define TYPE_VM_SVGA "vmware-svga" + +#define VM_SVGA (obj) \ + OBJECT_CHECK(struct pci_vmsvga_state_s, (obj), TYPE_VM_SVGA) +struct pci_vmsvga_state_s {PCIDevice card;struct vmsvga_state_s chip;
@@ -1092,8 +1097,7 @@ static void vmsvga_update_display(void *opaque)static void vmsvga_reset (DeviceState *dev) { -struct pci_vmsvga_state_s *pci = - DO_UPCAST(struct pci_vmsvga_state_s, card.qdev, dev); +struct pci_vmsvga_state_s *pci =VM_SVGA (dev);struct vmsvga_state_s *s = &pci->chip; s->index =0 ;
@@ -1246,8 +1250,7 @@ static const MemoryRegionOps vmsvga_io_ops = {static int pci_vmsvga_initfn (PCIDevice *dev) { -struct pci_vmsvga_state_s *s = - DO_UPCAST(struct pci_vmsvga_state_s, card, dev); +struct pci_vmsvga_state_s *s =VM_SVGA (dev); s->card.config[PCI_CACHE_LINE_SIZE ] =0x08 ;/* Cache line size */ s->card.config[PCI_LATENCY_TIMER ] =0x40 ;/* Latency timer */
@@ -1299,7 +1302,7 @@ static void vmsvga_class_init(ObjectClass *klass, void *data) }static const TypeInfo vmsvga_info = { - .name ="vmware-svga" , + .name =TYPE_VM_SVGA , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (struct pci_vmsvga_state_s ), .class_init = vmsvga_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 12/30] virtio/vmware_vga: QOM casting sweep
"display/vmware_vga: ..." obviously.
Am 24.06.2013 08:58, schrieb [email protected]:
Quoted 16 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style casting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/display/vmware_vga.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)hw/display/vmware_vga.c +0
-0
hw/display/vmware_vga.c struct vmsvga_state_s { · line 87
Quoted 7 lines
hw/display/vmware_vga.c +4
-0@@ -81,6 +81,11 @@ struct vmsvga_state_s {int redraw_fifo_first, redraw_fifo_last; }; +#define TYPE_VM_SVGA "vmware-svga" + +#define VM_SVGA (obj) \ + OBJECT_CHECK(struct pci_vmsvga_state_s, (obj), TYPE_VM_SVGA)
Let's use VMWARE_VGA for uniqueness. Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
Quoted 34 lines
hw/display/vmware_vga.c +4
-5+struct pci_vmsvga_state_s {PCIDevice card;struct vmsvga_state_s chip;@@ -1092,8 +1097,7 @@ static void vmsvga_update_display(void *opaque)static void vmsvga_reset (DeviceState *dev) { -struct pci_vmsvga_state_s *pci = - DO_UPCAST(struct pci_vmsvga_state_s, card.qdev, dev); +struct pci_vmsvga_state_s *pci =VM_SVGA (dev);struct vmsvga_state_s *s = &pci->chip; s->index =0 ;@@ -1246,8 +1250,7 @@ static const MemoryRegionOps vmsvga_io_ops = {static int pci_vmsvga_initfn (PCIDevice *dev) { -struct pci_vmsvga_state_s *s = - DO_UPCAST(struct pci_vmsvga_state_s, card, dev); +struct pci_vmsvga_state_s *s =VM_SVGA (dev); s->card.config[PCI_CACHE_LINE_SIZE ] =0x08 ;/* Cache line size */ s->card.config[PCI_LATENCY_TIMER ] =0x40 ;/* Latency timer */ @@ -1299,7 +1302,7 @@ static void vmsvga_class_init(ObjectClass *klass, void *data) }static const TypeInfo vmsvga_info = { - .name ="vmware-svga" , + .name =TYPE_VM_SVGA , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (struct pci_vmsvga_state_s ), .class_init = vmsvga_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 display/vmware_vga: QOM parent field cleanup
In reply to [email protected]Rename to parent_obj and fix any fallout.
--- hw/display/vmware_vga.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
hw/display/vmware_vga.c +13 -10
@@ -87,7 +87,10 @@ struct vmsvga_state_s { OBJECT_CHECK(struct pci_vmsvga_state_s, (obj), TYPE_VMWARE_SVGA)struct pci_vmsvga_state_s { -PCIDevice card; +/*< private >*/ +PCIDevice parent_obj; +/*< public >*/ +struct vmsvga_state_s chip;MemoryRegion io_bar; };
@@ -792,7 +795,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)case SVGA_REG_FB_START : {struct pci_vmsvga_state_s *pci_vmsvga = container_of(s, struct pci_vmsvga_state_s, chip); - ret =pci_get_bar_addr (&pci_vmsvga->card,1 ); + ret =pci_get_bar_addr (PCI_DEVICE (pci_vmsvga),1 );break ; }
@@ -828,7 +831,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)case SVGA_REG_MEM_START : {struct pci_vmsvga_state_s *pci_vmsvga = container_of(s, struct pci_vmsvga_state_s, chip); - ret =pci_get_bar_addr (&pci_vmsvga->card,2 ); + ret =pci_get_bar_addr (PCI_DEVICE (pci_vmsvga),2 );break ; }
@@ -1176,7 +1179,7 @@ static const VMStateDescription vmstate_vmware_vga = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(card, struct pci_vmsvga_state_s), + VMSTATE_PCI_DEVICE(parent_obj, struct pci_vmsvga_state_s), VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0, vmstate_vmware_vga_internal, struct vmsvga_state_s),VMSTATE_END_OF_LIST ()
@@ -1252,21 +1255,21 @@ static int pci_vmsvga_initfn(PCIDevice *dev) {struct pci_vmsvga_state_s *s =VMWARE_SVGA (dev); - s->card.config[PCI_CACHE_LINE_SIZE ] =0x08 ;/* Cache line size */ - s->card.config[PCI_LATENCY_TIMER ] =0x40 ;/* Latency timer */ - s->card.config[PCI_INTERRUPT_LINE ] =0xff ;/* End */ + dev->config[PCI_CACHE_LINE_SIZE ] =0x08 ; + dev->config[PCI_LATENCY_TIMER ] =0x40 ; + dev->config[PCI_INTERRUPT_LINE ] =0xff ;/* End */ memory_region_init_io (&s->io_bar, &vmsvga_io_ops, &s->chip,"vmsvga-io" ,0x10 );memory_region_set_flush_coalesced (&s->io_bar); -pci_register_bar (&s->card,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->io_bar); +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &s->io_bar);vmsvga_init (DEVICE (dev), &s->chip,pci_address_space (dev),pci_address_space_io (dev)); -pci_register_bar (&s->card,1 ,PCI_BASE_ADDRESS_MEM_PREFETCH , +pci_register_bar (dev,1 ,PCI_BASE_ADDRESS_MEM_PREFETCH , &s->chip.vga.vram); -pci_register_bar (&s->card,2 ,PCI_BASE_ADDRESS_MEM_PREFETCH , +pci_register_bar (dev,2 ,PCI_BASE_ADDRESS_MEM_PREFETCH , &s->chip.fifo_ram);if (!dev->rom_bar) {
Signature · 1 line
1.8.1.4
PATCH v2 13/30 misc/ivshmem: QOM Upcast Sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/misc/ivshmem.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
hw/misc/ivshmem.c +11 -7
@@ -48,6 +48,10 @@#define IVSHMEM_DPRINTF (fmt, ...)#endif +#define TYPE_IVSHMEM "ivshmem" +#define IVSHMEM (obj) \ + OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM) + typedef struct Peer { int nb_eventfds; EventNotifier *eventfds;
@@ -341,7 +345,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) {memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));memory_region_add_subregion (&s->bar,0 , &s->ivshmem);/* region for shared memory */
@@ -469,7 +473,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) incoming_fd, 0);memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, map_ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));IVSHMEM_DPRINTF ("guest h/w addr = %" PRIu64", size = %" PRIu64"\n" , s->ivshmem_offset, s->ivshmem_size);
@@ -534,7 +538,7 @@ static void ivshmem_use_msix(IVShmemState * s)static void ivshmem_reset (DeviceState *d) { -IVShmemState *s =DO_UPCAST (IVShmemState, dev.qdev, d); +IVShmemState *s =IVSHMEM (d); s->intrstatus =0 ;ivshmem_use_msix (s);
@@ -648,7 +652,7 @@ static int pci_ivshmem_init(PCIDevice *dev) s->ivshmem_size =ivshmem_get_size (s); } -register_savevm (&s->dev.qdev,"ivshmem" ,0 ,0 , ivshmem_save, ivshmem_load, +register_savevm (DEVICE (dev),"ivshmem" ,0 ,0 , ivshmem_save, ivshmem_load, dev);/* IRQFD requires MSI */
@@ -780,10 +784,10 @@ static void pci_ivshmem_uninit(PCIDevice *dev)memory_region_destroy (&s->ivshmem_mmio);memory_region_del_subregion (&s->bar, &s->ivshmem); -vmstate_unregister_ram (&s->ivshmem, &s->dev.qdev); +vmstate_unregister_ram (&s->ivshmem,DEVICE (dev));memory_region_destroy (&s->ivshmem);memory_region_destroy (&s->bar); -unregister_savevm (&dev->qdev,"ivshmem" , s); +unregister_savevm (DEVICE (dev),"ivshmem" , s); }static Property ivshmem_properties[] = {
@@ -813,7 +817,7 @@ static void ivshmem_class_init(ObjectClass *klass, void *data) }static const TypeInfo ivshmem_info = { - .name ="ivshmem" , + .name =TYPE_IVSHMEM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (IVShmemState), .class_init = ivshmem_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 13/30] misc/ivshmem: QOM Upcast Sweep
Am 24.06.2013 08:59, schrieb [email protected]:
Quoted 27 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/misc/ivshmem.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)hw/misc/ivshmem.c +4
-0@@ -48,6 +48,10 @@#define IVSHMEM_DPRINTF (fmt, ...)#endif +#define TYPE_IVSHMEM "ivshmem" +#define IVSHMEM (obj) \ + OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM) + typedef struct Peer { int nb_eventfds; EventNotifier *eventfds;
hw/misc/ivshmem.c static void create_shared_memory_BAR(IVShmemState *s, int fd) { · line 348
Quoted 5 lines
hw/misc/ivshmem.c +1
-1@@ -341,7 +345,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) {memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));
DEVICE(s)
hw/misc/ivshmem.c static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) · line 476
Quoted 9 lines
hw/misc/ivshmem.c +1
-1memory_region_add_subregion (&s->bar,0 , &s->ivshmem);/* region for shared memory */ @@ -469,7 +473,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) incoming_fd, 0);memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, map_ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));
DEVICE(s)
Renaming the parent field showed that there are still some s->dev accesses missed in this patch. Applying anyway to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
IMO such casting cleanup patches make the most sense when they are complete in removing all accesses to the parent field and proving that by renaming the parent field with the only remaining usage being in VMSTATE_PCI(). We won't be able to drop DO_UPCAST() since it's being used outside QOM in the block layer for instance. I'm hoping we can squash a fixup so that we don't need to touch each device twice.
Regards,
Andreas
Quoted 44 lines
hw/misc/ivshmem.c +5
-5IVSHMEM_DPRINTF ("guest h/w addr = %" PRIu64", size = %" PRIu64"\n" , s->ivshmem_offset, s->ivshmem_size);@@ -534,7 +538,7 @@ static void ivshmem_use_msix(IVShmemState * s)static void ivshmem_reset (DeviceState *d) { -IVShmemState *s =DO_UPCAST (IVShmemState, dev.qdev, d); +IVShmemState *s =IVSHMEM (d); s->intrstatus =0 ;ivshmem_use_msix (s);@@ -648,7 +652,7 @@ static int pci_ivshmem_init(PCIDevice *dev) s->ivshmem_size =ivshmem_get_size (s); } -register_savevm (&s->dev.qdev,"ivshmem" ,0 ,0 , ivshmem_save, ivshmem_load, +register_savevm (DEVICE (dev),"ivshmem" ,0 ,0 , ivshmem_save, ivshmem_load, dev);/* IRQFD requires MSI */ @@ -780,10 +784,10 @@ static void pci_ivshmem_uninit(PCIDevice *dev)memory_region_destroy (&s->ivshmem_mmio);memory_region_del_subregion (&s->bar, &s->ivshmem); -vmstate_unregister_ram (&s->ivshmem, &s->dev.qdev); +vmstate_unregister_ram (&s->ivshmem,DEVICE (dev));memory_region_destroy (&s->ivshmem);memory_region_destroy (&s->bar); -unregister_savevm (&dev->qdev,"ivshmem" , s); +unregister_savevm (DEVICE (dev),"ivshmem" , s); }static Property ivshmem_properties[] = {@@ -813,7 +817,7 @@ static void ivshmem_class_init(ObjectClass *klass, void *data) }static const TypeInfo ivshmem_info = { - .name ="ivshmem" , + .name =TYPE_IVSHMEM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (IVShmemState), .class_init = ivshmem_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 13/30] misc/ivshmem: QOM Upcast Sweep
Am 30.06.2013 11:18, schrieb Andreas Färber:
Quoted 48 lines
Am 24.06.2013 08:59, schrieb [email protected]:
Quoted 27 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/misc/ivshmem.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)hw/misc/ivshmem.c +4
-0@@ -48,6 +48,10 @@#define IVSHMEM_DPRINTF (fmt, ...)#endif +#define TYPE_IVSHMEM "ivshmem" +#define IVSHMEM (obj) \ + OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM) + typedef struct Peer { int nb_eventfds; EventNotifier *eventfds;hw/misc/ivshmem.c static void create_shared_memory_BAR(IVShmemState *s, int fd) { · line 348
Quoted 5 lines
hw/misc/ivshmem.c +1
-1@@ -341,7 +345,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) {memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));DEVICE(s)
hw/misc/ivshmem.c static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) · line 476
Quoted 9 lines
hw/misc/ivshmem.c +1
-1memory_region_add_subregion (&s->bar,0 , &s->ivshmem);/* region for shared memory */ @@ -469,7 +473,7 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) incoming_fd, 0);memory_region_init_ram_ptr (&s->ivshmem,"ivshmem.bar2" , s->ivshmem_size, map_ptr); -vmstate_register_ram (&s->ivshmem, &s->dev.qdev); +vmstate_register_ram (&s->ivshmem,DEVICE (&s->dev));DEVICE(s)
Quoted 3 lines
Renaming the parent field showed that there are still some
s->devaccesses missed in this patch. Applying anyway to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Missed two DO_UPCAST()s, fixed up.
Andreas
hw/misc/ivshmem.c +0 -0
@@ -643,7 +643,7 @@ static void ivshmem_write_config(PCIDevice *pci_dev,
uint32_t address,
static int pci_ivshmem_init(PCIDevice *dev)
{
- IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
+ IVShmemState *s = IVSHMEM(dev);
uint8_t *pci_conf;
if (s->sizearg == NULL)@@ -775,7 +775,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
static void pci_ivshmem_uninit(PCIDevice *dev)
{
- IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
+ IVShmemState *s = IVSHMEM(dev);
if (s->migration_blocker) {
migrate_del_blocker(s->migration_blocker);Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 misc/ivshmem: QOM parent field cleanup
In reply to [email protected]Rename to parent_obj and fix any fallout.
--- hw/misc/ivshmem.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
hw/misc/ivshmem.c +22 -15
@@ -63,7 +63,10 @@ typedef struct EventfdEntry { } EventfdEntry; typedef struct IVShmemState { - PCIDevice dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + uint32_t intrmask; uint32_t intrstatus; uint32_t doorbell;
@@ -120,6 +123,7 @@ static inline bool is_power_of_two(uint64_t x) {/* accessing registers - based on rtl8139 */ static void ivshmem_update_irq (IVShmemState *s,int val) { +PCIDevice *d =PCI_DEVICE (s);int isr; isr = (s->intrstatus & s->intrmask) &0xffffffff ;
@@ -129,7 +133,7 @@ static void ivshmem_update_irq(IVShmemState *s, int val) isr ? 1 : 0, s->intrstatus, s->intrmask); } -qemu_set_irq (s->dev.irq[0 ], (isr !=0 )); +qemu_set_irq (d->irq[0 ], (isr !=0 )); }static void ivshmem_IntrMask_write (IVShmemState *s,uint32_t val)
@@ -300,7 +304,7 @@ static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier */* if MSI is supported we need multiple interrupts */ if (ivshmem_has_feature (s,IVSHMEM_MSI )) { - s->eventfd_table[vector].pdev = &s->dev; + s->eventfd_table[vector].pdev =PCI_DEVICE (s); s->eventfd_table[vector].vector = vector; qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd,
@@ -349,7 +353,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) {memory_region_add_subregion (&s->bar,0 , &s->ivshmem);/* region for shared memory */ -pci_register_bar (&s->dev,2 , s->ivshmem_attr, &s->bar); +pci_register_bar (PCI_DEVICE (s),2 , s->ivshmem_attr, &s->bar); }static void ivshmem_add_eventfd (IVShmemState *s,int posn,int i)
@@ -525,14 +529,15 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags)* we just enable all vectors on init and after reset. */ static void ivshmem_use_msix (IVShmemState * s) { +PCIDevice *d =PCI_DEVICE (s);int i; -if (!msix_present (&s->dev)) { +if (!msix_present (d)) {return ; }for (i =0 ; i < s->vectors; i++) { -msix_vector_use (&s->dev, i); +msix_vector_use (d, i); } }
@@ -573,7 +578,7 @@ static uint64_t ivshmem_get_size(IVShmemState * s) {static void ivshmem_setup_msi (IVShmemState * s) { -if (msix_init_exclusive_bar (&s->dev, s->vectors,1 )) { +if (msix_init_exclusive_bar (PCI_DEVICE (s), s->vectors,1 )) {IVSHMEM_DPRINTF ("msix initialization failed\n" );exit (1 ); }
@@ -589,12 +594,13 @@ static void ivshmem_setup_msi(IVShmemState * s)static void ivshmem_save (QEMUFile * f,void *opaque) {IVShmemState *proxy = opaque; +PCIDevice *pci_dev =PCI_DEVICE (proxy);IVSHMEM_DPRINTF ("ivshmem_save\n" ); -pci_device_save (&proxy->dev, f); +pci_device_save (pci_dev, f);if (ivshmem_has_feature (proxy,IVSHMEM_MSI )) { -msix_save (&proxy->dev, f); +msix_save (pci_dev, f); }else {qemu_put_be32 (f, proxy->intrstatus);qemu_put_be32 (f, proxy->intrmask);
@@ -607,6 +613,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id)IVSHMEM_DPRINTF ("ivshmem_load\n" );IVShmemState *proxy = opaque; +PCIDevice *pci_dev =PCI_DEVICE (proxy);int ret;if (version_id >0 ) {
@@ -618,13 +625,13 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id)return -EINVAL ; } - ret =pci_device_load (&proxy->dev, f); + ret =pci_device_load (pci_dev, f);if (ret) {return ret; }if (ivshmem_has_feature (proxy,IVSHMEM_MSI )) { -msix_load (&proxy->dev, f); +msix_load (pci_dev, f);ivshmem_use_msix (proxy); }else { proxy->intrstatus =qemu_get_be32 (f);
@@ -682,7 +689,7 @@ static int pci_ivshmem_init(PCIDevice *dev)migrate_add_blocker (s->migration_blocker); } - pci_conf = s->dev.config; + pci_conf = dev->config; pci_conf[PCI_COMMAND ] =PCI_COMMAND_IO |PCI_COMMAND_MEMORY ;pci_config_set_interrupt_pin (pci_conf,1 );
@@ -693,7 +700,7 @@ static int pci_ivshmem_init(PCIDevice *dev) "ivshmem-mmio", IVSHMEM_REG_BAR_SIZE);/* region for registers*/ -pci_register_bar (&s->dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &s->ivshmem_mmio);memory_region_init (&s->bar,"ivshmem-bar2-container" , s->ivshmem_size);
@@ -727,7 +734,7 @@ static int pci_ivshmem_init(PCIDevice *dev)/* allocate/initialize space for interrupt handling */ s->peers =g_malloc0 (s->nb_peers *sizeof (Peer)); -pci_register_bar (&s->dev,2 , s->ivshmem_attr, &s->bar); +pci_register_bar (dev,2 , s->ivshmem_attr, &s->bar); s->eventfd_chr =g_malloc0 (s->vectors *sizeof (CharDriverState *));
@@ -768,7 +775,7 @@ static int pci_ivshmem_init(PCIDevice *dev) } - s->dev.config_write = ivshmem_write_config; + dev->config_write = ivshmem_write_config;return 0 ; }
Signature · 1 line
1.8.1.4
PATCH v2 14/30 xen/xen_platform: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and direct -> style upcasting.
---
hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
hw/xen/xen_platform.c +16 -12
@@ -62,6 +62,10 @@ typedef struct PCIXenPlatformState {int log_buffer_off; } PCIXenPlatformState; +#define TYPE_XEN_PLATFORM "xen-platform" +#define XEN_PLATFORM (obj) \ + OBJECT_CHECK(PCIXenPlatformState, (obj), TYPE_XEN_PLATFORM) +#define XEN_PLATFORM_IOPORT 0x10/* Send bytes to syslog */
@@ -88,7 +92,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)if (pci_get_word (d->config +PCI_CLASS_DEVICE ) ==PCI_CLASS_NETWORK_ETHERNET &&strcmp (d->name,"xen-pci-passthrough" ) !=0 ) { -qdev_free (&d->qdev); +qdev_free (DEVICE (d)); } }
@@ -103,7 +107,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)if (pci_get_word (d->config +PCI_CLASS_DEVICE ) ==PCI_CLASS_STORAGE_IDE &&strcmp (d->name,"xen-pci-passthrough" ) !=0 ) { -qdev_unplug (&(d->qdev),NULL ); +qdev_unplug (DEVICE (d),NULL ); } }
@@ -114,7 +118,7 @@ static void pci_unplug_disks(PCIBus *bus)static void platform_fixed_ioport_writew (void *opaque,uint32_t addr,uint32_t val) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :
@@ -164,7 +168,7 @@ static void platform_fixed_ioport_writel(void *opaque, uint32_t addr,static void platform_fixed_ioport_writeb (void *opaque,uint32_t addr,uint32_t val) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :/* Platform flags */ {
@@ -187,7 +191,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t vstatic uint32_t platform_fixed_ioport_readw (void *opaque,uint32_t addr) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :
@@ -206,7 +210,7 @@ static uint32_t platform_fixed_ioport_readw(void *opaque, uint32_t addr)static uint32_t platform_fixed_ioport_readb (void *opaque,uint32_t addr) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :
@@ -222,7 +226,7 @@ static uint32_t platform_fixed_ioport_readb(void *opaque, uint32_t addr)static void platform_fixed_ioport_reset (void *opaque) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);platform_fixed_ioport_writeb (s,0 ,0 ); }
@@ -292,7 +296,7 @@ static uint64_t xen_platform_ioport_readb(void *opaque, hwaddr addr,static void xen_platform_ioport_writeb (void *opaque,hwaddr addr,uint64_t val,unsigned int size) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :/* Platform flags */
@@ -349,7 +353,7 @@ static void platform_mmio_setup(PCIXenPlatformState *d)static int xen_platform_post_load (void *opaque,int version_id) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);platform_fixed_ioport_writeb (s,0 , s->flags);
@@ -371,7 +375,7 @@ static const VMStateDescription vmstate_xen_platform = {static int xen_platform_initfn (PCIDevice *dev) { -PCIXenPlatformState *d =DO_UPCAST (PCIXenPlatformState, pci_dev, dev); +PCIXenPlatformState *d =XEN_PLATFORM (dev);uint8_t *pci_conf; pci_conf = d->pci_dev.config;
@@ -397,7 +401,7 @@ static int xen_platform_initfn(PCIDevice *dev)static void platform_reset (DeviceState *dev) { -PCIXenPlatformState *s =DO_UPCAST (PCIXenPlatformState, pci_dev.qdev, dev); +PCIXenPlatformState *s =XEN_PLATFORM (dev);platform_fixed_ioport_reset (s); }
@@ -420,7 +424,7 @@ static void xen_platform_class_init(ObjectClass *klass, void *data) }static const TypeInfo xen_platform_info = { - .name ="xen-platform" , + .name =TYPE_XEN_PLATFORM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIXenPlatformState), .class_init = xen_platform_class_init,
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Andreas Färber
AppliedRe: [Qemu-devel] [PATCH v2 14/30] xen/xen_platform: QOM casting sweep
Am 24.06.2013 09:00, schrieb [email protected]:
Quoted 45 lines
From: Peter Crosthwaite <[email protected]>
Define and use standard QOM cast macro. Remove usages of
DO_UPCASTand direct -> style upcasting.Signed-off-by Peter Crosthwaite <[email protected]>---
hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)hw/xen/xen_platform.c +6
-2@@ -62,6 +62,10 @@ typedef struct PCIXenPlatformState {int log_buffer_off; } PCIXenPlatformState; +#define TYPE_XEN_PLATFORM "xen-platform" +#define XEN_PLATFORM (obj) \ + OBJECT_CHECK(PCIXenPlatformState, (obj), TYPE_XEN_PLATFORM) +#define XEN_PLATFORM_IOPORT 0x10/* Send bytes to syslog */ @@ -88,7 +92,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)if (pci_get_word (d->config +PCI_CLASS_DEVICE ) ==PCI_CLASS_NETWORK_ETHERNET &&strcmp (d->name,"xen-pci-passthrough" ) !=0 ) { -qdev_free (&d->qdev); +qdev_free (DEVICE (d)); } }@@ -103,7 +107,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d, void *o)if (pci_get_word (d->config +PCI_CLASS_DEVICE ) ==PCI_CLASS_STORAGE_IDE &&strcmp (d->name,"xen-pci-passthrough" ) !=0 ) { -qdev_unplug (&(d->qdev),NULL ); +qdev_unplug (DEVICE (d),NULL ); } }
hw/xen/xen_platform.c static void pci_unplug_disks(PCIBus *bus) · line 121
Quoted 5 lines
hw/xen/xen_platform.c +1
-1@@ -114,7 +118,7 @@ static void pci_unplug_disks(PCIBus *bus)static void platform_fixed_ioport_writew (void *opaque,uint32_t addr,uint32_t val) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);
These are superfluous since PCIXenPlatformState is passed for both MemoryRegionOps. Dropping these hunks.
Some usages of the parent field are still left behind.
Thanks, applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
Quoted 85 lines
hw/xen/xen_platform.c +9
-9switch (addr) {case 0 :@@ -164,7 +168,7 @@ static void platform_fixed_ioport_writel(void *opaque, uint32_t addr,static void platform_fixed_ioport_writeb (void *opaque,uint32_t addr,uint32_t val) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :/* Platform flags */ {@@ -187,7 +191,7 @@ static void platform_fixed_ioport_writeb(void *opaque, uint32_t addr, uint32_t vstatic uint32_t platform_fixed_ioport_readw (void *opaque,uint32_t addr) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :@@ -206,7 +210,7 @@ static uint32_t platform_fixed_ioport_readw(void *opaque, uint32_t addr)static uint32_t platform_fixed_ioport_readb (void *opaque,uint32_t addr) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :@@ -222,7 +226,7 @@ static uint32_t platform_fixed_ioport_readb(void *opaque, uint32_t addr)static void platform_fixed_ioport_reset (void *opaque) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);platform_fixed_ioport_writeb (s,0 ,0 ); }@@ -292,7 +296,7 @@ static uint64_t xen_platform_ioport_readb(void *opaque, hwaddr addr,static void xen_platform_ioport_writeb (void *opaque,hwaddr addr,uint64_t val,unsigned int size) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);switch (addr) {case 0 :/* Platform flags */ @@ -349,7 +353,7 @@ static void platform_mmio_setup(PCIXenPlatformState *d)static int xen_platform_post_load (void *opaque,int version_id) { -PCIXenPlatformState *s = opaque; +PCIXenPlatformState *s =XEN_PLATFORM (opaque);platform_fixed_ioport_writeb (s,0 , s->flags);@@ -371,7 +375,7 @@ static const VMStateDescription vmstate_xen_platform = {static int xen_platform_initfn (PCIDevice *dev) { -PCIXenPlatformState *d =DO_UPCAST (PCIXenPlatformState, pci_dev, dev); +PCIXenPlatformState *d =XEN_PLATFORM (dev);uint8_t *pci_conf; pci_conf = d->pci_dev.config;@@ -397,7 +401,7 @@ static int xen_platform_initfn(PCIDevice *dev)static void platform_reset (DeviceState *dev) { -PCIXenPlatformState *s =DO_UPCAST (PCIXenPlatformState, pci_dev.qdev, dev); +PCIXenPlatformState *s =XEN_PLATFORM (dev);platform_fixed_ioport_reset (s); }@@ -420,7 +424,7 @@ static void xen_platform_class_init(ObjectClass *klass, void *data) }static const TypeInfo xen_platform_info = { - .name ="xen-platform" , + .name =TYPE_XEN_PLATFORM , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIXenPlatformState), .class_init = xen_platform_class_init,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 1/1 xen/xen_platform: QOM parent field cleanup
In reply to [email protected]Replace direct uses of PCIXenPlatformState::pci_dev field with QOM casts and rename it to parent_obj.
--- hw/xen/xen_platform.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
hw/xen/xen_platform.c +13 -8
@@ -49,7 +49,10 @@#define PFFLAG_ROM_LOCK 1/* Sets whether ROM memory area is RW or RO */ typedef struct PCIXenPlatformState { - PCIDevice pci_dev; + /*< private >*/ + PCIDevice parent_obj; + /*< public >*/ + MemoryRegion fixed_io; MemoryRegion bar; MemoryRegion mmio_bar;
@@ -121,7 +124,8 @@ static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t vPCIXenPlatformState *s = opaque;switch (addr) { -case 0 : +case 0 : { +PCIDevice *pci_dev =PCI_DEVICE (s);/* Unplug devices. Value is a bitmask of which devices to unplug, with bit 0 the IDE devices, bit 1 the network devices, and bit 2 the non-primary-master IDE devices. */
@@ -129,16 +133,17 @@ static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t vDPRINTF ("unplug disks\n" );bdrv_drain_all ();bdrv_flush_all (); -pci_unplug_disks (s->pci_dev.bus); +pci_unplug_disks (pci_dev->bus); }if (val &UNPLUG_ALL_NICS ) {DPRINTF ("unplug nics\n" ); -pci_unplug_nics (s->pci_dev.bus); +pci_unplug_nics (pci_dev->bus); }if (val &UNPLUG_AUX_IDE_DISKS ) {DPRINTF ("unplug auxiliary disks not supported\n" ); }break ; + }case 2 :switch (val) {case 1 :
@@ -367,7 +372,7 @@ static const VMStateDescription vmstate_xen_platform = { .minimum_version_id_old = 4, .post_load = xen_platform_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci_dev, PCIXenPlatformState), +VMSTATE_PCI_DEVICE (parent_obj, PCIXenPlatformState),VMSTATE_UINT8 (flags, PCIXenPlatformState),VMSTATE_END_OF_LIST () }
@@ -378,7 +383,7 @@ static int xen_platform_initfn(PCIDevice *dev)PCIXenPlatformState *d =XEN_PLATFORM (dev);uint8_t *pci_conf; - pci_conf = d->pci_dev.config; + pci_conf = dev->config;pci_set_word (pci_conf +PCI_COMMAND ,PCI_COMMAND_IO |PCI_COMMAND_MEMORY );
@@ -387,11 +392,11 @@ static int xen_platform_initfn(PCIDevice *dev) pci_conf[PCI_INTERRUPT_PIN ] =1 ;platform_ioport_bar_setup (d); -pci_register_bar (&d->pci_dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bar); +pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bar);/* reserve 16MB mmio address for share memory*/ platform_mmio_setup (d); -pci_register_bar (&d->pci_dev,1 ,PCI_BASE_ADDRESS_MEM_PREFETCH , +pci_register_bar (dev,1 ,PCI_BASE_ADDRESS_MEM_PREFETCH , &d->mmio_bar);platform_fixed_ioport_init (d);
Signature · 1 line
1.8.1.4
PATCH v2 15/30 isa/*: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macros. Remove usage of DO_UPCAST and direct -> style upcasting.
---
hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
hw/isa/i82378.c +4 -4
@@ -159,8 +159,7 @@ static void i82378_request_out0_irq(void *opaque, int irq, int level)static void i82378_request_pic_irq (void *opaque,int irq,int level) { -DeviceState *dev = opaque; -PCIDevice *pci =DO_UPCAST (PCIDevice, qdev, dev); +PCIDevice *pci =PCI_DEVICE (opaque);PCIi82378State *s =DO_UPCAST (PCIi82378State, pci_dev, pci);qemu_set_irq (s->state.i8259[irq], level);
@@ -210,6 +209,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)static int pci_i82378_init (PCIDevice *dev) {PCIi82378State *pci =DO_UPCAST (PCIi82378State, pci_dev, dev); +DeviceState *d =DEVICE (pci);I82378State *s = &pci->state;uint8_t *pci_conf;
@@ -233,9 +233,9 @@ static int pci_i82378_init(PCIDevice *dev)pci_set_long (pci_conf +PCI_BASE_ADDRESS_0 , pci->isa_io_base); isa_mem_base = pci->isa_mem_base; -isa_bus_new (&dev->qdev,pci_address_space_io (dev)); +isa_bus_new (d,pci_address_space_io (dev)); -i82378_init (&dev->qdev, s); +i82378_init (d, s);return 0 ; }
hw/isa/lpc_ich9.c +3 -3
@@ -277,7 +277,7 @@ void ich9_lpc_set_irq(void *opaque, int pirq, int level)*/ int ich9_lpc_map_irq (PCIDevice *pci_dev,int intx) { -BusState *bus =qdev_get_parent_bus (&pci_dev->qdev); +BusState *bus =qdev_get_parent_bus (DEVICE (pci_dev));PCIBus *pci_bus =PCI_BUS (bus);PCIDevice *lpc_pdev = pci_bus->devices[PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC )];
@@ -364,7 +364,7 @@ void ich9_lpc_pm_init(PCIDevice *lpc_pci) sci_irq =qemu_allocate_irqs (ich9_set_sci, lpc,1 );ich9_pm_init (lpc_pci, &lpc->pm, sci_irq[0 ]); -ich9_lpc_reset (&lpc->d.qdev); +ich9_lpc_reset (DEVICE (lpc)); }/* APM */
@@ -529,7 +529,7 @@ static int ich9_lpc_initfn(PCIDevice *d)ICH9LPCState *lpc =ICH9_LPC_DEVICE (d);ISABus *isa_bus; - isa_bus =isa_bus_new (&d->qdev,get_system_io ()); + isa_bus =isa_bus_new (DEVICE (d),get_system_io ());pci_set_long (d->wmask +ICH9_LPC_PMBASE ,ICH9_LPC_PMBASE_BASE_ADDRESS_MASK );
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 16/30 pci/*: QOM casting sweep
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Use standard QOM cast macro. Remove usages of DO_UPCAST, container_of() and direct -> style upcasting.
---
hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- 4 files changed, 25 insertions(+), 22 deletions(-)
hw/pci/pci-hotplug.c +10 -8
@@ -129,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo)monitor_printf (mon,"no pci device with address %s\n" , pci_addr); goto err; } -if (scsi_hot_add (mon, &dev->qdev, dinfo,1 ) !=0 ) { +if (scsi_hot_add (mon,DEVICE (dev), dinfo,1 ) !=0 ) { goto err; }break ;
@@ -193,11 +193,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,switch (type) {case IF_SCSI : dev =pci_create (bus, devfn,"lsi53c895a" ); -if (qdev_init (&dev->qdev) <0 ) +if (qdev_init (DEVICE (dev)) <0 ) { dev =NULL ; + }if (dev && dinfo) { -if (scsi_hot_add (mon, &dev->qdev, dinfo,0 ) !=0 ) { -qdev_unplug (&dev->qdev,NULL ); +if (scsi_hot_add (mon,DEVICE (dev), dinfo,0 ) !=0 ) { +qdev_unplug (DEVICE (dev),NULL ); dev =NULL ; } }
@@ -208,13 +209,14 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,return NULL ; } dev =pci_create (bus, devfn,"virtio-blk-pci" ); -if (qdev_prop_set_drive (&dev->qdev,"drive" , dinfo->bdrv) <0 ) { -qdev_free (&dev->qdev); +if (qdev_prop_set_drive (DEVICE (dev),"drive" , dinfo->bdrv) <0 ) { +qdev_free (DEVICE (dev)); dev =NULL ;break ; } -if (qdev_init (&dev->qdev) <0 ) +if (qdev_init (DEVICE (dev)) <0 ) { dev =NULL ; + }break ;default : dev =NULL ;
@@ -276,7 +278,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)return -1 ; } -qdev_unplug (&d->qdev, &local_err); +qdev_unplug (DEVICE (d), &local_err);if (error_is_set (&local_err)) {monitor_printf (mon,"%s\n" ,error_get_pretty (local_err));error_free (local_err);
hw/pci/pci.c +9 -8
@@ -177,7 +177,7 @@ void pci_device_reset(PCIDevice *dev) {int r; -qdev_reset_all (&dev->qdev); +qdev_reset_all (DEVICE (dev)); dev->irq_state =0 ;pci_update_irq_status (dev);
@@ -1446,6 +1446,7 @@ static PciBridgeInfo *qmp_query_pci_bridge(PCIDevice *dev, PCIBus *bus,static PciDeviceInfo *qmp_query_pci_device (PCIDevice *dev,PCIBus *bus,int bus_num) { +DeviceState *d =DEVICE (dev);const pci_class_desc *desc;PciDeviceInfo *info;uint8_t type;
@@ -1467,7 +1468,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus, info->id.vendor =pci_get_word (dev->config +PCI_VENDOR_ID ); info->id.device =pci_get_word (dev->config +PCI_DEVICE_ID ); info->regions =qmp_query_pci_regions (dev); - info->qdev_id =g_strdup (dev->qdev.id ? dev->qdev.id :"" ); + info->qdev_id =g_strdup (d->id ? d->id :"" );if (dev->config[PCI_INTERRUPT_PIN ] !=0 ) { info->has_irq = true;
@@ -1591,7 +1592,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, } pci_dev =pci_create (bus, devfn, pci_nic_names[i]); - dev = &pci_dev->qdev; + dev =DEVICE (pci_dev);qdev_set_nic_properties (dev, nd);if (qdev_init (dev) <0 )return NULL ;
@@ -1731,7 +1732,7 @@ static int pci_qdev_init(DeviceState *qdev) qdev->hotplugged ?PCI_HOTPLUG_ENABLED : PCI_COLDPLUG_ENABLED);if (rc !=0 ) { -int r =pci_unregister_device (&pci_dev->qdev); +int r =pci_unregister_device (DEVICE (pci_dev));assert (!r);return rc; }
@@ -1768,7 +1769,7 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, const char *name) {PCIDevice *dev =pci_create_multifunction (bus, devfn, multifunction, name); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev));return dev; }
@@ -1946,7 +1947,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) } pdev->has_rom = true;memory_region_init_ram (&pdev->rom, name, size); -vmstate_register_ram (&pdev->rom, &pdev->qdev); +vmstate_register_ram (&pdev->rom,DEVICE (pdev)); ptr =memory_region_get_ram_ptr (&pdev->rom);load_image (path, ptr);g_free (path);
@@ -1966,7 +1967,7 @@ static void pci_del_option_rom(PCIDevice *pdev)if (!pdev->has_rom)return ; -vmstate_unregister_ram (&pdev->rom, &pdev->qdev); +vmstate_unregister_ram (&pdev->rom,DEVICE (pdev));memory_region_destroy (&pdev->rom); pdev->has_rom = false; }
@@ -2126,7 +2127,7 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev)static char *pcibus_get_dev_path (DeviceState *dev) { -PCIDevice *d =container_of (dev, PCIDevice, qdev); +PCIDevice *d =PCI_DEVICE (dev);PCIDevice *t;int slot_depth;/* Path format: Domain:00:Slot.Function:Slot.Function....:Slot.Function.
hw/pci/pcie.c +2 -2
@@ -251,7 +251,7 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev, PCI_EXP_SLTSTA_PDS);pcie_cap_slot_event (d,PCI_EXP_HP_EV_PDC ); }else { -qdev_free (&pci_dev->qdev); +qdev_free (DEVICE (pci_dev));pci_word_test_and_clear_mask (exp_cap +PCI_EXP_SLTSTA ,PCI_EXP_SLTSTA_PDS );pcie_cap_slot_event (d,PCI_EXP_HP_EV_PDC );
@@ -306,7 +306,7 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) dev->exp.hpev_notified = false;pci_bus_hotplug (pci_bridge_get_sec_bus (DO_UPCAST (PCIBridge, dev, dev)), - pcie_cap_slot_hotplug, &dev->qdev); + pcie_cap_slot_hotplug,DEVICE (dev)); }void pcie_cap_slot_reset (PCIDevice *dev)
hw/pci/shpc.c +4 -4
@@ -252,9 +252,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot)for (devfn =PCI_DEVFN (pci_slot,0 ); devfn <=PCI_DEVFN (pci_slot,PCI_FUNC_MAX -1 ); ++devfn) { -PCIDevice *affected_dev = shpc->sec_bus->devices[devfn]; +DeviceState *affected_dev =DEVICE (shpc->sec_bus->devices[devfn]);if (affected_dev) { -qdev_free (&affected_dev->qdev); +qdev_free (affected_dev); } } }
@@ -497,7 +497,7 @@ static int shpc_device_hotplug(DeviceState *qdev, PCIDevice *affected_dev,int pci_slot =PCI_SLOT (affected_dev->devfn);uint8_t state;uint8_t led; -PCIDevice *d =DO_UPCAST (PCIDevice, qdev, qdev); +PCIDevice *d =PCI_DEVICE (qdev);SHPCDevice *shpc = d->shpc;int slot =SHPC_PCI_TO_IDX (pci_slot);if (pci_slot <SHPC_IDX_TO_PCI (0 ) || slot >= shpc->nslots) {
@@ -616,7 +616,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegion *bar, unsigned offset) SHPC_SIZEOF(d));shpc_cap_update_dword (d);memory_region_add_subregion (bar, offset, &shpc->mmio); -pci_bus_hotplug (sec_bus, shpc_device_hotplug, &d->qdev); +pci_bus_hotplug (sec_bus, shpc_device_hotplug,DEVICE (d)); d->cap_present |=QEMU_PCI_CAP_SHPC ;return 0 ;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 16/30] pci/*: QOM casting sweep
Am 24.06.2013 09:01, schrieb [email protected]:
hw/pci/shpc.c static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) · line 256
Quoted 11 lines
hw/pci/shpc.c +1
-1@@ -252,9 +252,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot)for (devfn =PCI_DEVFN (pci_slot,0 ); devfn <=PCI_DEVFN (pci_slot,PCI_FUNC_MAX -1 ); ++devfn) { -PCIDevice *affected_dev = shpc->sec_bus->devices[devfn]; +DeviceState *affected_dev =DEVICE (shpc->sec_bus->devices[devfn]);if (affected_dev) {
Did you verify this works as expected? Or might we need object_dynamic_cast() here? I remember we had issues with assertions in the past, not sure if all are resolved...
Andreas
Quoted 5 lines
hw/pci/shpc.c +1
-1-qdev_free (&affected_dev->qdev); +qdev_free (affected_dev); } } }
[snip]
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH v2 17/30 pci-bridge/pci_bridge_dev: Don't use DO_UPCAST
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
Just use the defined PCI_DEVICE cast macro.
---
hw/pci-bridge/pci_bridge_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-bridge/pci_bridge_dev.c +1 -1
@@ -104,7 +104,7 @@ static void pci_bridge_dev_write_config(PCIDevice *d,static void qdev_pci_bridge_dev_reset (DeviceState *qdev) { -PCIDevice *dev =DO_UPCAST (PCIDevice, qdev, qdev); +PCIDevice *dev =PCI_DEVICE (qdev);pci_bridge_reset (qdev);shpc_reset (dev);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 18/30 pci-bridge/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
hw/pci-bridge/i82801b11.c +1 -1
@@ -108,7 +108,7 @@ PCIBus *ich9_d2pbr_init(PCIBus *bus, int devfn, int sec_bus)return NULL ; } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);snprintf (buf,sizeof (buf),"pci.%d" , sec_bus);pci_bridge_map_irq (br, buf, pci_swizzle_map_irq_fn);
hw/pci-bridge/ioh3420.c +1 -1
@@ -173,7 +173,7 @@ PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction, } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);pci_bridge_map_irq (br, bus_name, map_irq);qdev_prop_set_uint8 (qdev,"port" , port);qdev_prop_set_uint8 (qdev,"chassis" , chassis);
hw/pci-bridge/xio3130_downstream.c +1 -1
@@ -140,7 +140,7 @@ PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction, } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);pci_bridge_map_irq (br, bus_name, map_irq);qdev_prop_set_uint8 (qdev,"port" , port);qdev_prop_set_uint8 (qdev,"chassis" , chassis);
hw/pci-bridge/xio3130_upstream.c +1 -1
@@ -120,7 +120,7 @@ PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction, } br =DO_UPCAST (PCIBridge, dev, d); - qdev = &br->dev.qdev; + qdev =DEVICE (br);pci_bridge_map_irq (br, bus_name, map_irq);qdev_prop_set_uint8 (qdev,"port" , port);qdev_init_nofail (qdev);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 19/30 pci/pci_bridge: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/pci/pci_bridge.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/pci/pci_bridge.c +4 -3
@@ -330,6 +330,7 @@ void pci_bridge_reset(DeviceState *qdev)/* default qdev initialization function for PCI-to-PCI bridge */ int pci_bridge_initfn (PCIDevice *dev,const char *typename) { +DeviceState *d =DEVICE (dev);PCIBus *parent = dev->bus;PCIBridge *br =DO_UPCAST (PCIBridge, dev, dev);PCIBus *sec_bus = &br->sec_bus;
@@ -359,11 +360,11 @@ int pci_bridge_initfn(PCIDevice *dev, const char *typename)* Since PCI Bridge devices have a single bus each, we don't need the index: * let users address the bus using the device name. */ -if (!br->bus_name && dev->qdev.id && *dev->qdev.id) { - br->bus_name = dev->qdev.id; +if (!br->bus_name && d->id && *d->id) { + br->bus_name = d->id; } -qbus_create_inplace (&sec_bus->qbus, typename, &dev->qdev, br->bus_name); +qbus_create_inplace (&sec_bus->qbus, typename, d, br->bus_name); sec_bus->parent_dev = dev; sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn; sec_bus->address_space_mem = &br->address_space_mem;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 20/30 misc/vfio: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/misc/vfio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/vfio.c +2 -2
@@ -3074,7 +3074,7 @@ static int vfio_initfn(PCIDevice *pdev) } } -add_boot_device_path (vdev->bootindex, &pdev->qdev,NULL ); +add_boot_device_path (vdev->bootindex,DEVICE (pdev),NULL );return 0 ;
@@ -3108,7 +3108,7 @@ static void vfio_exitfn(PCIDevice *pdev)static void vfio_pci_reset (DeviceState *dev) { -PCIDevice *pdev =DO_UPCAST (PCIDevice, qdev, dev); +PCIDevice *pdev =PCI_DEVICE (dev);VFIODevice *vdev =DO_UPCAST (VFIODevice, pdev, pdev);uint16_t cmd;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 21/30 net/eepro100: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/net/eepro100.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
hw/net/eepro100.c +8 -6
@@ -1842,13 +1842,14 @@ static void nic_cleanup(NetClientState *nc)static void pci_nic_uninit (PCIDevice *pci_dev) { +DeviceState *d =DEVICE (pci_dev);EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);memory_region_destroy (&s->mmio_bar);memory_region_destroy (&s->io_bar);memory_region_destroy (&s->flash_bar); -vmstate_unregister (&pci_dev->qdev, s->vmstate, s); -eeprom93xx_free (&pci_dev->qdev, s->eeprom); +vmstate_unregister (d, s->vmstate, s); +eeprom93xx_free (d, s->eeprom);qemu_del_nic (s->nic); }
@@ -1862,6 +1863,7 @@ static NetClientInfo net_eepro100_info = {static int e100_nic_init (PCIDevice *pci_dev) { +DeviceState *d =DEVICE (pci_dev);EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);E100PCIDeviceInfo *info =eepro100_get_class (s);
@@ -1873,7 +1875,7 @@ static int e100_nic_init(PCIDevice *pci_dev)/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ - s->eeprom =eeprom93xx_new (&pci_dev->qdev,EEPROM_SIZE ); + s->eeprom =eeprom93xx_new (d,EEPROM_SIZE );/* Handler for memory-mapped I/O */ memory_region_init_io(&s->mmio_bar, &eepro100_ops, s, "eepro100-mmio",
@@ -1893,7 +1895,7 @@ static int e100_nic_init(PCIDevice *pci_dev)nic_reset (s); s->nic =qemu_new_nic (&net_eepro100_info, &s->conf, -object_get_typename (OBJECT (pci_dev)), pci_dev->qdev.id, s); +object_get_typename (OBJECT (pci_dev)), d->id, s);qemu_format_nic_info_str (qemu_get_queue (s->nic), s->conf.macaddr.a);TRACE (OTHER ,logout ("%s\n" ,qemu_get_queue (s->nic)->info_str));
@@ -1903,9 +1905,9 @@ static int e100_nic_init(PCIDevice *pci_dev) s->vmstate =g_malloc (sizeof (vmstate_eepro100));memcpy (s->vmstate, &vmstate_eepro100,sizeof (vmstate_eepro100)); s->vmstate->name =qemu_get_queue (s->nic)->model; -vmstate_register (&pci_dev->qdev,-1 , s->vmstate, s); +vmstate_register (d,-1 , s->vmstate, s); -add_boot_device_path (s->conf.bootindex, &pci_dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (s->conf.bootindex, d,"/ethernet-phy@0" );return 0 ; }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 22/30 net/ne2000: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/net/ne2000.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/net/ne2000.c +4 -2
@@ -722,6 +722,8 @@ static NetClientInfo net_ne2000_info = {static int pci_ne2000_init (PCIDevice *pci_dev) {PCINE2000State *d =DO_UPCAST (PCINE2000State, dev, pci_dev); +DeviceState *ds =DEVICE (pci_dev); +NE2000State *s;uint8_t *pci_conf;
@@ -737,10 +739,10 @@ static int pci_ne2000_init(PCIDevice *pci_dev)ne2000_reset (s); s->nic =qemu_new_nic (&net_ne2000_info, &s->c, -object_get_typename (OBJECT (pci_dev)), pci_dev->qdev.id, s); +object_get_typename (OBJECT (pci_dev)), ds->id, s);qemu_format_nic_info_str (qemu_get_queue (s->nic), s->c.macaddr.a); -add_boot_device_path (s->c.bootindex, &pci_dev->qdev,"/ethernet-phy@0" ); +add_boot_device_path (s->c.bootindex, ds,"/ethernet-phy@0" );return 0 ; }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 23/30 usb/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-)
hw/usb/hcd-ehci-pci.c +8 -5
@@ -197,6 +197,7 @@ int ehci_create_ich9_with_companions(PCIBus *bus, int slot)const struct ehci_companions *comp;PCIDevice *ehci, *uhci;BusState *usbbus; +DeviceState *dev;const char *name;int i;
@@ -214,15 +215,17 @@ int ehci_create_ich9_with_companions(PCIBus *bus, int slot) } ehci =pci_create_multifunction (bus,PCI_DEVFN (slot,7 ), true, name); -qdev_init_nofail (&ehci->qdev); - usbbus =QLIST_FIRST (&ehci->qdev.child_bus); + dev =DEVICE (ehci); +qdev_init_nofail (dev); + usbbus =QLIST_FIRST (&dev->child_bus);for (i =0 ; i <3 ; i++) { uhci =pci_create_multifunction (bus,PCI_DEVFN (slot, comp[i].func), true, comp[i].name); -qdev_prop_set_string (&uhci->qdev,"masterbus" , usbbus->name); -qdev_prop_set_uint32 (&uhci->qdev,"firstport" , comp[i].port); -qdev_init_nofail (&uhci->qdev); + dev =DEVICE (uhci); +qdev_prop_set_string (dev,"masterbus" , usbbus->name); +qdev_prop_set_uint32 (dev,"firstport" , comp[i].port); +qdev_init_nofail (dev); }return 0 ; }
hw/usb/hcd-ohci.c +1 -1
@@ -1857,7 +1857,7 @@ static int usb_ohci_initfn_pci(struct PCIDevice *dev) ohci->pci_dev.config[PCI_CLASS_PROG ] =0x10 ;/* OHCI */ ohci->pci_dev.config[PCI_INTERRUPT_PIN ] =0x01 ;/* interrupt pin A */ -if (usb_ohci_init (&ohci->state, &dev->qdev, ohci->num_ports,0 , +if (usb_ohci_init (&ohci->state,DEVICE (dev), ohci->num_ports,0 , ohci->masterbus, ohci->firstport,pci_get_address_space (dev)) !=0 ) {return -1 ;
hw/usb/hcd-uhci.c +1 -1
@@ -1246,7 +1246,7 @@ static int usb_uhci_common_initfn(PCIDevice *dev)return -1 ; } }else { -usb_bus_new (&s->bus, &uhci_bus_ops, &s->dev.qdev); +usb_bus_new (&s->bus, &uhci_bus_ops,DEVICE (dev));for (i =0 ; i <NB_PORTS ; i++) {usb_register_port (&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,USB_SPEED_MASK_LOW |USB_SPEED_MASK_FULL );
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 24/30 watchdog/wdt_i6300esb: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/watchdog/wdt_i6300esb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/watchdog/wdt_i6300esb.c +1 -1
@@ -195,7 +195,7 @@ static void i6300esb_timer_expired(void *vp)if (d->reboot_enabled) { d->previous_reboot_flag =1 ;watchdog_perform_action ();/* This reboots, exits, etc */ -i6300esb_reset (&d->dev.qdev); +i6300esb_reset (DEVICE (d)); }/* In "free running mode" we start stage 1 again. */
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 25/30 scsi/vmw_pvscsi: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/scsi/vmw_pvscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vmw_pvscsi.c +1 -1
@@ -1088,7 +1088,7 @@ pvscsi_init(PCIDevice *pci_dev)return -ENOMEM ; } -scsi_bus_new (&s->bus, &pci_dev->qdev, &pvscsi_scsi_info,NULL ); +scsi_bus_new (&s->bus,DEVICE (pci_dev), &pvscsi_scsi_info,NULL );pvscsi_reset_state (s);return 0 ;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 26/30 i2c/smbus_ich9: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/i2c/smbus_ich9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/smbus_ich9.c +1 -1
@@ -82,7 +82,7 @@ static int ich9_smbus_initfn(PCIDevice *d)pci_set_byte (d->config +ICH9_SMB_HOSTC ,0 );/* TODO bar0, bar1: 64bit BAR support*/ -pm_smbus_init (&d->qdev, &s->smb); +pm_smbus_init (DEVICE (d), &s->smb);pci_register_bar (d,ICH9_SMB_SMB_BASE_BAR ,PCI_BASE_ADDRESS_SPACE_IO , &s->smb.io);return 0 ;
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 27/30 ide/cmd646: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/ide/cmd646.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ide/cmd646.c +4 -4
@@ -281,7 +281,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) irq =qemu_allocate_irqs (cmd646_set_irq, d,2 );for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init2 (&d->bus[i], irq[i]);bmdma_init (&d->bus[i], &d->bmdma[i], d);
@@ -290,7 +290,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev) &d->bmdma[i].dma); } -vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);qemu_register_reset (cmd646_reset, d);return 0 ; }
@@ -317,8 +317,8 @@ void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table,PCIDevice *dev; dev =pci_create (bus,-1 ,"cmd646-ide" ); -qdev_prop_set_uint32 (&dev->qdev,"secondary" , secondary_ide_enabled); -qdev_init_nofail (&dev->qdev); +qdev_prop_set_uint32 (DEVICE (dev),"secondary" , secondary_ide_enabled); +qdev_init_nofail (DEVICE (dev));pci_ide_create_devs (dev, hd_table); }
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 28/30 ide/via: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/ide/via.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ide/via.c +2 -2
@@ -158,7 +158,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) {int i;for (i =0 ; i <2 ; i++) { -ide_bus_new (&d->bus[i], &d->dev.qdev, i,2 ); +ide_bus_new (&d->bus[i],DEVICE (d), i,2 );ide_init_ioport (&d->bus[i],NULL , port_info[i].iobase, port_info[i].iobase2);ide_init2 (&d->bus[i],isa_get_irq (NULL , port_info[i].isairq));
@@ -183,7 +183,7 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)bmdma_setup_bar (d);pci_register_bar (&d->dev,4 ,PCI_BASE_ADDRESS_SPACE_IO , &d->bmdma_bar); -vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d); +vmstate_register (DEVICE (dev),0 , &vmstate_ide_pci, d);vt82c686b_init_ports (d);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 29/30 pci-host/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/pci-bridge/dec.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
hw/pci-bridge/dec.c +1 -1
@@ -88,7 +88,7 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn) "dec-21154-p2p-bridge"); br =DO_UPCAST (PCIBridge, dev, dev);pci_bridge_map_irq (br,"DEC 21154 PCI-PCI bridge" , dec_map_irq); -qdev_init_nofail (&dev->qdev); +qdev_init_nofail (DEVICE (dev));return pci_bridge_get_sec_bus (br); }
hw/pci-host/apb.c +2 -2
@@ -467,7 +467,7 @@ PCIBus *pci_apb_init(hwaddr special_base, br =DO_UPCAST (PCIBridge, dev, pci_dev);pci_bridge_map_irq (br,"Advanced PCI Bus secondary bridge 1" , pci_apb_map_irq); -qdev_init_nofail (&pci_dev->qdev); +qdev_init_nofail (DEVICE (dev)); *bus2 =pci_bridge_get_sec_bus (br); pci_dev = pci_create_multifunction(d->bus, PCI_DEVFN(1, 1), true,
@@ -475,7 +475,7 @@ PCIBus *pci_apb_init(hwaddr special_base, br =DO_UPCAST (PCIBridge, dev, pci_dev);pci_bridge_map_irq (br,"Advanced PCI Bus secondary bridge 2" , pci_apb_map_irq); -qdev_init_nofail (&pci_dev->qdev); +qdev_init_nofail (DEVICE (pci_dev)); *bus3 =pci_bridge_get_sec_bus (br);return d->bus;
hw/pci-host/q35.c +2 -2
@@ -104,8 +104,8 @@ static const TypeInfo q35_host_info = {/* PCIe MMCFG */ static void mch_update_pciexbar (MCHPCIState *mch) { -PCIDevice *pci_dev = &mch->d; -BusState *bus =qdev_get_parent_bus (&pci_dev->qdev); +PCIDevice *pci_dev =PCI_DEVICE (mch); +BusState *bus =qdev_get_parent_bus (DEVICE (pci_dev));DeviceState *qdev = bus->parent;Q35PCIHost *s =Q35_HOST_DEVICE (qdev);
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
PATCH v2 30/30 i386/*: substitute ->qdev casts with DEVICE()
In reply to [email protected]From: Peter Crosthwaite <[email protected]>
---
hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 3 ++- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-)
hw/i386/kvm/pci-assign.c +12 -9
@@ -491,7 +491,7 @@ static int assigned_dev_register_regions(PCIRegion *io_regions, name, cur_region->size, virtbase);vmstate_register_ram (&pci_dev->v_addrs[i].real_iomem, - &pci_dev->dev.qdev); +DEVICE (&pci_dev->dev)); }assigned_dev_iomem_setup (&pci_dev->dev, i, cur_region->size);
@@ -817,6 +817,7 @@ fail:static int assign_device (AssignedDevice *dev) { +DeviceState *d =DEVICE (&dev->dev);uint32_t flags =KVM_DEV_ASSIGN_ENABLE_IOMMU ;int r;
@@ -830,7 +831,7 @@ static int assign_device(AssignedDevice *dev)if (!kvm_check_extension (kvm_state,KVM_CAP_IOMMU )) {error_report ("No IOMMU found. Unable to assign device \"%s\"" , - dev->dev.qdev.id); + d->id);return -ENODEV ; }
@@ -842,7 +843,7 @@ static int assign_device(AssignedDevice *dev) r =kvm_device_pci_assign (kvm_state, &dev->host, flags, &dev->dev_id);if (r <0 ) {error_report ("Failed to assign device \"%s\" : %s" , - dev->dev.qdev.id,strerror (-r)); + d->id,strerror (-r));switch (r) {case -EBUSY :
@@ -867,6 +868,7 @@ static bool check_irqchip_in_kernel(void)static int assign_intx (AssignedDevice *dev) { +DeviceState *d =DEVICE (&dev->dev);AssignedIRQType new_type;PCIINTxRoute intx_route;bool intx_host_msi;
@@ -942,7 +944,7 @@ retry: goto retry; }error_report ("Failed to assign irq for \"%s\": %s" , - dev->dev.qdev.id,strerror (-r)); + d->id,strerror (-r));error_report ("Perhaps you are assigning a device " "that shares an IRQ with another device?" );return r;
@@ -972,7 +974,7 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev) r =assign_intx (assigned_dev);if (r <0 ) { -qdev_unplug (&dev->qdev, &err); +qdev_unplug (DEVICE (dev), &err);assert (!err); } }
@@ -1675,7 +1677,7 @@ static const VMStateDescription vmstate_assigned_device = {static void reset_assigned_device (DeviceState *dev) { -PCIDevice *pci_dev =DO_UPCAST (PCIDevice, qdev, dev); +PCIDevice *pci_dev =PCI_DEVICE (dev);AssignedDevice *adev =DO_UPCAST (AssignedDevice, dev, pci_dev);char reset_file[64 ];const char reset[] ="1" ;
@@ -1731,6 +1733,7 @@ static void reset_assigned_device(DeviceState *dev)static int assigned_initfn (struct PCIDevice *pci_dev) { +DeviceState *d =DEVICE (pci_dev);AssignedDevice *dev =DO_UPCAST (AssignedDevice, dev, pci_dev);uint8_t e_intx;int r;
@@ -1769,7 +1772,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev)if (get_real_device (dev, dev->host.domain, dev->host.bus, dev->host.slot, dev->host.function)) {error_report ("pci-assign: Error: Couldn't get real device (%s)!" , - dev->dev.qdev.id); + d->id); goto out; }
@@ -1811,7 +1814,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev)assigned_dev_load_option_rom (dev); -add_boot_device_path (dev->bootindex, &pci_dev->qdev,NULL ); +add_boot_device_path (dev->bootindex, d,NULL );return 0 ;
@@ -1916,7 +1919,7 @@ static void assigned_dev_load_option_rom(AssignedDevice *dev)snprintf (name,sizeof (name),"%s.rom" ,object_get_typename (OBJECT (dev)));memory_region_init_ram (&dev->dev.rom, name, st.st_size); -vmstate_register_ram (&dev->dev.rom, &dev->dev.qdev); +vmstate_register_ram (&dev->dev.rom,DEVICE (&dev->dev)); ptr =memory_region_get_ram_ptr (&dev->dev.rom);memset (ptr,0xff , st.st_size);
hw/i386/pc.c +2 -1
@@ -1096,10 +1096,11 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)if (pci_bus) {PCIDevice *pcidev =pci_vga_init (pci_bus); - dev = pcidev ? &pcidev->qdev :NULL ; + dev =DEVICE (pcidev); }else if (isa_bus) {ISADevice *isadev =isa_vga_init (isa_bus); dev = isadev ?DEVICE (isadev) :NULL ; + dev =DEVICE (isadev); }return dev; }
hw/i386/pc_piix.c +2 -2
@@ -191,8 +191,8 @@ static void pc_init1(MemoryRegion *system_memory, }else { dev =pci_piix3_ide_init (pci_bus, hd, piix3_devfn +1 ); } - idebus[0 ] =qdev_get_child_bus (&dev->qdev,"ide.0" ); - idebus[1 ] =qdev_get_child_bus (&dev->qdev,"ide.1" ); + idebus[0 ] =qdev_get_child_bus (DEVICE (dev),"ide.0" ); + idebus[1 ] =qdev_get_child_bus (DEVICE (dev),"ide.1" ); }else {for (i =0 ; i <MAX_IDE_BUS ; i++) {ISADevice *dev;
hw/i386/pc_q35.c +2 -2
@@ -179,8 +179,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)PCI_DEVFN (ICH9_SATA1_DEV ,ICH9_SATA1_FUNC ), true, "ich9-ahci"); - idebus[0 ] =qdev_get_child_bus (&ahci->qdev,"ide.0" ); - idebus[1 ] =qdev_get_child_bus (&ahci->qdev,"ide.1" ); + idebus[0 ] =qdev_get_child_bus (DEVICE (ahci),"ide.0" ); + idebus[1 ] =qdev_get_child_bus (DEVICE (ahci),"ide.1" );if (usb_enabled (false)) {/* Should we create 6 UHCI according to ich9 spec? */
Signature · 1 line
1.8.3.rc1.44.gb387c77.dirty
Re: [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land -- ANN: qom-next revived
In reply to [email protected]Hi Peter,
Am 24.06.2013 08:49, schrieb [email protected]:
Quoted 7 lines
From: Peter Crosthwaite <[email protected]>
There are a number of different cast implementations from various stages of QEMU development out in device model land. This series cleans up the ones involving
TYPE_PCI_DEVICEto consistently use proper QOM casts for both up and down casts.
Quoted 7 lines
Some were easy, some needed QOM cast macros which are added as appropriate.
Following the recent discussion RE performance consequences of QOM casts, im interested in any reports of possible performance regressions here, although I am hoping that Anthony current efforts to improve QOM casting efficiency make this a non-issue.
While I did not run extensive benchmarks, state of the discussion between Paolo, Anthony and me, I believe, was that it can be considered okay to use QOM casts "everywhere" consistently now, but we should not use casts where they are unnecessary (i.e., only where we change type). E.g., http://patchwork.ozlabs.org/patch/255367/
I have therefore dropped some opaque casts where the type on both sides of void* matched (for an up-/downcast I do prefer the cast for safety).
Anyway, if we get this merged early, then there is still time for more benchmarking/optimizations during Soft Freeze IMO.
Maybe our staging tree will facilitate testing, too. ;)
Quoted 6 lines
Changed since V1:
Removed hunks which macroified VMSD names
Dropped virtio/virtio.pci patch
Rebased
Quoted 15 lines
Peter Crosthwaite (30):
net/e1000: QOM Upcast Sweep
net/rtl8139: QOM Upcast Sweep
net/pcnet-pci: QOM Upcast Sweep
usb/hcd-xhci: QOM Upcast Sweep
scsi/lsi53c895a: QOM Upcast Sweep
scsi/megasas: QOM Upcast Sweep
scsi/esp-pci: QOM Upcast Sweep
ide/ich: QOM Upcast Sweep
ide/piix: QOM casting sweep
acpi/piix4: QOM Upcast Sweep
misc/pci-testdev: QOM Upcast Sweep
virtio/vmware_vga: QOM casting sweep
misc/ivshmem: QOM Upcast Sweep
xen/xen_platform: QOM casting sweep
As requested, I've started picking up QOM type/cast/realize patches on:
git://github.com/afaerber/qemu-cpu.git qom-next
https://github.com/afaerber/qemu-cpu/commits/qom-next
(Not to be confused with my qom-cpu / qom-cpu-next CPU trees.)
If anyone wishes to contribute patches against that tree, please indicate so with --subject-prefix="PATCH qom-next ...".
As a matter of personal taste and consistency, I've used the gtk-doc notation DO_UPCAST() wherever I stumbled over it in commit messages.
I've queued all patches above except for ide/piix (09/30) and had comments and/or minor changes for some of them. Noticing some incompleteness, I will reiterate over them.
Whether I send a pull when we're all happy with it or whether we let submaintainers pick/pull by subsystem at some point doesn't matter to me, as long as we can join efforts to make QOM realize reality soon. :)
Quoted 8 lines
isa/*: QOM casting sweep
pci/*: QOM casting sweep pci-bridge/pci_bridge_dev: Don't useDO_UPCASTpci-bridge/*: substitute ->qdev casts withDEVICE()pci/pci_bridge: substitute ->qdev casts withDEVICE()misc/vfio: substitute ->qdev casts withDEVICE()net/eepro100: substitute ->qdev casts withDEVICE()net/ne2000: substitute ->qdev casts withDEVICE()
Quoted 8 lines
usb/*: substitute ->qdev casts with
DEVICE()watchdog/wdt_i6300esb: substitute ->qdev casts withDEVICE()scsi/vmw_pvscsi: substitute ->qdev casts withDEVICE()i2c/smbus_ich9: substitute ->qdev casts withDEVICE()ide/cmd646: substitute ->qdev casts withDEVICE()ide/via: substitute ->qdev casts withDEVICE()pci-host/*: substitute ->qdev casts withDEVICE()i386/*: substitute ->qdev casts withDEVICE()
These patches seem more "sloppy" while not reaching a clear goal such as dropping a macro or renaming PCIDevice::qdev, so I'd prefer to get open issues sorted out before rushing ahead with half-done conversions. Functionally everything I've seen so far looked fine though.
But maybe I'm missing something? What exactly was the motivation behind the series? Do you have a follow-up?
Regards,
Andreas
Quoted 48 lines
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- hw/display/vmware_vga.c | 13 ++++++++----- hw/i2c/smbus_ich9.c | 2 +- hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 3 ++- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.h | 5 +++++ hw/ide/cmd646.c | 8 ++++---- hw/ide/ich.c | 10 +++++----- hw/ide/piix.c | 8 ++++---- hw/ide/via.c | 4 ++-- hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/misc/ivshmem.c | 18 +++++++++++------- hw/misc/pci-testdev.c | 11 ++++++++--- hw/misc/vfio.c | 4 ++-- hw/net/e1000.c | 18 ++++++++++++------ hw/net/eepro100.c | 14 ++++++++------ hw/net/ne2000.c | 6 ++++-- hw/net/pcnet-pci.c | 14 +++++++++----- hw/net/rtl8139.c | 26 ++++++++++++++++++-------- hw/pci-bridge/dec.c | 2 +- hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pci_bridge.c | 7 ++++--- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- hw/scsi/esp-pci.c | 14 +++++++++----- hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- hw/scsi/megasas.c | 15 ++++++++++----- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 19 +++++++++++++------ hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 45 files changed, 258 insertions(+), 177 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Am 30.06.2013 12:44, schrieb Andreas Färber:
Quoted 20 lines
Quoted 7 lines
Peter Crosthwaite (30):
net/e1000: QOM Upcast Sweep
net/rtl8139: QOM Upcast Sweep
net/pcnet-pci: QOM Upcast Sweep
usb/hcd-xhci: QOM Upcast Sweep
scsi/lsi53c895a: QOM Upcast Sweep
scsi/megasas: QOM Upcast SweepQuoted 8 lines
scsi/esp-pci: QOM Upcast Sweep
ide/ich: QOM Upcast Sweep
ide/piix: QOM casting sweep
acpi/piix4: QOM Upcast Sweep
misc/pci-testdev: QOM Upcast Sweep
virtio/vmware_vga: QOM casting sweep
misc/ivshmem: QOM Upcast Sweep
xen/xen_platform: QOM casting sweepAs requested, I've started picking up QOM type/cast/realize patches on:
git://github.com/afaerber/qemu-cpu.gitqom-next
https://github.com/afaerber/qemu-cpu/commits/qom-next
[...]
Quoted 3 lines
I've queued all patches above except for ide/piix (09/30) and had comments and/or minor changes for some of them. Noticing some incompleteness, I will reiterate over them.
I've posted and inserted patches accompanying these or squashed casts/parent_obj as indicated where trivial, so that these devices are QOM'ified modulo any remaining ->qdev or ->qbus accesses or realizefn. (My commit messages have been tidied à la xen-platform.)
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land -- ANN: qom-next revived
In reply to Andreas FärberHi Andreas,
Quoted 53 lines · Andreas Färber
Hi Peter,
Am 24.06.2013 08:49, schrieb [email protected]:
Quoted 7 lines
From: Peter Crosthwaite <[email protected]>
There are a number of different cast implementations from various stages of QEMU development out in device model land. This series cleans up the ones involving
TYPE_PCI_DEVICEto consistently use proper QOM casts for both up and down casts.Quoted 7 lines
Some were easy, some needed QOM cast macros which are added as appropriate.
Following the recent discussion RE performance consequences of QOM casts, im interested in any reports of possible performance regressions here, although I am hoping that Anthony current efforts to improve QOM casting efficiency make this a non-issue.
While I did not run extensive benchmarks, state of the discussion between Paolo, Anthony and me, I believe, was that it can be considered okay to use QOM casts "everywhere" consistently now, but we should not use casts where they are unnecessary (i.e., only where we change type). E.g., http://patchwork.ozlabs.org/patch/255367/
I have therefore dropped some opaque casts where the type on both sides of void* matched (for an up-/downcast I do prefer the cast for safety).
Anyway, if we get this merged early, then there is still time for more benchmarking/optimizations during Soft Freeze IMO.
Maybe our staging tree will facilitate testing, too. ;)Quoted 6 lines
Changed since V1:
Removed hunks which macroified VMSD names
Dropped virtio/virtio.pci patch
RebasedQuoted 15 lines
Peter Crosthwaite (30):
net/e1000: QOM Upcast Sweep
net/rtl8139: QOM Upcast Sweep
net/pcnet-pci: QOM Upcast Sweep
usb/hcd-xhci: QOM Upcast Sweep
scsi/lsi53c895a: QOM Upcast Sweep
scsi/megasas: QOM Upcast Sweep
scsi/esp-pci: QOM Upcast Sweep
ide/ich: QOM Upcast Sweep
ide/piix: QOM casting sweep
acpi/piix4: QOM Upcast Sweep
misc/pci-testdev: QOM Upcast Sweep
virtio/vmware_vga: QOM casting sweep
misc/ivshmem: QOM Upcast Sweep
xen/xen_platform: QOM casting sweep
Quoted 3 lines
As requested, I've started picking up QOM type/cast/realize patches on:
git://github.com/afaerber/qemu-cpu.gitqom-next
Perhaps this is becoming the "qom-devices" queue?
Quoted 7 lines
https://github.com/afaerber/qemu-cpu/commits/qom-next
(Not to be confused with my qom-cpu / qom-cpu-next CPU trees.)
If anyone wishes to contribute patches against that tree, please indicate so with --subject-prefix="PATCH qom-next ...".
Quoted 7 lines
As a matter of personal taste and consistency, I've used the gtk-doc notation
DO_UPCAST()wherever I stumbled over it in commit messages.I've queued all patches above except for ide/piix (09/30) and had comments and/or minor changes for some of them. Noticing some incompleteness, I will reiterate over them.
I think the incompleteness comes from the fact that my series is only worrying about type PCI_DEVICE. I have left alone QOM cast issues for casts that are not to/from or through TYPE_PCI_DEVICE, so there are instances where a QOM cast macro may be introduces but not used.
Quoted 4 lines
Whether I send a pull when we're all happy with it or whether we let submaintainers pick/pull by subsystem at some point doesn't matter to me, as long as we can join efforts to make QOM realize reality soon. :)
I think getting it all into one giant queue then we can centralise testing a little better.
Quoted 17 lines
Quoted 8 lines
isa/*: QOM casting sweep
pci/*: QOM casting sweep pci-bridge/pci_bridge_dev: Don't useDO_UPCASTpci-bridge/*: substitute ->qdev casts withDEVICE()pci/pci_bridge: substitute ->qdev casts withDEVICE()misc/vfio: substitute ->qdev casts withDEVICE()net/eepro100: substitute ->qdev casts withDEVICE()net/ne2000: substitute ->qdev casts withDEVICE()Quoted 8 lines
usb/*: substitute ->qdev casts with
DEVICE()watchdog/wdt_i6300esb: substitute ->qdev casts withDEVICE()scsi/vmw_pvscsi: substitute ->qdev casts withDEVICE()i2c/smbus_ich9: substitute ->qdev casts withDEVICE()ide/cmd646: substitute ->qdev casts withDEVICE()ide/via: substitute ->qdev casts withDEVICE()pci-host/*: substitute ->qdev casts withDEVICE()i386/*: substitute ->qdev casts withDEVICE()
Quoted 8 lines
These patches seem more "sloppy" while not reaching a clear goal such as dropping a macro or renaming
PCIDevice::qdev, so I'd prefer to get open issues sorted out before rushing ahead with half-done conversions. Functionally everything I've seen so far looked fine though.But maybe I'm missing something? What exactly was the motivation behind the series? Do you have a follow-up?
I have an experimental series out-of-tree (change the parent type of TYPE_PCI_DEVICE to TYPE_SYSBUS) to remove the need to coreify devices for use as both sysbus and PCI (e.g. EHCI). These casts get in the way of that series.
I really want to make it clear though, that this series is legitimate cleanup without that goal, so I didn't want to tangle this series in that much-longer discussion.
So this series specifically is a compile bug chase on:
include/hw/pci/pci.h +0 -1
@@ -217,7 +217,6 @@ typedef void (*MSIVectorPollNotifier)(PCIDevice *dev, unsigned int vector_end);struct PCIDevice { -DeviceState qdev;/* PCI config space */ uint8_t *config;
FWIW, one could actually remove all parent_obj fields from QOM structs (just like this) and the tree should compile, good way to catch all legacy casts.
Regards,
Peter
Quoted 57 lines
Regards,
AndreasQuoted 39 lines
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- hw/display/vmware_vga.c | 13 ++++++++----- hw/i2c/smbus_ich9.c | 2 +- hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 3 ++- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.h | 5 +++++ hw/ide/cmd646.c | 8 ++++---- hw/ide/ich.c | 10 +++++----- hw/ide/piix.c | 8 ++++---- hw/ide/via.c | 4 ++-- hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/misc/ivshmem.c | 18 +++++++++++------- hw/misc/pci-testdev.c | 11 ++++++++--- hw/misc/vfio.c | 4 ++-- hw/net/e1000.c | 18 ++++++++++++------ hw/net/eepro100.c | 14 ++++++++------ hw/net/ne2000.c | 6 ++++-- hw/net/pcnet-pci.c | 14 +++++++++----- hw/net/rtl8139.c | 26 ++++++++++++++++++-------- hw/pci-bridge/dec.c | 2 +- hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pci_bridge.c | 7 ++++--- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- hw/scsi/esp-pci.c | 14 +++++++++----- hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- hw/scsi/megasas.c | 15 ++++++++++-----Quoted 9 lines
hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 19 +++++++++++++------ hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 45 files changed, 258 insertions(+), 177 deletions(-)--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 00/30] PCI: Cleanup legacy casts in device land -- ANN: qom-next revived
In reply to Andreas FärberHi Andreas,
Thanks for the review and fixups. ACK to all modifications and squashes as commented.
Regards,
Peter
Quoted 156 lines · Andreas Färber
Hi Peter,
Am 24.06.2013 08:49, schrieb [email protected]:
Quoted 7 lines
From: Peter Crosthwaite <[email protected]>
There are a number of different cast implementations from various stages of QEMU development out in device model land. This series cleans up the ones involving
TYPE_PCI_DEVICEto consistently use proper QOM casts for both up and down casts.Quoted 7 lines
Some were easy, some needed QOM cast macros which are added as appropriate.
Following the recent discussion RE performance consequences of QOM casts, im interested in any reports of possible performance regressions here, although I am hoping that Anthony current efforts to improve QOM casting efficiency make this a non-issue.
While I did not run extensive benchmarks, state of the discussion between Paolo, Anthony and me, I believe, was that it can be considered okay to use QOM casts "everywhere" consistently now, but we should not use casts where they are unnecessary (i.e., only where we change type). E.g., http://patchwork.ozlabs.org/patch/255367/
I have therefore dropped some opaque casts where the type on both sides of void* matched (for an up-/downcast I do prefer the cast for safety).
Anyway, if we get this merged early, then there is still time for more benchmarking/optimizations during Soft Freeze IMO.
Maybe our staging tree will facilitate testing, too. ;)Quoted 6 lines
Changed since V1:
Removed hunks which macroified VMSD names
Dropped virtio/virtio.pci patch
RebasedQuoted 15 lines
Peter Crosthwaite (30):
net/e1000: QOM Upcast Sweep
net/rtl8139: QOM Upcast Sweep
net/pcnet-pci: QOM Upcast Sweep
usb/hcd-xhci: QOM Upcast Sweep
scsi/lsi53c895a: QOM Upcast Sweep
scsi/megasas: QOM Upcast Sweep
scsi/esp-pci: QOM Upcast Sweep
ide/ich: QOM Upcast Sweep
ide/piix: QOM casting sweep
acpi/piix4: QOM Upcast Sweep
misc/pci-testdev: QOM Upcast Sweep
virtio/vmware_vga: QOM casting sweep
misc/ivshmem: QOM Upcast Sweep
xen/xen_platform: QOM casting sweepAs requested, I've started picking up QOM type/cast/realize patches on:
git://github.com/afaerber/qemu-cpu.gitqom-next
https://github.com/afaerber/qemu-cpu/commits/qom-next(Not to be confused with my qom-cpu / qom-cpu-next CPU trees.)
If anyone wishes to contribute patches against that tree, please indicate so with --subject-prefix="PATCH qom-next ...".
As a matter of personal taste and consistency, I've used the gtk-doc notation
DO_UPCAST()wherever I stumbled over it in commit messages.I've queued all patches above except for ide/piix (09/30) and had comments and/or minor changes for some of them. Noticing some incompleteness, I will reiterate over them.
Whether I send a pull when we're all happy with it or whether we let submaintainers pick/pull by subsystem at some point doesn't matter to me, as long as we can join efforts to make QOM realize reality soon. :)
Quoted 8 lines
isa/*: QOM casting sweep
pci/*: QOM casting sweep pci-bridge/pci_bridge_dev: Don't useDO_UPCASTpci-bridge/*: substitute ->qdev casts withDEVICE()pci/pci_bridge: substitute ->qdev casts withDEVICE()misc/vfio: substitute ->qdev casts withDEVICE()net/eepro100: substitute ->qdev casts withDEVICE()net/ne2000: substitute ->qdev casts withDEVICE()Quoted 8 lines
usb/*: substitute ->qdev casts with
DEVICE()watchdog/wdt_i6300esb: substitute ->qdev casts withDEVICE()scsi/vmw_pvscsi: substitute ->qdev casts withDEVICE()i2c/smbus_ich9: substitute ->qdev casts withDEVICE()ide/cmd646: substitute ->qdev casts withDEVICE()ide/via: substitute ->qdev casts withDEVICE()pci-host/*: substitute ->qdev casts withDEVICE()i386/*: substitute ->qdev casts withDEVICE()These patches seem more "sloppy" while not reaching a clear goal such as dropping a macro or renaming
PCIDevice::qdev, so I'd prefer to get open issues sorted out before rushing ahead with half-done conversions. Functionally everything I've seen so far looked fine though.But maybe I'm missing something? What exactly was the motivation behind the series? Do you have a follow-up?
Regards,
AndreasQuoted 39 lines
hw/acpi/piix4.c | 31 +++++++++++++++++-------------- hw/display/vmware_vga.c | 13 ++++++++----- hw/i2c/smbus_ich9.c | 2 +- hw/i386/kvm/pci-assign.c | 21 ++++++++++++--------- hw/i386/pc.c | 3 ++- hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- hw/ide/ahci.h | 5 +++++ hw/ide/cmd646.c | 8 ++++---- hw/ide/ich.c | 10 +++++----- hw/ide/piix.c | 8 ++++---- hw/ide/via.c | 4 ++-- hw/isa/i82378.c | 8 ++++---- hw/isa/lpc_ich9.c | 6 +++--- hw/misc/ivshmem.c | 18 +++++++++++------- hw/misc/pci-testdev.c | 11 ++++++++--- hw/misc/vfio.c | 4 ++-- hw/net/e1000.c | 18 ++++++++++++------ hw/net/eepro100.c | 14 ++++++++------ hw/net/ne2000.c | 6 ++++-- hw/net/pcnet-pci.c | 14 +++++++++----- hw/net/rtl8139.c | 26 ++++++++++++++++++-------- hw/pci-bridge/dec.c | 2 +- hw/pci-bridge/i82801b11.c | 2 +- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci-host/apb.c | 4 ++-- hw/pci-host/q35.c | 4 ++-- hw/pci/pci-hotplug.c | 18 ++++++++++-------- hw/pci/pci.c | 17 +++++++++-------- hw/pci/pci_bridge.c | 7 ++++--- hw/pci/pcie.c | 4 ++-- hw/pci/shpc.c | 8 ++++---- hw/scsi/esp-pci.c | 14 +++++++++----- hw/scsi/lsi53c895a.c | 26 ++++++++++++++++---------- hw/scsi/megasas.c | 15 ++++++++++-----Quoted 9 lines
hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 13 ++++++++----- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 19 +++++++++++++------ hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 28 ++++++++++++++++------------ 45 files changed, 258 insertions(+), 177 deletions(-)--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg