From: Allen Pais <apais@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: tj@kernel.org, keescook@chromium.org,
mporter@kernel.crashing.org, alex.bou9@gmail.com
Subject: [PATCH] rapidio/tsi721: Convert from tasklet to BH workqueue
Date: Wed, 3 Apr 2024 16:36:17 +0000 [thread overview]
Message-ID: <20240403163617.20710-1-apais@linux.microsoft.com> (raw)
The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.
This patch converts drivers/rapidio/* from tasklet to BH workqueue.
Based on the work done by Tejun Heo <tj@kernel.org>
Branch: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-6.10
Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
drivers/rapidio/devices/tsi721.h | 2 +-
drivers/rapidio/devices/tsi721_dma.c | 15 +++++++--------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/rapidio/devices/tsi721.h b/drivers/rapidio/devices/tsi721.h
index 4f996ce62725..8fd8127d11d1 100644
--- a/drivers/rapidio/devices/tsi721.h
+++ b/drivers/rapidio/devices/tsi721.h
@@ -704,7 +704,7 @@ struct tsi721_bdma_chan {
struct tsi721_tx_desc *active_tx;
struct list_head queue;
struct list_head free_list;
- struct tasklet_struct tasklet;
+ struct work_struct work;
bool active;
};
diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c
index f77f75172bdc..f71cbbacca12 100644
--- a/drivers/rapidio/devices/tsi721_dma.c
+++ b/drivers/rapidio/devices/tsi721_dma.c
@@ -278,7 +278,7 @@ void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan)
/* Disable BDMA channel interrupts */
iowrite32(0, bdma_chan->regs + TSI721_DMAC_INTE);
if (bdma_chan->active)
- tasklet_hi_schedule(&bdma_chan->tasklet);
+ queue_work(system_bh_highpri_wq, &bdma_chan->work);
}
#ifdef CONFIG_PCI_MSI
@@ -296,7 +296,7 @@ static irqreturn_t tsi721_bdma_msix(int irq, void *ptr)
struct tsi721_bdma_chan *bdma_chan = ptr;
if (bdma_chan->active)
- tasklet_hi_schedule(&bdma_chan->tasklet);
+ queue_work(system_bh_highpri_wq, &bdma_chan->work);
return IRQ_HANDLED;
}
#endif /* CONFIG_PCI_MSI */
@@ -568,9 +568,9 @@ static void tsi721_advance_work(struct tsi721_bdma_chan *bdma_chan,
bdma_chan->id);
}
-static void tsi721_dma_tasklet(unsigned long data)
+static void tsi721_dma_work(struct work_struct *t)
{
- struct tsi721_bdma_chan *bdma_chan = (struct tsi721_bdma_chan *)data;
+ struct tsi721_bdma_chan *bdma_chan = from_work(bdma_chan, t, work);
u32 dmac_int, dmac_sts;
dmac_int = ioread32(bdma_chan->regs + TSI721_DMAC_INT);
@@ -790,7 +790,7 @@ static void tsi721_free_chan_resources(struct dma_chan *dchan)
tsi721_bdma_interrupt_enable(bdma_chan, 0);
bdma_chan->active = false;
tsi721_sync_dma_irq(bdma_chan);
- tasklet_kill(&bdma_chan->tasklet);
+ cancel_work_sync(&bdma_chan->work);
INIT_LIST_HEAD(&bdma_chan->free_list);
kfree(bdma_chan->tx_desc);
tsi721_bdma_ch_free(bdma_chan);
@@ -990,8 +990,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
INIT_LIST_HEAD(&bdma_chan->queue);
INIT_LIST_HEAD(&bdma_chan->free_list);
- tasklet_init(&bdma_chan->tasklet, tsi721_dma_tasklet,
- (unsigned long)bdma_chan);
+ INIT_WORK(&bdma_chan->work, tsi721_dma_work);
list_add_tail(&bdma_chan->dchan.device_node,
&mport->dma.channels);
nr_channels++;
@@ -1033,7 +1032,7 @@ void tsi721_unregister_dma(struct tsi721_device *priv)
tsi721_bdma_interrupt_enable(bdma_chan, 0);
bdma_chan->active = false;
tsi721_sync_dma_irq(bdma_chan);
- tasklet_kill(&bdma_chan->tasklet);
+ cancel_work_sync(&bdma_chan->work);
INIT_LIST_HEAD(&bdma_chan->free_list);
kfree(bdma_chan->tx_desc);
tsi721_bdma_ch_free(bdma_chan);
--
2.17.1
reply other threads:[~2024-04-03 16:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240403163617.20710-1-apais@linux.microsoft.com \
--to=apais@linux.microsoft.com \
--cc=alex.bou9@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mporter@kernel.crashing.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.