From 4c5a1c3b00d7b95d4a3599576137ba65dce34fd9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 10 Oct 2022 08:34:57 +0200 Subject: [PATCH] 5.4-stable patches added patches: mmc-core-replace-with-already-defined-values-for-readability.patch mmc-core-terminate-infinite-loop-in-sd-uhs-voltage-switch.patch --- ...ready-defined-values-for-readability.patch | 33 ++++++++++ ...finite-loop-in-sd-uhs-voltage-switch.patch | 63 +++++++++++++++++++ queue-5.4/series | 2 + 3 files changed, 98 insertions(+) create mode 100644 queue-5.4/mmc-core-replace-with-already-defined-values-for-readability.patch create mode 100644 queue-5.4/mmc-core-terminate-infinite-loop-in-sd-uhs-voltage-switch.patch diff --git a/queue-5.4/mmc-core-replace-with-already-defined-values-for-readability.patch b/queue-5.4/mmc-core-replace-with-already-defined-values-for-readability.patch new file mode 100644 index 00000000000..24aaceb16d7 --- /dev/null +++ b/queue-5.4/mmc-core-replace-with-already-defined-values-for-readability.patch @@ -0,0 +1,33 @@ +From e427266460826bea21b70f9b2bb29decfb2c2620 Mon Sep 17 00:00:00 2001 +From: ChanWoo Lee +Date: Wed, 6 Jul 2022 09:48:40 +0900 +Subject: mmc: core: Replace with already defined values for readability + +From: ChanWoo Lee + +commit e427266460826bea21b70f9b2bb29decfb2c2620 upstream. + +SD_ROCR_S18A is already defined and is used to check the rocr value, so +let's replace with already defined values for readability. + +Signed-off-by: ChanWoo Lee +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20220706004840.24812-1-cw9316.lee@samsung.com +Signed-off-by: Ulf Hansson +Signed-off-by: Brian Norris +Signed-off-by: Greg Kroah-Hartman +--- + drivers/mmc/core/sd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mmc/core/sd.c ++++ b/drivers/mmc/core/sd.c +@@ -799,7 +799,7 @@ try_again: + * the CCS bit is set as well. We deliberately deviate from the spec in + * regards to this, which allows UHS-I to be supported for SDSC cards. + */ +- if (!mmc_host_is_spi(host) && rocr && (*rocr & 0x01000000)) { ++ if (!mmc_host_is_spi(host) && rocr && (*rocr & SD_ROCR_S18A)) { + err = mmc_set_uhs_voltage(host, pocr); + if (err == -EAGAIN) { + retries--; diff --git a/queue-5.4/mmc-core-terminate-infinite-loop-in-sd-uhs-voltage-switch.patch b/queue-5.4/mmc-core-terminate-infinite-loop-in-sd-uhs-voltage-switch.patch new file mode 100644 index 00000000000..75cf3f6d4bd --- /dev/null +++ b/queue-5.4/mmc-core-terminate-infinite-loop-in-sd-uhs-voltage-switch.patch @@ -0,0 +1,63 @@ +From e9233917a7e53980664efbc565888163c0a33c3f Mon Sep 17 00:00:00 2001 +From: Brian Norris +Date: Tue, 13 Sep 2022 18:40:10 -0700 +Subject: mmc: core: Terminate infinite loop in SD-UHS voltage switch + +From: Brian Norris + +commit e9233917a7e53980664efbc565888163c0a33c3f upstream. + +This loop intends to retry a max of 10 times, with some implicit +termination based on the SD_{R,}OCR_S18A bit. Unfortunately, the +termination condition depends on the value reported by the SD card +(*rocr), which may or may not correctly reflect what we asked it to do. + +Needless to say, it's not wise to rely on the card doing what we expect; +we should at least terminate the loop regardless. So, check both the +input and output values, so we ensure we will terminate regardless of +the SD card behavior. + +Note that SDIO learned a similar retry loop in commit 0797e5f1453b +("mmc: core: Fixup signal voltage switch"), but that used the 'ocr' +result, and so the current pre-terminating condition looks like: + + rocr & ocr & R4_18V_PRESENT + +(i.e., it doesn't have the same bug.) + +This addresses a number of crash reports seen on ChromeOS that look +like the following: + + ... // lots of repeated: ... + <4>[13142.846061] mmc1: Skipping voltage switch + <4>[13143.406087] mmc1: Skipping voltage switch + <4>[13143.964724] mmc1: Skipping voltage switch + <4>[13144.526089] mmc1: Skipping voltage switch + <4>[13145.086088] mmc1: Skipping voltage switch + <4>[13145.645941] mmc1: Skipping voltage switch + <3>[13146.153969] INFO: task halt:30352 blocked for more than 122 seconds. + ... + +Fixes: f2119df6b764 ("mmc: sd: add support for signal voltage switch procedure") +Cc: +Signed-off-by: Brian Norris +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20220914014010.2076169-1-briannorris@chromium.org +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman +--- + drivers/mmc/core/sd.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/mmc/core/sd.c ++++ b/drivers/mmc/core/sd.c +@@ -799,7 +799,8 @@ try_again: + * the CCS bit is set as well. We deliberately deviate from the spec in + * regards to this, which allows UHS-I to be supported for SDSC cards. + */ +- if (!mmc_host_is_spi(host) && rocr && (*rocr & SD_ROCR_S18A)) { ++ if (!mmc_host_is_spi(host) && (ocr & SD_OCR_S18R) && ++ rocr && (*rocr & SD_ROCR_S18A)) { + err = mmc_set_uhs_voltage(host, pocr); + if (err == -EAGAIN) { + retries--; diff --git a/queue-5.4/series b/queue-5.4/series index e88d1fdb3a6..7b5dd8b2efe 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -14,3 +14,5 @@ um-cleanup-compiler-warning-in-arch-x86-um-tls_32.c.patch arch-um-mark-the-stack-non-executable-to-fix-a-binut.patch usb-mon-make-mmapped-memory-read-only.patch usb-serial-ftdi_sio-fix-300-bps-rate-for-sio.patch +mmc-core-replace-with-already-defined-values-for-readability.patch +mmc-core-terminate-infinite-loop-in-sd-uhs-voltage-switch.patch -- 2.47.3