From 590cc701597839b1b05ec9d1bb4cf42b06ca9c0f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 16 Jun 2020 14:05:47 +0200 Subject: [PATCH] 5.6-stable patches added patches: agp-intel-reinforce-the-barrier-after-gtt-updates.patch arm-dts-at91-sama5d2_ptc_ek-fix-sdmmc0-node-description.patch block-floppy-fix-contended-case-in-floppy_queue_rq.patch mmc-mmci_sdmmc-fix-dma-api-warning-overlapping-mappings.patch mmc-sdhci-msm-clear-tuning-done-flag-while-hs400-tuning.patch mmc-sdhci-of-at91-fix-calcr-register-being-rewritten.patch mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch mmc-tmio-further-fixup-runtime-pm-management-at-remove.patch mmc-uniphier-sd-call-devm_request_irq-after-tmio_mmc_host_probe.patch --- ...nforce-the-barrier-after-gtt-updates.patch | 55 +++++++ ...2_ptc_ek-fix-sdmmc0-node-description.patch | 34 ++++ ...ix-contended-case-in-floppy_queue_rq.patch | 69 ++++++++ ...dma-api-warning-overlapping-mappings.patch | 66 ++++++++ ...-tuning-done-flag-while-hs400-tuning.patch | 42 +++++ ...1-fix-calcr-register-being-rewritten.patch | 41 +++++ ...-pointer-error-in-mmc_sdio_init_card.patch | 40 +++++ ...l-memory-leaks-in-mmc_sdio_init_card.patch | 151 ++++++++++++++++++ ...ixup-runtime-pm-management-at-remove.patch | 60 +++++++ ...equest_irq-after-tmio_mmc_host_probe.patch | 60 +++++++ queue-5.6/series | 10 ++ 11 files changed, 628 insertions(+) create mode 100644 queue-5.6/agp-intel-reinforce-the-barrier-after-gtt-updates.patch create mode 100644 queue-5.6/arm-dts-at91-sama5d2_ptc_ek-fix-sdmmc0-node-description.patch create mode 100644 queue-5.6/block-floppy-fix-contended-case-in-floppy_queue_rq.patch create mode 100644 queue-5.6/mmc-mmci_sdmmc-fix-dma-api-warning-overlapping-mappings.patch create mode 100644 queue-5.6/mmc-sdhci-msm-clear-tuning-done-flag-while-hs400-tuning.patch create mode 100644 queue-5.6/mmc-sdhci-of-at91-fix-calcr-register-being-rewritten.patch create mode 100644 queue-5.6/mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch create mode 100644 queue-5.6/mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch create mode 100644 queue-5.6/mmc-tmio-further-fixup-runtime-pm-management-at-remove.patch create mode 100644 queue-5.6/mmc-uniphier-sd-call-devm_request_irq-after-tmio_mmc_host_probe.patch diff --git a/queue-5.6/agp-intel-reinforce-the-barrier-after-gtt-updates.patch b/queue-5.6/agp-intel-reinforce-the-barrier-after-gtt-updates.patch new file mode 100644 index 00000000000..b81ba71b75e --- /dev/null +++ b/queue-5.6/agp-intel-reinforce-the-barrier-after-gtt-updates.patch @@ -0,0 +1,55 @@ +From f30d3ced9fafa03e4855508929b5b6334907f45e Mon Sep 17 00:00:00 2001 +From: Chris Wilson +Date: Fri, 10 Apr 2020 09:35:35 +0100 +Subject: agp/intel: Reinforce the barrier after GTT updates + +From: Chris Wilson + +commit f30d3ced9fafa03e4855508929b5b6334907f45e upstream. + +After changing the timing between GTT updates and execution on the GPU, +we started seeing sporadic failures on Ironlake. These were narrowed +down to being an insufficiently strong enough barrier/delay after +updating the GTT and scheduling execution on the GPU. By forcing the +uncached read, and adding the missing barrier for the singular +insert_page (relocation paths), the sporadic failures go away. + +Fixes: 983d308cb8f6 ("agp/intel: Serialise after GTT updates") +Fixes: 3497971a71d8 ("agp/intel: Flush chipset writes after updating a single PTE") +Signed-off-by: Chris Wilson +Acked-by: Andi Shyti +Cc: stable@vger.kernel.org # v4.0+ +Link: https://patchwork.freedesktop.org/patch/msgid/20200410083535.25464-1-chris@chris-wilson.co.uk +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/agp/intel-gtt.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/char/agp/intel-gtt.c ++++ b/drivers/char/agp/intel-gtt.c +@@ -846,6 +846,7 @@ void intel_gtt_insert_page(dma_addr_t ad + unsigned int flags) + { + intel_private.driver->write_entry(addr, pg, flags); ++ readl(intel_private.gtt + pg); + if (intel_private.driver->chipset_flush) + intel_private.driver->chipset_flush(); + } +@@ -871,7 +872,7 @@ void intel_gtt_insert_sg_entries(struct + j++; + } + } +- wmb(); ++ readl(intel_private.gtt + j - 1); + if (intel_private.driver->chipset_flush) + intel_private.driver->chipset_flush(); + } +@@ -1105,6 +1106,7 @@ static void i9xx_cleanup(void) + + static void i9xx_chipset_flush(void) + { ++ wmb(); + if (intel_private.i9xx_flush_page) + writel(1, intel_private.i9xx_flush_page); + } diff --git a/queue-5.6/arm-dts-at91-sama5d2_ptc_ek-fix-sdmmc0-node-description.patch b/queue-5.6/arm-dts-at91-sama5d2_ptc_ek-fix-sdmmc0-node-description.patch new file mode 100644 index 00000000000..bb5ff30e8ce --- /dev/null +++ b/queue-5.6/arm-dts-at91-sama5d2_ptc_ek-fix-sdmmc0-node-description.patch @@ -0,0 +1,34 @@ +From a1af7f36c70369b971ee1cf679dd68368dad23f0 Mon Sep 17 00:00:00 2001 +From: Ludovic Desroches +Date: Thu, 2 Apr 2020 00:15:00 +0200 +Subject: ARM: dts: at91: sama5d2_ptc_ek: fix sdmmc0 node description + +From: Ludovic Desroches + +commit a1af7f36c70369b971ee1cf679dd68368dad23f0 upstream. + +Remove non-removable and mmc-ddr-1_8v properties from the sdmmc0 +node which come probably from an unchecked copy/paste. + +Signed-off-by: Ludovic Desroches +Fixes:42ed535595ec "ARM: dts: at91: introduce the sama5d2 ptc ek board" +Cc: stable@vger.kernel.org # 4.19 and later +Link: https://lore.kernel.org/r/20200401221504.41196-1-ludovic.desroches@microchip.com +Signed-off-by: Alexandre Belloni +Signed-off-by: Greg Kroah-Hartman + +--- + arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts | 2 -- + 1 file changed, 2 deletions(-) + +--- a/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts ++++ b/arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts +@@ -125,8 +125,6 @@ + bus-width = <8>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sdmmc0_default>; +- non-removable; +- mmc-ddr-1_8v; + status = "okay"; + }; + diff --git a/queue-5.6/block-floppy-fix-contended-case-in-floppy_queue_rq.patch b/queue-5.6/block-floppy-fix-contended-case-in-floppy_queue_rq.patch new file mode 100644 index 00000000000..eac81611f0c --- /dev/null +++ b/queue-5.6/block-floppy-fix-contended-case-in-floppy_queue_rq.patch @@ -0,0 +1,69 @@ +From 263c61581a38d0a5ad1f5f4a9143b27d68caeffd Mon Sep 17 00:00:00 2001 +From: Jiri Kosina +Date: Tue, 26 May 2020 11:49:18 +0200 +Subject: block/floppy: fix contended case in floppy_queue_rq() + +From: Jiri Kosina + +commit 263c61581a38d0a5ad1f5f4a9143b27d68caeffd upstream. + +Since the switch of floppy driver to blk-mq, the contended (fdc_busy) case +in floppy_queue_rq() is not handled correctly. + +In case we reach floppy_queue_rq() with fdc_busy set (i.e. with the floppy +locked due to another request still being in-flight), we put the request +on the list of requests and return BLK_STS_OK to the block core, without +actually scheduling delayed work / doing further processing of the +request. This means that processing of this request is postponed until +another request comes and passess uncontended. + +Which in some cases might actually never happen and we keep waiting +indefinitely. The simple testcase is + + for i in `seq 1 2000`; do echo -en $i '\r'; blkid --info /dev/fd0 2> /dev/null; done + +run in quemu. That reliably causes blkid eventually indefinitely hanging +in __floppy_read_block_0() waiting for completion, as the BIO callback +never happens, and no further IO is ever submitted on the (non-existent) +floppy device. This was observed reliably on qemu-emulated device. + +Fix that by not queuing the request in the contended case, and return +BLK_STS_RESOURCE instead, so that blk core handles the request +rescheduling and let it pass properly non-contended later. + +Fixes: a9f38e1dec107a ("floppy: convert to blk-mq") +Cc: stable@vger.kernel.org +Tested-by: Libor Pechacek +Signed-off-by: Jiri Kosina +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/block/floppy.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/block/floppy.c ++++ b/drivers/block/floppy.c +@@ -2902,17 +2902,17 @@ static blk_status_t floppy_queue_rq(stru + (unsigned long long) current_req->cmd_flags)) + return BLK_STS_IOERR; + +- spin_lock_irq(&floppy_lock); +- list_add_tail(&bd->rq->queuelist, &floppy_reqs); +- spin_unlock_irq(&floppy_lock); +- + if (test_and_set_bit(0, &fdc_busy)) { + /* fdc busy, this new request will be treated when the + current one is done */ + is_alive(__func__, "old request running"); +- return BLK_STS_OK; ++ return BLK_STS_RESOURCE; + } + ++ spin_lock_irq(&floppy_lock); ++ list_add_tail(&bd->rq->queuelist, &floppy_reqs); ++ spin_unlock_irq(&floppy_lock); ++ + command_status = FD_COMMAND_NONE; + __reschedule_timeout(MAXTIMEOUT, "fd_request"); + set_fdc(0); diff --git a/queue-5.6/mmc-mmci_sdmmc-fix-dma-api-warning-overlapping-mappings.patch b/queue-5.6/mmc-mmci_sdmmc-fix-dma-api-warning-overlapping-mappings.patch new file mode 100644 index 00000000000..ae11a01062e --- /dev/null +++ b/queue-5.6/mmc-mmci_sdmmc-fix-dma-api-warning-overlapping-mappings.patch @@ -0,0 +1,66 @@ +From fe8d33bd33d527dee3155d2bccd714a655f37334 Mon Sep 17 00:00:00 2001 +From: Ludovic Barre +Date: Tue, 26 May 2020 17:51:02 +0200 +Subject: mmc: mmci_sdmmc: fix DMA API warning overlapping mappings + +From: Ludovic Barre + +commit fe8d33bd33d527dee3155d2bccd714a655f37334 upstream. + +Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning: +WARNING: CPU: 1 PID: 20 at kernel/dma/debug.c:500 add_dma_entry+0x16c/0x17c +DMA-API: exceeded 7 overlapping mappings of cacheline 0x031d2645 +Modules linked in: +CPU: 1 PID: 20 Comm: kworker/1:1 Not tainted 5.5.0-rc2-00021-gdeda30999c2b-dirty #49 +Hardware name: STM32 (Device Tree Support) +Workqueue: events_freezable mmc_rescan +[] (unwind_backtrace) from [] (show_stack+0x10/0x14) +[] (show_stack) from [] (dump_stack+0xc0/0xd4) +[] (dump_stack) from [] (__warn+0xd0/0xf8) +[] (__warn) from [] (warn_slowpath_fmt+0x94/0xb8) +[] (warn_slowpath_fmt) from [] (add_dma_entry+0x16c/0x17c) +[] (add_dma_entry) from [] (debug_dma_map_sg+0xe4/0x3d4) +[] (debug_dma_map_sg) from [] (sdmmc_idma_prep_data+0x94/0xf8) +[] (sdmmc_idma_prep_data) from [] (mmci_prep_data+0x2c/0xb0) +[] (mmci_prep_data) from [] (mmci_start_data+0x134/0x2f0) +[] (mmci_start_data) from [] (mmci_request+0xe8/0x154) +[] (mmci_request) from [] (mmc_start_request+0x94/0xbc) + +DMA api debug brings to light leaking dma-mappings, dma_map_sg and +dma_unmap_sg are not correctly balanced. + +If a request is prepared, the dma_map/unmap are done in asynchronous call +pre_req (prep_data) and post_req (unprep_data). In this case the +dma-mapping is right balanced. + +But if the request was not prepared, the data->host_cookie is define to +zero and the dma_map/unmap must be done in the request. The dma_map is +called by mmci_dma_start (prep_data), but there is no dma_unmap in this +case. + +This patch adds dma_unmap_sg when the dma is finalized and the data cookie +is zero (request not prepared). + +Signed-off-by: Ludovic Barre +Link: https://lore.kernel.org/r/20200526155103.12514-2-ludovic.barre@st.com +Fixes: 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant") +Cc: stable@vger.kernel.org +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/mmci_stm32_sdmmc.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/mmc/host/mmci_stm32_sdmmc.c ++++ b/drivers/mmc/host/mmci_stm32_sdmmc.c +@@ -162,6 +162,9 @@ static int sdmmc_idma_start(struct mmci_ + static void sdmmc_idma_finalize(struct mmci_host *host, struct mmc_data *data) + { + writel_relaxed(0, host->base + MMCI_STM32_IDMACTRLR); ++ ++ if (!data->host_cookie) ++ sdmmc_idma_unprep_data(host, data, 0); + } + + static void mmci_sdmmc_set_clkreg(struct mmci_host *host, unsigned int desired) diff --git a/queue-5.6/mmc-sdhci-msm-clear-tuning-done-flag-while-hs400-tuning.patch b/queue-5.6/mmc-sdhci-msm-clear-tuning-done-flag-while-hs400-tuning.patch new file mode 100644 index 00000000000..98c41b24113 --- /dev/null +++ b/queue-5.6/mmc-sdhci-msm-clear-tuning-done-flag-while-hs400-tuning.patch @@ -0,0 +1,42 @@ +From 9253d71011c349d5f5cc0cebdf68b4a80811b92d Mon Sep 17 00:00:00 2001 +From: Veerabhadrarao Badiganti +Date: Thu, 28 May 2020 20:43:52 +0530 +Subject: mmc: sdhci-msm: Clear tuning done flag while hs400 tuning + +From: Veerabhadrarao Badiganti + +commit 9253d71011c349d5f5cc0cebdf68b4a80811b92d upstream. + +Clear tuning_done flag while executing tuning to ensure vendor +specific HS400 settings are applied properly when the controller +is re-initialized in HS400 mode. + +Without this, re-initialization of the qcom SDHC in HS400 mode fails +while resuming the driver from runtime-suspend or system-suspend. + +Fixes: ff06ce417828 ("mmc: sdhci-msm: Add HS400 platform support") +Cc: stable@vger.kernel.org +Signed-off-by: Veerabhadrarao Badiganti +Link: https://lore.kernel.org/r/1590678838-18099-1-git-send-email-vbadigan@codeaurora.org +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/sdhci-msm.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/mmc/host/sdhci-msm.c ++++ b/drivers/mmc/host/sdhci-msm.c +@@ -1118,6 +1118,12 @@ static int sdhci_msm_execute_tuning(stru + msm_host->use_cdr = true; + + /* ++ * Clear tuning_done flag before tuning to ensure proper ++ * HS400 settings. ++ */ ++ msm_host->tuning_done = 0; ++ ++ /* + * For HS400 tuning in HS200 timing requires: + * - select MCLK/2 in VENDOR_SPEC + * - program MCLK to 400MHz (or nearest supported) in GCC diff --git a/queue-5.6/mmc-sdhci-of-at91-fix-calcr-register-being-rewritten.patch b/queue-5.6/mmc-sdhci-of-at91-fix-calcr-register-being-rewritten.patch new file mode 100644 index 00000000000..c2cd712b925 --- /dev/null +++ b/queue-5.6/mmc-sdhci-of-at91-fix-calcr-register-being-rewritten.patch @@ -0,0 +1,41 @@ +From dbdea70f71d672c12bc4454e7c258a8f78194d74 Mon Sep 17 00:00:00 2001 +From: Eugen Hristev +Date: Wed, 27 May 2020 13:56:59 +0300 +Subject: mmc: sdhci-of-at91: fix CALCR register being rewritten + +From: Eugen Hristev + +commit dbdea70f71d672c12bc4454e7c258a8f78194d74 upstream. + +When enabling calibration at reset, the CALCR register was completely +rewritten. This may cause certain bits being deleted unintentedly. +Fix by issuing a read-modify-write operation. + +Fixes: 727d836a375a ("mmc: sdhci-of-at91: add DT property to enable calibration on full reset") +Signed-off-by: Eugen Hristev +Link: https://lore.kernel.org/r/20200527105659.142560-1-eugen.hristev@microchip.com +Cc: stable@vger.kernel.org +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/sdhci-of-at91.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/mmc/host/sdhci-of-at91.c ++++ b/drivers/mmc/host/sdhci-of-at91.c +@@ -136,9 +136,12 @@ static void sdhci_at91_reset(struct sdhc + || mmc_gpio_get_cd(host->mmc) >= 0) + sdhci_at91_set_force_card_detect(host); + +- if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) +- sdhci_writel(host, SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN, ++ if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) { ++ u32 calcr = sdhci_readl(host, SDMMC_CALCR); ++ ++ sdhci_writel(host, calcr | SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN, + SDMMC_CALCR); ++ } + } + + static const struct sdhci_ops sdhci_at91_sama5d2_ops = { diff --git a/queue-5.6/mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch b/queue-5.6/mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch new file mode 100644 index 00000000000..09282b99258 --- /dev/null +++ b/queue-5.6/mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch @@ -0,0 +1,40 @@ +From f04086c225da11ad16d7f9a2fbca6483ab16dded Mon Sep 17 00:00:00 2001 +From: Ulf Hansson +Date: Thu, 30 Apr 2020 11:16:37 +0200 +Subject: mmc: sdio: Fix potential NULL pointer error in mmc_sdio_init_card() + +From: Ulf Hansson + +commit f04086c225da11ad16d7f9a2fbca6483ab16dded upstream. + +During some scenarios mmc_sdio_init_card() runs a retry path for the UHS-I +specific initialization, which leads to removal of the previously allocated +card. A new card is then re-allocated while retrying. + +However, in one of the corresponding error paths we may end up to remove an +already removed card, which likely leads to a NULL pointer exception. So, +let's fix this. + +Fixes: 5fc3d80ef496 ("mmc: sdio: don't use rocr to check if the card could support UHS mode") +Cc: +Signed-off-by: Ulf Hansson +Link: https://lore.kernel.org/r/20200430091640.455-2-ulf.hansson@linaro.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/core/sdio.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/mmc/core/sdio.c ++++ b/drivers/mmc/core/sdio.c +@@ -718,9 +718,8 @@ try_again: + /* Retry init sequence, but without R4_18V_PRESENT. */ + retries = 0; + goto try_again; +- } else { +- goto remove; + } ++ return err; + } + + /* diff --git a/queue-5.6/mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch b/queue-5.6/mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch new file mode 100644 index 00000000000..5d20a711ec5 --- /dev/null +++ b/queue-5.6/mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch @@ -0,0 +1,151 @@ +From a94a59f43749b4f8cd81b8be87c95f9ef898d19d Mon Sep 17 00:00:00 2001 +From: Ulf Hansson +Date: Thu, 30 Apr 2020 11:16:38 +0200 +Subject: mmc: sdio: Fix several potential memory leaks in mmc_sdio_init_card() + +From: Ulf Hansson + +commit a94a59f43749b4f8cd81b8be87c95f9ef898d19d upstream. + +Over the years, the code in mmc_sdio_init_card() has grown to become quite +messy. Unfortunate this has also lead to that several paths are leaking +memory in form of an allocated struct mmc_card, which includes additional +data, such as initialized struct device for example. + +Unfortunate, it's a too complex task find each offending commit. Therefore, +this change fixes all memory leaks at once. + +Cc: +Signed-off-by: Ulf Hansson +Link: https://lore.kernel.org/r/20200430091640.455-3-ulf.hansson@linaro.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/core/sdio.c | 58 ++++++++++++++++++++++-------------------------- + 1 file changed, 27 insertions(+), 31 deletions(-) + +--- a/drivers/mmc/core/sdio.c ++++ b/drivers/mmc/core/sdio.c +@@ -584,7 +584,7 @@ try_again: + */ + err = mmc_send_io_op_cond(host, ocr, &rocr); + if (err) +- goto err; ++ return err; + + /* + * For SPI, enable CRC as appropriate. +@@ -592,17 +592,15 @@ try_again: + if (mmc_host_is_spi(host)) { + err = mmc_spi_set_crc(host, use_spi_crc); + if (err) +- goto err; ++ return err; + } + + /* + * Allocate card structure. + */ + card = mmc_alloc_card(host, NULL); +- if (IS_ERR(card)) { +- err = PTR_ERR(card); +- goto err; +- } ++ if (IS_ERR(card)) ++ return PTR_ERR(card); + + if ((rocr & R4_MEMORY_PRESENT) && + mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) { +@@ -610,19 +608,15 @@ try_again: + + if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO || + memcmp(card->raw_cid, oldcard->raw_cid, sizeof(card->raw_cid)) != 0)) { +- mmc_remove_card(card); +- pr_debug("%s: Perhaps the card was replaced\n", +- mmc_hostname(host)); +- return -ENOENT; ++ err = -ENOENT; ++ goto mismatch; + } + } else { + card->type = MMC_TYPE_SDIO; + + if (oldcard && oldcard->type != MMC_TYPE_SDIO) { +- mmc_remove_card(card); +- pr_debug("%s: Perhaps the card was replaced\n", +- mmc_hostname(host)); +- return -ENOENT; ++ err = -ENOENT; ++ goto mismatch; + } + } + +@@ -677,7 +671,7 @@ try_again: + if (!oldcard && card->type == MMC_TYPE_SD_COMBO) { + err = mmc_sd_get_csd(host, card); + if (err) +- return err; ++ goto remove; + + mmc_decode_cid(card); + } +@@ -704,7 +698,12 @@ try_again: + mmc_set_timing(card->host, MMC_TIMING_SD_HS); + } + +- goto finish; ++ if (oldcard) ++ mmc_remove_card(card); ++ else ++ host->card = card; ++ ++ return 0; + } + + /* +@@ -730,16 +729,14 @@ try_again: + goto remove; + + if (oldcard) { +- int same = (card->cis.vendor == oldcard->cis.vendor && +- card->cis.device == oldcard->cis.device); +- mmc_remove_card(card); +- if (!same) { +- pr_debug("%s: Perhaps the card was replaced\n", +- mmc_hostname(host)); +- return -ENOENT; ++ if (card->cis.vendor == oldcard->cis.vendor && ++ card->cis.device == oldcard->cis.device) { ++ mmc_remove_card(card); ++ card = oldcard; ++ } else { ++ err = -ENOENT; ++ goto mismatch; + } +- +- card = oldcard; + } + card->ocr = ocr_card; + mmc_fixup_device(card, sdio_fixup_methods); +@@ -800,16 +797,15 @@ try_again: + err = -EINVAL; + goto remove; + } +-finish: +- if (!oldcard) +- host->card = card; ++ ++ host->card = card; + return 0; + ++mismatch: ++ pr_debug("%s: Perhaps the card was replaced\n", mmc_hostname(host)); + remove: +- if (!oldcard) ++ if (oldcard != card) + mmc_remove_card(card); +- +-err: + return err; + } + diff --git a/queue-5.6/mmc-tmio-further-fixup-runtime-pm-management-at-remove.patch b/queue-5.6/mmc-tmio-further-fixup-runtime-pm-management-at-remove.patch new file mode 100644 index 00000000000..6d858e4346a --- /dev/null +++ b/queue-5.6/mmc-tmio-further-fixup-runtime-pm-management-at-remove.patch @@ -0,0 +1,60 @@ +From 4bd784411aca022622e484eb262f5a0540ae732c Mon Sep 17 00:00:00 2001 +From: Ulf Hansson +Date: Tue, 19 May 2020 17:24:34 +0200 +Subject: mmc: tmio: Further fixup runtime PM management at remove + +From: Ulf Hansson + +commit 4bd784411aca022622e484eb262f5a0540ae732c upstream. + +Before calling tmio_mmc_host_probe(), the caller is required to enable +clocks for its device, as to make it accessible when reading/writing +registers during probe. + +Therefore, the responsibility to disable these clocks, in the error path of +->probe() and during ->remove(), is better managed outside +tmio_mmc_host_remove(). As a matter of fact, callers of +tmio_mmc_host_remove() already expects this to be the behaviour. + +However, there's a problem with tmio_mmc_host_remove() when the Kconfig +option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then +disable the clock via runtime PM, which leads to clock enable/disable +imbalance problems, when the caller of tmio_mmc_host_remove() also tries to +disable the same clocks. + +To solve the problem, let's make sure tmio_mmc_host_remove() leaves the +device with clocks enabled, but also make sure to disable the IRQs, as we +normally do at ->runtime_suspend(). + +Reported-by: Geert Uytterhoeven +Reviewed-by: Wolfram Sang +Tested-by: Wolfram Sang +Signed-off-by: Ulf Hansson +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20200519152434.6867-1-ulf.hansson@linaro.org +Tested-by: Geert Uytterhoeven +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/tmio_mmc_core.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/mmc/host/tmio_mmc_core.c ++++ b/drivers/mmc/host/tmio_mmc_core.c +@@ -1286,12 +1286,14 @@ void tmio_mmc_host_remove(struct tmio_mm + cancel_work_sync(&host->done); + cancel_delayed_work_sync(&host->delayed_reset_work); + tmio_mmc_release_dma(host); ++ tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); + +- pm_runtime_dont_use_autosuspend(&pdev->dev); + if (host->native_hotplug) + pm_runtime_put_noidle(&pdev->dev); +- pm_runtime_put_sync(&pdev->dev); ++ + pm_runtime_disable(&pdev->dev); ++ pm_runtime_dont_use_autosuspend(&pdev->dev); ++ pm_runtime_put_noidle(&pdev->dev); + } + EXPORT_SYMBOL_GPL(tmio_mmc_host_remove); + diff --git a/queue-5.6/mmc-uniphier-sd-call-devm_request_irq-after-tmio_mmc_host_probe.patch b/queue-5.6/mmc-uniphier-sd-call-devm_request_irq-after-tmio_mmc_host_probe.patch new file mode 100644 index 00000000000..921d4de877d --- /dev/null +++ b/queue-5.6/mmc-uniphier-sd-call-devm_request_irq-after-tmio_mmc_host_probe.patch @@ -0,0 +1,60 @@ +From 5d1f42e14b135773c0cc1d82e904c5b223783a9d Mon Sep 17 00:00:00 2001 +From: Masahiro Yamada +Date: Mon, 11 May 2020 15:21:58 +0900 +Subject: mmc: uniphier-sd: call devm_request_irq() after tmio_mmc_host_probe() + +From: Masahiro Yamada + +commit 5d1f42e14b135773c0cc1d82e904c5b223783a9d upstream. + +Currently, tmio_mmc_irq() handler is registered before the host is +fully initialized by tmio_mmc_host_probe(). I did not previously notice +this problem. + +The boot ROM of a new Socionext SoC unmasks interrupts (CTL_IRQ_MASK) +somehow. The handler is invoked before tmio_mmc_host_probe(), then +emits noisy call trace. + +Move devm_request_irq() below tmio_mmc_host_probe(). + +Fixes: 3fd784f745dd ("mmc: uniphier-sd: add UniPhier SD/eMMC controller driver") +Signed-off-by: Masahiro Yamada +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20200511062158.1790924-1-yamada.masahiro@socionext.com +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/uniphier-sd.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +--- a/drivers/mmc/host/uniphier-sd.c ++++ b/drivers/mmc/host/uniphier-sd.c +@@ -610,11 +610,6 @@ static int uniphier_sd_probe(struct plat + } + } + +- ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED, +- dev_name(dev), host); +- if (ret) +- goto free_host; +- + if (priv->caps & UNIPHIER_SD_CAP_EXTENDED_IP) + host->dma_ops = &uniphier_sd_internal_dma_ops; + else +@@ -642,8 +637,15 @@ static int uniphier_sd_probe(struct plat + if (ret) + goto free_host; + ++ ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED, ++ dev_name(dev), host); ++ if (ret) ++ goto remove_host; ++ + return 0; + ++remove_host: ++ tmio_mmc_host_remove(host); + free_host: + tmio_mmc_host_free(host); + diff --git a/queue-5.6/series b/queue-5.6/series index 6342ec49b52..b24439dcb78 100644 --- a/queue-5.6/series +++ b/queue-5.6/series @@ -144,3 +144,13 @@ drm-vkms-hold-gem-object-while-still-in-use.patch mm-slub-fix-a-memory-leak-in-sysfs_slab_add.patch fat-don-t-allow-to-mount-if-the-fat-length-0.patch perf-add-cond_resched-to-task_function_call.patch +agp-intel-reinforce-the-barrier-after-gtt-updates.patch +mmc-sdhci-msm-clear-tuning-done-flag-while-hs400-tuning.patch +mmc-sdhci-of-at91-fix-calcr-register-being-rewritten.patch +mmc-mmci_sdmmc-fix-dma-api-warning-overlapping-mappings.patch +mmc-tmio-further-fixup-runtime-pm-management-at-remove.patch +mmc-uniphier-sd-call-devm_request_irq-after-tmio_mmc_host_probe.patch +arm-dts-at91-sama5d2_ptc_ek-fix-sdmmc0-node-description.patch +mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch +mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch +block-floppy-fix-contended-case-in-floppy_queue_rq.patch -- 2.47.3