All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: rtsx: Let MMC core handle runtime PM
@ 2022-02-16  5:54 Kai-Heng Feng
  2022-02-16 10:29 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Kai-Heng Feng @ 2022-02-16  5:54 UTC (permalink / raw)
  To: ulf.hansson
  Cc: Kai-Heng Feng, Thomas Hebb, Greg Kroah-Hartman, linux-mmc, linux-kernel

Since MMC core handles runtime PM reference counting, we can avoid doing
redundant runtime PM work in the driver. That means the only thing
commit 5b4258f6721f ("misc: rtsx: rts5249 support runtime PM") misses is
to always enable runtime PM, to let its parent driver enable ASPM in the
runtime idle routine.

Fixes: 7499b529d97f ("mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 2a3f14afe9f83..265b3889f9d72 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -823,7 +823,6 @@ static void sd_request(struct work_struct *work)
 	}
 
 	mutex_lock(&pcr->pcr_mutex);
-	pm_runtime_get_sync(dev);
 
 	rtsx_pci_start_run(pcr);
 
@@ -860,8 +859,6 @@ static void sd_request(struct work_struct *work)
 			data->bytes_xfered = data->blocks * data->blksz;
 	}
 
-	pm_runtime_mark_last_busy(dev);
-	pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&pcr->pcr_mutex);
 
 finish:
@@ -1093,7 +1090,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		return;
 
 	mutex_lock(&pcr->pcr_mutex);
-	pm_runtime_get_sync(dev);
 
 	rtsx_pci_start_run(pcr);
 
@@ -1127,8 +1123,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	rtsx_pci_switch_clock(pcr, ios->clock, host->ssc_depth,
 			host->initial_mode, host->double_clk, host->vpclk);
 
-	pm_runtime_mark_last_busy(dev);
-	pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&pcr->pcr_mutex);
 }
 
@@ -1144,7 +1138,6 @@ static int sdmmc_get_ro(struct mmc_host *mmc)
 		return -ENOMEDIUM;
 
 	mutex_lock(&pcr->pcr_mutex);
-	pm_runtime_get_sync(dev);
 
 	rtsx_pci_start_run(pcr);
 
@@ -1154,8 +1147,6 @@ static int sdmmc_get_ro(struct mmc_host *mmc)
 	if (val & SD_WRITE_PROTECT)
 		ro = 1;
 
-	pm_runtime_mark_last_busy(dev);
-	pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&pcr->pcr_mutex);
 
 	return ro;
@@ -1173,7 +1164,6 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 		return cd;
 
 	mutex_lock(&pcr->pcr_mutex);
-	pm_runtime_get_sync(dev);
 
 	rtsx_pci_start_run(pcr);
 
@@ -1183,8 +1173,6 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 	if (val & SD_EXIST)
 		cd = 1;
 
-	pm_runtime_mark_last_busy(dev);
-	pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&pcr->pcr_mutex);
 
 	return cd;
@@ -1282,7 +1270,6 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
 		return err;
 
 	mutex_lock(&pcr->pcr_mutex);
-	pm_runtime_get_sync(dev);
 
 	rtsx_pci_start_run(pcr);
 
@@ -1312,8 +1299,6 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
 	err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
 			SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
 
-	pm_runtime_mark_last_busy(dev);
-	pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&pcr->pcr_mutex);
 
 	return err;
@@ -1334,7 +1319,6 @@ static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
 		return err;
 
 	mutex_lock(&pcr->pcr_mutex);
-	pm_runtime_get_sync(dev);
 
 	rtsx_pci_start_run(pcr);
 
@@ -1367,8 +1351,6 @@ static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
 		err = sd_change_phase(host, DDR50_RX_PHASE(pcr), true);
 
 out:
-	pm_runtime_mark_last_busy(dev);
-	pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&pcr->pcr_mutex);
 
 	return err;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: rtsx: Let MMC core handle runtime PM
  2022-02-16  5:54 [PATCH] mmc: rtsx: Let MMC core handle runtime PM Kai-Heng Feng
@ 2022-02-16 10:29 ` Ulf Hansson
  2022-02-22  7:14   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2022-02-16 10:29 UTC (permalink / raw)
  To: Kai-Heng Feng, Greg Kroah-Hartman; +Cc: Thomas Hebb, linux-mmc, linux-kernel

On Wed, 16 Feb 2022 at 06:55, Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
>
> Since MMC core handles runtime PM reference counting, we can avoid doing
> redundant runtime PM work in the driver. That means the only thing
> commit 5b4258f6721f ("misc: rtsx: rts5249 support runtime PM") misses is
> to always enable runtime PM, to let its parent driver enable ASPM in the
> runtime idle routine.
>
> Fixes: 7499b529d97f ("mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

This looks good to me!

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Greg, do you want to funnel this through your tree - or should I wait
for an rc containing 7499b529d97f and take it through my mmc tree?
Either way works for me.

Kind regards
Uffe

> ---
>  drivers/mmc/host/rtsx_pci_sdmmc.c | 18 ------------------
>  1 file changed, 18 deletions(-)
>
> diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
> index 2a3f14afe9f83..265b3889f9d72 100644
> --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
> +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
> @@ -823,7 +823,6 @@ static void sd_request(struct work_struct *work)
>         }
>
>         mutex_lock(&pcr->pcr_mutex);
> -       pm_runtime_get_sync(dev);
>
>         rtsx_pci_start_run(pcr);
>
> @@ -860,8 +859,6 @@ static void sd_request(struct work_struct *work)
>                         data->bytes_xfered = data->blocks * data->blksz;
>         }
>
> -       pm_runtime_mark_last_busy(dev);
> -       pm_runtime_put_autosuspend(dev);
>         mutex_unlock(&pcr->pcr_mutex);
>
>  finish:
> @@ -1093,7 +1090,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>                 return;
>
>         mutex_lock(&pcr->pcr_mutex);
> -       pm_runtime_get_sync(dev);
>
>         rtsx_pci_start_run(pcr);
>
> @@ -1127,8 +1123,6 @@ static void sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>         rtsx_pci_switch_clock(pcr, ios->clock, host->ssc_depth,
>                         host->initial_mode, host->double_clk, host->vpclk);
>
> -       pm_runtime_mark_last_busy(dev);
> -       pm_runtime_put_autosuspend(dev);
>         mutex_unlock(&pcr->pcr_mutex);
>  }
>
> @@ -1144,7 +1138,6 @@ static int sdmmc_get_ro(struct mmc_host *mmc)
>                 return -ENOMEDIUM;
>
>         mutex_lock(&pcr->pcr_mutex);
> -       pm_runtime_get_sync(dev);
>
>         rtsx_pci_start_run(pcr);
>
> @@ -1154,8 +1147,6 @@ static int sdmmc_get_ro(struct mmc_host *mmc)
>         if (val & SD_WRITE_PROTECT)
>                 ro = 1;
>
> -       pm_runtime_mark_last_busy(dev);
> -       pm_runtime_put_autosuspend(dev);
>         mutex_unlock(&pcr->pcr_mutex);
>
>         return ro;
> @@ -1173,7 +1164,6 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
>                 return cd;
>
>         mutex_lock(&pcr->pcr_mutex);
> -       pm_runtime_get_sync(dev);
>
>         rtsx_pci_start_run(pcr);
>
> @@ -1183,8 +1173,6 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
>         if (val & SD_EXIST)
>                 cd = 1;
>
> -       pm_runtime_mark_last_busy(dev);
> -       pm_runtime_put_autosuspend(dev);
>         mutex_unlock(&pcr->pcr_mutex);
>
>         return cd;
> @@ -1282,7 +1270,6 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
>                 return err;
>
>         mutex_lock(&pcr->pcr_mutex);
> -       pm_runtime_get_sync(dev);
>
>         rtsx_pci_start_run(pcr);
>
> @@ -1312,8 +1299,6 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
>         err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
>                         SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
>
> -       pm_runtime_mark_last_busy(dev);
> -       pm_runtime_put_autosuspend(dev);
>         mutex_unlock(&pcr->pcr_mutex);
>
>         return err;
> @@ -1334,7 +1319,6 @@ static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
>                 return err;
>
>         mutex_lock(&pcr->pcr_mutex);
> -       pm_runtime_get_sync(dev);
>
>         rtsx_pci_start_run(pcr);
>
> @@ -1367,8 +1351,6 @@ static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
>                 err = sd_change_phase(host, DDR50_RX_PHASE(pcr), true);
>
>  out:
> -       pm_runtime_mark_last_busy(dev);
> -       pm_runtime_put_autosuspend(dev);
>         mutex_unlock(&pcr->pcr_mutex);
>
>         return err;
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: rtsx: Let MMC core handle runtime PM
  2022-02-16 10:29 ` Ulf Hansson
@ 2022-02-22  7:14   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-02-22  7:14 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: Kai-Heng Feng, Thomas Hebb, linux-mmc, linux-kernel

On Wed, Feb 16, 2022 at 11:29:52AM +0100, Ulf Hansson wrote:
> On Wed, 16 Feb 2022 at 06:55, Kai-Heng Feng <kai.heng.feng@canonical.com> wrote:
> >
> > Since MMC core handles runtime PM reference counting, we can avoid doing
> > redundant runtime PM work in the driver. That means the only thing
> > commit 5b4258f6721f ("misc: rtsx: rts5249 support runtime PM") misses is
> > to always enable runtime PM, to let its parent driver enable ASPM in the
> > runtime idle routine.
> >
> > Fixes: 7499b529d97f ("mmc: rtsx: Use pm_runtime_{get,put}() to handle runtime PM")
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> This looks good to me!
> 
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Greg, do you want to funnel this through your tree - or should I wait
> for an rc containing 7499b529d97f and take it through my mmc tree?
> Either way works for me.

I will take it now, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-22  7:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16  5:54 [PATCH] mmc: rtsx: Let MMC core handle runtime PM Kai-Heng Feng
2022-02-16 10:29 ` Ulf Hansson
2022-02-22  7:14   ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.