aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2007-12-09 11:50:47 -0500
committerJeff Garzik <jeff@garzik.org>2007-12-14 15:26:00 -0500
commit14c9d9b03bb8ec63c77aebddea9a6f730f1b62d5 (patch)
treeef70f59cd9cb97be5825c835d94331d3c3f8760f
parent798fdd07fcc131f396e521febb4a7d42559bf4b5 (diff)
sundance fixes
* all places where we assign ->addr get cpu_to_le32(pci_map_single(....)), so we ought to convert back to host-endian before doing pci_unmap_single() et.al. * poisoning addresses in netdev_close() should be done _after_ unmapping them, not before it... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/net/sundance.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index ff98f5d597f1..0a6186d4a48e 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -340,9 +340,9 @@ enum mac_ctrl1_bits {
340/* Note that using only 32 bit fields simplifies conversion to big-endian 340/* Note that using only 32 bit fields simplifies conversion to big-endian
341 architectures. */ 341 architectures. */
342struct netdev_desc { 342struct netdev_desc {
343 u32 next_desc; 343 __le32 next_desc;
344 u32 status; 344 __le32 status;
345 struct desc_frag { u32 addr, length; } frag[1]; 345 struct desc_frag { __le32 addr, length; } frag[1];
346}; 346};
347 347
348/* Bits in netdev_desc.status */ 348/* Bits in netdev_desc.status */
@@ -495,8 +495,8 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
495 goto err_out_res; 495 goto err_out_res;
496 496
497 for (i = 0; i < 3; i++) 497 for (i = 0; i < 3; i++)
498 ((u16 *)dev->dev_addr)[i] = 498 ((__le16 *)dev->dev_addr)[i] =
499 le16_to_cpu(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET)); 499 cpu_to_le16(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET));
500 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 500 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
501 501
502 dev->base_addr = (unsigned long)ioaddr; 502 dev->base_addr = (unsigned long)ioaddr;
@@ -1090,8 +1090,8 @@ reset_tx (struct net_device *dev)
1090 skb = np->tx_skbuff[i]; 1090 skb = np->tx_skbuff[i];
1091 if (skb) { 1091 if (skb) {
1092 pci_unmap_single(np->pci_dev, 1092 pci_unmap_single(np->pci_dev,
1093 np->tx_ring[i].frag[0].addr, skb->len, 1093 le32_to_cpu(np->tx_ring[i].frag[0].addr),
1094 PCI_DMA_TODEVICE); 1094 skb->len, PCI_DMA_TODEVICE);
1095 if (irq) 1095 if (irq)
1096 dev_kfree_skb_irq (skb); 1096 dev_kfree_skb_irq (skb);
1097 else 1097 else
@@ -1214,7 +1214,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
1214 skb = np->tx_skbuff[entry]; 1214 skb = np->tx_skbuff[entry];
1215 /* Free the original skb. */ 1215 /* Free the original skb. */
1216 pci_unmap_single(np->pci_dev, 1216 pci_unmap_single(np->pci_dev,
1217 np->tx_ring[entry].frag[0].addr, 1217 le32_to_cpu(np->tx_ring[entry].frag[0].addr),
1218 skb->len, PCI_DMA_TODEVICE); 1218 skb->len, PCI_DMA_TODEVICE);
1219 dev_kfree_skb_irq (np->tx_skbuff[entry]); 1219 dev_kfree_skb_irq (np->tx_skbuff[entry]);
1220 np->tx_skbuff[entry] = NULL; 1220 np->tx_skbuff[entry] = NULL;
@@ -1233,7 +1233,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
1233 skb = np->tx_skbuff[entry]; 1233 skb = np->tx_skbuff[entry];
1234 /* Free the original skb. */ 1234 /* Free the original skb. */
1235 pci_unmap_single(np->pci_dev, 1235 pci_unmap_single(np->pci_dev,
1236 np->tx_ring[entry].frag[0].addr, 1236 le32_to_cpu(np->tx_ring[entry].frag[0].addr),
1237 skb->len, PCI_DMA_TODEVICE); 1237 skb->len, PCI_DMA_TODEVICE);
1238 dev_kfree_skb_irq (np->tx_skbuff[entry]); 1238 dev_kfree_skb_irq (np->tx_skbuff[entry]);
1239 np->tx_skbuff[entry] = NULL; 1239 np->tx_skbuff[entry] = NULL;
@@ -1311,19 +1311,19 @@ static void rx_poll(unsigned long data)
1311 && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1311 && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
1312 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1312 skb_reserve(skb, 2); /* 16 byte align the IP header */
1313 pci_dma_sync_single_for_cpu(np->pci_dev, 1313 pci_dma_sync_single_for_cpu(np->pci_dev,
1314 desc->frag[0].addr, 1314 le32_to_cpu(desc->frag[0].addr),
1315 np->rx_buf_sz, 1315 np->rx_buf_sz,
1316 PCI_DMA_FROMDEVICE); 1316 PCI_DMA_FROMDEVICE);
1317 1317
1318 skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); 1318 skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len);
1319 pci_dma_sync_single_for_device(np->pci_dev, 1319 pci_dma_sync_single_for_device(np->pci_dev,
1320 desc->frag[0].addr, 1320 le32_to_cpu(desc->frag[0].addr),
1321 np->rx_buf_sz, 1321 np->rx_buf_sz,
1322 PCI_DMA_FROMDEVICE); 1322 PCI_DMA_FROMDEVICE);
1323 skb_put(skb, pkt_len); 1323 skb_put(skb, pkt_len);
1324 } else { 1324 } else {
1325 pci_unmap_single(np->pci_dev, 1325 pci_unmap_single(np->pci_dev,
1326 desc->frag[0].addr, 1326 le32_to_cpu(desc->frag[0].addr),
1327 np->rx_buf_sz, 1327 np->rx_buf_sz,
1328 PCI_DMA_FROMDEVICE); 1328 PCI_DMA_FROMDEVICE);
1329 skb_put(skb = np->rx_skbuff[entry], pkt_len); 1329 skb_put(skb = np->rx_skbuff[entry], pkt_len);
@@ -1709,23 +1709,23 @@ static int netdev_close(struct net_device *dev)
1709 /* Free all the skbuffs in the Rx queue. */ 1709 /* Free all the skbuffs in the Rx queue. */
1710 for (i = 0; i < RX_RING_SIZE; i++) { 1710 for (i = 0; i < RX_RING_SIZE; i++) {
1711 np->rx_ring[i].status = 0; 1711 np->rx_ring[i].status = 0;
1712 np->rx_ring[i].frag[0].addr = 0xBADF00D0; /* An invalid address. */
1713 skb = np->rx_skbuff[i]; 1712 skb = np->rx_skbuff[i];
1714 if (skb) { 1713 if (skb) {
1715 pci_unmap_single(np->pci_dev, 1714 pci_unmap_single(np->pci_dev,
1716 np->rx_ring[i].frag[0].addr, np->rx_buf_sz, 1715 le32_to_cpu(np->rx_ring[i].frag[0].addr),
1717 PCI_DMA_FROMDEVICE); 1716 np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1718 dev_kfree_skb(skb); 1717 dev_kfree_skb(skb);
1719 np->rx_skbuff[i] = NULL; 1718 np->rx_skbuff[i] = NULL;
1720 } 1719 }
1720 np->rx_ring[i].frag[0].addr = cpu_to_le32(0xBADF00D0); /* poison */
1721 } 1721 }
1722 for (i = 0; i < TX_RING_SIZE; i++) { 1722 for (i = 0; i < TX_RING_SIZE; i++) {
1723 np->tx_ring[i].next_desc = 0; 1723 np->tx_ring[i].next_desc = 0;
1724 skb = np->tx_skbuff[i]; 1724 skb = np->tx_skbuff[i];
1725 if (skb) { 1725 if (skb) {
1726 pci_unmap_single(np->pci_dev, 1726 pci_unmap_single(np->pci_dev,
1727 np->tx_ring[i].frag[0].addr, skb->len, 1727 le32_to_cpu(np->tx_ring[i].frag[0].addr),
1728 PCI_DMA_TODEVICE); 1728 skb->len, PCI_DMA_TODEVICE);
1729 dev_kfree_skb(skb); 1729 dev_kfree_skb(skb);
1730 np->tx_skbuff[i] = NULL; 1730 np->tx_skbuff[i] = NULL;
1731 } 1731 }