netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net: stmmac: fix unsafe MTL DMA macro
@ 2022-10-21 11:47 Junxiao Chang
  2022-10-21 11:47 ` [PATCH net-next 2/2] net: stmmac: remove duplicate dma queue channel macros Junxiao Chang
  2022-10-25  4:00 ` [PATCH net-next 1/2] net: stmmac: fix unsafe MTL DMA macro Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Junxiao Chang @ 2022-10-21 11:47 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

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(-)

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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-25  4:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-21 11:47 [PATCH net-next 1/2] net: stmmac: fix unsafe MTL DMA macro Junxiao Chang
2022-10-21 11:47 ` [PATCH net-next 2/2] net: stmmac: remove duplicate dma queue channel macros Junxiao Chang
2022-10-25  4:00 ` [PATCH net-next 1/2] net: stmmac: fix unsafe MTL DMA macro Jakub Kicinski
2022-10-25  4:58   ` Chang, Junxiao

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).