From patchwork Fri Oct 21 11:47:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chang, Junxiao" X-Patchwork-Id: 6664 Return-Path: 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 + 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 ); 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 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 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: 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?= 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 --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From patchwork Fri Oct 21 11:47:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chang, Junxiao" X-Patchwork-Id: 6665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp665845wrr; Fri, 21 Oct 2022 05:20:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59EHamDCwOaXXR9Qydd7iQxw7n9Kqo2MdXgJu4qErPV1eKsRIkrfSJIWhhsdXWkX2aXdaV X-Received: by 2002:a05:6402:2402:b0:45c:a1ce:94d8 with SMTP id t2-20020a056402240200b0045ca1ce94d8mr16674029eda.50.1666354838865; Fri, 21 Oct 2022 05:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666354838; cv=none; d=google.com; s=arc-20160816; b=yS/XWKawA0deh1rZyDGbxDDmXpWKFVtJB+Y9PiXAMqOH+o4OTs0ESGTU/THB6qDRh2 hkbbo0f4EbwUCxAY/wR5p1CfkdpeUtkYtV9BKrxQT1qrk63JuEOX9BHGG/uPijJLUiYR YFB4+TkrBenxE0cvpxKHQjposY0e5RrZz5CEfpv0t0+sWKv4c+43lYE8cy0s6nwR9V9/ I85Ak33W9mBzuIf47gNpg5Lm06fyg+SYeqHmWkz2a+B38h2GhsEDhOqg3/KfiLG3Z+yo MQ4VZ3VdhzhTpM5N+YAvy4K6Ue6WXUmwIElxvSFN5UzloPzZ8gJ6LVtUEvmUFx1zArjr yQ9w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eo7v2XpMJF4gtv1nLx6LNm55I3cDwEAWMHivvxK9wBs=; b=VdIJYBYHc36ZJ6/X5frfkBWjlM9xnO1UqZCw/rvNc0vQ4FabtiwjRh5XCK5AZC4toJ ptzrclB9+Rti0vxI3vyUgeKLWdS+zOfTKeK+298EWXio5IHP3RrBezs42IfzZFBaURTB 52leeC5Ju6NcmEk6NbxxrYeChaQd7set0+iUdiC+mDn6wtC6qvOOzHp1twE6Jx9ywKQJ //t+djHRHdDmKOsrZkKERV7WlebEip08ykgJXRnfuB4jag4fRTqS3ju0Ln9NDN/qpuLi DlOtas2qmrlk4RR/m5cwnY290ygA53Go96ohXQuxX5H+sm8ukXCYZOA39P+ah/kRfe1E eKag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=loxhvW5S; 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 i13-20020a1709064fcd00b00780def41dc4si21443586ejw.527.2022.10.21.05.20.13; Fri, 21 Oct 2022 05:20:38 -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=loxhvW5S; 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 S229832AbiJUL4o (ORCPT + 99 others); Fri, 21 Oct 2022 07:56:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbiJUL4l (ORCPT ); Fri, 21 Oct 2022 07:56:41 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED65262DFD; Fri, 21 Oct 2022 04:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666353393; x=1697889393; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X4ReGExCC4IsU35G/nCfB0MLcAh4NzfBpvMtiQxP8CQ=; b=loxhvW5SOviAIKBj3efLMWmGt3uWx0KRTW0gDh2/WsNNdEmzHeSQk9k4 /EQPj4igUi9nLiJIMZyyMdcpDqh6k0cyeh2W86KxlMaN/n2inznnDe1jr Y0UONI27XfwUpWmhpYrqtpocHqJvBOo9cHkg2Cr3cwp3jSegpLlDYsTH7 1ET06XLmsqGjNRDVpu7EGjCF0XjJ97O0tmf8ImxXTmzffgC6go5zCj5lE SZxjLpXujSmQRqIb8vQODZiObZ0vUog+SlwhG5Esq8mDGoL5hz5mVjkSz ftb/l+7wyycuFWMsKKpIjfKvi5ht5BLbGn87VsPkh1b5j/vgdZzb3cDDU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="393286605" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="393286605" 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:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="632891131" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="632891131" 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:28 -0700 From: Junxiao Chang 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 2/2] net: stmmac: remove duplicate dma queue channel macros Date: Fri, 21 Oct 2022 19:47:11 +0800 Message-Id: <20221021114711.1610797-2-junxiao.chang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021114711.1610797-1-junxiao.chang@intel.com> References: <20221021114711.1610797-1-junxiao.chang@intel.com> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747299691174632048?= X-GMAIL-MSGID: =?utf-8?q?1747299691174632048?= It doesn't need extra macros for queue 0 & 4. Same macro could be used for all 8 queues. Signed-off-by: Junxiao Chang --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 2 -- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 ++++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index 3c1490408a1c3..ccd49346d3b30 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -331,8 +331,6 @@ enum power_event { #define MTL_RXQ_DMA_MAP0 0x00000c30 /* queue 0 to 3 */ #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) (0xf << 8 * (x)) #define MTL_RXQ_DMA_QXMDMACH(chan, q) ((chan) << (8 * (q))) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index c25bfecb4a2df..64b916728bdd4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -219,15 +219,12 @@ static void dwmac4_map_mtl_dma(struct mac_device_info *hw, u32 queue, u32 chan) else value = readl(ioaddr + MTL_RXQ_DMA_MAP1); - if (queue == 0 || queue == 4) { - value &= ~MTL_RXQ_DMA_Q04MDMACH_MASK; - value |= MTL_RXQ_DMA_Q04MDMACH(chan); - } else if (queue > 4) { - value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4); - value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4); - } else { + if (queue < 4) { value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue); value |= MTL_RXQ_DMA_QXMDMACH(chan, queue); + } else { + value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4); + value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4); } if (queue < 4)