Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.17 commit in: /
Date: Fri, 08 Apr 2022 13:09:59
Message-Id: 1649423372.90bdc1445c17fabda7246e1e43ee93e26fba1c95.mpagano@gentoo
1 commit: 90bdc1445c17fabda7246e1e43ee93e26fba1c95
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Apr 8 13:09:32 2022 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Apr 8 13:09:32 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=90bdc144
7
8 Removed redundant patches
9
10 Removed:
11 2400_mt76-mt7921e-fix-possible-probe-failure-after-reboot.patch
12 2410_revert-swiotlb-rework-fix-info-leak-with-dma_from_device.patch
13
14 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
15
16 0000_README | 8 -
17 ...e-fix-possible-probe-failure-after-reboot.patch | 436 ---------------------
18 ...rework-fix-info-leak-with-dma_from_device.patch | 187 ---------
19 3 files changed, 631 deletions(-)
20
21 diff --git a/0000_README b/0000_README
22 index 07650c38..18d9a104 100644
23 --- a/0000_README
24 +++ b/0000_README
25 @@ -63,14 +63,6 @@ Patch: 2000_BT-Check-key-sizes-only-if-Secure-Simple-Pairing-enabled.patch
26 From: https://lore.kernel.org/linux-bluetooth/20190522070540.48895-1-marcel@××××××××.org/raw
27 Desc: Bluetooth: Check key sizes only when Secure Simple Pairing is enabled. See bug #686758
28
29 -Patch: 2400_mt76-mt7921e-fix-possible-probe-failure-after-reboot.patch
30 -From: https://patchwork.kernel.org/project/linux-wireless/patch/70e27cbc652cbdb78277b9c691a3a5ba02653afb.1641540175.git.objelf@×××××.com/
31 -Desc: mt76: mt7921e: fix possible probe failure after reboot
32 -
33 -Patch: 2410_revert-swiotlb-rework-fix-info-leak-with-dma_from_device.patch
34 -From: https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git
35 -Desc: Revert swiotlb: rework fix info leak with DMA_FROM_DEVICE
36 -
37 Patch: 2900_tmp513-Fix-build-issue-by-selecting-CONFIG_REG.patch
38 From: https://bugs.gentoo.org/710790
39 Desc: tmp513 requies REGMAP_I2C to build. Select it by default in Kconfig. See bug #710790. Thanks to Phil Stracchino
40
41 diff --git a/2400_mt76-mt7921e-fix-possible-probe-failure-after-reboot.patch b/2400_mt76-mt7921e-fix-possible-probe-failure-after-reboot.patch
42 deleted file mode 100644
43 index 4440e910..00000000
44 --- a/2400_mt76-mt7921e-fix-possible-probe-failure-after-reboot.patch
45 +++ /dev/null
46 @@ -1,436 +0,0 @@
47 -From patchwork Fri Jan 7 07:30:03 2022
48 -Content-Type: text/plain; charset="utf-8"
49 -MIME-Version: 1.0
50 -Content-Transfer-Encoding: 7bit
51 -X-Patchwork-Submitter: Sean Wang <sean.wang@××××××××.com>
52 -X-Patchwork-Id: 12706336
53 -X-Patchwork-Delegate: nbd@×××.name
54 -Return-Path: <linux-wireless-owner@××××××.org>
55 -X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
56 - aws-us-west-2-korg-lkml-1.web.codeaurora.org
57 -Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
58 - by smtp.lore.kernel.org (Postfix) with ESMTP id 21BAFC433F5
59 - for <linux-wireless@×××××××××××××××.org>;
60 - Fri, 7 Jan 2022 07:30:14 +0000 (UTC)
61 -Received: (majordomo@×××××××××××.org) by vger.kernel.org via listexpand
62 - id S234590AbiAGHaN (ORCPT
63 - <rfc822;linux-wireless@×××××××××××××××.org>);
64 - Fri, 7 Jan 2022 02:30:13 -0500
65 -Received: from mailgw01.mediatek.com ([60.244.123.138]:50902 "EHLO
66 - mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org
67 - with ESMTP id S234589AbiAGHaM (ORCPT
68 - <rfc822;linux-wireless@×××××××××××.org>);
69 - Fri, 7 Jan 2022 02:30:12 -0500
70 -X-UUID: 13aa3d5f268849bb8556160d0ceca5f3-20220107
71 -X-UUID: 13aa3d5f268849bb8556160d0ceca5f3-20220107
72 -Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by
73 - mailgw01.mediatek.com
74 - (envelope-from <sean.wang@××××××××.com>)
75 - (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
76 - with ESMTP id 982418171; Fri, 07 Jan 2022 15:30:06 +0800
77 -Received: from mtkcas10.mediatek.inc (172.21.101.39) by
78 - mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server
79 - (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3;
80 - Fri, 7 Jan 2022 15:30:05 +0800
81 -Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc
82 - (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
83 - Transport; Fri, 7 Jan 2022 15:30:04 +0800
84 -From: <sean.wang@××××××××.com>
85 -To: <nbd@×××.name>, <lorenzo.bianconi@××××××.com>
86 -CC: <sean.wang@××××××××.com>, <Soul.Huang@××××××××.com>,
87 - <YN.Chen@××××××××.com>, <Leon.Yen@××××××××.com>,
88 - <Eric-SY.Chang@××××××××.com>, <Mark-YW.Chen@××××××××.com>,
89 - <Deren.Wu@××××××××.com>, <km.lin@××××××××.com>,
90 - <jenhao.yang@××××××××.com>, <robin.chiu@××××××××.com>,
91 - <Eddie.Chen@××××××××.com>, <ch.yeh@××××××××.com>,
92 - <posh.sun@××××××××.com>, <ted.huang@××××××××.com>,
93 - <Eric.Liang@××××××××.com>, <Stella.Chang@××××××××.com>,
94 - <Tom.Chou@××××××××.com>, <steve.lee@××××××××.com>,
95 - <jsiuda@××××××.com>, <frankgor@××××××.com>, <jemele@××××××.com>,
96 - <abhishekpandit@××××××.com>, <shawnku@××××××.com>,
97 - <linux-wireless@×××××××××××.org>,
98 - <linux-mediatek@×××××××××××××××.org>,
99 - "Deren Wu" <deren.wu@××××××××.com>
100 -Subject: [PATCH] mt76: mt7921e: fix possible probe failure after reboot
101 -Date: Fri, 7 Jan 2022 15:30:03 +0800
102 -Message-ID:
103 - <70e27cbc652cbdb78277b9c691a3a5ba02653afb.1641540175.git.objelf@×××××.com>
104 -X-Mailer: git-send-email 1.7.9.5
105 -MIME-Version: 1.0
106 -X-MTK: N
107 -Precedence: bulk
108 -List-ID: <linux-wireless.vger.kernel.org>
109 -X-Mailing-List: linux-wireless@×××××××××××.org
110 -
111 -From: Sean Wang <sean.wang@××××××××.com>
112 -
113 -It doesn't guarantee the mt7921e gets started with ASPM L0 after each
114 -machine reboot on every platform.
115 -
116 -If mt7921e gets started with not ASPM L0, it would be possible that the
117 -driver encounters time to time failure in mt7921_pci_probe, like a
118 -weird chip identifier is read
119 -
120 -[ 215.514503] mt7921e 0000:05:00.0: ASIC revision: feed0000
121 -[ 216.604741] mt7921e: probe of 0000:05:00.0 failed with error -110
122 -
123 -or failing to init hardware because the driver is not allowed to access the
124 -register until the device is in ASPM L0 state. So, we call
125 -__mt7921e_mcu_drv_pmctrl in early mt7921_pci_probe to force the device
126 -to bring back to the L0 state for we can safely access registers in any
127 -case.
128 -
129 -In the patch, we move all functions from dma.c to pci.c and register mt76
130 -bus operation earilier, that is the __mt7921e_mcu_drv_pmctrl depends on.
131 -
132 -Fixes: bf3747ae2e25 ("mt76: mt7921: enable aspm by default")
133 -Reported-by: Kai-Chuan Hsieh <kaichuan.hsieh@×××××××××.com>
134 -Co-developed-by: Deren Wu <deren.wu@××××××××.com>
135 -Signed-off-by: Deren Wu <deren.wu@××××××××.com>
136 -Signed-off-by: Sean Wang <sean.wang@××××××××.com>
137 ----
138 - .../net/wireless/mediatek/mt76/mt7921/dma.c | 119 -----------------
139 - .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 +
140 - .../net/wireless/mediatek/mt76/mt7921/pci.c | 124 ++++++++++++++++++
141 - .../wireless/mediatek/mt76/mt7921/pci_mcu.c | 18 ++-
142 - 4 files changed, 139 insertions(+), 123 deletions(-)
143 -
144 -diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
145 -index cdff1fd52d93..39d6ce4ecddd 100644
146 ---- a/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
147 -+++ b/drivers/net/wireless/mediatek/mt76/mt7921/dma.c
148 -@@ -78,110 +78,6 @@ static void mt7921_dma_prefetch(struct mt7921_dev *dev)
149 - mt76_wr(dev, MT_WFDMA0_TX_RING17_EXT_CTRL, PREFETCH(0x380, 0x4));
150 - }
151 -
152 --static u32 __mt7921_reg_addr(struct mt7921_dev *dev, u32 addr)
153 --{
154 -- static const struct {
155 -- u32 phys;
156 -- u32 mapped;
157 -- u32 size;
158 -- } fixed_map[] = {
159 -- { 0x820d0000, 0x30000, 0x10000 }, /* WF_LMAC_TOP (WF_WTBLON) */
160 -- { 0x820ed000, 0x24800, 0x0800 }, /* WF_LMAC_TOP BN0 (WF_MIB) */
161 -- { 0x820e4000, 0x21000, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_TMAC) */
162 -- { 0x820e7000, 0x21e00, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_DMA) */
163 -- { 0x820eb000, 0x24200, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_LPON) */
164 -- { 0x820e2000, 0x20800, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_AGG) */
165 -- { 0x820e3000, 0x20c00, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_ARB) */
166 -- { 0x820e5000, 0x21400, 0x0800 }, /* WF_LMAC_TOP BN0 (WF_RMAC) */
167 -- { 0x00400000, 0x80000, 0x10000 }, /* WF_MCU_SYSRAM */
168 -- { 0x00410000, 0x90000, 0x10000 }, /* WF_MCU_SYSRAM (configure register) */
169 -- { 0x40000000, 0x70000, 0x10000 }, /* WF_UMAC_SYSRAM */
170 -- { 0x54000000, 0x02000, 0x1000 }, /* WFDMA PCIE0 MCU DMA0 */
171 -- { 0x55000000, 0x03000, 0x1000 }, /* WFDMA PCIE0 MCU DMA1 */
172 -- { 0x58000000, 0x06000, 0x1000 }, /* WFDMA PCIE1 MCU DMA0 (MEM_DMA) */
173 -- { 0x59000000, 0x07000, 0x1000 }, /* WFDMA PCIE1 MCU DMA1 */
174 -- { 0x7c000000, 0xf0000, 0x10000 }, /* CONN_INFRA */
175 -- { 0x7c020000, 0xd0000, 0x10000 }, /* CONN_INFRA, WFDMA */
176 -- { 0x7c060000, 0xe0000, 0x10000 }, /* CONN_INFRA, conn_host_csr_top */
177 -- { 0x80020000, 0xb0000, 0x10000 }, /* WF_TOP_MISC_OFF */
178 -- { 0x81020000, 0xc0000, 0x10000 }, /* WF_TOP_MISC_ON */
179 -- { 0x820c0000, 0x08000, 0x4000 }, /* WF_UMAC_TOP (PLE) */
180 -- { 0x820c8000, 0x0c000, 0x2000 }, /* WF_UMAC_TOP (PSE) */
181 -- { 0x820cc000, 0x0e000, 0x1000 }, /* WF_UMAC_TOP (PP) */
182 -- { 0x820cd000, 0x0f000, 0x1000 }, /* WF_MDP_TOP */
183 -- { 0x820ce000, 0x21c00, 0x0200 }, /* WF_LMAC_TOP (WF_SEC) */
184 -- { 0x820cf000, 0x22000, 0x1000 }, /* WF_LMAC_TOP (WF_PF) */
185 -- { 0x820e0000, 0x20000, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_CFG) */
186 -- { 0x820e1000, 0x20400, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_TRB) */
187 -- { 0x820e9000, 0x23400, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_WTBLOFF) */
188 -- { 0x820ea000, 0x24000, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_ETBF) */
189 -- { 0x820ec000, 0x24600, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_INT) */
190 -- { 0x820f0000, 0xa0000, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_CFG) */
191 -- { 0x820f1000, 0xa0600, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_TRB) */
192 -- { 0x820f2000, 0xa0800, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_AGG) */
193 -- { 0x820f3000, 0xa0c00, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_ARB) */
194 -- { 0x820f4000, 0xa1000, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_TMAC) */
195 -- { 0x820f5000, 0xa1400, 0x0800 }, /* WF_LMAC_TOP BN1 (WF_RMAC) */
196 -- { 0x820f7000, 0xa1e00, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_DMA) */
197 -- { 0x820f9000, 0xa3400, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_WTBLOFF) */
198 -- { 0x820fa000, 0xa4000, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_ETBF) */
199 -- { 0x820fb000, 0xa4200, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_LPON) */
200 -- { 0x820fc000, 0xa4600, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_INT) */
201 -- { 0x820fd000, 0xa4800, 0x0800 }, /* WF_LMAC_TOP BN1 (WF_MIB) */
202 -- };
203 -- int i;
204 --
205 -- if (addr < 0x100000)
206 -- return addr;
207 --
208 -- for (i = 0; i < ARRAY_SIZE(fixed_map); i++) {
209 -- u32 ofs;
210 --
211 -- if (addr < fixed_map[i].phys)
212 -- continue;
213 --
214 -- ofs = addr - fixed_map[i].phys;
215 -- if (ofs > fixed_map[i].size)
216 -- continue;
217 --
218 -- return fixed_map[i].mapped + ofs;
219 -- }
220 --
221 -- if ((addr >= 0x18000000 && addr < 0x18c00000) ||
222 -- (addr >= 0x70000000 && addr < 0x78000000) ||
223 -- (addr >= 0x7c000000 && addr < 0x7c400000))
224 -- return mt7921_reg_map_l1(dev, addr);
225 --
226 -- dev_err(dev->mt76.dev, "Access currently unsupported address %08x\n",
227 -- addr);
228 --
229 -- return 0;
230 --}
231 --
232 --static u32 mt7921_rr(struct mt76_dev *mdev, u32 offset)
233 --{
234 -- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
235 -- u32 addr = __mt7921_reg_addr(dev, offset);
236 --
237 -- return dev->bus_ops->rr(mdev, addr);
238 --}
239 --
240 --static void mt7921_wr(struct mt76_dev *mdev, u32 offset, u32 val)
241 --{
242 -- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
243 -- u32 addr = __mt7921_reg_addr(dev, offset);
244 --
245 -- dev->bus_ops->wr(mdev, addr, val);
246 --}
247 --
248 --static u32 mt7921_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
249 --{
250 -- struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
251 -- u32 addr = __mt7921_reg_addr(dev, offset);
252 --
253 -- return dev->bus_ops->rmw(mdev, addr, mask, val);
254 --}
255 --
256 - static int mt7921_dma_disable(struct mt7921_dev *dev, bool force)
257 - {
258 - if (force) {
259 -@@ -341,23 +237,8 @@ int mt7921_wpdma_reinit_cond(struct mt7921_dev *dev)
260 -
261 - int mt7921_dma_init(struct mt7921_dev *dev)
262 - {
263 -- struct mt76_bus_ops *bus_ops;
264 - int ret;
265 -
266 -- dev->phy.dev = dev;
267 -- dev->phy.mt76 = &dev->mt76.phy;
268 -- dev->mt76.phy.priv = &dev->phy;
269 -- dev->bus_ops = dev->mt76.bus;
270 -- bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops),
271 -- GFP_KERNEL);
272 -- if (!bus_ops)
273 -- return -ENOMEM;
274 --
275 -- bus_ops->rr = mt7921_rr;
276 -- bus_ops->wr = mt7921_wr;
277 -- bus_ops->rmw = mt7921_rmw;
278 -- dev->mt76.bus = bus_ops;
279 --
280 - mt76_dma_attach(&dev->mt76);
281 -
282 - ret = mt7921_dma_disable(dev, true);
283 -diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
284 -index 8b674e042568..63e3c7ef5e89 100644
285 ---- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
286 -+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
287 -@@ -443,6 +443,7 @@ int mt7921e_mcu_init(struct mt7921_dev *dev);
288 - int mt7921s_wfsys_reset(struct mt7921_dev *dev);
289 - int mt7921s_mac_reset(struct mt7921_dev *dev);
290 - int mt7921s_init_reset(struct mt7921_dev *dev);
291 -+int __mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev);
292 - int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev);
293 - int mt7921e_mcu_fw_pmctrl(struct mt7921_dev *dev);
294 -
295 -diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
296 -index 1ae0d5826ca7..a0c82d19c4d9 100644
297 ---- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
298 -+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
299 -@@ -121,6 +121,110 @@ static void mt7921e_unregister_device(struct mt7921_dev *dev)
300 - mt76_free_device(&dev->mt76);
301 - }
302 -
303 -+static u32 __mt7921_reg_addr(struct mt7921_dev *dev, u32 addr)
304 -+{
305 -+ static const struct {
306 -+ u32 phys;
307 -+ u32 mapped;
308 -+ u32 size;
309 -+ } fixed_map[] = {
310 -+ { 0x820d0000, 0x30000, 0x10000 }, /* WF_LMAC_TOP (WF_WTBLON) */
311 -+ { 0x820ed000, 0x24800, 0x0800 }, /* WF_LMAC_TOP BN0 (WF_MIB) */
312 -+ { 0x820e4000, 0x21000, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_TMAC) */
313 -+ { 0x820e7000, 0x21e00, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_DMA) */
314 -+ { 0x820eb000, 0x24200, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_LPON) */
315 -+ { 0x820e2000, 0x20800, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_AGG) */
316 -+ { 0x820e3000, 0x20c00, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_ARB) */
317 -+ { 0x820e5000, 0x21400, 0x0800 }, /* WF_LMAC_TOP BN0 (WF_RMAC) */
318 -+ { 0x00400000, 0x80000, 0x10000 }, /* WF_MCU_SYSRAM */
319 -+ { 0x00410000, 0x90000, 0x10000 }, /* WF_MCU_SYSRAM (configure register) */
320 -+ { 0x40000000, 0x70000, 0x10000 }, /* WF_UMAC_SYSRAM */
321 -+ { 0x54000000, 0x02000, 0x1000 }, /* WFDMA PCIE0 MCU DMA0 */
322 -+ { 0x55000000, 0x03000, 0x1000 }, /* WFDMA PCIE0 MCU DMA1 */
323 -+ { 0x58000000, 0x06000, 0x1000 }, /* WFDMA PCIE1 MCU DMA0 (MEM_DMA) */
324 -+ { 0x59000000, 0x07000, 0x1000 }, /* WFDMA PCIE1 MCU DMA1 */
325 -+ { 0x7c000000, 0xf0000, 0x10000 }, /* CONN_INFRA */
326 -+ { 0x7c020000, 0xd0000, 0x10000 }, /* CONN_INFRA, WFDMA */
327 -+ { 0x7c060000, 0xe0000, 0x10000 }, /* CONN_INFRA, conn_host_csr_top */
328 -+ { 0x80020000, 0xb0000, 0x10000 }, /* WF_TOP_MISC_OFF */
329 -+ { 0x81020000, 0xc0000, 0x10000 }, /* WF_TOP_MISC_ON */
330 -+ { 0x820c0000, 0x08000, 0x4000 }, /* WF_UMAC_TOP (PLE) */
331 -+ { 0x820c8000, 0x0c000, 0x2000 }, /* WF_UMAC_TOP (PSE) */
332 -+ { 0x820cc000, 0x0e000, 0x1000 }, /* WF_UMAC_TOP (PP) */
333 -+ { 0x820cd000, 0x0f000, 0x1000 }, /* WF_MDP_TOP */
334 -+ { 0x820ce000, 0x21c00, 0x0200 }, /* WF_LMAC_TOP (WF_SEC) */
335 -+ { 0x820cf000, 0x22000, 0x1000 }, /* WF_LMAC_TOP (WF_PF) */
336 -+ { 0x820e0000, 0x20000, 0x0400 }, /* WF_LMAC_TOP BN0 (WF_CFG) */
337 -+ { 0x820e1000, 0x20400, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_TRB) */
338 -+ { 0x820e9000, 0x23400, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_WTBLOFF) */
339 -+ { 0x820ea000, 0x24000, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_ETBF) */
340 -+ { 0x820ec000, 0x24600, 0x0200 }, /* WF_LMAC_TOP BN0 (WF_INT) */
341 -+ { 0x820f0000, 0xa0000, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_CFG) */
342 -+ { 0x820f1000, 0xa0600, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_TRB) */
343 -+ { 0x820f2000, 0xa0800, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_AGG) */
344 -+ { 0x820f3000, 0xa0c00, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_ARB) */
345 -+ { 0x820f4000, 0xa1000, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_TMAC) */
346 -+ { 0x820f5000, 0xa1400, 0x0800 }, /* WF_LMAC_TOP BN1 (WF_RMAC) */
347 -+ { 0x820f7000, 0xa1e00, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_DMA) */
348 -+ { 0x820f9000, 0xa3400, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_WTBLOFF) */
349 -+ { 0x820fa000, 0xa4000, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_ETBF) */
350 -+ { 0x820fb000, 0xa4200, 0x0400 }, /* WF_LMAC_TOP BN1 (WF_LPON) */
351 -+ { 0x820fc000, 0xa4600, 0x0200 }, /* WF_LMAC_TOP BN1 (WF_INT) */
352 -+ { 0x820fd000, 0xa4800, 0x0800 }, /* WF_LMAC_TOP BN1 (WF_MIB) */
353 -+ };
354 -+ int i;
355 -+
356 -+ if (addr < 0x100000)
357 -+ return addr;
358 -+
359 -+ for (i = 0; i < ARRAY_SIZE(fixed_map); i++) {
360 -+ u32 ofs;
361 -+
362 -+ if (addr < fixed_map[i].phys)
363 -+ continue;
364 -+
365 -+ ofs = addr - fixed_map[i].phys;
366 -+ if (ofs > fixed_map[i].size)
367 -+ continue;
368 -+
369 -+ return fixed_map[i].mapped + ofs;
370 -+ }
371 -+
372 -+ if ((addr >= 0x18000000 && addr < 0x18c00000) ||
373 -+ (addr >= 0x70000000 && addr < 0x78000000) ||
374 -+ (addr >= 0x7c000000 && addr < 0x7c400000))
375 -+ return mt7921_reg_map_l1(dev, addr);
376 -+
377 -+ dev_err(dev->mt76.dev, "Access currently unsupported address %08x\n",
378 -+ addr);
379 -+
380 -+ return 0;
381 -+}
382 -+
383 -+static u32 mt7921_rr(struct mt76_dev *mdev, u32 offset)
384 -+{
385 -+ struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
386 -+ u32 addr = __mt7921_reg_addr(dev, offset);
387 -+
388 -+ return dev->bus_ops->rr(mdev, addr);
389 -+}
390 -+
391 -+static void mt7921_wr(struct mt76_dev *mdev, u32 offset, u32 val)
392 -+{
393 -+ struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
394 -+ u32 addr = __mt7921_reg_addr(dev, offset);
395 -+
396 -+ dev->bus_ops->wr(mdev, addr, val);
397 -+}
398 -+
399 -+static u32 mt7921_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
400 -+{
401 -+ struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
402 -+ u32 addr = __mt7921_reg_addr(dev, offset);
403 -+
404 -+ return dev->bus_ops->rmw(mdev, addr, mask, val);
405 -+}
406 -+
407 - static int mt7921_pci_probe(struct pci_dev *pdev,
408 - const struct pci_device_id *id)
409 - {
410 -@@ -152,6 +256,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
411 - .fw_own = mt7921e_mcu_fw_pmctrl,
412 - };
413 -
414 -+ struct mt76_bus_ops *bus_ops;
415 - struct mt7921_dev *dev;
416 - struct mt76_dev *mdev;
417 - int ret;
418 -@@ -189,6 +294,25 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
419 -
420 - mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);
421 - tasklet_init(&dev->irq_tasklet, mt7921_irq_tasklet, (unsigned long)dev);
422 -+
423 -+ dev->phy.dev = dev;
424 -+ dev->phy.mt76 = &dev->mt76.phy;
425 -+ dev->mt76.phy.priv = &dev->phy;
426 -+ dev->bus_ops = dev->mt76.bus;
427 -+ bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops),
428 -+ GFP_KERNEL);
429 -+ if (!bus_ops)
430 -+ return -ENOMEM;
431 -+
432 -+ bus_ops->rr = mt7921_rr;
433 -+ bus_ops->wr = mt7921_wr;
434 -+ bus_ops->rmw = mt7921_rmw;
435 -+ dev->mt76.bus = bus_ops;
436 -+
437 -+ ret = __mt7921e_mcu_drv_pmctrl(dev);
438 -+ if (ret)
439 -+ return ret;
440 -+
441 - mdev->rev = (mt7921_l1_rr(dev, MT_HW_CHIPID) << 16) |
442 - (mt7921_l1_rr(dev, MT_HW_REV) & 0xff);
443 - dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
444 -diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c
445 -index f9e350b67fdc..36669e5aeef3 100644
446 ---- a/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c
447 -+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c
448 -@@ -59,10 +59,8 @@ int mt7921e_mcu_init(struct mt7921_dev *dev)
449 - return err;
450 - }
451 -
452 --int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
453 -+int __mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
454 - {
455 -- struct mt76_phy *mphy = &dev->mt76.phy;
456 -- struct mt76_connac_pm *pm = &dev->pm;
457 - int i, err = 0;
458 -
459 - for (i = 0; i < MT7921_DRV_OWN_RETRY_COUNT; i++) {
460 -@@ -75,9 +73,21 @@ int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
461 - if (i == MT7921_DRV_OWN_RETRY_COUNT) {
462 - dev_err(dev->mt76.dev, "driver own failed\n");
463 - err = -EIO;
464 -- goto out;
465 - }
466 -
467 -+ return err;
468 -+}
469 -+
470 -+int mt7921e_mcu_drv_pmctrl(struct mt7921_dev *dev)
471 -+{
472 -+ struct mt76_phy *mphy = &dev->mt76.phy;
473 -+ struct mt76_connac_pm *pm = &dev->pm;
474 -+ int err;
475 -+
476 -+ err = __mt7921e_mcu_drv_pmctrl(dev);
477 -+ if (err < 0)
478 -+ goto out;
479 -+
480 - mt7921_wpdma_reinit_cond(dev);
481 - clear_bit(MT76_STATE_PM, &mphy->state);
482 -
483
484 diff --git a/2410_revert-swiotlb-rework-fix-info-leak-with-dma_from_device.patch b/2410_revert-swiotlb-rework-fix-info-leak-with-dma_from_device.patch
485 deleted file mode 100644
486 index 69476ab1..00000000
487 --- a/2410_revert-swiotlb-rework-fix-info-leak-with-dma_from_device.patch
488 +++ /dev/null
489 @@ -1,187 +0,0 @@
490 -From bddac7c1e02ba47f0570e494c9289acea3062cc1 Mon Sep 17 00:00:00 2001
491 -From: Linus Torvalds <torvalds@××××××××××××××××.org>
492 -Date: Sat, 26 Mar 2022 10:42:04 -0700
493 -Subject: Revert "swiotlb: rework "fix info leak with DMA_FROM_DEVICE""
494 -MIME-Version: 1.0
495 -Content-Type: text/plain; charset=UTF-8
496 -Content-Transfer-Encoding: 8bit
497 -
498 -From: Linus Torvalds <torvalds@××××××××××××××××.org>
499 -
500 -commit bddac7c1e02ba47f0570e494c9289acea3062cc1 upstream.
501 -
502 -This reverts commit aa6f8dcbab473f3a3c7454b74caa46d36cdc5d13.
503 -
504 -It turns out this breaks at least the ath9k wireless driver, and
505 -possibly others.
506 -
507 -What the ath9k driver does on packet receive is to set up the DMA
508 -transfer with:
509 -
510 - int ath_rx_init(..)
511 - ..
512 - bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
513 - common->rx_bufsize,
514 - DMA_FROM_DEVICE);
515 -
516 -and then the receive logic (through ath_rx_tasklet()) will fetch
517 -incoming packets
518 -
519 - static bool ath_edma_get_buffers(..)
520 - ..
521 - dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
522 - common->rx_bufsize, DMA_FROM_DEVICE);
523 -
524 - ret = ath9k_hw_process_rxdesc_edma(ah, rs, skb->data);
525 - if (ret == -EINPROGRESS) {
526 - /*let device gain the buffer again*/
527 - dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
528 - common->rx_bufsize, DMA_FROM_DEVICE);
529 - return false;
530 - }
531 -
532 -and it's worth noting how that first DMA sync:
533 -
534 - dma_sync_single_for_cpu(..DMA_FROM_DEVICE);
535 -
536 -is there to make sure the CPU can read the DMA buffer (possibly by
537 -copying it from the bounce buffer area, or by doing some cache flush).
538 -The iommu correctly turns that into a "copy from bounce bufer" so that
539 -the driver can look at the state of the packets.
540 -
541 -In the meantime, the device may continue to write to the DMA buffer, but
542 -we at least have a snapshot of the state due to that first DMA sync.
543 -
544 -But that _second_ DMA sync:
545 -
546 - dma_sync_single_for_device(..DMA_FROM_DEVICE);
547 -
548 -is telling the DMA mapping that the CPU wasn't interested in the area
549 -because the packet wasn't there. In the case of a DMA bounce buffer,
550 -that is a no-op.
551 -
552 -Note how it's not a sync for the CPU (the "for_device()" part), and it's
553 -not a sync for data written by the CPU (the "DMA_FROM_DEVICE" part).
554 -
555 -Or rather, it _should_ be a no-op. That's what commit aa6f8dcbab47
556 -broke: it made the code bounce the buffer unconditionally, and changed
557 -the DMA_FROM_DEVICE to just unconditionally and illogically be
558 -DMA_TO_DEVICE.
559 -
560 -[ Side note: purely within the confines of the swiotlb driver it wasn't
561 - entirely illogical: The reason it did that odd DMA_FROM_DEVICE ->
562 - DMA_TO_DEVICE conversion thing is because inside the swiotlb driver,
563 - it uses just a swiotlb_bounce() helper that doesn't care about the
564 - whole distinction of who the sync is for - only which direction to
565 - bounce.
566 -
567 - So it took the "sync for device" to mean that the CPU must have been
568 - the one writing, and thought it meant DMA_TO_DEVICE. ]
569 -
570 -Also note how the commentary in that commit was wrong, probably due to
571 -that whole confusion, claiming that the commit makes the swiotlb code
572 -
573 - "bounce unconditionally (that is, also
574 - when dir == DMA_TO_DEVICE) in order do avoid synchronising back stale
575 - data from the swiotlb buffer"
576 -
577 -which is nonsensical for two reasons:
578 -
579 - - that "also when dir == DMA_TO_DEVICE" is nonsensical, as that was
580 - exactly when it always did - and should do - the bounce.
581 -
582 - - since this is a sync for the device (not for the CPU), we're clearly
583 - fundamentally not coping back stale data from the bounce buffers at
584 - all, because we'd be copying *to* the bounce buffers.
585 -
586 -So that commit was just very confused. It confused the direction of the
587 -synchronization (to the device, not the cpu) with the direction of the
588 -DMA (from the device).
589 -
590 -Reported-and-bisected-by: Oleksandr Natalenko <oleksandr@×××××××××.name>
591 -Reported-by: Olha Cherevyk <olha.cherevyk@×××××.com>
592 -Cc: Halil Pasic <pasic@×××××××××.com>
593 -Cc: Christoph Hellwig <hch@×××.de>
594 -Cc: Kalle Valo <kvalo@××××××.org>
595 -Cc: Robin Murphy <robin.murphy@×××.com>
596 -Cc: Toke Høiland-Jørgensen <toke@××××.dk>
597 -Cc: Maxime Bizon <mbizon@×××××××.fr>
598 -Cc: Johannes Berg <johannes@××××××××××××.net>
599 -Signed-off-by: Linus Torvalds <torvalds@××××××××××××××××.org>
600 -Signed-off-by: Greg Kroah-Hartman <gregkh@×××××××××××××××.org>
601 ----
602 - Documentation/core-api/dma-attributes.rst | 8 ++++++++
603 - include/linux/dma-mapping.h | 8 ++++++++
604 - kernel/dma/swiotlb.c | 23 ++++++++---------------
605 - 3 files changed, 24 insertions(+), 15 deletions(-)
606 -
607 ---- a/Documentation/core-api/dma-attributes.rst
608 -+++ b/Documentation/core-api/dma-attributes.rst
609 -@@ -130,3 +130,11 @@ accesses to DMA buffers in both privileg
610 - subsystem that the buffer is fully accessible at the elevated privilege
611 - level (and ideally inaccessible or at least read-only at the
612 - lesser-privileged levels).
613 -+
614 -+DMA_ATTR_OVERWRITE
615 -+------------------
616 -+
617 -+This is a hint to the DMA-mapping subsystem that the device is expected to
618 -+overwrite the entire mapped size, thus the caller does not require any of the
619 -+previous buffer contents to be preserved. This allows bounce-buffering
620 -+implementations to optimise DMA_FROM_DEVICE transfers.
621 ---- a/include/linux/dma-mapping.h
622 -+++ b/include/linux/dma-mapping.h
623 -@@ -62,6 +62,14 @@
624 - #define DMA_ATTR_PRIVILEGED (1UL << 9)
625 -
626 - /*
627 -+ * This is a hint to the DMA-mapping subsystem that the device is expected
628 -+ * to overwrite the entire mapped size, thus the caller does not require any
629 -+ * of the previous buffer contents to be preserved. This allows
630 -+ * bounce-buffering implementations to optimise DMA_FROM_DEVICE transfers.
631 -+ */
632 -+#define DMA_ATTR_OVERWRITE (1UL << 10)
633 -+
634 -+/*
635 - * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
636 - * be given to a device to use as a DMA source or target. It is specific to a
637 - * given device and there may be a translation between the CPU physical address
638 ---- a/kernel/dma/swiotlb.c
639 -+++ b/kernel/dma/swiotlb.c
640 -@@ -627,14 +627,10 @@ phys_addr_t swiotlb_tbl_map_single(struc
641 - for (i = 0; i < nr_slots(alloc_size + offset); i++)
642 - mem->slots[index + i].orig_addr = slot_addr(orig_addr, i);
643 - tlb_addr = slot_addr(mem->start, index) + offset;
644 -- /*
645 -- * When dir == DMA_FROM_DEVICE we could omit the copy from the orig
646 -- * to the tlb buffer, if we knew for sure the device will
647 -- * overwirte the entire current content. But we don't. Thus
648 -- * unconditional bounce may prevent leaking swiotlb content (i.e.
649 -- * kernel memory) to user-space.
650 -- */
651 -- swiotlb_bounce(dev, tlb_addr, mapping_size, DMA_TO_DEVICE);
652 -+ if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
653 -+ (!(attrs & DMA_ATTR_OVERWRITE) || dir == DMA_TO_DEVICE ||
654 -+ dir == DMA_BIDIRECTIONAL))
655 -+ swiotlb_bounce(dev, tlb_addr, mapping_size, DMA_TO_DEVICE);
656 - return tlb_addr;
657 - }
658 -
659 -@@ -701,13 +697,10 @@ void swiotlb_tbl_unmap_single(struct dev
660 - void swiotlb_sync_single_for_device(struct device *dev, phys_addr_t tlb_addr,
661 - size_t size, enum dma_data_direction dir)
662 - {
663 -- /*
664 -- * Unconditional bounce is necessary to avoid corruption on
665 -- * sync_*_for_cpu or dma_ummap_* when the device didn't overwrite
666 -- * the whole lengt of the bounce buffer.
667 -- */
668 -- swiotlb_bounce(dev, tlb_addr, size, DMA_TO_DEVICE);
669 -- BUG_ON(!valid_dma_direction(dir));
670 -+ if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
671 -+ swiotlb_bounce(dev, tlb_addr, size, DMA_TO_DEVICE);
672 -+ else
673 -+ BUG_ON(dir != DMA_FROM_DEVICE);
674 - }
675 -
676 - void swiotlb_sync_single_for_cpu(struct device *dev, phys_addr_t tlb_addr,