[v2,10/13] mwifiex: re-fix for unaligned accesses

Message ID 20210514100106.3404011-11-arnd@kernel.org
State New
Headers show
Series
  • Untitled series #127453
Related show

Commit Message

Arnd Bergmann May 14, 2021, 10 a.m.
From: Arnd Bergmann <arnd@arndb.de>


A patch from 2017 changed some accesses to DMA memory to use
get_unaligned_le32() and similar interfaces, to avoid problems
with doing unaligned accesson uncached memory.

However, the change in the mwifiex_pcie_alloc_sleep_cookie_buf()
function ended up changing the size of the access instead,
as it operates on a pointer to u8.

Change this function back to actually access the entire 32 bits.
Note that the pointer is aligned by definition because it came
from dma_alloc_coherent().

Fixes: 92c70a958b0b ("mwifiex: fix for unaligned reads")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

-- 
2.29.2

Comments

Kalle Valo May 15, 2021, 6:22 a.m. | #1
Arnd Bergmann <arnd@kernel.org> writes:

> From: Arnd Bergmann <arnd@arndb.de>
>
> A patch from 2017 changed some accesses to DMA memory to use
> get_unaligned_le32() and similar interfaces, to avoid problems
> with doing unaligned accesson uncached memory.
>
> However, the change in the mwifiex_pcie_alloc_sleep_cookie_buf()
> function ended up changing the size of the access instead,
> as it operates on a pointer to u8.
>
> Change this function back to actually access the entire 32 bits.
> Note that the pointer is aligned by definition because it came
> from dma_alloc_coherent().
>
> Fixes: 92c70a958b0b ("mwifiex: fix for unaligned reads")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Via which tree should this go? I assume it will go via some other tree
so:

Acked-by: Kalle Valo <kvalo@codeaurora.org>
Arnd Bergmann May 15, 2021, 9:01 a.m. | #2
On Sat, May 15, 2021 at 8:22 AM Kalle Valo <kvalo@codeaurora.org> wrote:
> Arnd Bergmann <arnd@kernel.org> writes:

> > From: Arnd Bergmann <arnd@arndb.de>

> >

> > A patch from 2017 changed some accesses to DMA memory to use

> > get_unaligned_le32() and similar interfaces, to avoid problems

> > with doing unaligned accesson uncached memory.

> >

> > However, the change in the mwifiex_pcie_alloc_sleep_cookie_buf()

> > function ended up changing the size of the access instead,

> > as it operates on a pointer to u8.

> >

> > Change this function back to actually access the entire 32 bits.

> > Note that the pointer is aligned by definition because it came

> > from dma_alloc_coherent().

> >

> > Fixes: 92c70a958b0b ("mwifiex: fix for unaligned reads")

> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>

> Via which tree should this go? I assume it will go via some other tree

> so:

>

> Acked-by: Kalle Valo <kvalo@codeaurora.org>


I have queued the series in the asm-generic tree for 5.14, as the patches
that depend on this one are a little too invasive for 5.13 at this point.

If you think this fix should be in 5.13, please take it through your tree.

        Arnd
Kalle Valo May 15, 2021, 6:23 p.m. | #3
Arnd Bergmann <arnd@kernel.org> writes:

> On Sat, May 15, 2021 at 8:22 AM Kalle Valo <kvalo@codeaurora.org> wrote:

>> Arnd Bergmann <arnd@kernel.org> writes:

>> > From: Arnd Bergmann <arnd@arndb.de>

>> >

>> > A patch from 2017 changed some accesses to DMA memory to use

>> > get_unaligned_le32() and similar interfaces, to avoid problems

>> > with doing unaligned accesson uncached memory.

>> >

>> > However, the change in the mwifiex_pcie_alloc_sleep_cookie_buf()

>> > function ended up changing the size of the access instead,

>> > as it operates on a pointer to u8.

>> >

>> > Change this function back to actually access the entire 32 bits.

>> > Note that the pointer is aligned by definition because it came

>> > from dma_alloc_coherent().

>> >

>> > Fixes: 92c70a958b0b ("mwifiex: fix for unaligned reads")

>> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>>

>> Via which tree should this go? I assume it will go via some other tree

>> so:

>>

>> Acked-by: Kalle Valo <kvalo@codeaurora.org>

>

> I have queued the series in the asm-generic tree for 5.14, as the patches

> that depend on this one are a little too invasive for 5.13 at this point.

>

> If you think this fix should be in 5.13, please take it through your tree.


I think v5.14 is more approriate, so please take this via your tree.
Thanks.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 94228b316df1..46517515ba72 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1231,7 +1231,7 @@  static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter)
 static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter)
 {
 	struct pcie_service_card *card = adapter->card;
-	u32 tmp;
+	u32 *cookie;
 
 	card->sleep_cookie_vbase = dma_alloc_coherent(&card->dev->dev,
 						      sizeof(u32),
@@ -1242,13 +1242,11 @@  static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter)
 			    "dma_alloc_coherent failed!\n");
 		return -ENOMEM;
 	}
+	cookie = (u32 *)card->sleep_cookie_vbase;
 	/* Init val of Sleep Cookie */
-	tmp = FW_AWAKE_COOKIE;
-	put_unaligned(tmp, card->sleep_cookie_vbase);
+	*cookie = FW_AWAKE_COOKIE;
 
-	mwifiex_dbg(adapter, INFO,
-		    "alloc_scook: sleep cookie=0x%x\n",
-		    get_unaligned(card->sleep_cookie_vbase));
+	mwifiex_dbg(adapter, INFO, "alloc_scook: sleep cookie=0x%x\n", *cookie);
 
 	return 0;
 }