Skip to content

Commit dd57a95

Browse files
committed
mt76: move txwi handling code to dma.c, since it is mmio specific
This way we can make some functions static Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent ed294ce commit dd57a95

File tree

4 files changed

+72
-73
lines changed

4 files changed

+72
-73
lines changed

drivers/net/wireless/mediatek/mt76/dma.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,76 @@
77
#include "mt76.h"
88
#include "dma.h"
99

10+
static struct mt76_txwi_cache *
11+
mt76_alloc_txwi(struct mt76_dev *dev)
12+
{
13+
struct mt76_txwi_cache *t;
14+
dma_addr_t addr;
15+
u8 *txwi;
16+
int size;
17+
18+
size = L1_CACHE_ALIGN(dev->drv->txwi_size + sizeof(*t));
19+
txwi = devm_kzalloc(dev->dev, size, GFP_ATOMIC);
20+
if (!txwi)
21+
return NULL;
22+
23+
addr = dma_map_single(dev->dev, txwi, dev->drv->txwi_size,
24+
DMA_TO_DEVICE);
25+
t = (struct mt76_txwi_cache *)(txwi + dev->drv->txwi_size);
26+
t->dma_addr = addr;
27+
28+
return t;
29+
}
30+
31+
static struct mt76_txwi_cache *
32+
__mt76_get_txwi(struct mt76_dev *dev)
33+
{
34+
struct mt76_txwi_cache *t = NULL;
35+
36+
spin_lock(&dev->lock);
37+
if (!list_empty(&dev->txwi_cache)) {
38+
t = list_first_entry(&dev->txwi_cache, struct mt76_txwi_cache,
39+
list);
40+
list_del(&t->list);
41+
}
42+
spin_unlock(&dev->lock);
43+
44+
return t;
45+
}
46+
47+
static struct mt76_txwi_cache *
48+
mt76_get_txwi(struct mt76_dev *dev)
49+
{
50+
struct mt76_txwi_cache *t = __mt76_get_txwi(dev);
51+
52+
if (t)
53+
return t;
54+
55+
return mt76_alloc_txwi(dev);
56+
}
57+
58+
void
59+
mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t)
60+
{
61+
if (!t)
62+
return;
63+
64+
spin_lock(&dev->lock);
65+
list_add(&t->list, &dev->txwi_cache);
66+
spin_unlock(&dev->lock);
67+
}
68+
EXPORT_SYMBOL_GPL(mt76_put_txwi);
69+
70+
static void
71+
mt76_free_pending_txwi(struct mt76_dev *dev)
72+
{
73+
struct mt76_txwi_cache *t;
74+
75+
while ((t = __mt76_get_txwi(dev)) != NULL)
76+
dma_unmap_single(dev->dev, t->dma_addr, dev->drv->txwi_size,
77+
DMA_TO_DEVICE);
78+
}
79+
1080
static int
1181
mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q,
1282
int idx, int n_desc, int bufsize,
@@ -598,5 +668,7 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
598668
netif_napi_del(&dev->napi[i]);
599669
mt76_dma_rx_cleanup(dev, &dev->q_rx[i]);
600670
}
671+
672+
mt76_free_pending_txwi(dev);
601673
}
602674
EXPORT_SYMBOL_GPL(mt76_dma_cleanup);

drivers/net/wireless/mediatek/mt76/mac80211.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,6 @@ void mt76_free_device(struct mt76_dev *dev)
515515
destroy_workqueue(dev->wq);
516516
dev->wq = NULL;
517517
}
518-
if (mt76_is_mmio(dev))
519-
mt76_tx_free(dev);
520518
ieee80211_free_hw(dev->hw);
521519
}
522520
EXPORT_SYMBOL_GPL(mt76_free_device);

drivers/net/wireless/mediatek/mt76/mt76.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,6 @@ mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb)
10051005
return hw;
10061006
}
10071007

1008-
void mt76_tx_free(struct mt76_dev *dev);
1009-
struct mt76_txwi_cache *mt76_get_txwi(struct mt76_dev *dev);
10101008
void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t);
10111009
void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
10121010
struct napi_struct *napi);

drivers/net/wireless/mediatek/mt76/tx.c

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,6 @@
55

66
#include "mt76.h"
77

8-
static struct mt76_txwi_cache *
9-
mt76_alloc_txwi(struct mt76_dev *dev)
10-
{
11-
struct mt76_txwi_cache *t;
12-
dma_addr_t addr;
13-
u8 *txwi;
14-
int size;
15-
16-
size = L1_CACHE_ALIGN(dev->drv->txwi_size + sizeof(*t));
17-
txwi = devm_kzalloc(dev->dev, size, GFP_ATOMIC);
18-
if (!txwi)
19-
return NULL;
20-
21-
addr = dma_map_single(dev->dev, txwi, dev->drv->txwi_size,
22-
DMA_TO_DEVICE);
23-
t = (struct mt76_txwi_cache *)(txwi + dev->drv->txwi_size);
24-
t->dma_addr = addr;
25-
26-
return t;
27-
}
28-
29-
static struct mt76_txwi_cache *
30-
__mt76_get_txwi(struct mt76_dev *dev)
31-
{
32-
struct mt76_txwi_cache *t = NULL;
33-
34-
spin_lock_bh(&dev->lock);
35-
if (!list_empty(&dev->txwi_cache)) {
36-
t = list_first_entry(&dev->txwi_cache, struct mt76_txwi_cache,
37-
list);
38-
list_del(&t->list);
39-
}
40-
spin_unlock_bh(&dev->lock);
41-
42-
return t;
43-
}
44-
45-
struct mt76_txwi_cache *
46-
mt76_get_txwi(struct mt76_dev *dev)
47-
{
48-
struct mt76_txwi_cache *t = __mt76_get_txwi(dev);
49-
50-
if (t)
51-
return t;
52-
53-
return mt76_alloc_txwi(dev);
54-
}
55-
56-
void
57-
mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t)
58-
{
59-
if (!t)
60-
return;
61-
62-
spin_lock_bh(&dev->lock);
63-
list_add(&t->list, &dev->txwi_cache);
64-
spin_unlock_bh(&dev->lock);
65-
}
66-
EXPORT_SYMBOL_GPL(mt76_put_txwi);
67-
68-
void mt76_tx_free(struct mt76_dev *dev)
69-
{
70-
struct mt76_txwi_cache *t;
71-
72-
while ((t = __mt76_get_txwi(dev)) != NULL)
73-
dma_unmap_single(dev->dev, t->dma_addr, dev->drv->txwi_size,
74-
DMA_TO_DEVICE);
75-
}
76-
778
static int
789
mt76_txq_get_qid(struct ieee80211_txq *txq)
7910
{

0 commit comments

Comments
 (0)