Skip to content

Commit

Permalink
mwifiex: re-fix for unaligned accesses
Browse files Browse the repository at this point in the history
[ Upstream commit 8f4e3d4 ]

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: 92c70a9 ("mwifiex: fix for unaligned reads")
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
arndb authored and gregkh committed Jul 14, 2021
1 parent afbcbf9 commit aa9f1fc
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/net/wireless/marvell/mwifiex/pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
}
Expand Down

0 comments on commit aa9f1fc

Please sign in to comment.