mmc: core: do power-off with resume failure
PATCH 1/3 mmc: core: do power-off with resume failure
Currently there is no mmc_power_off() when resume failed. Somehow, state from mmc_power_on() will be kept. This change makes a pair with its use in case of failure.
--- drivers/mmc/core/mmc.c | 3 +++ drivers/mmc/core/sd.c | 3 +++ drivers/mmc/core/sdio.c | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)
drivers/mmc/core/mmc.c +3 -0
@@ -1536,6 +1536,9 @@ static int mmc_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;
drivers/mmc/core/sd.c +3 -0
@@ -1099,6 +1099,9 @@ static int mmc_sd_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_sd_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;
drivers/mmc/core/sdio.c +3 -0
@@ -1033,6 +1033,9 @@ static int mmc_sdio_resume(struct mmc_host *host) } } +if (err && !mmc_card_keep_power (host)) +mmc_power_off (host); + host->pm_flags &= ~MMC_PM_KEEP_POWER ;return err; }
Signature · 1 line
1.7.0.4
Quoted 3 lines · Seungwon Jeon
Currently there is no
mmc_power_off()when resume failed. Somehow, state frommmc_power_on()will be kept. This change makes a pair with its use in case of failure.
Hi Seungwon,
To be safe, we can not power off, even if a resume failures. The reason is that the bus/card/host is still available for sending commands to it and those will then likely hang since IP controllers internal registers is configured for "power off" state.
Instead, we must leave the power off to be handled from the next rescan work when the card is no longer properly "detected". For NONREMOVABLE we will instead at error path try to do a "power_restore_host".
Kind regards
Ulf Hansson
Quoted 58 lines
Signed-off-by Seungwon Jeon <[email protected]>--- drivers/mmc/core/mmc.c | 3 +++ drivers/mmc/core/sd.c | 3 +++ drivers/mmc/core/sdio.c | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)drivers/mmc/core/mmc.c +3
-0@@ -1536,6 +1536,9 @@ static int mmc_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sd.c +3
-0@@ -1099,6 +1099,9 @@ static int mmc_sd_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_sd_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sdio.c +3
-1@@ -1033,6 +1033,9 @@ static int mmc_sdio_resume(struct mmc_host *host) } } +if (err && !mmc_card_keep_power (host)) +mmc_power_off (host); + host->pm_flags &= ~MMC_PM_KEEP_POWER ;return err; } --1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · Ulf Hansson
Quoted 3 lines · Seungwon Jeon
Currently there is no
mmc_power_off()when resume failed. Somehow, state frommmc_power_on()will be kept. This change makes a pair with its use in case of failure.Hi Seungwon,
To be safe, we can not power off, even if a resume failures. The reason is that the bus/card/host is still available for sending commands to it and those will then likely hang since IP controllers internal registers is configured for "power off" state.
Generally when host drivers get MMC_POWER_OFF, host doesn't gate clock for host running. MMC_POWER_ON/OFF is related to card side. So, I guess hanging isn't expected because host is kept ready.
Quoted 5 lines
Instead, we must leave the power off to be handled from the next rescan work when the card is no longer properly "detected". For NONREMOVABLE we will instead at error path try to do a "
power_restore_host".
It might be needed graceful error handling.
Ok, I'll consider further.
Thanks,
Seungwon Jeon
Quoted 67 lines
Kind regards
Ulf HanssonQuoted 54 lines
Signed-off-by Seungwon Jeon <[email protected]>--- drivers/mmc/core/mmc.c | 3 +++ drivers/mmc/core/sd.c | 3 +++ drivers/mmc/core/sdio.c | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)drivers/mmc/core/mmc.c +3
-0@@ -1536,6 +1536,9 @@ static int mmc_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sd.c +3
-0@@ -1099,6 +1099,9 @@ static int mmc_sd_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_sd_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sdio.c +3
-1@@ -1033,6 +1033,9 @@ static int mmc_sdio_resume(struct mmc_host *host) } } +if (err && !mmc_card_keep_power (host)) +mmc_power_off (host); + host->pm_flags &= ~MMC_PM_KEEP_POWER ;return err; } --1.7.0.4
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Seungwon Jeon
Quoted 5 lines · Ulf Hansson
Quoted 3 lines · Seungwon Jeon
Currently there is no
mmc_power_off()when resume failed. Somehow, state frommmc_power_on()will be kept. This change makes a pair with its use in case of failure.
Quoted 8 lines
Quoted 6 lines
Hi Seungwon,
To be safe, we can not power off, even if a resume failures. The reason is that the bus/card/host is still available for sending commands to it and those will then likely hang since IP controllers internal registers is configured for "power off" state.
Generally when host drivers get
MMC_POWER_OFF, host doesn't gate clock for host running. MMC_POWER_ON/OFF is related to card side. So, I guess hanging isn't expected because host is kept ready.
At least for mmci host driver a hang may happen. Internal IP registers needs to be set properly as done for MMC_POWER_ON mode, otherwise a cmd can not be sent to the card without a potential hang, forever waiting for an interrupt.
I would be surprised if similar issues could not occur for other host controllers/drivers.
Kind regards
Ulf Hansson
Quoted 84 lines
Quoted 6 lines
Instead, we must leave the power off to be handled from the next rescan work when the card is no longer properly "detected". For NONREMOVABLE we will instead at error path try to do a "
power_restore_host".It might be needed graceful error handling.
Ok, I'll consider further.Thanks,
Seungwon JeonQuoted 59 lines
Kind regards
Ulf HanssonQuoted 54 lines
Signed-off-by Seungwon Jeon <[email protected]>--- drivers/mmc/core/mmc.c | 3 +++ drivers/mmc/core/sd.c | 3 +++ drivers/mmc/core/sdio.c | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)drivers/mmc/core/mmc.c +3
-0@@ -1536,6 +1536,9 @@ static int mmc_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sd.c +3
-0@@ -1099,6 +1099,9 @@ static int mmc_sd_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_sd_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sdio.c +3
-1@@ -1033,6 +1033,9 @@ static int mmc_sdio_resume(struct mmc_host *host) } } +if (err && !mmc_card_keep_power (host)) +mmc_power_off (host); + host->pm_flags &= ~MMC_PM_KEEP_POWER ;return err; } --1.7.0.4
Quoted 8 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Ulf Hansson
Quoted 12 lines · Seungwon Jeon
Quoted 11 lines · Ulf Hansson
Quoted 3 lines · Seungwon Jeon
Currently there is no
mmc_power_off()when resume failed. Somehow, state frommmc_power_on()will be kept. This change makes a pair with its use in case of failure.Hi Seungwon,
To be safe, we can not power off, even if a resume failures. The reason is that the bus/card/host is still available for sending commands to it and those will then likely hang since IP controllers internal registers is configured for "power off" state.
Quoted 8 lines
Quoted 2 lines
Generally when host drivers get
MMC_POWER_OFF, host doesn't gate clock for host running. MMC_POWER_ON/OFF is related to card side. So, I guess hanging isn't expected because host is keptready.
At least for mmci host driver a hang may happen. Internal IP registers needs to be set properly as done for
MMC_POWER_ONmode, otherwise a cmd can not be sent to the card without a potential hang, forever waiting for an interrupt.
I looked into the set_ios function of mmci host.
Power for I/O bus lines are controlled there. Then unexpected occurrence from host may be possible. Host can raise interrupt though.
Ok.
Thanks,
Seungwon Jeon
Quoted 95 lines
I would be surprised if similar issues could not occur for other host controllers/drivers.
Kind regards
Ulf HanssonQuoted 80 lines
Quoted 6 lines
Instead, we must leave the power off to be handled from the next rescan work when the card is no longer properly "detected". For NONREMOVABLE we will instead at error path try to do a "
power_restore_host".It might be needed graceful error handling.
Ok, I'll consider further.Thanks,
Seungwon JeonQuoted 59 lines
Kind regards
Ulf HanssonQuoted 54 lines
Signed-off-by Seungwon Jeon <[email protected]>--- drivers/mmc/core/mmc.c | 3 +++ drivers/mmc/core/sd.c | 3 +++ drivers/mmc/core/sdio.c | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)drivers/mmc/core/mmc.c +3
-0@@ -1536,6 +1536,9 @@ static int mmc_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sd.c +3
-0@@ -1099,6 +1099,9 @@ static int mmc_sd_resume(struct mmc_host *host)mmc_power_up (host);mmc_select_voltage (host, host->ocr); err =mmc_sd_init_card (host, host->ocr, host->card); +if (err) +mmc_power_off (host); +mmc_release_host (host);return err;drivers/mmc/core/sdio.c +3
-1@@ -1033,6 +1033,9 @@ static int mmc_sdio_resume(struct mmc_host *host) } } +if (err && !mmc_card_keep_power (host)) +mmc_power_off (host); + host->pm_flags &= ~MMC_PM_KEEP_POWER ;return err; } --1.7.0.4
Quoted 8 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlQuoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html