Re: [PATCH v2 09/64] dmaengine: ioat: convert cleanup tasklet to dma_chan BH

From: Dave Jiang

Date: Mon Jul 27 2026 - 16:42:25 EST




On 7/27/26 1:28 PM, Allen Pais wrote:
> Replace the per-channel tasklet with the shared dma_chan BH helper.
> The handler continues to run in softirq context while dmaengine owns
> the common scheduling and teardown mechanism.
>
> Signed-off-by: Allen Pais <allen.lkml@xxxxxxxxx>

Acked-by: Dave Jiang <dave.jiang@xxxxxxxxx>


> ---
> drivers/dma/ioat/dma.c | 14 +++++++-------
> drivers/dma/ioat/dma.h | 3 +--
> drivers/dma/ioat/init.c | 2 +-
> 3 files changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
> index ee93b029f9e3..827b46c6354a 100644
> --- a/drivers/dma/ioat/dma.c
> +++ b/drivers/dma/ioat/dma.c
> @@ -110,7 +110,7 @@ irqreturn_t ioat_dma_do_interrupt(int irq, void *data)
> for_each_set_bit(bit, &attnstatus, BITS_PER_LONG) {
> ioat_chan = ioat_chan_by_index(instance, bit);
> if (test_bit(IOAT_RUN, &ioat_chan->state))
> - tasklet_schedule(&ioat_chan->cleanup_task);
> + dma_chan_schedule_bh(&ioat_chan->dma_chan);
> }
>
> writeb(intrctrl, instance->reg_base + IOAT_INTRCTRL_OFFSET);
> @@ -127,7 +127,7 @@ irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data)
> struct ioatdma_chan *ioat_chan = data;
>
> if (test_bit(IOAT_RUN, &ioat_chan->state))
> - tasklet_schedule(&ioat_chan->cleanup_task);
> + dma_chan_schedule_bh(&ioat_chan->dma_chan);
>
> return IRQ_HANDLED;
> }
> @@ -161,11 +161,11 @@ void ioat_stop(struct ioatdma_chan *ioat_chan)
> /* flush inflight timers */
> timer_delete_sync(&ioat_chan->timer);
>
> - /* flush inflight tasklet runs */
> - tasklet_kill(&ioat_chan->cleanup_task);
> + /* flush inflight BH runs */
> + dma_chan_kill_bh(&ioat_chan->dma_chan);
>
> /* final cleanup now that everything is quiesced and can't re-arm */
> - ioat_cleanup_event(&ioat_chan->cleanup_task);
> + ioat_cleanup_event(&ioat_chan->dma_chan);
> }
>
> static void __ioat_issue_pending(struct ioatdma_chan *ioat_chan)
> @@ -690,9 +690,9 @@ static void ioat_cleanup(struct ioatdma_chan *ioat_chan)
> spin_unlock_bh(&ioat_chan->cleanup_lock);
> }
>
> -void ioat_cleanup_event(struct tasklet_struct *t)
> +void ioat_cleanup_event(struct dma_chan *c)
> {
> - struct ioatdma_chan *ioat_chan = from_tasklet(ioat_chan, t, cleanup_task);
> + struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
>
> ioat_cleanup(ioat_chan);
> if (!test_bit(IOAT_RUN, &ioat_chan->state))
> diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
> index e8a880f338c6..4bdb1ae937e4 100644
> --- a/drivers/dma/ioat/dma.h
> +++ b/drivers/dma/ioat/dma.h
> @@ -111,7 +111,6 @@ struct ioatdma_chan {
> struct ioatdma_device *ioat_dma;
> dma_addr_t completion_dma;
> u64 *completion;
> - struct tasklet_struct cleanup_task;
> struct kobject kobj;
>
> /* ioat v2 / v3 channel attributes
> @@ -385,7 +384,7 @@ int ioat_reset_hw(struct ioatdma_chan *ioat_chan);
> enum dma_status
> ioat_tx_status(struct dma_chan *c, dma_cookie_t cookie,
> struct dma_tx_state *txstate);
> -void ioat_cleanup_event(struct tasklet_struct *t);
> +void ioat_cleanup_event(struct dma_chan *c);
> void ioat_timer_event(struct timer_list *t);
> int ioat_check_space_lock(struct ioatdma_chan *ioat_chan, int num_descs);
> void ioat_issue_pending(struct dma_chan *chan);
> diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
> index 737496391109..314676e1cbc4 100644
> --- a/drivers/dma/ioat/init.c
> +++ b/drivers/dma/ioat/init.c
> @@ -765,7 +765,7 @@ ioat_init_channel(struct ioatdma_device *ioat_dma,
> list_add_tail(&ioat_chan->dma_chan.device_node, &dma->channels);
> ioat_dma->idx[idx] = ioat_chan;
> timer_setup(&ioat_chan->timer, ioat_timer_event, 0);
> - tasklet_setup(&ioat_chan->cleanup_task, ioat_cleanup_event);
> + dma_chan_init_bh(&ioat_chan->dma_chan, ioat_cleanup_event);
> }
>
> #define IOAT_NUM_SRC_TEST 6 /* must be <= 8 */