From patchwork Fri May 14 10:00:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12257373 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA2CBC43461 for ; Fri, 14 May 2021 10:04:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A049C61454 for ; Fri, 14 May 2021 10:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233971AbhENKGH (ORCPT ); Fri, 14 May 2021 06:06:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:59878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233095AbhENKGB (ORCPT ); Fri, 14 May 2021 06:06:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E00461451; Fri, 14 May 2021 10:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620986690; bh=Z8/t58HXrQWvRNq7RJkw/zVGS+awX9fu5iAau4CEuTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iMFORgVvpUam5l1Ot5WAFAEdgQ6hOWylryRauPWqLSM9oyPVkSljtnfsp/tRLqts7 x1rivjkt8EjbhW/aipO0alcOfrFjzx+xSiB77wNyk5lkjq/iHNe6J2XZmA2uNgD99O Z4JieUdSSp34tMB49wHV2NvgIR4jRfuRwudTyu/+7OgSFkTtyKN0DA6ju5r0F9SrdD fu7s2OLdk+DKsHYxI4FTheOl17iZ5pV/TBH5LDFcinKYuncpC9GQKysvTEuxpZHWmF +/7JnHdLJzsOWGZc9wDHc8mXYOb2d7XF5Cf6KRSdBVofjwhBXAUoxLh6jaF1vgFuXK 8VzxZxEm6yIYQ== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Linus Torvalds , Vineet Gupta , Arnd Bergmann , Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu , Kalle Valo , "David S. Miller" , Jakub Kicinski , Devidas Puranik , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/13] mwifiex: re-fix for unaligned accesses Date: Fri, 14 May 2021 12:00:58 +0200 Message-Id: <20210514100106.3404011-11-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210514100106.3404011-1-arnd@kernel.org> References: <20210514100106.3404011-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Arnd Bergmann 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 Acked-by: Kalle Valo --- drivers/net/wireless/marvell/mwifiex/pcie.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; } From patchwork Fri May 14 10:00:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12257375 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54C1EC433ED for ; Fri, 14 May 2021 10:05:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BE796101D for ; Fri, 14 May 2021 10:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233944AbhENKGR (ORCPT ); Fri, 14 May 2021 06:06:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233976AbhENKGI (ORCPT ); Fri, 14 May 2021 06:06:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B44506101D; Fri, 14 May 2021 10:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620986696; bh=+A8VF6/YLLVZtHfI0InfFULYrSxtxYtufbUrU8xRDtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gmhKJJL5SXQjQHnTSGgQ2PjxnGS+rwWSAS3V/Z/ffTc9JenAPf10igkOoMsjVN2Rb e5mST0FjQNa+/WQs2dSiN4FdAejisks0FgWfOrG/AcT3ImFcuomEpazmDe677XdvOz mQm3c49fFcei1qSN14KkY1AjMAhOjkFWKdxewjc1CurH3IXjf4iSvJY52Fmf9e6QSZ 0KiesqlzEeTUXEQIPrZjo/C6Y6x5/OesVx20g8jImzwBziM/K8oz7yyA0lZ1gMiXvO zL7ucIYZVeODSqj5GMsB82HFn3YUj6U7NioxAmfJ7JafuH/EvqiIQZ0dTWzLkVyEuD cLidUnIE5ceUQ== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Linus Torvalds , Vineet Gupta , Arnd Bergmann , "David S. Miller" , Jakub Kicinski , Florian Fainelli , Andrew Lunn , Vladimir Oltean , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 11/13] netpoll: avoid put_unaligned() on single character Date: Fri, 14 May 2021 12:00:59 +0200 Message-Id: <20210514100106.3404011-12-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210514100106.3404011-1-arnd@kernel.org> References: <20210514100106.3404011-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Arnd Bergmann With a planned cleanup, using put_unaligned() on a single character results in a harmless warning: In file included from ./arch/x86/include/generated/asm/unaligned.h:1, from include/linux/etherdevice.h:24, from net/core/netpoll.c:18: net/core/netpoll.c: In function 'netpoll_send_udp': include/asm-generic/unaligned.h:23:9: error: 'packed' attribute ignored for field of type 'unsigned char' [-Werror=attributes] net/core/netpoll.c:431:3: note: in expansion of macro 'put_unaligned' 431 | put_unaligned(0x60, (unsigned char *)ip6h); | ^~~~~~~~~~~~~ include/asm-generic/unaligned.h:23:9: error: 'packed' attribute ignored for field of type 'unsigned char' [-Werror=attributes] net/core/netpoll.c:459:3: note: in expansion of macro 'put_unaligned' 459 | put_unaligned(0x45, (unsigned char *)iph); | ^~~~~~~~~~~~~ Replace this with an open-coded pointer dereference. Signed-off-by: Arnd Bergmann --- net/core/netpoll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index c310c7c1cef7..9c49a38fa315 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len) ip6h = ipv6_hdr(skb); /* ip6h->version = 6; ip6h->priority = 0; */ - put_unaligned(0x60, (unsigned char *)ip6h); + *(unsigned char *)ip6h = 0x60; ip6h->flow_lbl[0] = 0; ip6h->flow_lbl[1] = 0; ip6h->flow_lbl[2] = 0; @@ -456,7 +456,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len) iph = ip_hdr(skb); /* iph->version = 4; iph->ihl = 5; */ - put_unaligned(0x45, (unsigned char *)iph); + *(unsigned char *)iph = 0x45; iph->tos = 0; put_unaligned(htons(ip_len), &(iph->tot_len)); iph->id = htons(atomic_inc_return(&ip_ident));