Re: [PATCH] net: dsa: use dma_alloc in receive path for symmetry

2024-04-29 Thread Sascha Hauer


On Tue, 23 Apr 2024 19:53:37 +0200, Ahmad Fatoum wrote:
> As explained by the comment, we don't strictly need this at moment, but,
> say, if in future, we decide to save a memory copy in the ping reply
> code by reusing the receive buffer for transmission, it would work for
> all interfaces, except for DSA. Therefore, let's iron out this wrinkle.
> 
> 

Applied, thanks!

[1/1] net: dsa: use dma_alloc in receive path for symmetry
  https://git.pengutronix.de/cgit/barebox/commit/?id=58998f56ee4c (link may 
not be stable)

Best regards,
-- 
Sascha Hauer 




[PATCH] net: dsa: use dma_alloc in receive path for symmetry

2024-04-23 Thread Ahmad Fatoum
As explained by the comment, we don't strictly need this at moment, but,
say, if in future, we decide to save a memory copy in the ping reply
code by reusing the receive buffer for transmission, it would work for
all interfaces, except for DSA. Therefore, let's iron out this wrinkle.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/dsa.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
index ccd7d8755035..e0bf079e4dbf 100644
--- a/drivers/net/dsa.c
+++ b/drivers/net/dsa.c
@@ -270,7 +270,14 @@ static int dsa_switch_register_edev(struct dsa_switch *ds,
struct dsa_port *dp;
 
dp = dsa_port_alloc(ds, dn, port);
-   dp->rx_buf = xmalloc(DSA_PKTSIZE);
+
+   /* DMA is done on buffer in receive ring allocated by network
+* driver. This is then copied into this buffer, so we don't
+* strictly need to use dma_alloc() here, unlike ds->tx_buf.
+* We do it anyway as we don't want DSA buffers to be subtly
+* different to that of a directly used network interface.
+*/
+   dp->rx_buf = dma_alloc(DSA_PKTSIZE);
 
edev = >edev;
edev->priv = dp;
-- 
2.39.2