Skip to content

Commit b71ccf6

Browse files
committed
Merge tag 'mmc-v7.3-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC/MEMSTICK fixes from Ulf Hansson: "MMC host: - cavium-octeon|thunderx: Destroy slot platform devices on remove - mtk-sd: Cancel request timeout work on remove - sdhci-sprd: Disable runtime PM on remove MEMSTICK: - Wait for request completion before freeing card - rtsx_usb_ms: Complete requests after eject instead of dropping them" * tag 'mmc-v7.3-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: memstick: rtsx_usb_ms: complete requests after eject instead of dropping them memstick: core: wait for request completion before freeing card mmc: cavium-thunderx: destroy slot platform devices on remove mmc: cavium-octeon: destroy slot platform devices on remove mmc: sdhci-sprd: disable runtime PM on remove mmc: mtk-sd: Cancel request timeout work on remove
2 parents f7bec60 + c96ca94 commit b71ccf6

6 files changed

Lines changed: 26 additions & 28 deletions

File tree

‎drivers/memstick/core/memstick.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,7 @@ int memstick_set_rw_addr(struct memstick_dev *card)
370370
{
371371
card->next_request = h_memstick_set_rw_addr;
372372
memstick_new_req(card->host);
373-
if (!wait_for_completion_timeout(&card->mrq_complete,
374-
msecs_to_jiffies(500)))
375-
card->current_mrq.error = -ETIMEDOUT;
373+
wait_for_completion(&card->mrq_complete);
376374

377375
return card->current_mrq.error;
378376
}
@@ -405,9 +403,7 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
405403

406404
card->next_request = h_memstick_read_dev_id;
407405
memstick_new_req(host);
408-
if (!wait_for_completion_timeout(&card->mrq_complete,
409-
msecs_to_jiffies(500)))
410-
card->current_mrq.error = -ETIMEDOUT;
406+
wait_for_completion(&card->mrq_complete);
411407

412408
if (card->current_mrq.error)
413409
goto err_out;

‎drivers/memstick/host/rtsx_usb_ms.c‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct rtsx_usb_ms {
2727
struct memstick_host *msh;
2828
struct memstick_request *req;
2929

30-
struct mutex host_mutex;
3130
struct work_struct handle_req;
3231
struct delayed_work poll_card;
3332

@@ -514,6 +513,13 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work)
514513
struct memstick_host *msh = host->msh;
515514
int rc;
516515

516+
/* Fail requests after eject so their waiters are released. */
517+
if (host->eject) {
518+
while (!memstick_next_req(msh, &host->req))
519+
host->req->error = -ENOMEDIUM;
520+
return;
521+
}
522+
517523
if (!host->req) {
518524
pm_runtime_get_sync(ms_dev(host));
519525
do {
@@ -547,8 +553,7 @@ static void rtsx_usb_ms_request(struct memstick_host *msh)
547553

548554
dev_dbg(ms_dev(host), "--> %s\n", __func__);
549555

550-
if (!host->eject)
551-
schedule_work(&host->handle_req);
556+
schedule_work(&host->handle_req);
552557
}
553558

554559
static int rtsx_usb_ms_set_param(struct memstick_host *msh,
@@ -781,7 +786,6 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
781786
host->power_mode = MEMSTICK_POWER_OFF;
782787
platform_set_drvdata(pdev, host);
783788

784-
mutex_init(&host->host_mutex);
785789
INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req);
786790

787791
INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card);
@@ -812,27 +816,12 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
812816
{
813817
struct rtsx_usb_ms *host = platform_get_drvdata(pdev);
814818
struct memstick_host *msh = host->msh;
815-
int err;
816819

817820
host->eject = true;
818821
msh->removing = true;
819-
cancel_work_sync(&host->handle_req);
822+
flush_work(&host->handle_req);
820823
cancel_delayed_work_sync(&host->poll_card);
821824

822-
mutex_lock(&host->host_mutex);
823-
if (host->req) {
824-
dev_dbg(ms_dev(host),
825-
"%s: Controller removed during transfer\n",
826-
dev_name(&msh->dev));
827-
host->req->error = -ENOMEDIUM;
828-
do {
829-
err = memstick_next_req(msh, &host->req);
830-
if (!err)
831-
host->req->error = -ENOMEDIUM;
832-
} while (!err);
833-
}
834-
mutex_unlock(&host->host_mutex);
835-
836825
/* Balance possible unbalanced usage count
837826
* e.g. unconditional module removal
838827
*/
@@ -841,6 +830,8 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
841830

842831
pm_runtime_disable(ms_dev(host));
843832
memstick_remove_host(msh);
833+
/* No card, no new requests; wait for the last failed one to finish. */
834+
cancel_work_sync(&host->handle_req);
844835
dev_dbg(ms_dev(host),
845836
": Realtek USB Memstick controller has been removed\n");
846837
memstick_free_host(msh);

‎drivers/mmc/host/cavium-octeon.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,12 @@ static void octeon_mmc_remove(struct platform_device *pdev)
295295
u64 dma_cfg;
296296
int i;
297297

298-
for (i = 0; i < CAVIUM_MAX_MMC; i++)
298+
for (i = 0; i < CAVIUM_MAX_MMC; i++) {
299299
if (host->slot[i])
300300
cvm_mmc_of_slot_remove(host->slot[i]);
301+
if (host->slot_pdev[i])
302+
of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL);
303+
}
301304

302305
dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host));
303306
dma_cfg &= ~MIO_EMM_DMA_CFG_EN;

‎drivers/mmc/host/cavium-thunderx.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ static void thunder_mmc_remove(struct pci_dev *pdev)
173173
u64 dma_cfg;
174174
int i;
175175

176-
for (i = 0; i < CAVIUM_MAX_MMC; i++)
176+
for (i = 0; i < CAVIUM_MAX_MMC; i++) {
177177
if (host->slot[i])
178178
cvm_mmc_of_slot_remove(host->slot[i]);
179+
if (host->slot_pdev[i])
180+
of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL);
181+
}
179182

180183
dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host));
181184
dma_cfg &= ~MIO_EMM_DMA_CFG_EN;

‎drivers/mmc/host/mtk-sd.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3216,6 +3216,7 @@ static void msdc_drv_remove(struct platform_device *pdev)
32163216

32173217
platform_set_drvdata(pdev, NULL);
32183218
mmc_remove_host(mmc);
3219+
cancel_delayed_work_sync(&host->req_timeout);
32193220
msdc_deinit_hw(host);
32203221
msdc_gate_clock(host);
32213222

‎drivers/mmc/host/sdhci-sprd.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,10 @@ static void sdhci_sprd_remove(struct platform_device *pdev)
890890
struct sdhci_host *host = platform_get_drvdata(pdev);
891891
struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
892892

893+
pm_runtime_get_sync(&pdev->dev);
894+
pm_runtime_disable(&pdev->dev);
895+
pm_runtime_put_noidle(&pdev->dev);
896+
893897
sdhci_remove_host(host, 0);
894898

895899
clk_disable_unprepare(sprd_host->clk_sdio);

0 commit comments

Comments
 (0)