Skip to content

Commit 379f56c

Browse files
AndreySVstorulf
authored andcommitted
mmc: core: Wait for command setting 'Power Off Notification' bit to complete
SD card is allowed to signal busy on DAT0 up to 1s after the CMD49. According to SD spec (version 6.0 section 5.8.1.3) first host waits until busy of CMD49 is released and only then polls Power Management Status register up to 1s until the card indicates ready to power off. Without waiting for busy before polling status register sometimes card becomes unresponsive and system fails to suspend: [ 205.907459] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. [ 206.421274] sunxi-mmc 1c0f000.mmc: data error, sending stop command [ 206.421321] sunxi-mmc 1c0f000.mmc: send stop command failed [ 206.421347] mmc0: error -110 reading status reg of PM func [ 206.421366] PM: dpm_run_callback(): mmc_bus_suspend+0x0/0x74 returns -110 [ 206.421402] mmcblk mmc0:aaaa: PM: failed to suspend async: error -110 [ 206.437064] PM: Some devices failed to suspend, or early wake event detected Tested with Sandisk Extreme PRO A2 64GB on Allwinner A64 system. Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com> Fixes: 2c5d427 ("mmc: core: Add support for Power Off Notification for SD cards") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220115121447.641524-1-andrej.skvortzov@gmail.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 4d31535 commit 379f56c

File tree

1 file changed

+7
-1
lines changed
  • drivers/mmc/core

1 file changed

+7
-1
lines changed

drivers/mmc/core/sd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static const unsigned int sd_au_size[] = {
6767
__res & __mask; \
6868
})
6969

70-
#define SD_POWEROFF_NOTIFY_TIMEOUT_MS 2000
70+
#define SD_POWEROFF_NOTIFY_TIMEOUT_MS 1000
7171
#define SD_WRITE_EXTR_SINGLE_TIMEOUT_MS 1000
7272

7373
struct sd_busy_data {
@@ -1664,6 +1664,12 @@ static int sd_poweroff_notify(struct mmc_card *card)
16641664
goto out;
16651665
}
16661666

1667+
/* Find out when the command is completed. */
1668+
err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false,
1669+
MMC_BUSY_EXTR_SINGLE);
1670+
if (err)
1671+
goto out;
1672+
16671673
cb_data.card = card;
16681674
cb_data.reg_buf = reg_buf;
16691675
err = __mmc_poll_for_busy(card->host, SD_POWEROFF_NOTIFY_TIMEOUT_MS,

0 commit comments

Comments
 (0)