Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: dw_mmc: make multiple instances of dw_mci_card_workqueue

The variable 'dw_mci_card_workqueue' is a global variable shared between
multiple instances of the dw_mmc host controller. Due to this, data
corruption has been noticed when multiple instances of dw_mmc controllers
are actively reading/writing the media. Fix this by adding a instance
of 'struct workqueue_struct' for each host instance and removing the
global 'dw_mci_card_workqueue' instance.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Will Newton <will.newton@imgtec.com>
Signed-off-by: Chris Ball <cjb@laptop.org>

authored by

Thomas Abraham and committed by
Chris Ball
95dcc2cb b41b6f1d

+7 -8
+6 -8
drivers/mmc/host/dw_mmc.c
··· 100 100 int last_detect_state; 101 101 }; 102 102 103 - static struct workqueue_struct *dw_mci_card_workqueue; 104 - 105 103 #if defined(CONFIG_DEBUG_FS) 106 104 static int dw_mci_req_show(struct seq_file *s, void *v) 107 105 { ··· 1603 1605 1604 1606 if (pending & SDMMC_INT_CD) { 1605 1607 mci_writel(host, RINTSTS, SDMMC_INT_CD); 1606 - queue_work(dw_mci_card_workqueue, &host->card_work); 1608 + queue_work(host->card_workqueue, &host->card_work); 1607 1609 } 1608 1610 1609 1611 /* Handle SDIO Interrupts */ ··· 1842 1844 * Card may have been plugged in prior to boot so we 1843 1845 * need to run the detect tasklet 1844 1846 */ 1845 - queue_work(dw_mci_card_workqueue, &host->card_work); 1847 + queue_work(host->card_workqueue, &host->card_work); 1846 1848 1847 1849 return 0; 1848 1850 } ··· 2019 2021 mci_writel(host, CLKSRC, 0); 2020 2022 2021 2023 tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host); 2022 - dw_mci_card_workqueue = alloc_workqueue("dw-mci-card", 2024 + host->card_workqueue = alloc_workqueue("dw-mci-card", 2023 2025 WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1); 2024 - if (!dw_mci_card_workqueue) 2026 + if (!host->card_workqueue) 2025 2027 goto err_dmaunmap; 2026 2028 INIT_WORK(&host->card_work, dw_mci_work_routine_card); 2027 2029 ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); ··· 2083 2085 free_irq(host->irq, host); 2084 2086 2085 2087 err_workqueue: 2086 - destroy_workqueue(dw_mci_card_workqueue); 2088 + destroy_workqueue(host->card_workqueue); 2087 2089 2088 2090 err_dmaunmap: 2089 2091 if (host->use_dma && host->dma_ops->exit) ··· 2117 2119 mci_writel(host, CLKSRC, 0); 2118 2120 2119 2121 free_irq(host->irq, host); 2120 - destroy_workqueue(dw_mci_card_workqueue); 2122 + destroy_workqueue(host->card_workqueue); 2121 2123 dma_free_coherent(&host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); 2122 2124 2123 2125 if (host->use_dma && host->dma_ops->exit)
+1
include/linux/mmc/dw_mmc.h
··· 125 125 struct mmc_request *mrq; 126 126 struct mmc_command *cmd; 127 127 struct mmc_data *data; 128 + struct workqueue_struct *card_workqueue; 128 129 129 130 /* DMA interface members*/ 130 131 int use_dma;