developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 1 | From 1ee5da0c9bab77e2659c62bad6458458e5b7e079 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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 0999/1048] 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 +++++- |
| 12 | mac80211.c | 57 ------------------------------------ |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 13 | mcu.c | 1 + |
| 14 | mt76.h | 22 +------------- |
| 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 +++++++++++++++++++++++++--------------- |
| 23 | 15 files changed, 123 insertions(+), 228 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 | bd9fa1e | 2023-10-16 11:04:00 +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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 41 | index 72a7bd5..8240691 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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 79 | @@ -630,11 +630,11 @@ free_skb: |
| 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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 94 | @@ -642,30 +642,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 137 | @@ -718,10 +718,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 148 | @@ -740,6 +736,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 156 | @@ -755,7 +752,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 165 | @@ -765,6 +762,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 179 | @@ -795,7 +799,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 188 | @@ -812,7 +816,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 197 | @@ -882,12 +886,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 211 | @@ -903,10 +906,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 224 | @@ -951,7 +954,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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 233 | @@ -1006,8 +1009,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 |
| 243 | index 1de5a2b..619dc0f 100644 |
| 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 | 1a17367 | 2023-12-21 14:49:33 +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 | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 278 | index 6e8ac6f..b30a74e 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 279 | --- a/mac80211.c |
| 280 | +++ b/mac80211.c |
| 281 | @@ -4,7 +4,6 @@ |
| 282 | */ |
| 283 | #include <linux/sched.h> |
| 284 | #include <linux/of.h> |
| 285 | -#include <net/page_pool.h> |
| 286 | #include "mt76.h" |
| 287 | |
| 288 | #define CHAN2G(_idx, _freq) { \ |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 289 | @@ -578,47 +577,6 @@ void mt76_unregister_phy(struct mt76_phy *phy) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 290 | } |
| 291 | EXPORT_SYMBOL_GPL(mt76_unregister_phy); |
| 292 | |
| 293 | -int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q) |
| 294 | -{ |
| 295 | - struct page_pool_params pp_params = { |
| 296 | - .order = 0, |
| 297 | - .flags = PP_FLAG_PAGE_FRAG, |
| 298 | - .nid = NUMA_NO_NODE, |
| 299 | - .dev = dev->dma_dev, |
| 300 | - }; |
| 301 | - int idx = q - dev->q_rx; |
| 302 | - |
| 303 | - switch (idx) { |
| 304 | - case MT_RXQ_MAIN: |
| 305 | - case MT_RXQ_BAND1: |
| 306 | - case MT_RXQ_BAND2: |
| 307 | - pp_params.pool_size = 256; |
| 308 | - break; |
| 309 | - default: |
| 310 | - pp_params.pool_size = 16; |
| 311 | - break; |
| 312 | - } |
| 313 | - |
| 314 | - if (mt76_is_mmio(dev)) { |
| 315 | - /* rely on page_pool for DMA mapping */ |
| 316 | - pp_params.flags |= PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; |
| 317 | - pp_params.dma_dir = DMA_FROM_DEVICE; |
| 318 | - pp_params.max_len = PAGE_SIZE; |
| 319 | - pp_params.offset = 0; |
| 320 | - } |
| 321 | - |
| 322 | - q->page_pool = page_pool_create(&pp_params); |
| 323 | - if (IS_ERR(q->page_pool)) { |
| 324 | - int err = PTR_ERR(q->page_pool); |
| 325 | - |
| 326 | - q->page_pool = NULL; |
| 327 | - return err; |
| 328 | - } |
| 329 | - |
| 330 | - return 0; |
| 331 | -} |
| 332 | -EXPORT_SYMBOL_GPL(mt76_create_page_pool); |
| 333 | - |
| 334 | struct mt76_dev * |
| 335 | mt76_alloc_device(struct device *pdev, unsigned int size, |
| 336 | const struct ieee80211_ops *ops, |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 337 | @@ -1818,21 +1776,6 @@ void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 338 | } |
| 339 | EXPORT_SYMBOL_GPL(mt76_ethtool_worker); |
| 340 | |
| 341 | -void mt76_ethtool_page_pool_stats(struct mt76_dev *dev, u64 *data, int *index) |
| 342 | -{ |
| 343 | -#ifdef CONFIG_PAGE_POOL_STATS |
| 344 | - struct page_pool_stats stats = {}; |
| 345 | - int i; |
| 346 | - |
| 347 | - mt76_for_each_q_rx(dev, i) |
| 348 | - page_pool_get_stats(dev->q_rx[i].page_pool, &stats); |
| 349 | - |
| 350 | - page_pool_ethtool_stats_get(data, &stats); |
| 351 | - *index += page_pool_ethtool_stats_get_count(); |
| 352 | -#endif |
| 353 | -} |
| 354 | -EXPORT_SYMBOL_GPL(mt76_ethtool_page_pool_stats); |
| 355 | - |
| 356 | enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy) |
| 357 | { |
| 358 | struct ieee80211_hw *hw = phy->hw; |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 359 | diff --git a/mcu.c b/mcu.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 360 | index a8cafa3..fa4b054 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 361 | --- a/mcu.c |
| 362 | +++ b/mcu.c |
| 363 | @@ -4,6 +4,7 @@ |
| 364 | */ |
| 365 | |
| 366 | #include "mt76.h" |
| 367 | +#include <linux/moduleparam.h> |
| 368 | |
| 369 | struct sk_buff * |
| 370 | __mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 371 | diff --git a/mt76.h b/mt76.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 372 | index 03116ff..1c37031 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 373 | --- a/mt76.h |
| 374 | +++ b/mt76.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 375 | @@ -233,7 +233,7 @@ struct mt76_queue { |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 376 | |
| 377 | dma_addr_t desc_dma; |
| 378 | struct sk_buff *rx_head; |
| 379 | - struct page_pool *page_pool; |
| 380 | + struct page_frag_cache rx_page; |
| 381 | }; |
| 382 | |
| 383 | struct mt76_mcu_ops { |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 384 | @@ -1517,7 +1517,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] | 385 | return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout); |
| 386 | } |
| 387 | |
| 388 | -void mt76_ethtool_page_pool_stats(struct mt76_dev *dev, u64 *data, int *index); |
| 389 | void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, |
| 390 | struct mt76_sta_stats *stats, bool eht); |
| 391 | int mt76_skb_adjust_pad(struct sk_buff *skb, int pad); |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 392 | @@ -1662,25 +1661,6 @@ void __mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 393 | struct mt76_txwi_cache *mt76_rx_token_release(struct mt76_dev *dev, int token); |
| 394 | int mt76_rx_token_consume(struct mt76_dev *dev, void *ptr, |
| 395 | struct mt76_txwi_cache *r, dma_addr_t phys); |
| 396 | -int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q); |
| 397 | -static inline void mt76_put_page_pool_buf(void *buf, bool allow_direct) |
| 398 | -{ |
| 399 | - struct page *page = virt_to_head_page(buf); |
| 400 | - |
| 401 | - page_pool_put_full_page(page->pp, page, allow_direct); |
| 402 | -} |
| 403 | - |
| 404 | -static inline void * |
| 405 | -mt76_get_page_pool_buf(struct mt76_queue *q, u32 *offset, u32 size) |
| 406 | -{ |
| 407 | - struct page *page; |
| 408 | - |
| 409 | - page = page_pool_dev_alloc_frag(q->page_pool, offset, size); |
| 410 | - if (!page) |
| 411 | - return NULL; |
| 412 | - |
| 413 | - return page_address(page) + *offset; |
| 414 | -} |
| 415 | |
| 416 | static inline void mt76_set_tx_blocked(struct mt76_dev *dev, bool blocked) |
| 417 | { |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 418 | diff --git a/mt7615/mcu.c b/mt7615/mcu.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 419 | index ae34d01..c9444c6 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 420 | --- a/mt7615/mcu.c |
| 421 | +++ b/mt7615/mcu.c |
| 422 | @@ -10,6 +10,7 @@ |
| 423 | #include "mcu.h" |
| 424 | #include "mac.h" |
| 425 | #include "eeprom.h" |
| 426 | +#include <linux/moduleparam.h> |
| 427 | |
| 428 | static bool prefer_offload_fw = true; |
| 429 | module_param(prefer_offload_fw, bool, 0644); |
| 430 | diff --git a/mt76_connac.h b/mt76_connac.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 431 | index 1be41d6..e23a41c 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 432 | --- a/mt76_connac.h |
| 433 | +++ b/mt76_connac.h |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 434 | @@ -56,7 +56,6 @@ enum { |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 435 | CMD_CBW_10MHZ, |
| 436 | CMD_CBW_5MHZ, |
| 437 | CMD_CBW_8080MHZ, |
| 438 | - CMD_CBW_320MHZ, |
| 439 | |
| 440 | CMD_HE_MCS_BW80 = 0, |
| 441 | CMD_HE_MCS_BW160, |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 442 | @@ -286,7 +285,6 @@ static inline u8 mt76_connac_chan_bw(struct cfg80211_chan_def *chandef) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 443 | [NL80211_CHAN_WIDTH_10] = CMD_CBW_10MHZ, |
| 444 | [NL80211_CHAN_WIDTH_20] = CMD_CBW_20MHZ, |
| 445 | [NL80211_CHAN_WIDTH_20_NOHT] = CMD_CBW_20MHZ, |
| 446 | - [NL80211_CHAN_WIDTH_320] = CMD_CBW_320MHZ, |
| 447 | }; |
| 448 | |
| 449 | if (chandef->width >= ARRAY_SIZE(width_to_bw)) |
| 450 | diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 451 | index fe5250c..7692423 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 452 | --- a/mt76_connac_mcu.c |
| 453 | +++ b/mt76_connac_mcu.c |
| 454 | @@ -4,6 +4,7 @@ |
| 455 | #include <linux/firmware.h> |
| 456 | #include "mt76_connac2_mac.h" |
| 457 | #include "mt76_connac_mcu.h" |
| 458 | +#include <linux/module.h> |
| 459 | |
| 460 | int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option) |
| 461 | { |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 462 | @@ -1350,40 +1351,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] | 463 | } |
| 464 | EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode); |
| 465 | |
| 466 | -u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 467 | - enum nl80211_band band) |
| 468 | -{ |
| 469 | - const struct ieee80211_sta_eht_cap *eht_cap; |
| 470 | - struct ieee80211_supported_band *sband; |
| 471 | - u8 mode = 0; |
| 472 | - |
| 473 | - if (band == NL80211_BAND_6GHZ) |
| 474 | - mode |= PHY_MODE_AX_6G; |
| 475 | - |
| 476 | - sband = phy->hw->wiphy->bands[band]; |
| 477 | - eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type); |
| 478 | - |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 479 | - if (!eht_cap || !eht_cap->has_eht || !vif->bss_conf.eht_support) |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 480 | - return mode; |
| 481 | - |
| 482 | - switch (band) { |
| 483 | - case NL80211_BAND_6GHZ: |
| 484 | - mode |= PHY_MODE_BE_6G; |
| 485 | - break; |
| 486 | - case NL80211_BAND_5GHZ: |
| 487 | - mode |= PHY_MODE_BE_5G; |
| 488 | - break; |
| 489 | - case NL80211_BAND_2GHZ: |
| 490 | - mode |= PHY_MODE_BE_24G; |
| 491 | - break; |
| 492 | - default: |
| 493 | - break; |
| 494 | - } |
| 495 | - |
| 496 | - return mode; |
| 497 | -} |
| 498 | -EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode_ext); |
| 499 | - |
| 500 | const struct ieee80211_sta_he_cap * |
| 501 | mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif) |
| 502 | { |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 503 | @@ -1399,18 +1366,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] | 504 | } |
| 505 | EXPORT_SYMBOL_GPL(mt76_connac_get_he_phy_cap); |
| 506 | |
| 507 | -const struct ieee80211_sta_eht_cap * |
| 508 | -mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif) |
| 509 | -{ |
| 510 | - enum nl80211_band band = phy->chandef.chan->band; |
| 511 | - struct ieee80211_supported_band *sband; |
| 512 | - |
| 513 | - sband = phy->hw->wiphy->bands[band]; |
| 514 | - |
| 515 | - return ieee80211_get_eht_iftype_cap(sband, vif->type); |
| 516 | -} |
| 517 | -EXPORT_SYMBOL_GPL(mt76_connac_get_eht_phy_cap); |
| 518 | - |
| 519 | #define DEFAULT_HE_PE_DURATION 4 |
| 520 | #define DEFAULT_HE_DURATION_RTS_THRES 1023 |
| 521 | static void |
| 522 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 523 | index 8d516e4..ea71d53 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 524 | --- a/mt76_connac_mcu.h |
| 525 | +++ b/mt76_connac_mcu.h |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 526 | @@ -1976,12 +1976,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] | 527 | |
| 528 | const struct ieee80211_sta_he_cap * |
| 529 | mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); |
| 530 | -const struct ieee80211_sta_eht_cap * |
| 531 | -mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif); |
| 532 | u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 533 | enum nl80211_band band, struct ieee80211_sta *sta); |
| 534 | -u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif, |
| 535 | - enum nl80211_band band); |
| 536 | |
| 537 | int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 538 | struct mt76_connac_sta_key_conf *sta_key_conf, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 539 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 540 | index 1548c1f..4e9a509 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 541 | --- a/mt7915/main.c |
| 542 | +++ b/mt7915/main.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 543 | @@ -1434,22 +1434,20 @@ void mt7915_get_et_strings(struct ieee80211_hw *hw, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 544 | struct ieee80211_vif *vif, |
| 545 | u32 sset, u8 *data) |
| 546 | { |
| 547 | - if (sset != ETH_SS_STATS) |
| 548 | - return; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 549 | + if (sset == ETH_SS_STATS) |
| 550 | + memcpy(data, *mt7915_gstrings_stats, |
| 551 | + sizeof(mt7915_gstrings_stats)); |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 552 | |
| 553 | - memcpy(data, mt7915_gstrings_stats, sizeof(mt7915_gstrings_stats)); |
| 554 | - data += sizeof(mt7915_gstrings_stats); |
| 555 | - page_pool_ethtool_stats_get_strings(data); |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | static |
| 559 | int mt7915_get_et_sset_count(struct ieee80211_hw *hw, |
| 560 | struct ieee80211_vif *vif, int sset) |
| 561 | { |
| 562 | - if (sset != ETH_SS_STATS) |
| 563 | - return 0; |
| 564 | + if (sset == ETH_SS_STATS) |
| 565 | + return MT7915_SSTATS_LEN; |
| 566 | |
| 567 | - return MT7915_SSTATS_LEN + page_pool_ethtool_stats_get_count(); |
| 568 | + return 0; |
| 569 | } |
| 570 | |
| 571 | static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 572 | @@ -1477,7 +1475,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 573 | .idx = mvif->mt76.idx, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 574 | }; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 575 | /* See mt7915_ampdu_stat_read_phy, etc */ |
| 576 | - int i, ei = 0, stats_size; |
| 577 | + int i, ei = 0; |
| 578 | |
| 579 | mutex_lock(&dev->mt76.mutex); |
| 580 | |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 581 | @@ -1589,12 +1587,9 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 582 | return; |
| 583 | |
| 584 | ei += wi.worker_stat_count; |
| 585 | - |
| 586 | - mt76_ethtool_page_pool_stats(&dev->mt76, &data[ei], &ei); |
| 587 | - |
| 588 | - stats_size = MT7915_SSTATS_LEN + page_pool_ethtool_stats_get_count(); |
| 589 | - if (ei != stats_size) |
| 590 | - dev_err(dev->mt76.dev, "ei: %d size: %d", ei, stats_size); |
| 591 | + if (ei != MT7915_SSTATS_LEN) |
| 592 | + dev_err(dev->mt76.dev, "ei: %d MT7915_SSTATS_LEN: %d", |
| 593 | + ei, (int)MT7915_SSTATS_LEN); |
| 594 | } |
| 595 | |
| 596 | static void |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 597 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 598 | index d443d50..32b6096 100644 |
developer | da18a74 | 2023-04-06 13:44:00 +0800 | [diff] [blame] | 599 | --- a/mt7915/mcu.c |
| 600 | +++ b/mt7915/mcu.c |
| 601 | @@ -6,6 +6,7 @@ |
| 602 | #include "mcu.h" |
| 603 | #include "mac.h" |
| 604 | #include "eeprom.h" |
| 605 | +#include <linux/moduleparam.h> |
| 606 | |
| 607 | #define fw_name(_dev, name, ...) ({ \ |
| 608 | char *_fw; \ |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 609 | diff --git a/usb.c b/usb.c |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 610 | index 1b25f2e..46831a2 100644 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 611 | --- a/usb.c |
| 612 | +++ b/usb.c |
| 613 | @@ -319,27 +319,29 @@ mt76u_set_endpoints(struct usb_interface *intf, |
| 614 | |
| 615 | static int |
| 616 | mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, |
| 617 | - int nsgs) |
| 618 | + int nsgs, gfp_t gfp) |
| 619 | { |
| 620 | int i; |
| 621 | |
| 622 | for (i = 0; i < nsgs; i++) { |
| 623 | + struct page *page; |
| 624 | void *data; |
| 625 | int offset; |
| 626 | |
| 627 | - data = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 628 | + data = page_frag_alloc(&q->rx_page, q->buf_size, gfp); |
| 629 | if (!data) |
| 630 | break; |
| 631 | |
| 632 | - sg_set_page(&urb->sg[i], virt_to_head_page(data), q->buf_size, |
| 633 | - offset); |
| 634 | + page = virt_to_head_page(data); |
| 635 | + offset = data - page_address(page); |
| 636 | + sg_set_page(&urb->sg[i], page, q->buf_size, offset); |
| 637 | } |
| 638 | |
| 639 | if (i < nsgs) { |
| 640 | int j; |
| 641 | |
| 642 | for (j = nsgs; j < urb->num_sgs; j++) |
| 643 | - mt76_put_page_pool_buf(sg_virt(&urb->sg[j]), false); |
| 644 | + skb_free_frag(sg_virt(&urb->sg[j])); |
| 645 | urb->num_sgs = i; |
| 646 | } |
| 647 | |
| 648 | @@ -352,16 +354,15 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, |
| 649 | |
| 650 | static int |
| 651 | mt76u_refill_rx(struct mt76_dev *dev, struct mt76_queue *q, |
| 652 | - struct urb *urb, int nsgs) |
| 653 | + struct urb *urb, int nsgs, gfp_t gfp) |
| 654 | { |
| 655 | enum mt76_rxq_id qid = q - &dev->q_rx[MT_RXQ_MAIN]; |
| 656 | - int offset; |
| 657 | |
| 658 | if (qid == MT_RXQ_MAIN && dev->usb.sg_en) |
| 659 | - return mt76u_fill_rx_sg(dev, q, urb, nsgs); |
| 660 | + return mt76u_fill_rx_sg(dev, q, urb, nsgs, gfp); |
| 661 | |
| 662 | urb->transfer_buffer_length = q->buf_size; |
| 663 | - urb->transfer_buffer = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 664 | + urb->transfer_buffer = page_frag_alloc(&q->rx_page, q->buf_size, gfp); |
| 665 | |
| 666 | return urb->transfer_buffer ? 0 : -ENOMEM; |
| 667 | } |
| 668 | @@ -399,7 +400,7 @@ mt76u_rx_urb_alloc(struct mt76_dev *dev, struct mt76_queue *q, |
| 669 | if (err) |
| 670 | return err; |
| 671 | |
| 672 | - return mt76u_refill_rx(dev, q, e->urb, sg_size); |
| 673 | + return mt76u_refill_rx(dev, q, e->urb, sg_size, GFP_KERNEL); |
| 674 | } |
| 675 | |
| 676 | static void mt76u_urb_free(struct urb *urb) |
| 677 | @@ -407,10 +408,10 @@ static void mt76u_urb_free(struct urb *urb) |
| 678 | int i; |
| 679 | |
| 680 | for (i = 0; i < urb->num_sgs; i++) |
| 681 | - mt76_put_page_pool_buf(sg_virt(&urb->sg[i]), false); |
| 682 | + skb_free_frag(sg_virt(&urb->sg[i])); |
| 683 | |
| 684 | if (urb->transfer_buffer) |
| 685 | - mt76_put_page_pool_buf(urb->transfer_buffer, false); |
| 686 | + skb_free_frag(urb->transfer_buffer); |
| 687 | |
| 688 | usb_free_urb(urb); |
| 689 | } |
| 690 | @@ -546,8 +547,6 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb, |
| 691 | len -= data_len; |
| 692 | nsgs++; |
| 693 | } |
| 694 | - |
| 695 | - skb_mark_for_recycle(skb); |
| 696 | dev->drv->rx_skb(dev, MT_RXQ_MAIN, skb, NULL); |
| 697 | |
| 698 | return nsgs; |
| 699 | @@ -613,7 +612,7 @@ mt76u_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) |
| 700 | |
| 701 | count = mt76u_process_rx_entry(dev, urb, q->buf_size); |
| 702 | if (count > 0) { |
| 703 | - err = mt76u_refill_rx(dev, q, urb, count); |
| 704 | + err = mt76u_refill_rx(dev, q, urb, count, GFP_ATOMIC); |
| 705 | if (err < 0) |
| 706 | break; |
| 707 | } |
| 708 | @@ -664,10 +663,6 @@ mt76u_alloc_rx_queue(struct mt76_dev *dev, enum mt76_rxq_id qid) |
| 709 | struct mt76_queue *q = &dev->q_rx[qid]; |
| 710 | int i, err; |
| 711 | |
| 712 | - err = mt76_create_page_pool(dev, q); |
| 713 | - if (err) |
| 714 | - return err; |
| 715 | - |
| 716 | spin_lock_init(&q->lock); |
| 717 | q->entry = devm_kcalloc(dev->dev, |
| 718 | MT_NUM_RX_ENTRIES, sizeof(*q->entry), |
| 719 | @@ -696,6 +691,7 @@ EXPORT_SYMBOL_GPL(mt76u_alloc_mcu_queue); |
| 720 | static void |
| 721 | mt76u_free_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) |
| 722 | { |
| 723 | + struct page *page; |
| 724 | int i; |
| 725 | |
| 726 | for (i = 0; i < q->ndesc; i++) { |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 727 | @@ -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] | 728 | mt76u_urb_free(q->entry[i].urb); |
| 729 | q->entry[i].urb = NULL; |
| 730 | } |
| 731 | - page_pool_destroy(q->page_pool); |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 732 | - q->page_pool = NULL; |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 733 | + |
| 734 | + if (!q->rx_page.va) |
| 735 | + return; |
| 736 | + |
| 737 | + page = virt_to_page(q->rx_page.va); |
| 738 | + __page_frag_cache_drain(page, q->rx_page.pagecnt_bias); |
| 739 | + memset(&q->rx_page, 0, sizeof(q->rx_page)); |
| 740 | } |
| 741 | |
| 742 | static void mt76u_free_rx(struct mt76_dev *dev) |
developer | 753619c | 2024-02-22 13:42:45 +0800 | [diff] [blame^] | 743 | diff --git a/wed.c b/wed.c |
| 744 | index f89e453..f7a3f1b 100644 |
| 745 | --- a/wed.c |
| 746 | +++ b/wed.c |
| 747 | @@ -9,8 +9,12 @@ |
| 748 | void mt76_wed_release_rx_buf(struct mtk_wed_device *wed) |
| 749 | { |
| 750 | struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed); |
| 751 | + u32 length; |
| 752 | int i; |
| 753 | |
| 754 | + length = SKB_DATA_ALIGN(NET_SKB_PAD + wed->wlan.rx_size + |
| 755 | + sizeof(struct skb_shared_info)); |
| 756 | + |
| 757 | for (i = 0; i < dev->rx_token_size; i++) { |
| 758 | struct mt76_txwi_cache *t; |
| 759 | |
| 760 | @@ -18,7 +22,9 @@ void mt76_wed_release_rx_buf(struct mtk_wed_device *wed) |
| 761 | if (!t || !t->ptr) |
| 762 | continue; |
| 763 | |
| 764 | - mt76_put_page_pool_buf(t->ptr, false); |
| 765 | + dma_unmap_single(dev->dma_dev, t->dma_addr, |
| 766 | + wed->wlan.rx_size, DMA_FROM_DEVICE); |
| 767 | + __free_pages(virt_to_page(t->ptr), get_order(length)); |
| 768 | t->ptr = NULL; |
| 769 | |
| 770 | mt76_put_rxwi(dev, t); |
| 771 | @@ -33,39 +39,51 @@ u32 mt76_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
| 772 | { |
| 773 | struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed); |
| 774 | struct mtk_wed_bm_desc *desc = wed->rx_buf_ring.desc; |
| 775 | - struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN]; |
| 776 | - int i, len = SKB_WITH_OVERHEAD(q->buf_size); |
| 777 | - struct mt76_txwi_cache *t = NULL; |
| 778 | + u32 length; |
| 779 | + int i; |
| 780 | + |
| 781 | + length = SKB_DATA_ALIGN(NET_SKB_PAD + wed->wlan.rx_size + |
| 782 | + sizeof(struct skb_shared_info)); |
| 783 | |
| 784 | for (i = 0; i < size; i++) { |
| 785 | - enum dma_data_direction dir; |
| 786 | - dma_addr_t addr; |
| 787 | - u32 offset; |
| 788 | + struct mt76_txwi_cache *t = mt76_get_rxwi(dev); |
| 789 | + dma_addr_t phy_addr; |
| 790 | + struct page *page; |
| 791 | int token; |
| 792 | - void *buf; |
| 793 | + void *ptr; |
| 794 | |
| 795 | - t = mt76_get_rxwi(dev); |
| 796 | if (!t) |
| 797 | goto unmap; |
| 798 | |
| 799 | - buf = mt76_get_page_pool_buf(q, &offset, q->buf_size); |
| 800 | - if (!buf) |
| 801 | + page = __dev_alloc_pages(GFP_KERNEL, get_order(length)); |
| 802 | + if (!page) { |
| 803 | + mt76_put_rxwi(dev, t); |
| 804 | goto unmap; |
| 805 | + } |
| 806 | |
| 807 | - addr = page_pool_get_dma_addr(virt_to_head_page(buf)) + offset; |
| 808 | - dir = page_pool_get_dma_dir(q->page_pool); |
| 809 | - dma_sync_single_for_device(dev->dma_dev, addr, len, dir); |
| 810 | + ptr = page_address(page); |
| 811 | + phy_addr = dma_map_single(dev->dma_dev, ptr, |
| 812 | + wed->wlan.rx_size, |
| 813 | + DMA_TO_DEVICE); |
| 814 | + if (unlikely(dma_mapping_error(dev->dev, phy_addr))) { |
| 815 | + __free_pages(page, get_order(length)); |
| 816 | + mt76_put_rxwi(dev, t); |
| 817 | + goto unmap; |
| 818 | + } |
| 819 | |
| 820 | - desc->buf0 = cpu_to_le32(addr); |
| 821 | - token = mt76_rx_token_consume(dev, buf, t, addr); |
| 822 | + desc->buf0 = cpu_to_le32(phy_addr); |
| 823 | + token = mt76_rx_token_consume(dev, ptr, t, phy_addr); |
| 824 | if (token < 0) { |
| 825 | - mt76_put_page_pool_buf(buf, false); |
| 826 | + dma_unmap_single(dev->dma_dev, phy_addr, |
| 827 | + wed->wlan.rx_size, DMA_TO_DEVICE); |
| 828 | + __free_pages(page, get_order(length)); |
| 829 | + mt76_put_rxwi(dev, t); |
| 830 | goto unmap; |
| 831 | } |
| 832 | |
| 833 | token = FIELD_PREP(MT_DMA_CTL_TOKEN, token); |
| 834 | #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT |
| 835 | - token |= FIELD_PREP(MT_DMA_CTL_SDP0_H, addr >> 32); |
| 836 | + token |= FIELD_PREP(MT_DMA_CTL_SDP0_H, phy_addr >> 32); |
| 837 | #endif |
| 838 | desc->token |= cpu_to_le32(token); |
| 839 | desc++; |
| 840 | @@ -74,8 +92,6 @@ u32 mt76_wed_init_rx_buf(struct mtk_wed_device *wed, int size) |
| 841 | return 0; |
| 842 | |
| 843 | unmap: |
| 844 | - if (t) |
| 845 | - mt76_put_rxwi(dev, t); |
| 846 | mt76_wed_release_rx_buf(wed); |
| 847 | |
| 848 | return -ENOMEM; |
| 849 | @@ -123,7 +139,7 @@ int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| 850 | /* WED txfree queue needs ring to be initialized before setup */ |
| 851 | q->flags = 0; |
| 852 | mt76_dma_queue_reset(dev, q); |
| 853 | - mt76_dma_rx_fill(dev, q, false); |
| 854 | + mt76_dma_rx_fill(dev, q); |
| 855 | |
| 856 | ret = mtk_wed_device_txfree_ring_setup(q->wed, q->regs); |
| 857 | if (!ret) |
| 858 | @@ -144,7 +160,7 @@ int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| 859 | break; |
| 860 | case MT76_WED_RRO_Q_MSDU_PG: |
| 861 | q->flags &= ~MT_QFLAG_WED; |
| 862 | - __mt76_dma_queue_reset(dev, q, false); |
| 863 | + __mt76_dma_queue_reset(dev, q); |
| 864 | mtk_wed_device_msdu_pg_rx_ring_setup(q->wed, ring, q->regs); |
| 865 | q->head = q->ndesc - 1; |
| 866 | q->queued = q->head; |
| 867 | @@ -152,7 +168,7 @@ int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset) |
| 868 | case MT76_WED_RRO_Q_IND: |
| 869 | q->flags &= ~MT_QFLAG_WED; |
| 870 | mt76_dma_queue_reset(dev, q); |
| 871 | - mt76_dma_rx_fill(dev, q, false); |
| 872 | + mt76_dma_rx_fill(dev, q); |
| 873 | mtk_wed_device_ind_rx_ring_setup(q->wed, q->regs); |
| 874 | break; |
| 875 | default: |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 876 | -- |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 877 | 2.18.0 |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 878 | |