developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 1 | From e3da91079dacc07f8e011f4b469e70bd78a93636 Mon Sep 17 00:00:00 2001 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Sat, 1 Apr 2023 08:18:17 +0800 |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 0999/1051] wifi: mt76: mt7915: build pass for Linux Kernel 5.4 |
developer | f9b0021 | 2023-07-31 12:27:06 +0800 | [diff] [blame] | 5 | fixes |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 8 | debugfs.c | 2 ++ |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 9 | dma.c | 73 ++++++++++++++++++++++++----------------------- |
| 10 | dma.h | 3 +- |
| 11 | eeprom.c | 8 +++++- |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 12 | mac80211.c | 56 ------------------------------------ |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 13 | mcu.c | 1 + |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 14 | mt76.h | 27 +----------------- |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 15 | mt7615/mcu.c | 1 + |
| 16 | mt76_connac.h | 2 -- |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 17 | mt76_connac_mcu.c | 47 +----------------------------- |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 18 | mt76_connac_mcu.h | 4 --- |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 19 | mt7915/main.c | 25 +++++++--------- |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 20 | mt7915/mcu.c | 1 + |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 21 | usb.c | 43 ++++++++++++++-------------- |
| 22 | wed.c | 62 +++++++++++++++++++++++++--------------- |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 23 | 15 files changed, 123 insertions(+), 232 deletions(-) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 24 | |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 25 | diff --git a/debugfs.c b/debugfs.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 26 | index c4649ba..1c8328d 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 27 | --- a/debugfs.c |
| 28 | +++ b/debugfs.c |
| 29 | @@ -33,8 +33,10 @@ mt76_napi_threaded_set(void *data, u64 val) |
| 30 | if (!mt76_is_mmio(dev)) |
| 31 | return -EOPNOTSUPP; |
| 32 | |
| 33 | +#if 0 /* disable in backport 5.15 */ |
| 34 | if (dev->napi_dev.threaded != val) |
| 35 | return dev_set_threaded(&dev->napi_dev, val); |
| 36 | +#endif |
| 37 | |
| 38 | return 0; |
| 39 | } |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 40 | diff --git a/dma.c b/dma.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 41 | index f4f88c4..ccdd564 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 42 | --- a/dma.c |
| 43 | +++ b/dma.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 44 | @@ -178,7 +178,7 @@ mt76_free_pending_rxwi(struct mt76_dev *dev) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 45 | local_bh_disable(); |
| 46 | while ((t = __mt76_get_rxwi(dev)) != NULL) { |
| 47 | if (t->ptr) |
| 48 | - mt76_put_page_pool_buf(t->ptr, false); |
| 49 | + skb_free_frag(t->ptr); |
| 50 | kfree(t); |
| 51 | } |
| 52 | local_bh_enable(); |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 53 | @@ -450,9 +450,9 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 54 | if (!t) |
| 55 | return NULL; |
| 56 | |
| 57 | - dma_sync_single_for_cpu(dev->dma_dev, t->dma_addr, |
| 58 | - SKB_WITH_OVERHEAD(q->buf_size), |
| 59 | - page_pool_get_dma_dir(q->page_pool)); |
| 60 | + dma_unmap_single(dev->dma_dev, t->dma_addr, |
| 61 | + SKB_WITH_OVERHEAD(q->buf_size), |
| 62 | + DMA_FROM_DEVICE); |
| 63 | |
| 64 | buf = t->ptr; |
| 65 | t->dma_addr = 0; |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 66 | @@ -462,9 +462,9 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 67 | if (drop) |
| 68 | *drop |= !!(buf1 & MT_DMA_CTL_WO_DROP); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 69 | } else { |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 70 | - dma_sync_single_for_cpu(dev->dma_dev, e->dma_addr[0], |
| 71 | - SKB_WITH_OVERHEAD(q->buf_size), |
| 72 | - page_pool_get_dma_dir(q->page_pool)); |
| 73 | + dma_unmap_single(dev->dma_dev, e->dma_addr[0], |
| 74 | + SKB_WITH_OVERHEAD(q->buf_size), |
| 75 | + DMA_FROM_DEVICE); |
| 76 | } |
| 77 | |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 78 | done: |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 79 | @@ -631,11 +631,11 @@ free_skb: |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 80 | return ret; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 81 | } |
| 82 | |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 83 | -int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q, |
| 84 | - bool allow_direct) |
| 85 | +int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 86 | { |
| 87 | int len = SKB_WITH_OVERHEAD(q->buf_size); |
| 88 | - int frames = 0; |
| 89 | + int frames = 0, offset = q->buf_offset; |
| 90 | + dma_addr_t addr; |
| 91 | |
| 92 | if (!q->ndesc) |
| 93 | return 0; |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 94 | @@ -643,30 +643,30 @@ int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 95 | spin_lock_bh(&q->lock); |
| 96 | |
| 97 | while (q->queued < q->ndesc - 1) { |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 98 | - struct mt76_queue_buf qbuf = {}; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 99 | - enum dma_data_direction dir; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 100 | - dma_addr_t addr; |
| 101 | - int offset; |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 102 | + struct mt76_queue_buf qbuf; |
| 103 | void *buf = NULL; |
| 104 | |
| 105 | if (mt76_queue_is_wed_rro_ind(q)) |
| 106 | goto done; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 107 | |
| 108 | - buf = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 109 | + buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC); |
| 110 | if (!buf) |
| 111 | break; |
| 112 | |
| 113 | - addr = page_pool_get_dma_addr(virt_to_head_page(buf)) + offset; |
| 114 | - dir = page_pool_get_dma_dir(q->page_pool); |
| 115 | - dma_sync_single_for_device(dev->dma_dev, addr, len, dir); |
| 116 | + addr = dma_map_single(dev->dma_dev, buf, len, DMA_FROM_DEVICE); |
| 117 | + if (unlikely(dma_mapping_error(dev->dma_dev, addr))) { |
| 118 | + skb_free_frag(buf); |
| 119 | + break; |
| 120 | + } |
| 121 | |
| 122 | - qbuf.addr = addr + q->buf_offset; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 123 | + qbuf.addr = addr + offset; |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 124 | done: |
| 125 | - qbuf.len = len - q->buf_offset; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 126 | + qbuf.len = len - offset; |
| 127 | qbuf.skip_unmap = false; |
| 128 | if (mt76_dma_add_rx_buf(dev, q, &qbuf, buf) < 0) { |
| 129 | - mt76_put_page_pool_buf(buf, allow_direct); |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 130 | - break; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 131 | + dma_unmap_single(dev->dma_dev, addr, len, |
| 132 | + DMA_FROM_DEVICE); |
| 133 | + skb_free_frag(buf); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 134 | } |
| 135 | frames++; |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 136 | } |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 137 | @@ -719,10 +719,6 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 138 | if (!q->entry) |
| 139 | return -ENOMEM; |
| 140 | |
| 141 | - ret = mt76_create_page_pool(dev, q); |
| 142 | - if (ret) |
| 143 | - return ret; |
| 144 | - |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 145 | ret = mt76_wed_dma_setup(dev, q, false); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 146 | if (ret) |
| 147 | return ret; |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 148 | @@ -741,6 +737,7 @@ mt76_dma_alloc_queue(struct mt76_dev *dev, struct mt76_queue *q, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 149 | static void |
| 150 | mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q) |
| 151 | { |
| 152 | + struct page *page; |
| 153 | void *buf; |
| 154 | bool more; |
| 155 | |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 156 | @@ -756,7 +753,7 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 157 | break; |
| 158 | |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 159 | if (!mt76_queue_is_wed_rro(q)) |
| 160 | - mt76_put_page_pool_buf(buf, false); |
| 161 | + skb_free_frag(buf); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 162 | } while (1); |
| 163 | |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 164 | spin_lock_bh(&q->lock); |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 165 | @@ -766,6 +763,13 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | spin_unlock_bh(&q->lock); |
| 169 | + |
| 170 | + if (!q->rx_page.va) |
| 171 | + return; |
| 172 | + |
| 173 | + page = virt_to_page(q->rx_page.va); |
| 174 | + __page_frag_cache_drain(page, q->rx_page.pagecnt_bias); |
| 175 | + memset(&q->rx_page, 0, sizeof(q->rx_page)); |
| 176 | } |
| 177 | |
| 178 | static void |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 179 | @@ -796,7 +800,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid) |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 180 | return; |
| 181 | |
| 182 | mt76_dma_sync_idx(dev, q); |
| 183 | - mt76_dma_rx_fill(dev, q, false); |
| 184 | + mt76_dma_rx_fill(dev, q); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 185 | } |
| 186 | |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 187 | static void |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 188 | @@ -813,7 +817,7 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 189 | |
| 190 | skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size); |
| 191 | } else { |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 192 | - mt76_put_page_pool_buf(data, allow_direct); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 193 | + skb_free_frag(data); |
| 194 | } |
| 195 | |
| 196 | if (more) |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 197 | @@ -883,12 +887,11 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 198 | !(dev->drv->rx_check(dev, data, len))) |
| 199 | goto free_frag; |
| 200 | |
| 201 | - skb = napi_build_skb(data, q->buf_size); |
| 202 | + skb = build_skb(data, q->buf_size); |
| 203 | if (!skb) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 204 | goto free_frag; |
| 205 | |
| 206 | skb_reserve(skb, q->buf_offset); |
| 207 | - skb_mark_for_recycle(skb); |
| 208 | |
| 209 | *(u32 *)skb->cb = info; |
| 210 | |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 211 | @@ -904,10 +907,10 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 212 | continue; |
| 213 | |
| 214 | free_frag: |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 215 | - mt76_put_page_pool_buf(data, allow_direct); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 216 | + skb_free_frag(data); |
| 217 | } |
| 218 | |
| 219 | - mt76_dma_rx_fill(dev, q, true); |
| 220 | + mt76_dma_rx_fill(dev, q); |
| 221 | return done; |
| 222 | } |
| 223 | |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 224 | @@ -952,7 +955,7 @@ mt76_dma_init(struct mt76_dev *dev, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 225 | |
| 226 | mt76_for_each_q_rx(dev, i) { |
| 227 | netif_napi_add(&dev->napi_dev, &dev->napi[i], poll); |
| 228 | - mt76_dma_rx_fill(dev, &dev->q_rx[i], false); |
| 229 | + mt76_dma_rx_fill(dev, &dev->q_rx[i]); |
| 230 | napi_enable(&dev->napi[i]); |
| 231 | } |
| 232 | |
developer | a46f613 | 2024-03-26 14:09:54 +0800 | [diff] [blame] | 233 | @@ -1007,8 +1010,6 @@ void mt76_dma_cleanup(struct mt76_dev *dev) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 234 | |
| 235 | netif_napi_del(&dev->napi[i]); |
| 236 | mt76_dma_rx_cleanup(dev, q); |
| 237 | - |
| 238 | - page_pool_destroy(q->page_pool); |
| 239 | } |
| 240 | |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 241 | if (mtk_wed_device_active(&dev->mmio.wed)) |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 242 | diff --git a/dma.h b/dma.h |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 243 | index 1de5a2b..619dc0f 100644 |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 244 | --- a/dma.h |
| 245 | +++ b/dma.h |
| 246 | @@ -79,8 +79,7 @@ enum mt76_dma_wed_ind_reason { |
| 247 | int mt76_dma_rx_poll(struct napi_struct *napi, int budget); |
| 248 | void mt76_dma_attach(struct mt76_dev *dev); |
| 249 | void mt76_dma_cleanup(struct mt76_dev *dev); |
| 250 | -int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q, |
| 251 | - bool allow_direct); |
| 252 | +int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q); |
| 253 | void __mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q, |
| 254 | bool reset_idx); |
| 255 | void mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q); |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 256 | diff --git a/eeprom.c b/eeprom.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 257 | index ecd09c0..a267397 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 258 | --- a/eeprom.c |
| 259 | +++ b/eeprom.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 260 | @@ -163,9 +163,15 @@ void |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 261 | mt76_eeprom_override(struct mt76_phy *phy) |
| 262 | { |
| 263 | struct mt76_dev *dev = phy->dev; |
| 264 | +#ifdef CONFIG_OF |
| 265 | struct device_node *np = dev->dev->of_node; |
| 266 | + const u8 *mac = NULL; |
| 267 | |
| 268 | - of_get_mac_address(np, phy->macaddr); |
| 269 | + if (np) |
| 270 | + mac = of_get_mac_address(np); |
| 271 | + if (!IS_ERR_OR_NULL(mac)) |
| 272 | + ether_addr_copy(phy->macaddr, mac); |
| 273 | +#endif |
| 274 | |
| 275 | if (!is_valid_ether_addr(phy->macaddr)) { |
| 276 | eth_random_addr(phy->macaddr); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 277 | diff --git a/mac80211.c b/mac80211.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 278 | index bc20f60..b30a74e 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 279 | --- a/mac80211.c |
| 280 | +++ b/mac80211.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 281 | @@ -577,47 +577,6 @@ void mt76_unregister_phy(struct mt76_phy *phy) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 282 | } |
| 283 | EXPORT_SYMBOL_GPL(mt76_unregister_phy); |
| 284 | |
| 285 | -int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q) |
| 286 | -{ |
| 287 | - struct page_pool_params pp_params = { |
| 288 | - .order = 0, |
| 289 | - .flags = PP_FLAG_PAGE_FRAG, |
| 290 | - .nid = NUMA_NO_NODE, |
| 291 | - .dev = dev->dma_dev, |
| 292 | - }; |
| 293 | - int idx = q - dev->q_rx; |
| 294 | - |
| 295 | - switch (idx) { |
| 296 | - case MT_RXQ_MAIN: |
| 297 | - case MT_RXQ_BAND1: |
| 298 | - case MT_RXQ_BAND2: |
| 299 | - pp_params.pool_size = 256; |
| 300 | - break; |
| 301 | - default: |
| 302 | - pp_params.pool_size = 16; |
| 303 | - break; |
| 304 | - } |
| 305 | - |
| 306 | - if (mt76_is_mmio(dev)) { |
| 307 | - /* rely on page_pool for DMA mapping */ |
| 308 | - pp_params.flags |= PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; |
| 309 | - pp_params.dma_dir = DMA_FROM_DEVICE; |
| 310 | - pp_params.max_len = PAGE_SIZE; |
| 311 | - pp_params.offset = 0; |
| 312 | - } |
| 313 | - |
| 314 | - q->page_pool = page_pool_create(&pp_params); |
| 315 | - if (IS_ERR(q->page_pool)) { |
| 316 | - int err = PTR_ERR(q->page_pool); |
| 317 | - |
| 318 | - q->page_pool = NULL; |
| 319 | - return err; |
| 320 | - } |
| 321 | - |
| 322 | - return 0; |
| 323 | -} |
| 324 | -EXPORT_SYMBOL_GPL(mt76_create_page_pool); |
| 325 | - |
| 326 | struct mt76_dev * |
| 327 | mt76_alloc_device(struct device *pdev, unsigned int size, |
| 328 | const struct ieee80211_ops *ops, |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 329 | @@ -1817,21 +1776,6 @@ void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 330 | } |
| 331 | EXPORT_SYMBOL_GPL(mt76_ethtool_worker); |
| 332 | |
| 333 | -void mt76_ethtool_page_pool_stats(struct mt76_dev *dev, u64 *data, int *index) |
| 334 | -{ |
| 335 | -#ifdef CONFIG_PAGE_POOL_STATS |
| 336 | - struct page_pool_stats stats = {}; |
| 337 | - int i; |
| 338 | - |
| 339 | - mt76_for_each_q_rx(dev, i) |
| 340 | - page_pool_get_stats(dev->q_rx[i].page_pool, &stats); |
| 341 | - |
| 342 | - page_pool_ethtool_stats_get(data, &stats); |
| 343 | - *index += page_pool_ethtool_stats_get_count(); |
| 344 | -#endif |
| 345 | -} |
| 346 | -EXPORT_SYMBOL_GPL(mt76_ethtool_page_pool_stats); |
| 347 | - |
| 348 | enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy) |
| 349 | { |
| 350 | struct ieee80211_hw *hw = phy->hw; |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 351 | diff --git a/mcu.c b/mcu.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 352 | index a8cafa3..fa4b054 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 353 | --- a/mcu.c |
| 354 | +++ b/mcu.c |
| 355 | @@ -4,6 +4,7 @@ |
| 356 | */ |
| 357 | |
| 358 | #include "mt76.h" |
| 359 | +#include <linux/moduleparam.h> |
| 360 | |
| 361 | struct sk_buff * |
| 362 | __mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 363 | diff --git a/mt76.h b/mt76.h |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 364 | index b83456b..a07c7df 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 365 | --- a/mt76.h |
| 366 | +++ b/mt76.h |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 367 | @@ -15,11 +15,6 @@ |
| 368 | #include <linux/average.h> |
| 369 | #include <linux/soc/mediatek/mtk_wed.h> |
| 370 | #include <net/mac80211.h> |
| 371 | -#if LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0) |
| 372 | -#include <net/page_pool.h> |
| 373 | -#else |
| 374 | -#include <net/page_pool/helpers.h> |
| 375 | -#endif |
| 376 | #include "util.h" |
| 377 | #include "testmode.h" |
| 378 | |
| 379 | @@ -238,7 +233,7 @@ struct mt76_queue { |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 380 | |
| 381 | dma_addr_t desc_dma; |
| 382 | struct sk_buff *rx_head; |
| 383 | - struct page_pool *page_pool; |
| 384 | + struct page_frag_cache rx_page; |
| 385 | }; |
| 386 | |
| 387 | struct mt76_mcu_ops { |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 388 | @@ -1527,7 +1522,6 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 389 | return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout); |
| 390 | } |
| 391 | |
| 392 | -void mt76_ethtool_page_pool_stats(struct mt76_dev *dev, u64 *data, int *index); |
| 393 | void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, |
| 394 | struct mt76_sta_stats *stats, bool eht); |
| 395 | int mt76_skb_adjust_pad(struct sk_buff *skb, int pad); |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 396 | @@ -1673,25 +1667,6 @@ void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 397 | struct mt76_txwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 398 | int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 399 | struct mt76_txwi_cache *r, dma_addr_t phys); |
| 400 | -int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q); |
| 401 | -static inline void mt76_put_page_pool_buf(void *buf, bool allow_direct) |
| 402 | -{ |
| 403 | - struct page *page = virt_to_head_page(buf); |
| 404 | - |
| 405 | - page_pool_put_full_page(page->pp, page, allow_direct); |
| 406 | -} |
| 407 | - |
| 408 | -static inline void * |
| 409 | -mt76_get_page_pool_buf(struct mt76_queue *q, u32 *offset, u32 size) |
| 410 | -{ |
| 411 | - struct page *page; |
| 412 | - |
| 413 | - page = page_pool_dev_alloc_frag(q->page_pool, offset, size); |
| 414 | - if (!page) |
| 415 | - return NULL; |
| 416 | - |
| 417 | - return page_address(page) + *offset; |
| 418 | -} |
| 419 | |
| 420 | static inline void mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked) |
| 421 | { |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 422 | diff --git a/mt7615/mcu.c b/mt7615/mcu.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 423 | index ae34d01..c9444c6 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 424 | --- a/mt7615/mcu.c |
| 425 | +++ b/mt7615/mcu.c |
| 426 | @@ -10,6 +10,7 @@ |
| 427 | #include "mcu.h" |
| 428 | #include "mac.h" |
| 429 | #include "eeprom.h" |
| 430 | +#include <linux/moduleparam.h> |
| 431 | |
| 432 | static bool prefer_offload_fw = true; |
| 433 | module_param(prefer_offload_fw, bool, 0644); |
| 434 | diff --git a/mt76_connac.h b/mt76_connac.h |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 435 | index 4871857..8e7068c 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 436 | --- a/mt76_connac.h |
| 437 | +++ b/mt76_connac.h |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 438 | @@ -56,7 +56,6 @@ enum { |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 439 | CMD_CBW_10MHZ, |
| 440 | CMD_CBW_5MHZ, |
| 441 | CMD_CBW_8080MHZ, |
| 442 | - CMD_CBW_320MHZ, |
| 443 | |
| 444 | CMD_HE_MCS_BW80 = 0, |
| 445 | CMD_HE_MCS_BW160, |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 446 | @@ -292,7 +291,6 @@ static inline u8 mt76_connac_chan_bw(struct cfg80211_chan_def *chandef) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 447 | [NL80211_CHAN_WIDTH_10] = CMD_CBW_10MHZ, |
| 448 | [NL80211_CHAN_WIDTH_20] = CMD_CBW_20MHZ, |
| 449 | [NL80211_CHAN_WIDTH_20_NOHT] = CMD_CBW_20MHZ, |
| 450 | - [NL80211_CHAN_WIDTH_320] = CMD_CBW_320MHZ, |
| 451 | }; |
| 452 | |
| 453 | if (chandef->width >= ARRAY_SIZE(width_to_bw)) |
| 454 | diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 455 | index 1ea9798..a8f097d 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 456 | --- a/mt76_connac_mcu.c |
| 457 | +++ b/mt76_connac_mcu.c |
| 458 | @@ -4,6 +4,7 @@ |
| 459 | #include <linux/firmware.h> |
| 460 | #include "mt76_connac2_mac.h" |
| 461 | #include "mt76_connac_mcu.h" |
| 462 | +#include <linux/module.h> |
| 463 | |
| 464 | int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option) |
| 465 | { |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 466 | @@ -1357,40 +1358,6 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 467 | } |
| 468 | EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode); |
| 469 | |
| 470 | -u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 471 | - enum nl80211_band band) |
| 472 | -{ |
| 473 | - const struct ieee80211_sta_eht_cap *eht_cap; |
| 474 | - struct ieee80211_supported_band *sband; |
| 475 | - u8 mode = 0; |
| 476 | - |
| 477 | - if (band == NL80211_BAND_6GHZ) |
| 478 | - mode |= PHY_MODE_AX_6G; |
| 479 | - |
| 480 | - sband = phy->hw->wiphy->bands[band]; |
| 481 | - eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type); |
| 482 | - |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 483 | - if (!eht_cap || !eht_cap->has_eht || !vif->bss_conf.eht_support) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 484 | - return mode; |
| 485 | - |
| 486 | - switch (band) { |
| 487 | - case NL80211_BAND_6GHZ: |
| 488 | - mode |= PHY_MODE_BE_6G; |
| 489 | - break; |
| 490 | - case NL80211_BAND_5GHZ: |
| 491 | - mode |= PHY_MODE_BE_5G; |
| 492 | - break; |
| 493 | - case NL80211_BAND_2GHZ: |
| 494 | - mode |= PHY_MODE_BE_24G; |
| 495 | - break; |
| 496 | - default: |
| 497 | - break; |
| 498 | - } |
| 499 | - |
| 500 | - return mode; |
| 501 | -} |
| 502 | -EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode_ext); |
| 503 | - |
| 504 | const struct ieee80211_sta_he_cap * |
| 505 | mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif) |
| 506 | { |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 507 | @@ -1406,18 +1373,6 @@ mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 508 | } |
| 509 | EXPORT_SYMBOL_GPL(mt76_connac_get_he_phy_cap); |
| 510 | |
| 511 | -const struct ieee80211_sta_eht_cap * |
| 512 | -mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif) |
| 513 | -{ |
| 514 | - enum nl80211_band band = phy->chandef.chan->band; |
| 515 | - struct ieee80211_supported_band *sband; |
| 516 | - |
| 517 | - sband = phy->hw->wiphy->bands[band]; |
| 518 | - |
| 519 | - return ieee80211_get_eht_iftype_cap(sband, vif->type); |
| 520 | -} |
| 521 | -EXPORT_SYMBOL_GPL(mt76_connac_get_eht_phy_cap); |
| 522 | - |
| 523 | #define DEFAULT_HE_PE_DURATION 4 |
| 524 | #define DEFAULT_HE_DURATION_RTS_THRES 1023 |
| 525 | static void |
| 526 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 527 | index 0936c1c..99cdd1b 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 528 | --- a/mt76_connac_mcu.h |
| 529 | +++ b/mt76_connac_mcu.h |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 530 | @@ -1985,12 +1985,8 @@ void mt76_connac_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val); |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 531 | |
| 532 | const struct ieee80211_sta_he_cap * |
| 533 | mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); |
| 534 | -const struct ieee80211_sta_eht_cap * |
| 535 | -mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); |
| 536 | u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 537 | enum nl80211_band band, struct ieee80211_sta *sta); |
| 538 | -u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 539 | - enum nl80211_band band); |
| 540 | |
| 541 | int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 542 | struct mt76_connac_sta_key_conf *sta_key_conf, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 543 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 544 | index 3783849..1da1d32 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 545 | --- a/mt7915/main.c |
| 546 | +++ b/mt7915/main.c |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 547 | @@ -1440,22 +1440,20 @@ void mt7915_get_et_strings(struct ieee80211_hw *hw, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 548 | struct ieee80211_vif *vif, |
| 549 | u32 sset, u8 *data) |
| 550 | { |
| 551 | - if (sset != ETH_SS_STATS) |
| 552 | - return; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 553 | + if (sset == ETH_SS_STATS) |
| 554 | + memcpy(data, *mt7915_gstrings_stats, |
| 555 | + sizeof(mt7915_gstrings_stats)); |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 556 | |
| 557 | - memcpy(data, mt7915_gstrings_stats, sizeof(mt7915_gstrings_stats)); |
| 558 | - data += sizeof(mt7915_gstrings_stats); |
| 559 | - page_pool_ethtool_stats_get_strings(data); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | static |
| 563 | int mt7915_get_et_sset_count(struct ieee80211_hw *hw, |
| 564 | struct ieee80211_vif *vif, int sset) |
| 565 | { |
| 566 | - if (sset != ETH_SS_STATS) |
| 567 | - return 0; |
| 568 | + if (sset == ETH_SS_STATS) |
| 569 | + return MT7915_SSTATS_LEN; |
| 570 | |
| 571 | - return MT7915_SSTATS_LEN + page_pool_ethtool_stats_get_count(); |
| 572 | + return 0; |
| 573 | } |
| 574 | |
| 575 | static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 576 | @@ -1483,7 +1481,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 577 | .idx = mvif->mt76.idx, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 578 | }; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 579 | /* See mt7915_ampdu_stat_read_phy, etc */ |
| 580 | - int i, ei = 0, stats_size; |
| 581 | + int i, ei = 0; |
| 582 | |
| 583 | mutex_lock(&dev->mt76.mutex); |
| 584 | |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 585 | @@ -1595,12 +1593,9 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 586 | return; |
| 587 | |
| 588 | ei += wi.worker_stat_count; |
| 589 | - |
| 590 | - mt76_ethtool_page_pool_stats(&dev->mt76, &data[ei], &ei); |
| 591 | - |
| 592 | - stats_size = MT7915_SSTATS_LEN + page_pool_ethtool_stats_get_count(); |
| 593 | - if (ei != stats_size) |
| 594 | - dev_err(dev->mt76.dev, "ei: %d size: %d", ei, stats_size); |
| 595 | + if (ei != MT7915_SSTATS_LEN) |
| 596 | + dev_err(dev->mt76.dev, "ei: %d MT7915_SSTATS_LEN: %d", |
| 597 | + ei, (int)MT7915_SSTATS_LEN); |
| 598 | } |
| 599 | |
| 600 | static void |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 601 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | a20cdc2 | 2024-05-31 18:57:31 +0800 | [diff] [blame^] | 602 | index 64d2710..91a1031 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 603 | --- a/mt7915/mcu.c |
| 604 | +++ b/mt7915/mcu.c |
| 605 | @@ -6,6 +6,7 @@ |
| 606 | #include "mcu.h" |
| 607 | #include "mac.h" |
| 608 | #include "eeprom.h" |
| 609 | +#include <linux/moduleparam.h> |
| 610 | |
| 611 | #define fw_name(_dev, name, ...) ({ \ |
| 612 | char *_fw; \ |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 613 | diff --git a/usb.c b/usb.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 614 | index dc690d1..058f2d1 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 615 | --- a/usb.c |
| 616 | +++ b/usb.c |
| 617 | @@ -319,27 +319,29 @@ mt76u_set_endpoints(struct usb_interface *intf, |
| 618 | |
| 619 | static int |
| 620 | mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, |
| 621 | - int nsgs) |
| 622 | + int nsgs, gfp_t gfp) |
| 623 | { |
| 624 | int i; |
| 625 | |
| 626 | for (i = 0; i < nsgs; i++) { |
| 627 | + struct page *page; |
| 628 | void *data; |
| 629 | int offset; |
| 630 | |
| 631 | - data = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 632 | + data = page_frag_alloc(&q->rx_page, q->buf_size, gfp); |
| 633 | if (!data) |
| 634 | break; |
| 635 | |
| 636 | - sg_set_page(&urb->sg[i], virt_to_head_page(data), q->buf_size, |
| 637 | - offset); |
| 638 | + page = virt_to_head_page(data); |
| 639 | + offset = data - page_address(page); |
| 640 | + sg_set_page(&urb->sg[i], page, q->buf_size, offset); |
| 641 | } |
| 642 | |
| 643 | if (i < nsgs) { |
| 644 | int j; |
| 645 | |
| 646 | for (j = nsgs; j < urb->num_sgs; j++) |
| 647 | - mt76_put_page_pool_buf(sg_virt(&urb->sg[j]), false); |
| 648 | + skb_free_frag(sg_virt(&urb->sg[j])); |
| 649 | urb->num_sgs = i; |
| 650 | } |
| 651 | |
| 652 | @@ -352,16 +354,15 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, |
| 653 | |
| 654 | static int |
| 655 | mt76u_refill_rx(struct mt76_dev *dev, struct mt76_queue *q, |
| 656 | - struct urb *urb, int nsgs) |
| 657 | + struct urb *urb, int nsgs, gfp_t gfp) |
| 658 | { |
| 659 | enum mt76_rxq_id qid = q - &dev->q_rx[MT_RXQ_MAIN]; |
| 660 | - int offset; |
| 661 | |
| 662 | if (qid == MT_RXQ_MAIN && dev->usb.sg_en) |
| 663 | - return mt76u_fill_rx_sg(dev, q, urb, nsgs); |
| 664 | + return mt76u_fill_rx_sg(dev, q, urb, nsgs, gfp); |
| 665 | |
| 666 | urb->transfer_buffer_length = q->buf_size; |
| 667 | - urb->transfer_buffer = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 668 | + urb->transfer_buffer = page_frag_alloc(&q->rx_page, q->buf_size, gfp); |
| 669 | |
| 670 | return urb->transfer_buffer ? 0 : -ENOMEM; |
| 671 | } |
| 672 | @@ -399,7 +400,7 @@ mt76u_rx_urb_alloc(struct mt76_dev *dev, struct mt76_queue *q, |
| 673 | if (err) |
| 674 | return err; |
| 675 | |
| 676 | - return mt76u_refill_rx(dev, q, e->urb, sg_size); |
| 677 | + return mt76u_refill_rx(dev, q, e->urb, sg_size, GFP_KERNEL); |
| 678 | } |
| 679 | |
| 680 | static void mt76u_urb_free(struct urb *urb) |
| 681 | @@ -407,10 +408,10 @@ static void mt76u_urb_free(struct urb *urb) |
| 682 | int i; |
| 683 | |
| 684 | for (i = 0; i < urb->num_sgs; i++) |
| 685 | - mt76_put_page_pool_buf(sg_virt(&urb->sg[i]), false); |
| 686 | + skb_free_frag(sg_virt(&urb->sg[i])); |
| 687 | |
| 688 | if (urb->transfer_buffer) |
| 689 | - mt76_put_page_pool_buf(urb->transfer_buffer, false); |
| 690 | + skb_free_frag(urb->transfer_buffer); |
| 691 | |
| 692 | usb_free_urb(urb); |
| 693 | } |
| 694 | @@ -546,8 +547,6 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb, |
| 695 | len -= data_len; |
| 696 | nsgs++; |
| 697 | } |
| 698 | - |
| 699 | - skb_mark_for_recycle(skb); |
| 700 | dev->drv->rx_skb(dev, MT_RXQ_MAIN, skb, NULL); |
| 701 | |
| 702 | return nsgs; |
| 703 | @@ -613,7 +612,7 @@ mt76u_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) |
| 704 | |
| 705 | count = mt76u_process_rx_entry(dev, urb, q->buf_size); |
| 706 | if (count > 0) { |
| 707 | - err = mt76u_refill_rx(dev, q, urb, count); |
| 708 | + err = mt76u_refill_rx(dev, q, urb, count, GFP_ATOMIC); |
| 709 | if (err < 0) |
| 710 | break; |
| 711 | } |
| 712 | @@ -664,10 +663,6 @@ mt76u_alloc_rx_queue(struct mt76_dev *dev, enum mt76_rxq_id qid) |
| 713 | struct mt76_queue *q = &dev->q_rx[qid]; |
| 714 | int i, err; |
| 715 | |
| 716 | - err = mt76_create_page_pool(dev, q); |
| 717 | - if (err) |
| 718 | - return err; |
| 719 | - |
| 720 | spin_lock_init(&q->lock); |
| 721 | q->entry = devm_kcalloc(dev->dev, |
| 722 | MT_NUM_RX_ENTRIES, sizeof(*q->entry), |
| 723 | @@ -696,6 +691,7 @@ EXPORT_SYMBOL_GPL(mt76u_alloc_mcu_queue); |
| 724 | static void |
| 725 | mt76u_free_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) |
| 726 | { |
| 727 | + struct page *page; |
| 728 | int i; |
| 729 | |
| 730 | for (i = 0; i < q->ndesc; i++) { |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 731 | @@ -705,8 +701,13 @@ mt76u_free_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 732 | mt76u_urb_free(q->entry[i].urb); |
| 733 | q->entry[i].urb = NULL; |
| 734 | } |
| 735 | - page_pool_destroy(q->page_pool); |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 736 | - q->page_pool = NULL; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 737 | + |
| 738 | + if (!q->rx_page.va) |
| 739 | + return; |
| 740 | + |
| 741 | + page = virt_to_page(q->rx_page.va); |
| 742 | + __page_frag_cache_drain(page, q->rx_page.pagecnt_bias); |
| 743 | + memset(&q->rx_page, 0, sizeof(q->rx_page)); |
| 744 | } |
| 745 | |
| 746 | static void mt76u_free_rx(struct mt76_dev *dev) |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 747 | diff --git a/wed.c b/wed.c |
developer | dc9eeae | 2024-04-08 14:36:46 +0800 | [diff] [blame] | 748 | index f89e453..f7a3f1b 100644 |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame] | 749 | --- a/wed.c |
| 750 | +++ b/wed.c |
| 751 | @@ -9,8 +9,12 @@ |
| 752 | void mt76_wed_release_rx_buf(struct mtk_wed_device *wed) |
| 753 | { |
| 754 | struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed); |
| 755 | + u32 length; |
| 756 | int i; |
| 757 | |
| 758 | + length = SKB_DATA_ALIGN(NET_SKB_PAD + wed->wlan.rx_size + |
| 759 | + sizeof(struct skb_shared_info)); |
| 760 | + |
| 761 | for (i = 0; i < dev->rx_token_size; i++) { |
| 762 | struct mt76_txwi_cache *t; |
| 763 | |
| 764 | @@ -18,7 +22,9 @@ void mt76_wed_release_rx_buf(struct mtk_wed_device *wed) |
| 765 | if (!t || !t->ptr) |
| 766 | continue; |
| 767 | |
| 768 | - mt76_put_page_pool_buf(t->ptr, false); |
| 769 | + dma_unmap_single(dev->dma_dev, t->dma_addr, |
| 770 | + wed->wlan.rx_size, DMA_FROM_DEVICE); |
| 771 | + __free_pages(virt_to_page(t->ptr), get_order(length)); |
| 772 | t->ptr = NULL; |
| 773 | |
| 774 | mt76_put_rxwi(dev, t); |
| 775 | @@ -33,39 +39,51 @@ u32 mt76_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
| 776 | { |
| 777 | struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed); |
| 778 | struct mtk_wed_bm_desc *desc = wed->rx_buf_ring.desc; |
| 779 | - struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN]; |
| 780 | - int i, len = SKB_WITH_OVERHEAD(q->buf_size); |
| 781 | - struct mt76_txwi_cache *t = NULL; |
| 782 | + u32 length; |
| 783 | + int i; |
| 784 | + |
| 785 | + length = SKB_DATA_ALIGN(NET_SKB_PAD + wed->wlan.rx_size + |
| 786 | + sizeof(struct skb_shared_info)); |
| 787 | |
| 788 | for (i = 0; i < size; i++) { |
| 789 | - enum dma_data_direction dir; |
| 790 | - dma_addr_t addr; |
| 791 | - u32 offset; |
| 792 | + struct mt76_txwi_cache *t = mt76_get_rxwi(dev); |
| 793 | + dma_addr_t phy_addr; |
| 794 | + struct page *page; |
| 795 | int token; |
| 796 | - void *buf; |
| 797 | + void *ptr; |
| 798 | |
| 799 | - t = mt76_get_rxwi(dev); |
| 800 | if (!t) |
| 801 | goto unmap; |
| 802 | |
| 803 | - buf = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 804 | - if (!buf) |
| 805 | + page = __dev_alloc_pages(GFP_KERNEL, get_order(length)); |
| 806 | + if (!page) { |
| 807 | + mt76_put_rxwi(dev, t); |
| 808 | goto unmap; |
| 809 | + } |
| 810 | |
| 811 | - addr = page_pool_get_dma_addr(virt_to_head_page(buf)) + offset; |
| 812 | - dir = page_pool_get_dma_dir(q->page_pool); |
| 813 | - dma_sync_single_for_device(dev->dma_dev, addr, len, dir); |
| 814 | + ptr = page_address(page); |
| 815 | + phy_addr = dma_map_single(dev->dma_dev, ptr, |
| 816 | + wed->wlan.rx_size, |
| 817 | + DMA_TO_DEVICE); |
| 818 | + if (unlikely(dma_mapping_error(dev->dev, phy_addr))) { |
| 819 | + __free_pages(page, get_order(length)); |
| 820 | + mt76_put_rxwi(dev, t); |
| 821 | + goto unmap; |
| 822 | + } |
| 823 | |
| 824 | - desc->buf0 = cpu_to_le32(addr); |
| 825 | - token = mt76_rx_token_consume(dev, buf, t, addr); |
| 826 | + desc->buf0 = cpu_to_le32(phy_addr); |
| 827 | + token = mt76_rx_token_consume(dev, ptr, t, phy_addr); |
| 828 | if (token < 0) { |
| 829 | - mt76_put_page_pool_buf(buf, false); |
| 830 | + dma_unmap_single(dev->dma_dev, phy_addr, |
| 831 | + wed->wlan.rx_size, DMA_TO_DEVICE); |
| 832 | + __free_pages(page, get_order(length)); |
| 833 | + mt76_put_rxwi(dev, t); |
| 834 | goto unmap; |
| 835 | } |
| 836 | |
| 837 | token = FIELD_PREP(MT_DMA_CTL_TOKEN, token); |
| 838 | #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT |
| 839 | - token |= FIELD_PREP(MT_DMA_CTL_SDP0_H, addr >> 32); |
| 840 | + token |= FIELD_PREP(MT_DMA_CTL_SDP0_H, phy_addr >> 32); |
| 841 | #endif |
| 842 | desc->token |= cpu_to_le32(token); |
| 843 | desc++; |
| 844 | @@ -74,8 +92,6 @@ u32 mt76_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
| 845 | return 0; |
| 846 | |
| 847 | unmap: |
| 848 | - if (t) |
| 849 | - mt76_put_rxwi(dev, t); |
| 850 | mt76_wed_release_rx_buf(wed); |
| 851 | |
| 852 | return -ENOMEM; |
| 853 | @@ -123,7 +139,7 @@ int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| 854 | /* WED txfree queue needs ring to be initialized before setup */ |
| 855 | q->flags = 0; |
| 856 | mt76_dma_queue_reset(dev, q); |
| 857 | - mt76_dma_rx_fill(dev, q, false); |
| 858 | + mt76_dma_rx_fill(dev, q); |
| 859 | |
| 860 | ret = mtk_wed_device_txfree_ring_setup(q->wed, q->regs); |
| 861 | if (!ret) |
| 862 | @@ -144,7 +160,7 @@ int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| 863 | break; |
| 864 | case MT76_WED_RRO_Q_MSDU_PG: |
| 865 | q->flags &= ~MT_QFLAG_WED; |
| 866 | - __mt76_dma_queue_reset(dev, q, false); |
| 867 | + __mt76_dma_queue_reset(dev, q); |
| 868 | mtk_wed_device_msdu_pg_rx_ring_setup(q->wed, ring, q->regs); |
| 869 | q->head = q->ndesc - 1; |
| 870 | q->queued = q->head; |
| 871 | @@ -152,7 +168,7 @@ int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| 872 | case MT76_WED_RRO_Q_IND: |
| 873 | q->flags &= ~MT_QFLAG_WED; |
| 874 | mt76_dma_queue_reset(dev, q); |
| 875 | - mt76_dma_rx_fill(dev, q, false); |
| 876 | + mt76_dma_rx_fill(dev, q); |
| 877 | mtk_wed_device_ind_rx_ring_setup(q->wed, q->regs); |
| 878 | break; |
| 879 | default: |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 880 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 881 | 2.18.0 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 882 | |