e100: fix dma error in direction for mapping

The e100 driver triggers BUG_ON(buf->direction != dir)
by doing pci_map_single(..., PCI_DMA_BIDIRECTIONAL)
and pci_dma_sync_single_for_device(..., PCI_DMA_TODEVICE).

Changing the DMA direction, especially with dmabounce will result
in unexpected behaviour.

Reported-by: Anders Grafstrom <grfstrm@users.sourceforge.net>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Jesse Brandeburg and committed by David S. Miller 773c9c1f ac450208

+10 -10
+10 -10
drivers/net/e100.c
··· 166 167 #define DRV_NAME "e100" 168 #define DRV_EXT "-NAPI" 169 - #define DRV_VERSION "3.5.23-k4"DRV_EXT 170 #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 171 #define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" 172 #define PFX DRV_NAME ": " ··· 1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; 1805 put_unaligned_le32(rx->dma_addr, &prev_rfd->link); 1806 pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, 1807 - sizeof(struct rfd), PCI_DMA_TODEVICE); 1808 } 1809 1810 return 0; ··· 1823 1824 /* Need to sync before taking a peek at cb_complete bit */ 1825 pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr, 1826 - sizeof(struct rfd), PCI_DMA_FROMDEVICE); 1827 rfd_status = le16_to_cpu(rfd->status); 1828 1829 DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); ··· 1850 1851 /* Get data */ 1852 pci_unmap_single(nic->pdev, rx->dma_addr, 1853 - RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 1854 1855 /* If this buffer has the el bit, but we think the receiver 1856 * is still running, check to see if it really stopped while ··· 1943 new_before_last_rfd->command |= cpu_to_le16(cb_el); 1944 pci_dma_sync_single_for_device(nic->pdev, 1945 new_before_last_rx->dma_addr, sizeof(struct rfd), 1946 - PCI_DMA_TODEVICE); 1947 1948 /* Now that we have a new stopping point, we can clear the old 1949 * stopping point. We must sync twice to get the proper ··· 1951 old_before_last_rfd->command &= ~cpu_to_le16(cb_el); 1952 pci_dma_sync_single_for_device(nic->pdev, 1953 old_before_last_rx->dma_addr, sizeof(struct rfd), 1954 - PCI_DMA_TODEVICE); 1955 old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); 1956 pci_dma_sync_single_for_device(nic->pdev, 1957 old_before_last_rx->dma_addr, sizeof(struct rfd), 1958 - PCI_DMA_TODEVICE); 1959 } 1960 1961 if(restart_required) { ··· 1978 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1979 if(rx->skb) { 1980 pci_unmap_single(nic->pdev, rx->dma_addr, 1981 - RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 1982 dev_kfree_skb(rx->skb); 1983 } 1984 } ··· 2021 before_last->command |= cpu_to_le16(cb_el); 2022 before_last->size = 0; 2023 pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, 2024 - sizeof(struct rfd), PCI_DMA_TODEVICE); 2025 2026 nic->rx_to_use = nic->rx_to_clean = nic->rxs; 2027 nic->ru_running = RU_SUSPENDED; ··· 2222 msleep(10); 2223 2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, 2225 - RFD_BUF_LEN, PCI_DMA_FROMDEVICE); 2226 2227 if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), 2228 skb->data, ETH_DATA_LEN))
··· 166 167 #define DRV_NAME "e100" 168 #define DRV_EXT "-NAPI" 169 + #define DRV_VERSION "3.5.23-k6"DRV_EXT 170 #define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 171 #define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" 172 #define PFX DRV_NAME ": " ··· 1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; 1805 put_unaligned_le32(rx->dma_addr, &prev_rfd->link); 1806 pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, 1807 + sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); 1808 } 1809 1810 return 0; ··· 1823 1824 /* Need to sync before taking a peek at cb_complete bit */ 1825 pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr, 1826 + sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); 1827 rfd_status = le16_to_cpu(rfd->status); 1828 1829 DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); ··· 1850 1851 /* Get data */ 1852 pci_unmap_single(nic->pdev, rx->dma_addr, 1853 + RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1854 1855 /* If this buffer has the el bit, but we think the receiver 1856 * is still running, check to see if it really stopped while ··· 1943 new_before_last_rfd->command |= cpu_to_le16(cb_el); 1944 pci_dma_sync_single_for_device(nic->pdev, 1945 new_before_last_rx->dma_addr, sizeof(struct rfd), 1946 + PCI_DMA_BIDIRECTIONAL); 1947 1948 /* Now that we have a new stopping point, we can clear the old 1949 * stopping point. We must sync twice to get the proper ··· 1951 old_before_last_rfd->command &= ~cpu_to_le16(cb_el); 1952 pci_dma_sync_single_for_device(nic->pdev, 1953 old_before_last_rx->dma_addr, sizeof(struct rfd), 1954 + PCI_DMA_BIDIRECTIONAL); 1955 old_before_last_rfd->size = cpu_to_le16(VLAN_ETH_FRAME_LEN); 1956 pci_dma_sync_single_for_device(nic->pdev, 1957 old_before_last_rx->dma_addr, sizeof(struct rfd), 1958 + PCI_DMA_BIDIRECTIONAL); 1959 } 1960 1961 if(restart_required) { ··· 1978 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1979 if(rx->skb) { 1980 pci_unmap_single(nic->pdev, rx->dma_addr, 1981 + RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1982 dev_kfree_skb(rx->skb); 1983 } 1984 } ··· 2021 before_last->command |= cpu_to_le16(cb_el); 2022 before_last->size = 0; 2023 pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, 2024 + sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); 2025 2026 nic->rx_to_use = nic->rx_to_clean = nic->rxs; 2027 nic->ru_running = RU_SUSPENDED; ··· 2222 msleep(10); 2223 2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, 2225 + RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 2226 2227 if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), 2228 skb->data, ETH_DATA_LEN))