Remove unnecessary casts introduced by PCI DMA stubs series
cover Remove unnecessary casts introduced by PCI DMA stubs series
As a few people pointed out, my recent patch series introducing a new (stub) PCI DMA API added unnecessary casts in quite a few places. I think this was a hangover from early days of the patchese where the casts were necessary for some reason I've now forgotten.
Thanks for applying the series anyway, here is the requested followup series which removes those unnecessary casts.
This still leaves the bug I introduced in eepro100 where stl_le_pci_dma() is now used on a possibly unaligned address. I'll be sending another patch to fix that.
PATCH 1/7 Remove unnecessary casts from PCI DMA code in eepro100
This patch removes some unnecessary casts in the eepro100 device, introduced by commit 16ef60c9a8eeee269f7cbc95219a431b1d7cbf29 'eepro100: Use PCI DMA stub functions'.
--- hw/eepro100.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
hw/eepro100.c +3 -4
@@ -713,8 +713,7 @@ static void dump_statistics(EEPRO100State * s)* values which really matter. * Number of data should check configuration!!! */ -pci_dma_write (&s->dev, s->statsaddr, - (uint8_t *) &s->statistics, s->stats_size); +pci_dma_write (&s->dev, s->statsaddr, &s->statistics, s->stats_size);stl_le_pci_dma (&s->dev, s->statsaddr +0 , s->statistics.tx_good_frames); stl_le_pci_dma(&s->dev, s->statsaddr + 36,
@@ -732,7 +731,7 @@ static void dump_statistics(EEPRO100State * s)static void read_cb (EEPRO100State *s) { -pci_dma_read (&s->dev, s->cb_address, (uint8_t *) &s->tx,sizeof (s->tx)); +pci_dma_read (&s->dev, s->cb_address, &s->tx,sizeof (s->tx)); s->tx.status =le16_to_cpu (s->tx.status); s->tx.command =le16_to_cpu (s->tx.command); s->tx.link =le32_to_cpu (s->tx.link);
@@ -1707,7 +1706,7 @@ static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size/* !!! */ eepro100_rx_t rx;pci_dma_read (&s->dev, s->ru_base + s->ru_offset, - (uint8_t *) &rx,sizeof (eepro100_rx_t)); + &rx,sizeof (eepro100_rx_t));uint16_t rfd_command =le16_to_cpu (rx.command);uint16_t rfd_size =le16_to_cpu (rx.size);
Signature · 1 line
1.7.7
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 1/7] Remove unnecessary casts from PCI DMA code in eepro100
Quoted 5 lines · David Gibson
This patch removes some unnecessary casts in the eepro100 device, introduced by commit
16ef60c9a8eeee269f7cbc95219a431b1d7cbf29'eepro100: Use PCI DMA stub functions'.Signed-off-by David Gibson<[email protected]>
Applied all. Thanks.
Regards,
Anthony Liguori
Quoted 36 lines
--- hw/eepro100.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)hw/eepro100.c +3
-4@@ -713,8 +713,7 @@ static void dump_statistics(EEPRO100State * s)* values which really matter. * Number of data should check configuration!!! */ -pci_dma_write (&s->dev, s->statsaddr, - (uint8_t *)&s->statistics, s->stats_size); +pci_dma_write (&s->dev, s->statsaddr,&s->statistics, s->stats_size);stl_le_pci_dma (&s->dev, s->statsaddr +0 , s->statistics.tx_good_frames); stl_le_pci_dma(&s->dev, s->statsaddr + 36,@@ -732,7 +731,7 @@ static void dump_statistics(EEPRO100State * s)static void read_cb (EEPRO100State *s) { -pci_dma_read (&s->dev, s->cb_address, (uint8_t *)&s->tx,sizeof (s->tx)); +pci_dma_read (&s->dev, s->cb_address,&s->tx,sizeof (s->tx)); s->tx.status =le16_to_cpu (s->tx.status); s->tx.command =le16_to_cpu (s->tx.command); s->tx.link =le32_to_cpu (s->tx.link);@@ -1707,7 +1706,7 @@ static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size/* !!! */ eepro100_rx_t rx;pci_dma_read (&s->dev, s->ru_base + s->ru_offset, - (uint8_t *)&rx,sizeof (eepro100_rx_t)); +&rx,sizeof (eepro100_rx_t));uint16_t rfd_command =le16_to_cpu (rx.command);uint16_t rfd_size =le16_to_cpu (rx.size);
PATCH 2/7 Remove unnecessary casts from PCI DMA code in e1000
In reply to David GibsonThis patch removes some unnecessary casts in the e1000 device, introduced by commit 62ecbd353d25e62c4a6c327ea88ba5404e13507a 'e1000:
Use PCI DMA stub functions'.
--- hw/e1000.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
hw/e1000.c +5 -6
@@ -507,7 +507,7 @@ txdesc_writeback(E1000State *s, dma_addr_t base, struct e1000_tx_desc *dp) ~(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), - (void *)&dp->upper,sizeof (dp->upper)); + &dp->upper,sizeof (dp->upper));return E1000_ICR_TXDW ; }
@@ -534,7 +534,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, (void *)&desc,sizeof (desc)); +pci_dma_read (&s->dev, 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,
@@ -714,7 +714,7 @@ e1000_receive(VLANClientState *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, (void *)&desc,sizeof (desc)); +pci_dma_read (&s->dev, base, &desc,sizeof (desc)); desc.special = vlan_special; desc.status |= (vlan_status |E1000_RXD_STAT_DD );if (desc.buffer_addr) {
@@ -724,8 +724,7 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) copy_size = s->rxbuf_size; }pci_dma_write (&s->dev,le64_to_cpu (desc.buffer_addr), - (void *)(buf + desc_offset + vlan_offset), - copy_size); + buf + desc_offset + vlan_offset, copy_size); } desc_offset += desc_size; desc.length =cpu_to_le16 (desc_size);
@@ -739,7 +738,7 @@ e1000_receive(VLANClientState *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, (void *)&desc,sizeof (desc)); +pci_dma_write (&s->dev, base, &desc,sizeof (desc));if (++s->mac_reg[RDH ] *sizeof (desc) >= s->mac_reg[RDLEN ]) s->mac_reg[RDH ] =0 ;
Signature · 1 line
1.7.7
PATCH 3/7 Remove unnecessary casts from PCI DMA code in PCI IDE
In reply to David GibsonThis patch removes some unnecessary casts in the PCI IDE device, introduced by commit 552908fef5b67ad9d96b76d7cb8371ebc26c9bc8 'PCI IDE: Use PCI DMA stub functions'.
--- hw/ide/pci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/ide/pci.c +2 -2
@@ -71,7 +71,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, (uint8_t *)&prd,8 ); +pci_dma_read (&bm->pci_dev->dev, bm->cur_addr, &prd,8 ); bm->cur_addr +=8 ; prd.addr =le32_to_cpu (prd.addr); prd.size =le32_to_cpu (prd.size);
@@ -113,7 +113,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, (uint8_t *)&prd,8 ); +pci_dma_read (&bm->pci_dev->dev, bm->cur_addr, &prd,8 ); bm->cur_addr +=8 ; prd.addr =le32_to_cpu (prd.addr); prd.size =le32_to_cpu (prd.size);
Signature · 1 line
1.7.7
PATCH 4/7 Remove unnecessary casts from PCI DMA code in lsi53c895a
In reply to David GibsonThis patch removes some unnecessary casts in the lsi53c895a device, introduced by commit 9ba4524cda1348cbe741535f77815dca6a57da05 'lsi53c895a: Use PCI DMA stub functions'.
--- hw/lsi53c895a.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/lsi53c895a.c +2 -2
@@ -392,7 +392,7 @@ static inline uint32_t read_dword(LSIState *s, uint32_t addr) {uint32_t buf; -pci_dma_read (&s->dev, addr, (uint8_t *)&buf,4 ); +pci_dma_read (&s->dev, addr, &buf,4 );return cpu_to_le32 (buf); }
@@ -1079,7 +1079,7 @@ again:/* 32-bit Table indirect */ offset =sxt24 (addr); -pci_dma_read (&s->dev, s->dsa + offset, (uint8_t *)buf,8 ); +pci_dma_read (&s->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;
Signature · 1 line
1.7.7
PATCH 5/7 Remove unnecessary casts from PCI DMA code in rtl8139
In reply to David GibsonThis patch removes some unnecessary casts in the rtl8139 device, introduced by commit 3ada003aee2004d24f23b9cd6f4eda87d9601ddb 'rtl8139: Use PCI DMA stub functions'.
--- hw/rtl8139.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
hw/rtl8139.c +4 -4
@@ -991,13 +991,13 @@ static ssize_t rtl8139_do_receive(VLANClientState *nc, const uint8_t *buf, size_uint32_t val, rxdw0,rxdw1,rxbufLO,rxbufHI; -pci_dma_read (&s->dev, cplus_rx_ring_desc, (uint8_t *)&val,4 ); +pci_dma_read (&s->dev, cplus_rx_ring_desc, &val,4 ); rxdw0 =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_rx_ring_desc+4 , (uint8_t *)&val,4 ); +pci_dma_read (&s->dev, cplus_rx_ring_desc+4 , &val,4 ); rxdw1 =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_rx_ring_desc+8 , (uint8_t *)&val,4 ); +pci_dma_read (&s->dev, cplus_rx_ring_desc+8 , &val,4 ); rxbufLO =le32_to_cpu (val); -pci_dma_read (&s->dev, cplus_rx_ring_desc+12 , (uint8_t *)&val,4 ); +pci_dma_read (&s->dev, cplus_rx_ring_desc+12 , &val,4 ); rxbufHI =le32_to_cpu (val); DPRINTF("+++ C+ mode RX descriptor %d %08x %08x %08x %08x\n",
Signature · 1 line
1.7.7
PATCH 6/7 Remove unnecessary casts from PCI DMA code in usb-ehci
In reply to David GibsonThis patch removes some unnecessary casts in the usb-ehci device, introduced by commit 68d553587c0aa271c3eb2902921b503740d775b6 'usb-ehci: Use PCI DMA stub functions'.
--- hw/usb-ehci.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
hw/usb-ehci.c +3 -3
@@ -1107,7 +1107,7 @@ static inline int get_dwords(EHCIState *ehci, uint32_t addr,int i;for (i =0 ; i < num; i++, buf++, addr +=sizeof (*buf)) { -pci_dma_read (&ehci->dev, addr, (uint8_t *)buf,sizeof (*buf)); +pci_dma_read (&ehci->dev, addr, buf,sizeof (*buf)); *buf =le32_to_cpu (*buf); }
@@ -1122,7 +1122,7 @@ static inline int put_dwords(EHCIState *ehci, uint32_t addr,for (i =0 ; i < num; i++, buf++, addr +=sizeof (*buf)) {uint32_t tmp =cpu_to_le32 (*buf); -pci_dma_write (&ehci->dev, addr, (uint8_t *)&tmp,sizeof (tmp)); +pci_dma_write (&ehci->dev, addr, &tmp,sizeof (tmp)); }return 1 ;
@@ -2154,7 +2154,7 @@ static void ehci_advance_periodic_state(EHCIState *ehci) } list |= ((ehci->frindex &0x1ff8 ) >>1 ); -pci_dma_read (&ehci->dev, list, (uint8_t *) &entry,sizeof entry); +pci_dma_read (&ehci->dev, list, &entry,sizeof entry); entry =le32_to_cpu (entry); DPRINTF("PERIODIC state adv fr=%d. [%08X] -> %08X\n",
Signature · 1 line
1.7.7
PATCH 7/7 Remove unnecessary casts from PCI DMA code in usb-uhci
In reply to David GibsonThis patch removes some unnecessary casts in the usb-uhci device, introduced by commit fff23ee9a5de74ab111b3cea9eec56782e7d7c50 'usb-uhci: Use PCI DMA stub functions'.
--- hw/usb-uhci.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-)
hw/usb-uhci.c +7 -10
@@ -876,7 +876,7 @@ static void uhci_async_complete(USBPort *port, USBPacket *packet)uint32_t link = async->td;uint32_t int_mask =0 , val; -pci_dma_read (&s->dev, link & ~0xf , (uint8_t *) &td,sizeof (td)); +pci_dma_read (&s->dev, link & ~0xf , &td,sizeof (td));le32_to_cpus (&td.link);le32_to_cpus (&td.ctrl);le32_to_cpus (&td.token);
@@ -888,8 +888,7 @@ static void uhci_async_complete(USBPort *port, USBPacket *packet)/* update the status bits of the TD */ val =cpu_to_le32 (td.ctrl); -pci_dma_write (&s->dev, (link & ~0xf ) +4 , - (const uint8_t *)&val,sizeof (val)); +pci_dma_write (&s->dev, (link & ~0xf ) +4 , &val,sizeof (val));uhci_async_free (s, async); }else { async->done =1 ;
@@ -952,7 +951,7 @@ static void uhci_process_frame(UHCIState *s)DPRINTF ("uhci: processing frame %d addr 0x%x\n" , s->frnum, frame_addr); -pci_dma_read (&s->dev, frame_addr, (uint8_t *)&link,4 ); +pci_dma_read (&s->dev, frame_addr, &link,4 );le32_to_cpus (&link); int_mask =0 ;
@@ -976,7 +975,7 @@ static void uhci_process_frame(UHCIState *s)break ; } -pci_dma_read (&s->dev, link & ~0xf , (uint8_t *) &qh,sizeof (qh)); +pci_dma_read (&s->dev, link & ~0xf , &qh,sizeof (qh));le32_to_cpus (&qh.link);le32_to_cpus (&qh.el_link);
@@ -996,7 +995,7 @@ static void uhci_process_frame(UHCIState *s) }/* TD */ -pci_dma_read (&s->dev, link & ~0xf , (uint8_t *) &td,sizeof (td)); +pci_dma_read (&s->dev, link & ~0xf , &td,sizeof (td));le32_to_cpus (&td.link);le32_to_cpus (&td.ctrl);le32_to_cpus (&td.token);
@@ -1010,8 +1009,7 @@ static void uhci_process_frame(UHCIState *s)if (old_td_ctrl != td.ctrl) {/* update the status bits of the TD */ val =cpu_to_le32 (td.ctrl); -pci_dma_write (&s->dev, (link & ~0xf ) +4 , - (const uint8_t *)&val,sizeof (val)); +pci_dma_write (&s->dev, (link & ~0xf ) +4 , &val,sizeof (val)); }if (ret <0 ) {
@@ -1039,8 +1037,7 @@ static void uhci_process_frame(UHCIState *s)/* update QH element link */ qh.el_link = link; val =cpu_to_le32 (qh.el_link); -pci_dma_write (&s->dev, (curr_qh & ~0xf ) +4 , - (const uint8_t *)&val,sizeof (val)); +pci_dma_write (&s->dev, (curr_qh & ~0xf ) +4 , &val,sizeof (val));if (!depth_first (link)) {/* done with this QH */
Signature · 1 line
1.7.7
Am 04.11.2011 02:03, schrieb David Gibson:
Quoted 7 lines
As a few people pointed out, my recent patch series introducing a new (stub) PCI DMA API added unnecessary casts in quite a few places. I think this was a hangover from early days of the patchese where the casts were necessary for some reason I've now forgotten.
Thanks for applying the series anyway, here is the requested followup series which removes those unnecessary casts.
Whole series only removes casts, plus one reindentation in 2/7 at a line touched anyway. Looks okay for 1.0 if it compiles.
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
Quoted 6 lines · Andreas Färber
Am 04.11.2011 02:03, schrieb David Gibson:
Quoted 5 lines
As a few people pointed out, my recent patch series introducing a new (stub) PCI DMA API added unnecessary casts in quite a few places. I think this was a hangover from early days of the patchese where the casts were necessary for some reason I've now forgotten.
Quoted 7 lines
Quoted 2 lines
Thanks for applying the series anyway, here is the requested followup series which removes those unnecessary casts.
Whole series only removes casts, plus one reindentation in 2/7 at a line touched anyway. Looks okay for 1.0 if it compiles.
Reviewed-by Andreas Färber <[email protected]>
Anthony, I notice this series hasn't gone into the 1.0 tree yet. Is there a particular reason for that, or has it just no happened yet?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson