Skip to contentSkip to conversation

ath5k: fix requested allocated RX skb size for DMA

PATCH New Luis R. Rodriguez 3 participants 5 messages Aug 12, 2009 – Aug 13, 2009 Atheros ATH5K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath5k: fix requested allocated RX skb size for DMA

When we dev_alloc_skb() our RX buffers we were asking for them to be of size:

sc->rxbufsize + sc->common.cachelsz - 1

but when mapping processor virtual memeory for access by the hardware we were only giving it the sc->rxbufsize, therefore always preventing the device from accessing the fully allocated skb.

This patch fixes the disparity. It is unclear to me if there are other consequences to having this mismatch other than perhaps never allowing the device to use the full capacity of the allocated skb.

Cc Jiri Slaby <[email protected]>
Cc Nick Kossifidis <[email protected]>
Cc Bob Copeland <[email protected]>
---
 drivers/net/wireless/ath/ath5k/base.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath5k/base.c +5 -3
index 2b3cf39..75843f2 100644
@@ -1157,17 +1157,18 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)
 	 * fake physical layer header at the start.
 	 */
 	skb = ath_rxbuf_alloc(&sc->common,
-			      sc->rxbufsize + sc->common.cachelsz - 1,
+			      sc->rxbufsize,
 			      GFP_ATOMIC);
 
 	if (!skb) {
 		ATH5K_ERR(sc, "can't alloc skbuff of size %u\n",
-				sc->rxbufsize + sc->common.cachelsz - 1);
+				sc->rxbufsize);
 		return NULL;
 	}
 
 	*skb_addr = pci_map_single(sc->pdev,
 		skb->data, sc->rxbufsize, PCI_DMA_FROMDEVICE);
+
 	if (unlikely(pci_dma_mapping_error(sc->pdev, *skb_addr))) {
 		ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__);
 		dev_kfree_skb(skb);
@@ -1607,9 +1608,10 @@ ath5k_rx_start(struct ath5k_softc *sc)
 	int ret;
 
 	sc->rxbufsize = roundup(IEEE80211_MAX_LEN, sc->common.cachelsz);
+	sc->rxbufsize += sc->common.cachelsz - 1;
 
 	ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "cachelsz %u rxbufsize %u\n",
-		sc->common.cachelsz, sc->rxbufsize);
+		  sc->common.cachelsz, sc->rxbufsize);
 
 	spin_lock_bh(&sc->rxbuflock);
 	sc->rxlink = NULL;
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/1 ath5k: fix requested allocated RX skb size for DMA

drivers/net/wireless/ath/ath5k/base.c struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr) · line 1160

Quoted 7 lines · Luis R. Rodriguez
drivers/net/wireless/ath/ath5k/base.c +0 -1
@@ -1157,17 +1157,18 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)
 	 * fake physical layer header at the start.
 	 */
 	skb = ath_rxbuf_alloc(&sc->common,
-			      sc->rxbufsize + sc->common.cachelsz - 1,

What was the exact purpose of this? My guess is that we should map starting at a next cache line boundary and put this aligned address to the device instead?

#2 lore raw

PATCH 1/1 ath5k: fix requested allocated RX skb size for DMA

Quoted 12 lines · Jiri Slaby
Quoted 7 lines · Luis R. Rodriguez
drivers/net/wireless/ath/ath5k/base.c +0 -0
@@ -1157,17 +1157,18 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr)

? ? ? ?* fake physical layer header at the start.
? ? ? ?*/
? ? ? skb = ath_rxbuf_alloc(&sc->common,
- ? ? ? ? ? ? ? ? ? ? ? ? ? sc->rxbufsize + sc->common.cachelsz - 1,

What was the exact purpose of this? My guess is that we should map starting at a next cache line boundary and put this aligned address to the device instead?

I've heard two theories:

1) AR5210 *required* it otherwise bad we would get bad data
2) Performance considerations

I've tried checking internally but haven't found out yet the exact answer and this seems purely historical. I poked Sam Leffler to see if he recalls. But as we the 0x41 reset which I removed it seems to be best to leave unless we can be 100% sure we can remove this.

Luis

#3 lore raw

PATCH 1/1 ath5k: fix requested allocated RX skb size for DMA

Quoted 9 lines · Luis R. Rodriguez
Quoted 3 lines · Jiri Slaby

What was the exact purpose of this? My guess is that we should map starting at a next cache line boundary and put this aligned address to the device instead?

I've heard two theories:

1) AR5210 *required* it otherwise bad we would get bad data
2) Performance considerations

#4 lore raw

PATCH 1/1 ath5k: fix requested allocated RX skb size for DMA

John please ignore this patch, its busted, as Bob noted on IRC.

Luis