Skip to content

Commit c9834d8

Browse files
allenpaisJassi Brar
authored andcommitted
mailbox: Convert from tasklet to BH workqueue
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. Based on the work done by Tejun Heo <[email protected]> Branch: https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-6.10 Signed-off-by: Allen Pais <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 747a69a commit c9834d8

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

drivers/mailbox/bcm-pdc-mailbox.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/dma-direction.h>
4444
#include <linux/dma-mapping.h>
4545
#include <linux/dmapool.h>
46+
#include <linux/workqueue.h>
4647

4748
#define PDC_SUCCESS 0
4849

@@ -293,8 +294,8 @@ struct pdc_state {
293294

294295
unsigned int pdc_irq;
295296

296-
/* tasklet for deferred processing after DMA rx interrupt */
297-
struct tasklet_struct rx_tasklet;
297+
/* work for deferred processing after DMA rx interrupt */
298+
struct work_struct rx_work;
298299

299300
/* Number of bytes of receive status prior to each rx frame */
300301
u32 rx_status_len;
@@ -952,18 +953,18 @@ static irqreturn_t pdc_irq_handler(int irq, void *data)
952953
iowrite32(intstatus, pdcs->pdc_reg_vbase + PDC_INTSTATUS_OFFSET);
953954

954955
/* Wakeup IRQ thread */
955-
tasklet_schedule(&pdcs->rx_tasklet);
956+
queue_work(system_bh_wq, &pdcs->rx_work);
956957
return IRQ_HANDLED;
957958
}
958959

959960
/**
960-
* pdc_tasklet_cb() - Tasklet callback that runs the deferred processing after
961+
* pdc_work_cb() - Work callback that runs the deferred processing after
961962
* a DMA receive interrupt. Reenables the receive interrupt.
962963
* @t: Pointer to the Altera sSGDMA channel structure
963964
*/
964-
static void pdc_tasklet_cb(struct tasklet_struct *t)
965+
static void pdc_work_cb(struct work_struct *t)
965966
{
966-
struct pdc_state *pdcs = from_tasklet(pdcs, t, rx_tasklet);
967+
struct pdc_state *pdcs = from_work(pdcs, t, rx_work);
967968

968969
pdc_receive(pdcs);
969970

@@ -1577,8 +1578,8 @@ static int pdc_probe(struct platform_device *pdev)
15771578

15781579
pdc_hw_init(pdcs);
15791580

1580-
/* Init tasklet for deferred DMA rx processing */
1581-
tasklet_setup(&pdcs->rx_tasklet, pdc_tasklet_cb);
1581+
/* Init work for deferred DMA rx processing */
1582+
INIT_WORK(&pdcs->rx_work, pdc_work_cb);
15821583

15831584
err = pdc_interrupts_init(pdcs);
15841585
if (err)
@@ -1595,7 +1596,7 @@ static int pdc_probe(struct platform_device *pdev)
15951596
return PDC_SUCCESS;
15961597

15971598
cleanup_buf_pool:
1598-
tasklet_kill(&pdcs->rx_tasklet);
1599+
cancel_work_sync(&pdcs->rx_work);
15991600
dma_pool_destroy(pdcs->rx_buf_pool);
16001601

16011602
cleanup_ring_pool:
@@ -1611,7 +1612,7 @@ static void pdc_remove(struct platform_device *pdev)
16111612

16121613
pdc_free_debugfs();
16131614

1614-
tasklet_kill(&pdcs->rx_tasklet);
1615+
cancel_work_sync(&pdcs->rx_work);
16151616

16161617
pdc_hw_disable(pdcs);
16171618

drivers/mailbox/imx-mailbox.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/pm_runtime.h>
2222
#include <linux/suspend.h>
2323
#include <linux/slab.h>
24+
#include <linux/workqueue.h>
2425

2526
#include "mailbox.h"
2627

@@ -80,7 +81,7 @@ struct imx_mu_con_priv {
8081
char irq_desc[IMX_MU_CHAN_NAME_SIZE];
8182
enum imx_mu_chan_type type;
8283
struct mbox_chan *chan;
83-
struct tasklet_struct txdb_tasklet;
84+
struct work_struct txdb_work;
8485
};
8586

8687
struct imx_mu_priv {
@@ -232,7 +233,7 @@ static int imx_mu_generic_tx(struct imx_mu_priv *priv,
232233
break;
233234
case IMX_MU_TYPE_TXDB:
234235
imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
235-
tasklet_schedule(&cp->txdb_tasklet);
236+
queue_work(system_bh_wq, &cp->txdb_work);
236237
break;
237238
case IMX_MU_TYPE_TXDB_V2:
238239
imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
@@ -420,7 +421,7 @@ static int imx_mu_seco_tx(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp,
420421
}
421422

422423
/* Simulate hack for mbox framework */
423-
tasklet_schedule(&cp->txdb_tasklet);
424+
queue_work(system_bh_wq, &cp->txdb_work);
424425

425426
break;
426427
default:
@@ -484,9 +485,9 @@ static int imx_mu_seco_rxdb(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp
484485
return err;
485486
}
486487

487-
static void imx_mu_txdb_tasklet(unsigned long data)
488+
static void imx_mu_txdb_work(struct work_struct *t)
488489
{
489-
struct imx_mu_con_priv *cp = (struct imx_mu_con_priv *)data;
490+
struct imx_mu_con_priv *cp = from_work(cp, t, txdb_work);
490491

491492
mbox_chan_txdone(cp->chan, 0);
492493
}
@@ -570,8 +571,7 @@ static int imx_mu_startup(struct mbox_chan *chan)
570571

571572
if (cp->type == IMX_MU_TYPE_TXDB) {
572573
/* Tx doorbell don't have ACK support */
573-
tasklet_init(&cp->txdb_tasklet, imx_mu_txdb_tasklet,
574-
(unsigned long)cp);
574+
INIT_WORK(&cp->txdb_work, imx_mu_txdb_work);
575575
return 0;
576576
}
577577

@@ -615,7 +615,7 @@ static void imx_mu_shutdown(struct mbox_chan *chan)
615615
}
616616

617617
if (cp->type == IMX_MU_TYPE_TXDB) {
618-
tasklet_kill(&cp->txdb_tasklet);
618+
cancel_work_sync(&cp->txdb_work);
619619
pm_runtime_put_sync(priv->dev);
620620
return;
621621
}

0 commit comments

Comments
 (0)