RE: [PATCH v19 09/12] mmc: renesas_sdhi: Save and restore IOVS across suspend/resume

Biju Das <[email protected]> Fri, 10 Jul 2026 08:55:03 +0000
Newsgroups org.kernel.vger.linux-mmc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-renesas-soc
Message-ID <TY3PR01MB113462EB460505037C4B7FCC786FD2@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Hi All,

> -----Original Message-----
> From: Biju <[email protected]>
> Sent: 09 July 2026 20:29
> Subject: [PATCH v19 09/12] mmc: renesas_sdhi: Save and restore IOVS across suspend/resume
> 
> From: Biju Das <[email protected]>
> 
> The SD_STATUS register, specifically the IOVS (I/O Voltage Switch) bit, is not automatically restored
> after a suspend/resume cycle, causing the regulator to report an incorrect voltage on resume.
> 
> Fix this by caching the CTL_SD_STATUS register value in the renesas_sdhi private struct at suspend time
> and writing it back during resume. The save/restore is only performed when a regulator device (rdev) is
> present, as the IOVS bit is only relevant in that context.
> 
> Signed-off-by: Biju Das <[email protected]>
> ---
> v18->v19:
>  * Updated suspend/resume with scoped runtime calls in suspend.
> v17->v18:
>  * No change.
> v1->v17:
>  * No change.
> ---
>  drivers/mmc/host/renesas_sdhi.h      |  2 ++
>  drivers/mmc/host/renesas_sdhi_core.c | 11 +++++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h index
> d46598190004..39d915da6f38 100644
> --- a/drivers/mmc/host/renesas_sdhi.h
> +++ b/drivers/mmc/host/renesas_sdhi.h
> @@ -104,6 +104,8 @@ struct renesas_sdhi {
>  	struct reset_control *rstc_axim;
>  	struct tmio_mmc_host *host;
>  	struct regulator_dev *rdev;
> +
> +	u32 cache_sd_status;
>  };
> 
>  #define host_to_priv(host) \
> diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> index c4908c09d89d..cec703122b22 100644
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -1400,6 +1400,15 @@ int renesas_sdhi_suspend(struct device *dev)
>  	};
>  	int ret;
> 
> +	if (priv->rdev) {
> +		PM_RUNTIME_ACQUIRE_IF_ENABLED(dev, pm);
> +		ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> +		if (ret < 0)
> +			return ret;
> +
> +		priv->cache_sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
> +	}
> +
>  	ret = pm_runtime_force_suspend(dev);
>  	if (ret)
>  		return ret;
> @@ -1430,6 +1439,8 @@ int renesas_sdhi_resume(struct device *dev)
>  	ret = pm_runtime_force_resume(dev);
>  	if (ret)
>  		reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
> +	else if (priv->rdev)
> +		sd_ctrl_write32(host, CTL_SD_STATUS, priv->cache_sd_status);

Will add scoped PM to handle the issue mentioned by sashiko [1]

https://sashiko.dev/#/patchset/20260709192916.630794-1-biju.das.jz%40bp.renesas.com

Cheers,
Biju

> 
>  	return ret;
>  }
> --
> 2.43.0