Skip to content

Commit b01a4f1

Browse files
Venkatraman Scjb
Venkatraman S
authored andcommitted
mmc: omap: convert to per instance workqueue
Currently, a global mmc_omap_wq is created for all instances of omap hosts, which can lead to races and doesn't lend itself to unload the module cleanly. Instead, create per instance workqueue and remove the common workqueue. Signed-off-by: Venkatraman S <[email protected]> Acked-by: Balaji T K <[email protected]> Signed-off-by: Chris Ball <[email protected]>
1 parent f6f4459 commit b01a4f1

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

drivers/mmc/host/omap.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ struct mmc_omap_host {
169169
struct timer_list clk_timer;
170170
spinlock_t clk_lock; /* for changing enabled state */
171171
unsigned int fclk_enabled:1;
172+
struct workqueue_struct *mmc_omap_wq;
172173

173174
struct omap_mmc_platform_data *pdata;
174175
};
175176

176-
static struct workqueue_struct *mmc_omap_wq;
177177

178178
static void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot)
179179
{
@@ -291,7 +291,7 @@ static void mmc_omap_release_slot(struct mmc_omap_slot *slot, int clk_enabled)
291291
host->next_slot = new_slot;
292292
host->mmc = new_slot->mmc;
293293
spin_unlock_irqrestore(&host->slot_lock, flags);
294-
queue_work(mmc_omap_wq, &host->slot_release_work);
294+
queue_work(host->mmc_omap_wq, &host->slot_release_work);
295295
return;
296296
}
297297

@@ -459,7 +459,7 @@ mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data)
459459
}
460460

461461
host->stop_data = data;
462-
queue_work(mmc_omap_wq, &host->send_stop_work);
462+
queue_work(host->mmc_omap_wq, &host->send_stop_work);
463463
}
464464

465465
static void
@@ -639,7 +639,7 @@ mmc_omap_cmd_timer(unsigned long data)
639639
OMAP_MMC_WRITE(host, IE, 0);
640640
disable_irq(host->irq);
641641
host->abort = 1;
642-
queue_work(mmc_omap_wq, &host->cmd_abort_work);
642+
queue_work(host->mmc_omap_wq, &host->cmd_abort_work);
643643
}
644644
spin_unlock_irqrestore(&host->slot_lock, flags);
645645
}
@@ -828,7 +828,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
828828
host->abort = 1;
829829
OMAP_MMC_WRITE(host, IE, 0);
830830
disable_irq_nosync(host->irq);
831-
queue_work(mmc_omap_wq, &host->cmd_abort_work);
831+
queue_work(host->mmc_omap_wq, &host->cmd_abort_work);
832832
return IRQ_HANDLED;
833833
}
834834

@@ -1389,7 +1389,7 @@ static void mmc_omap_remove_slot(struct mmc_omap_slot *slot)
13891389

13901390
tasklet_kill(&slot->cover_tasklet);
13911391
del_timer_sync(&slot->cover_timer);
1392-
flush_workqueue(mmc_omap_wq);
1392+
flush_workqueue(slot->host->mmc_omap_wq);
13931393

13941394
mmc_remove_host(mmc);
13951395
mmc_free_host(mmc);
@@ -1497,6 +1497,10 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
14971497

14981498
host->reg_shift = (cpu_is_omap7xx() ? 1 : 2);
14991499

1500+
host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
1501+
if (!host->mmc_omap_wq)
1502+
goto err_plat_cleanup;
1503+
15001504
return 0;
15011505

15021506
err_plat_cleanup:
@@ -1542,6 +1546,7 @@ static int mmc_omap_remove(struct platform_device *pdev)
15421546
iounmap(host->virt_base);
15431547
release_mem_region(pdev->resource[0].start,
15441548
pdev->resource[0].end - pdev->resource[0].start + 1);
1549+
destroy_workqueue(host->mmc_omap_wq);
15451550

15461551
kfree(host);
15471552

@@ -1610,22 +1615,12 @@ static struct platform_driver mmc_omap_driver = {
16101615

16111616
static int __init mmc_omap_init(void)
16121617
{
1613-
int ret;
1614-
1615-
mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
1616-
if (!mmc_omap_wq)
1617-
return -ENOMEM;
1618-
1619-
ret = platform_driver_probe(&mmc_omap_driver, mmc_omap_probe);
1620-
if (ret)
1621-
destroy_workqueue(mmc_omap_wq);
1622-
return ret;
1618+
return platform_driver_probe(&mmc_omap_driver, mmc_omap_probe);
16231619
}
16241620

16251621
static void __exit mmc_omap_exit(void)
16261622
{
16271623
platform_driver_unregister(&mmc_omap_driver);
1628-
destroy_workqueue(mmc_omap_wq);
16291624
}
16301625

16311626
module_init(mmc_omap_init);

0 commit comments

Comments
 (0)