* [PATCH net-next,v2] net: stmmac: remove duplicate dma queue channel macros
@ 2022-10-25 8:17 Junxiao Chang
2022-10-27 10:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Junxiao Chang @ 2022-10-25 8:17 UTC (permalink / raw)
To: peppe.cavallaro, alexandre.torgue, joabreu, davem, edumazet,
kuba, pabeni, mcoquelin.stm32, Joao.Pinto, netdev, linux-stm32,
linux-arm-kernel, linux-kernel
Cc: junxiao.chang, veekhee
It doesn't need extra macros for queue 0 & 4. Same macro could
be used for all 8 queues. Related queue/channel functions could
be combined together.
Original macro which has two same parameters is unsafe macro and
might have potential 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.
Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
v2: combined "if (queue < 4)" and "else" according to Vee Khee's suggestion.
v1: https://lore.kernel.org/r/20221025053555.1883731-1-junxiao.chang@intel.com
---
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 4 +---
.../net/ethernet/stmicro/stmmac/dwmac4_core.c | 21 ++++++-------------
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 71dad409f78b0..ccd49346d3b30 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -331,9 +331,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) (0xf << 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 c25bfecb4a2df..513f6ea335a82 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -214,26 +214,17 @@ static void dwmac4_map_mtl_dma(struct mac_device_info *hw, u32 queue, u32 chan)
void __iomem *ioaddr = hw->pcsr;
u32 value;
- if (queue < 4)
+ if (queue < 4) {
value = readl(ioaddr + MTL_RXQ_DMA_MAP0);
- 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 {
value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue);
value |= MTL_RXQ_DMA_QXMDMACH(chan, queue);
- }
-
- if (queue < 4)
writel(value, ioaddr + MTL_RXQ_DMA_MAP0);
- else
+ } else {
+ value = readl(ioaddr + MTL_RXQ_DMA_MAP1);
+ value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4);
+ value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4);
writel(value, ioaddr + MTL_RXQ_DMA_MAP1);
+ }
}
static void dwmac4_config_cbs(struct mac_device_info *hw,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next,v2] net: stmmac: remove duplicate dma queue channel macros
2022-10-25 8:17 [PATCH net-next,v2] net: stmmac: remove duplicate dma queue channel macros Junxiao Chang
@ 2022-10-27 10:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-27 10:20 UTC (permalink / raw)
To: Junxiao Chang
Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, edumazet,
kuba, pabeni, mcoquelin.stm32, Joao.Pinto, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, veekhee
Hello:
This patch was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 25 Oct 2022 16:17:47 +0800 you wrote:
> It doesn't need extra macros for queue 0 & 4. Same macro could
> be used for all 8 queues. Related queue/channel functions could
> be combined together.
>
> Original macro which has two same parameters is unsafe macro and
> might have potential 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.
>
> [...]
Here is the summary with links:
- [net-next,v2] net: stmmac: remove duplicate dma queue channel macros
https://git.kernel.org/netdev/net-next/c/330543d04f2c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-27 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 8:17 [PATCH net-next,v2] net: stmmac: remove duplicate dma queue channel macros Junxiao Chang
2022-10-27 10:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).