Message ID | 20221021114711.1610797-1-junxiao.chang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp664931wrr; Fri, 21 Oct 2022 05:18:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JsbnTOEjzIbl2qKr74mupsuX1nGpi36a7xv4oDZgf24J/Pk6jz41+1l+NPFmd0svr52Be X-Received: by 2002:a17:907:2e01:b0:78d:e768:e845 with SMTP id ig1-20020a1709072e0100b0078de768e845mr15379488ejc.484.1666354714126; Fri, 21 Oct 2022 05:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666354714; cv=none; d=google.com; s=arc-20160816; b=jTDqYoVpi4O6SECa3hc+ec2NajrbBH1l/wbnnfoZ/p4cxKVGdPS1KDPhhvW8Nhlndw Nvet6M53MG6BBDDrc2oDGwmQEUKb2PbvqYgYkq5BNod0LDaQM3gDcWAZQl6mSUtJPMLY 12CvF6oFzVvJI5PlQQFH2BEDBV8XXmpH5o06lrRzbjTAG0abISjnkYGBwlJYzpEgebJM 1XwDS1Ay6A0KJ5ZZo9egkcBkkL/fwHrT2mhNEk4oMgTZL+W60yBV8Bd2MJS6jKfLPL1L cUP84n13gaCLPRji8LPSeIXvKgzzhrEDKmWKI9pkDMY8gBYPSZcVqRM1ejG7b4pRaAj0 hYUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RoBLc/gaRPBSLRqxLnx5ICTWfOaiz9mx8i8ZwEWMH6w=; b=xwgtLcGcN5oOa7sVk/b7be1/477dJ+zKzQkNMMrPUDs0CqdGFtRDL9sg6yRi/3ib6g YKaAfKf95O7SEdVUDkqDqgmkYqvEyLZVuEYpxPmqJKI9SnKLkkjuwB5xLU4LHgQXyKH4 Wzr/2LK2ttGFS2vjDgG+7+mnRppMwFkdDp2Qf10pBv2YQ0HLgnQhjU4jeOP3B8PfIDoK vjAJgbaA5efO0RzBH5lNVCFyU4dGsbwgic1Fgfla5Wc5mt9qUgaF9IRpM4w0hWgrZn/X KCzuPIe6uUdKkK0vLWWMb3bCZMWWGO+Swl5IedlBfJGyn/KJdFP517du3IxeSuTynU3j 0fAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nbDCEMIU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz4-20020a1709072ce400b0079a9eed8c1bsi1656885ejc.894.2022.10.21.05.18.04; Fri, 21 Oct 2022 05:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nbDCEMIU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbiJUL4g (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Fri, 21 Oct 2022 07:56:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiJUL4e (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Oct 2022 07:56:34 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04DA5263964; Fri, 21 Oct 2022 04:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666353390; x=1697889390; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Rtll0/nGhqW301uS5yfdR9R0zXk9od1cA+YGVzH/vYA=; b=nbDCEMIUyrpr7IwTriwxi2GG3V1yrfAV2H8ITQ47fIwv17waLH0XzhPt xoWEYk9migK/zxJ1IVq1xzNp6VyZIiZ1nsQGfIGZofCXcEs18FZSYppGy /7Z5cDkPFjdBfsdvh813ony9wpEZSTPt6J8fSeskAkFIpaSEH9ffwxgpT l2bZIohdckV3AxUCzJ8ZWdqURP/e7U7IrEwyvqX3Mpbr0hLCrM7kxjlLu 9/DCXbcnSIZ8PNyjX2OQIFfnFCrJOaCTYRcbgYchQxVCD83OWe8KjCyDy EPc7LVFF613ukw/FrglpAxbwqacLNVXbeTicejdmFtyZwwCUucFbpZTJf Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="393286599" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="393286599" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 04:56:28 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="632891119" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="632891119" Received: from junxiaochang.bj.intel.com ([10.238.135.52]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 04:56:25 -0700 From: Junxiao Chang <junxiao.chang@intel.com> To: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, Joao.Pinto@synopsys.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: junxiao.chang@intel.com Subject: [PATCH net-next 1/2] net: stmmac: fix unsafe MTL DMA macro Date: Fri, 21 Oct 2022 19:47:10 +0800 Message-Id: <20221021114711.1610797-1-junxiao.chang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747299560701514647?= X-GMAIL-MSGID: =?utf-8?q?1747299560701514647?= |
Series |
[net-next,1/2] net: stmmac: fix unsafe MTL DMA macro
|
|
Commit Message
Chang, Junxiao
Oct. 21, 2022, 11:47 a.m. UTC
Macro like "#define abc(x) (x, x)" is unsafe which might introduce
side effects. Each MTL RxQ DMA channel mask is 4 bits, so using
(0xf << chan) instead of GENMASK(x + 3, x) to avoid unsafe macro.
Fixes: d43042f4da3e ("net: stmmac: mapping mtl rx to dma channel")
Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, 21 Oct 2022 19:47:10 +0800 Junxiao Chang wrote: > Macro like "#define abc(x) (x, x)" is unsafe which might introduce > side effects. Each MTL RxQ DMA channel mask is 4 bits, so using > (0xf << chan) instead of GENMASK(x + 3, x) to avoid unsafe macro. > > Fixes: d43042f4da3e ("net: stmmac: mapping mtl rx to dma channel") You need to point out an existing usage where this is causing problems, otherwise this is not a fix. And squash the two patches together, it's going to be easier to review.
Thank you for reviewing it. There is no real issue if this macro only be used in stmmac driver and parameter is not function or "i++". I will squash these two patches. Regards, Junxiao -----Original Message----- From: Jakub Kicinski <kuba@kernel.org> Sent: Tuesday, October 25, 2022 12:00 PM To: Chang, Junxiao <junxiao.chang@intel.com> Cc: peppe.cavallaro@st.com; alexandre.torgue@foss.st.com; joabreu@synopsys.com; davem@davemloft.net; edumazet@google.com; pabeni@redhat.com; mcoquelin.stm32@gmail.com; Joao.Pinto@synopsys.com; netdev@vger.kernel.org; linux-stm32@st-md-mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 1/2] net: stmmac: fix unsafe MTL DMA macro On Fri, 21 Oct 2022 19:47:10 +0800 Junxiao Chang wrote: > Macro like "#define abc(x) (x, x)" is unsafe which might introduce > side effects. Each MTL RxQ DMA channel mask is 4 bits, so using (0xf > << chan) instead of GENMASK(x + 3, x) to avoid unsafe macro. > > Fixes: d43042f4da3e ("net: stmmac: mapping mtl rx to dma channel") You need to point out an existing usage where this is causing problems, otherwise this is not a fix. And squash the two patches together, it's going to be easier to review.
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index 71dad409f78b0..3c1490408a1c3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -333,7 +333,7 @@ enum power_event { #define MTL_RXQ_DMA_MAP1 0x00000c34 /* queue 4 to 7 */ #define MTL_RXQ_DMA_Q04MDMACH_MASK GENMASK(3, 0) #define MTL_RXQ_DMA_Q04MDMACH(x) ((x) << 0) -#define MTL_RXQ_DMA_QXMDMACH_MASK(x) GENMASK(11 + (8 * ((x) - 1)), 8 * (x)) +#define MTL_RXQ_DMA_QXMDMACH_MASK(x) (0xf << 8 * (x)) #define MTL_RXQ_DMA_QXMDMACH(chan, q) ((chan) << (8 * (q))) #define MTL_CHAN_BASE_ADDR 0x00000d00