Re: [PATCH 2/2] mmc: core: Add post-power-off-delay-ms support
Ulf Hansson <[email protected]> Fri, 17 Jul 2026 12:41:34 +0200
| Newsgroups | org.kernel.vger.linux-mmc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAPx+jO8H=J-B-DgXG5Qrg02y2GZDMFr+mySt=oCP5L7WBbzZAQ@mail.gmail.com> |
On Fri, Jul 17, 2026 at 1:26 AM Judith Mendez <[email protected]> wrote: > > Add support for post-power-off-delay-ms which shall be used to insert > a configurable delay post MMC power off. > > Signed-off-by: Judith Mendez <[email protected]> > --- > drivers/mmc/core/core.c | 8 ++++++-- > drivers/mmc/core/host.c | 8 ++++++++ > include/linux/mmc/host.h | 1 + > 3 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > index 29e80e5f928e9..f9049aaf44394 100644 > --- a/drivers/mmc/core/core.c > +++ b/drivers/mmc/core/core.c > @@ -1394,8 +1394,12 @@ void mmc_power_off(struct mmc_host *host) > void mmc_power_cycle(struct mmc_host *host, u32 ocr) > { > mmc_power_off(host); > - /* Wait at least 1 ms according to SD spec */ > - mmc_delay(1); The above delay is kind of questionable in the first place, as we already have a mmc_delay(1) at the end of mmc_power_off(). Maybe the delay is needed for legacy reasons and because of that, I would suggest that we leave mmc_power_cycle() as is, for now. In the end, I would rather see that the above delay gets removed altogether. Instead, how about making the mmc_delay(1) in mmc_power_off() configurable? Moreover, rather than the code below, I think it would be better to set a default value for "host->post_power_off_delay_ms" to 1 in mmc_alloc_host(). In fact, there is already similar code for "host->ios.power_delay_ms", please try to follow that for this case too. > + if (host->post_power_off_delay_ms) { > + mmc_delay(host->post_power_off_delay_ms); > + } else { > + /* Wait at least 1 ms according to SD spec */ > + mmc_delay(1); > + } > mmc_power_up(host, ocr); > } > > diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c > index b7ce3137d4529..ea8f36827e41c 100644 > --- a/drivers/mmc/core/host.c > +++ b/drivers/mmc/core/host.c > @@ -421,6 +421,14 @@ int mmc_of_parse(struct mmc_host *host) > device_property_read_u32(dev, "post-power-on-delay-ms", > &host->ios.power_delay_ms); > > + device_property_read_u32(dev, "post-power-off-delay-ms", > + &host->post_power_off_delay_ms); > + if (host->post_power_off_delay_ms > 10000) { > + dev_err(dev, "post-power-off-delay-ms %u exceeds max 10000, setting 10000\n", > + host->post_power_off_delay_ms); > + host->post_power_off_delay_ms = 10000; > + } > + > return mmc_pwrseq_alloc(host); > } > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h > index ba84f02c2a101..b751b61b1116e 100644 > --- a/include/linux/mmc/host.h > +++ b/include/linux/mmc/host.h > @@ -578,6 +578,7 @@ struct mmc_host { > > u32 err_stats[MMC_ERR_MAX]; > u32 max_sd_hs_hz; > + u32 post_power_off_delay_ms; > unsigned long private[] ____cacheline_aligned; > }; > > -- > 2.54.0 > Kind regards Uffe