diff mbox series

[2/2] net: stmmac: remove duplicate dma queue channel macros

Message ID 20220713084728.1311465-2-junxiao.chang@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [1/2] net: stmmac: fix dma queue left shift overflow issue | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/cc_maintainers warning 7 maintainers not CCed: linux-stm32@st-md-mailman.stormreply.com linux-arm-kernel@lists.infradead.org pabeni@redhat.com davem@davemloft.net edumazet@google.com kuba@kernel.org mcoquelin.stm32@gmail.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Chang, Junxiao July 13, 2022, 8:47 a.m. UTC
It doesn't need extra macros for queue 0 & 4. Same macro could
be used for all 8 queues.

Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h      |  4 +---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 ++++-------
 2 files changed, 5 insertions(+), 10 deletions(-)

Comments

Paolo Abeni July 14, 2022, 10:12 a.m. UTC | #1
On Wed, 2022-07-13 at 16:47 +0800, Junxiao Chang wrote:
> It doesn't need extra macros for queue 0 & 4. Same macro could
> be used for all 8 queues.
> 
> Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>

This looks like a net-next cleanup for the previous patch, which
instead looks like a proper -net candidate. Would you mind re-posting
the two patch separatelly, waiting for the fix to land into net-next
before posting the cleanup?

> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h      |  4 +---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 ++++-------
>  2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> index 462ca7ed095a2..a7b725a7519bb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> @@ -330,9 +330,7 @@ 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)	GENMASK(11 + (8 * ((x) - 1)), 8 * (x))
> +#define MTL_RXQ_DMA_QXMDMACH_MASK(x)	GENMASK(3 + (8 * (x)), 8 * (x))
>  #define MTL_RXQ_DMA_QXMDMACH(chan, q)	((chan) << (8 * (q)))

if you here use ((x) & 0x3) instead of (x) and ((q) & 0x3) instead of
(q), you can avoid the if statement below. 
>  
cheers,

Paolo
Chang, Junxiao July 15, 2022, 1:30 a.m. UTC | #2
Sure. Thank you for reviewing it. I will submit 1st "net: stmmac: fix dma queue left shift overflow issue" to net. In future, will post this patch to net-next after 1st patch landing.

Thanks,
Junxiao

-----Original Message-----
From: Paolo Abeni <pabeni@redhat.com> 
Sent: Thursday, July 14, 2022 6:13 PM
To: Chang, Junxiao <junxiao.chang@intel.com>; peppe.cavallaro@st.com; alexandre.torgue@foss.st.com; joabreu@synopsys.com; netdev@vger.kernel.org
Subject: Re: [PATCH 2/2] net: stmmac: remove duplicate dma queue channel macros

On Wed, 2022-07-13 at 16:47 +0800, Junxiao Chang wrote:
> It doesn't need extra macros for queue 0 & 4. Same macro could be used 
> for all 8 queues.
> 
> Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>

This looks like a net-next cleanup for the previous patch, which instead looks like a proper -net candidate. Would you mind re-posting the two patch separatelly, waiting for the fix to land into net-next before posting the cleanup?

> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4.h      |  4 +---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 ++++-------
>  2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
> b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> index 462ca7ed095a2..a7b725a7519bb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
> @@ -330,9 +330,7 @@ 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)	GENMASK(11 + (8 * ((x) - 1)), 8 * (x))
> +#define MTL_RXQ_DMA_QXMDMACH_MASK(x)	GENMASK(3 + (8 * (x)), 8 * (x))
>  #define MTL_RXQ_DMA_QXMDMACH(chan, q)	((chan) << (8 * (q)))

if you here use ((x) & 0x3) instead of (x) and ((q) & 0x3) instead of (q), you can avoid the if statement below. 
>
0x7 since there might be 8 channels/queues? This way looks a bit tricky. 
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 462ca7ed095a2..a7b725a7519bb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -330,9 +330,7 @@  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)	GENMASK(11 + (8 * ((x) - 1)), 8 * (x))
+#define MTL_RXQ_DMA_QXMDMACH_MASK(x)	GENMASK(3 + (8 * (x)), 8 * (x))
 #define MTL_RXQ_DMA_QXMDMACH(chan, q)	((chan) << (8 * (q)))
 
 #define MTL_CHAN_BASE_ADDR		0x00000d00
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index c4d1072fbea39..eccd6b7702c4a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -266,15 +266,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)