diff options
author | andrea.merello <andrea.merello@gmail.com> | 2014-02-05 16:38:05 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-02-06 14:35:45 -0500 |
commit | 2b4db05e7e2f1efc71e36a9dc1adf5ba164a2330 (patch) | |
tree | 19570147e57de17c75cdc7039c77f8c42cfee3a0 /drivers/net/wireless | |
parent | 199160bbc9271b9351c062a477699fea72b29e3a (diff) |
rtl8180: Add error check for pci_map_single return value in RX path
In original code the old RX DMA buffer is unmapped and processed and at the end
of the isr a new buffer is mapped with pci_map_single and attached to the RX
descriptor.
If pci_map_single fails then the RX descriptor remains with no valid DMA buffer
attached.
In this condition the DMA will target where it shouldn't with obvious evil
consequences.
Simply avoiding re-arming the descriptor will prevent buggy DMA but it will
result soon in RX stuck.
This patch move the DMA mapping of the new buffer at the beginning of the ISR
(and it adds error check for pci_map_single success/fail).
If the DMA mapping fails then we do not unmap the old buffer and we re-arm the
descriptor without processing it, with the old DMA buffer still attached.
In this way we lose the currently RX-ed packet, but whenever next calls to
pci_map_single will succeed again,then the RX process will go on without stuck.
Signed-off-by: andrea merello <andrea.merello@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl8180/dev.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 8ec17aad0e52..fad616a0fa37 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c | |||
@@ -107,6 +107,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
107 | struct rtl8180_priv *priv = dev->priv; | 107 | struct rtl8180_priv *priv = dev->priv; |
108 | unsigned int count = 32; | 108 | unsigned int count = 32; |
109 | u8 signal, agc, sq; | 109 | u8 signal, agc, sq; |
110 | dma_addr_t mapping; | ||
110 | 111 | ||
111 | while (count--) { | 112 | while (count--) { |
112 | struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx]; | 113 | struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx]; |
@@ -128,6 +129,17 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
128 | if (unlikely(!new_skb)) | 129 | if (unlikely(!new_skb)) |
129 | goto done; | 130 | goto done; |
130 | 131 | ||
132 | mapping = pci_map_single(priv->pdev, | ||
133 | skb_tail_pointer(new_skb), | ||
134 | MAX_RX_SIZE, PCI_DMA_FROMDEVICE); | ||
135 | |||
136 | if (pci_dma_mapping_error(priv->pdev, mapping)) { | ||
137 | kfree_skb(new_skb); | ||
138 | dev_err(&priv->pdev->dev, "RX DMA map error\n"); | ||
139 | |||
140 | goto done; | ||
141 | } | ||
142 | |||
131 | pci_unmap_single(priv->pdev, | 143 | pci_unmap_single(priv->pdev, |
132 | *((dma_addr_t *)skb->cb), | 144 | *((dma_addr_t *)skb->cb), |
133 | MAX_RX_SIZE, PCI_DMA_FROMDEVICE); | 145 | MAX_RX_SIZE, PCI_DMA_FROMDEVICE); |
@@ -158,9 +170,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
158 | 170 | ||
159 | skb = new_skb; | 171 | skb = new_skb; |
160 | priv->rx_buf[priv->rx_idx] = skb; | 172 | priv->rx_buf[priv->rx_idx] = skb; |
161 | *((dma_addr_t *) skb->cb) = | 173 | *((dma_addr_t *) skb->cb) = mapping; |
162 | pci_map_single(priv->pdev, skb_tail_pointer(skb), | ||
163 | MAX_RX_SIZE, PCI_DMA_FROMDEVICE); | ||
164 | } | 174 | } |
165 | 175 | ||
166 | done: | 176 | done: |