]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
mwifiex: re-fix for unaligned accesses
authorArnd Bergmann <arnd@arndb.de>
Fri, 7 May 2021 22:07:55 +0000 (00:07 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 13 Aug 2021 07:31:08 +0000 (09:31 +0200)
BugLink: https://bugs.launchpad.net/bugs/1938340
[ Upstream commit 8f4e3d48bb50765ab27ae5bebed2595b20de80a1 ]

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")
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/wireless/marvell/mwifiex/pcie.c

index 1f9266ecfe6d14dab348bae69f7e16c8fe86aaf2..27634aa38bf8575d12e2bc2b1d5984aea60cfa21 100644 (file)
@@ -1241,7 +1241,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),
@@ -1252,13 +1252,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;
 }