net: dma: use dmaengine_desc_set_callback()
Subsystems (9)
PATCH 1/1 net: dma: use dmaengine_desc_set_callback()
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and callback_param fields of struct dma_async_tx_descriptor with calls to the dmaengine_desc_set_callback() helper across net drivers.
No functional change intended. Prepare to make struct dma_async_tx_descriptor private to the DMA engine.
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++---- drivers/net/wwan/qcom_bam_dmux.c | 10 ++++------ 4 files changed, 9 insertions(+), 16 deletions(-)
drivers/net/ethernet/allwinner/sun4i-emac.c +1 -2
@@ -303,8 +303,7 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, goto prepare_err; } - desc->callback_param = req; - desc->callback = emac_dma_done_callback; +dmaengine_desc_set_callback (desc, emac_dma_done_callback,NULL , req); cookie =dmaengine_submit (desc); ret =dma_submit_error (cookie);
drivers/net/ethernet/micrel/ks8842.c +2 -4
@@ -453,8 +453,7 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)if (!ctl->adesc)return NETDEV_TX_BUSY ; - ctl->adesc->callback_param = netdev; - ctl->adesc->callback = ks8842_dma_tx_cb; +dmaengine_desc_set_callback (ctl->adesc, ks8842_dma_tx_cb,NULL , netdev);dmaengine_submit (ctl->adesc); netdev->stats.tx_bytes += skb->len;
@@ -567,8 +566,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev) goto out; } - ctl->adesc->callback_param = netdev; - ctl->adesc->callback = ks8842_dma_rx_cb; +dmaengine_desc_set_callback (ctl->adesc, ks8842_dma_rx_cb,NULL , netdev);dmaengine_submit (ctl->adesc); }else { err = -ENOMEM ;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2 -4
@@ -1014,8 +1014,7 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) skbuf_dma->skb = skb; skbuf_dma->sg_len = sg_len; - dma_tx_desc->callback_param = lp; - dma_tx_desc->callback_result = axienet_dma_tx_cb; +dmaengine_desc_set_callback (dma_tx_desc,NULL , axienet_dma_tx_cb, lp);/* Claim the ring slot only after the steps above that can fail. The * completion callback can't run before dmaengine_submit(). */
@@ -1565,8 +1564,7 @@ static void axienet_rx_submit_desc(struct net_device *ndev) skbuf_dma->skb = skb; skbuf_dma->dma_address =sg_dma_address (skbuf_dma->sgl); skbuf_dma->desc = dma_rx_desc; - dma_rx_desc->callback_param = lp; - dma_rx_desc->callback_result = axienet_dma_rx_cb; +dmaengine_desc_set_callback (dma_rx_desc,NULL , axienet_dma_rx_cb, lp); lp->rx_ring_head++;dmaengine_submit (dma_rx_desc);
drivers/net/wwan/qcom_bam_dmux.c +4 -6
@@ -195,9 +195,8 @@ static bool bam_dmux_skb_dma_submit_tx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_tx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_tx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }
@@ -477,9 +476,8 @@ static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_rx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_rx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }
Signature · 1 line
2.43.0
Quoted 16 lines · On Mon, Nov 02, 2026 at 02:19:16PM -0500, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across net drivers.No functional change intended. Prepare to make struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>--- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++---- drivers/net/wwan/qcom_bam_dmux.c | 10 ++++------ 4 files changed, 9 insertions(+), 16 deletions(-)
[...]
Quoted 17 lines
drivers/net/wwan/qcom_bam_dmux.c +2
-3@@ -195,9 +195,8 @@ static bool bam_dmux_skb_dma_submit_tx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_tx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_tx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }
drivers/net/wwan/qcom_bam_dmux.c static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma) · line 480
Quoted 8 lines
drivers/net/wwan/qcom_bam_dmux.c +2
-3@@ -477,9 +476,8 @@ static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_rx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_rx_callback,NULL , skb_dma); +dmaengine_submit (desc);
I noticed in the above that the return value of dmaengine_submit is discarded instead of stored.
Is that intentional? I suppose it might be because AFAICT cookie is never used and the commit message says "no functional change intended".
Quoted 49 lines · Joe Damato
Quoted 16 lines · On Mon, Nov 02, 2026 at 02:19:16PM -0500, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across net drivers.No functional change intended. Prepare to make struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>--- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++---- drivers/net/wwan/qcom_bam_dmux.c | 10 ++++------ 4 files changed, 9 insertions(+), 16 deletions(-)[...]
Quoted 17 lines
drivers/net/wwan/qcom_bam_dmux.c +2
-3@@ -195,9 +195,8 @@ static bool bam_dmux_skb_dma_submit_tx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_tx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_tx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }drivers/net/wwan/qcom_bam_dmux.c static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma) · line 480
Quoted 8 lines
drivers/net/wwan/qcom_bam_dmux.c +2
-3@@ -477,9 +476,8 @@ static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_rx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_rx_callback,NULL , skb_dma); +dmaengine_submit (desc);I noticed in the above that the return value of
dmaengine_submitis discarded instead of stored.
Quoted 2 lines
Is that intentional? I suppose it might be because AFAICT cookie is never used and the commit message says "no functional change intended".
dma_cookie_assign() already set desc->cookie in dmaengine_submit(). Of couse it is not obvious. Do you need me update commit message to descript it.
Frank
Quoted 2 lines
Reviewed-by Joe Damato <[email protected]>
Quoted 50 lines · Frank Li
Quoted 49 lines · Joe Damato
Quoted 16 lines · On Mon, Nov 02, 2026 at 02:19:16PM -0500, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across net drivers.No functional change intended. Prepare to make struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>--- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++---- drivers/net/wwan/qcom_bam_dmux.c | 10 ++++------ 4 files changed, 9 insertions(+), 16 deletions(-)[...]
Quoted 17 lines
drivers/net/wwan/qcom_bam_dmux.c +2
-3@@ -195,9 +195,8 @@ static bool bam_dmux_skb_dma_submit_tx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_tx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_tx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }drivers/net/wwan/qcom_bam_dmux.c static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma) · line 480
Quoted 8 lines
drivers/net/wwan/qcom_bam_dmux.c +2
-3@@ -477,9 +476,8 @@ static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_rx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_rx_callback,NULL , skb_dma); +dmaengine_submit (desc);I noticed in the above that the return value of
dmaengine_submitis discarded instead of stored.
Quoted 5 lines
Quoted 2 lines
Is that intentional? I suppose it might be because AFAICT cookie is never used and the commit message says "no functional change intended".
dma_cookie_assign()already setdesc->cookieindmaengine_submit(). Of couse it is not obvious. Do you need me update commit message to descript it.
Ah, I see it now. In the tx_submit callback it looks like dma drivers set the cookie.
So removing it here really is a no-op since it was getting set, as you said, during submit.
My mistake. I don't think it's worth respinning just to fix the commit message just because I didn't dig deep enough :)
Quoted 11 lines · On Mon, Nov 2, 2026 at 8:19 PM <[email protected]> wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across net drivers.No functional change intended. Prepare to make struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>
Quoted 100 lines
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++---- drivers/net/wwan/qcom_bam_dmux.c | 10 ++++------ 4 files changed, 9 insertions(+), 16 deletions(-)drivers/net/ethernet/allwinner/sun4i-emac.c +1
-2@@ -303,8 +303,7 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, goto prepare_err; } - desc->callback_param = req; - desc->callback = emac_dma_done_callback; +dmaengine_desc_set_callback (desc, emac_dma_done_callback,NULL , req); cookie =dmaengine_submit (desc); ret =dma_submit_error (cookie);drivers/net/ethernet/micrel/ks8842.c +2
-4@@ -453,8 +453,7 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)if (!ctl->adesc)return NETDEV_TX_BUSY ; - ctl->adesc->callback_param = netdev; - ctl->adesc->callback = ks8842_dma_tx_cb; +dmaengine_desc_set_callback (ctl->adesc, ks8842_dma_tx_cb,NULL , netdev);dmaengine_submit (ctl->adesc); netdev->stats.tx_bytes += skb->len;@@ -567,8 +566,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev) goto out; } - ctl->adesc->callback_param = netdev; - ctl->adesc->callback = ks8842_dma_rx_cb; +dmaengine_desc_set_callback (ctl->adesc, ks8842_dma_rx_cb,NULL , netdev);dmaengine_submit (ctl->adesc); }else { err = -ENOMEM ;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-4@@ -1014,8 +1014,7 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) skbuf_dma->skb = skb; skbuf_dma->sg_len = sg_len; - dma_tx_desc->callback_param = lp; - dma_tx_desc->callback_result = axienet_dma_tx_cb; +dmaengine_desc_set_callback (dma_tx_desc,NULL , axienet_dma_tx_cb, lp);/* Claim the ring slot only after the steps above that can fail. The * completion callback can't run before dmaengine_submit(). */ @@ -1565,8 +1564,7 @@ static void axienet_rx_submit_desc(struct net_device *ndev) skbuf_dma->skb = skb; skbuf_dma->dma_address =sg_dma_address (skbuf_dma->sgl); skbuf_dma->desc = dma_rx_desc; - dma_rx_desc->callback_param = lp; - dma_rx_desc->callback_result = axienet_dma_rx_cb; +dmaengine_desc_set_callback (dma_rx_desc,NULL , axienet_dma_rx_cb, lp); lp->rx_ring_head++;dmaengine_submit (dma_rx_desc);drivers/net/wwan/qcom_bam_dmux.c +4
-7@@ -195,9 +195,8 @@ static bool bam_dmux_skb_dma_submit_tx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_tx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_tx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }@@ -477,9 +476,8 @@ static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_rx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_rx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; } --2.43.0
Quoted 10 lines · On 11/3/2026 12:49 AM, [email protected] wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across net drivers.No functional change intended. Prepare to make struct
dma_async_tx_descriptorprivate to the DMA engine.Signed-off-by Frank Li <[email protected]>
Thanks!
Suraj
Quoted 97 lines
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- drivers/net/ethernet/micrel/ks8842.c | 6 ++---- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++---- drivers/net/wwan/qcom_bam_dmux.c | 10 ++++------ 4 files changed, 9 insertions(+), 16 deletions(-)drivers/net/ethernet/allwinner/sun4i-emac.c +1
-2@@ -303,8 +303,7 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, goto prepare_err; } - desc->callback_param = req; - desc->callback = emac_dma_done_callback; +dmaengine_desc_set_callback (desc, emac_dma_done_callback,NULL , req); cookie =dmaengine_submit (desc); ret =dma_submit_error (cookie);drivers/net/ethernet/micrel/ks8842.c +2
-4@@ -453,8 +453,7 @@ static int ks8842_tx_frame_dma(struct sk_buff *skb, struct net_device *netdev)if (!ctl->adesc)return NETDEV_TX_BUSY ; - ctl->adesc->callback_param = netdev; - ctl->adesc->callback = ks8842_dma_tx_cb; +dmaengine_desc_set_callback (ctl->adesc, ks8842_dma_tx_cb,NULL , netdev);dmaengine_submit (ctl->adesc); netdev->stats.tx_bytes += skb->len;@@ -567,8 +566,7 @@ static int __ks8842_start_new_rx_dma(struct net_device *netdev) goto out; } - ctl->adesc->callback_param = netdev; - ctl->adesc->callback = ks8842_dma_rx_cb; +dmaengine_desc_set_callback (ctl->adesc, ks8842_dma_rx_cb,NULL , netdev);dmaengine_submit (ctl->adesc); }else { err = -ENOMEM ;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-4@@ -1014,8 +1014,7 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) skbuf_dma->skb = skb; skbuf_dma->sg_len = sg_len; - dma_tx_desc->callback_param = lp; - dma_tx_desc->callback_result = axienet_dma_tx_cb; +dmaengine_desc_set_callback (dma_tx_desc,NULL , axienet_dma_tx_cb, lp);/* Claim the ring slot only after the steps above that can fail. The * completion callback can't run before dmaengine_submit(). */ @@ -1565,8 +1564,7 @@ static void axienet_rx_submit_desc(struct net_device *ndev) skbuf_dma->skb = skb; skbuf_dma->dma_address =sg_dma_address (skbuf_dma->sgl); skbuf_dma->desc = dma_rx_desc; - dma_rx_desc->callback_param = lp; - dma_rx_desc->callback_result = axienet_dma_rx_cb; +dmaengine_desc_set_callback (dma_rx_desc,NULL , axienet_dma_rx_cb, lp); lp->rx_ring_head++;dmaengine_submit (dma_rx_desc);drivers/net/wwan/qcom_bam_dmux.c +4
-6@@ -195,9 +195,8 @@ static bool bam_dmux_skb_dma_submit_tx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_tx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_tx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }@@ -477,9 +476,8 @@ static bool bam_dmux_skb_dma_submit_rx(struct bam_dmux_skb_dma *skb_dma)return false; } - desc->callback = bam_dmux_rx_callback; - desc->callback_param = skb_dma; - desc->cookie =dmaengine_submit (desc); +dmaengine_desc_set_callback (desc, bam_dmux_rx_callback,NULL , skb_dma); +dmaengine_submit (desc);return true; }
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Mon, 2 Nov 2026 14:19:16 -0500 you wrote:
From: Frank Li <[email protected]>
Replace open-coded assignments to callback and
callback_paramfields of structdma_async_tx_descriptorwith calls to thedmaengine_desc_set_callback()helper across net drivers.No functional change intended. Prepare to make struct
dma_async_tx_descriptorprivate to the DMA engine.[...]
Here is the summary with links:
- net: dma: use dmaengine_desc_set_callback()
https://git.kernel.org/netdev/net-next/c/e281e85235cf
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html