Split the skb/ptr union into separate skb and ptr fields to support keeping both the SKB pointer and page pool pointer at the same time. Also add skip_unmap flag to tx_info.buf to handle cases where DMA unmapping should be skipped. Signed-off-by: Eason Lai --- v2: revert to original naming for less intrusive --- drivers/net/wireless/mediatek/mt76/dma.c | 15 +++++++++++---- drivers/net/wireless/mediatek/mt76/mt76.h | 6 ++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 1658c37835cf..57632656eafa 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -43,6 +43,7 @@ mt76_alloc_rxwi(struct mt76_dev *dev) if (!t) return NULL; + t->skb = NULL; t->ptr = NULL; return t; } @@ -84,8 +85,11 @@ mt76_get_txwi(struct mt76_dev *dev) { struct mt76_txwi_cache *t = __mt76_get_txwi(dev); - if (t) + if (t) { + t->skb = NULL; + t->ptr = NULL; return t; + } return mt76_alloc_txwi(dev); } @@ -716,6 +720,7 @@ mt76_dma_tx_queue_skb(struct mt76_phy *phy, struct mt76_queue *q, goto unmap; tx_info.buf[n].addr = addr; + tx_info.buf[n].skip_unmap = false; tx_info.buf[n++].len = iter->len; } tx_info.nbuf = n; @@ -740,9 +745,11 @@ mt76_dma_tx_queue_skb(struct mt76_phy *phy, struct mt76_queue *q, tx_info.info, tx_info.skb, t); unmap: - for (n--; n > 0; n--) - dma_unmap_single(dev->dma_dev, tx_info.buf[n].addr, - tx_info.buf[n].len, DMA_TO_DEVICE); + for (n--; n > 0; n--) { + if (!tx_info.buf[n].skip_unmap) + dma_unmap_single(dev->dma_dev, tx_info.buf[n].addr, + tx_info.buf[n].len, DMA_TO_DEVICE); + } free: #ifdef CONFIG_NL80211_TESTMODE diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 0090e16e8f78..ec679d12a2af 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -446,10 +446,8 @@ struct mt76_txwi_cache { struct list_head list; dma_addr_t dma_addr; - union { - struct sk_buff *skb; - void *ptr; - }; + struct sk_buff *skb; + void *ptr; u8 qid; u8 phy_idx; -- 2.45.2