linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind
@ 2022-08-10  2:25 Samuel Holland
  2022-08-14  8:22 ` Jernej Škrabec
  2022-08-15 10:11 ` Ulf Hansson
  0 siblings, 2 replies; 6+ messages in thread
From: Samuel Holland @ 2022-08-10  2:25 UTC (permalink / raw)
  To: Chen-Yu Tsai, Jernej Skrabec, Ulf Hansson, Wolfram Sang
  Cc: Samuel Holland, Andre Przywara, Maxime Ripard, linux-arm-kernel,
	linux-kernel, linux-mmc, linux-sunxi

If the controller is suspended by runtime PM, the clock is already
disabled, so do not try to disable it again during removal. Use
pm_runtime_disable() to flush any pending runtime PM transitions.

Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 drivers/mmc/host/sunxi-mmc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index b16e12e62e72..3db9f32d6a7b 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1492,9 +1492,11 @@ static int sunxi_mmc_remove(struct platform_device *pdev)
 	struct sunxi_mmc_host *host = mmc_priv(mmc);
 
 	mmc_remove_host(mmc);
-	pm_runtime_force_suspend(&pdev->dev);
-	disable_irq(host->irq);
-	sunxi_mmc_disable(host);
+	pm_runtime_disable(&pdev->dev);
+	if (!pm_runtime_status_suspended(&pdev->dev)) {
+		disable_irq(host->irq);
+		sunxi_mmc_disable(host);
+	}
 	dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
 	mmc_free_host(mmc);
 
-- 
2.35.1


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

* Re: [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind
  2022-08-10  2:25 [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind Samuel Holland
@ 2022-08-14  8:22 ` Jernej Škrabec
  2022-08-14 17:56   ` Samuel Holland
  2022-08-15 10:11 ` Ulf Hansson
  1 sibling, 1 reply; 6+ messages in thread
From: Jernej Škrabec @ 2022-08-14  8:22 UTC (permalink / raw)
  To: Chen-Yu Tsai, Ulf Hansson, Wolfram Sang, Samuel Holland
  Cc: Samuel Holland, Andre Przywara, Maxime Ripard, linux-arm-kernel,
	linux-kernel, linux-mmc, linux-sunxi

Dne sreda, 10. avgust 2022 ob 04:25:09 CEST je Samuel Holland napisal(a):
> If the controller is suspended by runtime PM, the clock is already
> disabled, so do not try to disable it again during removal. Use
> pm_runtime_disable() to flush any pending runtime PM transitions.
> 
> Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Did you get any warnings for unbalanced disable calls?

Anyway:
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej



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

* Re: [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind
  2022-08-14  8:22 ` Jernej Škrabec
@ 2022-08-14 17:56   ` Samuel Holland
  0 siblings, 0 replies; 6+ messages in thread
From: Samuel Holland @ 2022-08-14 17:56 UTC (permalink / raw)
  To: Jernej Škrabec, Chen-Yu Tsai, Ulf Hansson, Wolfram Sang
  Cc: Andre Przywara, Maxime Ripard, linux-arm-kernel, linux-kernel,
	linux-mmc, linux-sunxi

On 8/14/22 3:22 AM, Jernej Škrabec wrote:
> Dne sreda, 10. avgust 2022 ob 04:25:09 CEST je Samuel Holland napisal(a):
>> If the controller is suspended by runtime PM, the clock is already
>> disabled, so do not try to disable it again during removal. Use
>> pm_runtime_disable() to flush any pending runtime PM transitions.
>>
>> Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
>> Signed-off-by: Samuel Holland <samuel@sholland.org>
> 
> Did you get any warnings for unbalanced disable calls?

Yes, I got warnings while I was doing unbind/bind cycles to force the SDIO WiFi
driver to reload.

Regards,
Samuel

> Anyway:
> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> 
> Best regards,
> Jernej
> 
> 


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

* Re: [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind
  2022-08-10  2:25 [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind Samuel Holland
  2022-08-14  8:22 ` Jernej Škrabec
@ 2022-08-15 10:11 ` Ulf Hansson
  2023-01-01 19:25   ` Samuel Holland
  1 sibling, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2022-08-15 10:11 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Chen-Yu Tsai, Jernej Skrabec, Wolfram Sang, Andre Przywara,
	Maxime Ripard, linux-arm-kernel, linux-kernel, linux-mmc,
	linux-sunxi

On Wed, 10 Aug 2022 at 04:25, Samuel Holland <samuel@sholland.org> wrote:
>
> If the controller is suspended by runtime PM, the clock is already
> disabled, so do not try to disable it again during removal. Use
> pm_runtime_disable() to flush any pending runtime PM transitions.
>
> Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
>  drivers/mmc/host/sunxi-mmc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> index b16e12e62e72..3db9f32d6a7b 100644
> --- a/drivers/mmc/host/sunxi-mmc.c
> +++ b/drivers/mmc/host/sunxi-mmc.c
> @@ -1492,9 +1492,11 @@ static int sunxi_mmc_remove(struct platform_device *pdev)
>         struct sunxi_mmc_host *host = mmc_priv(mmc);
>
>         mmc_remove_host(mmc);
> -       pm_runtime_force_suspend(&pdev->dev);
> -       disable_irq(host->irq);
> -       sunxi_mmc_disable(host);

Perhaps a better option than the below, would just be to drop the
above calls to disable_irq() and sunxi_mmc_disable(), as that is
already managed through the call to pm_runtime_force_suspend().

> +       pm_runtime_disable(&pdev->dev);
> +       if (!pm_runtime_status_suspended(&pdev->dev)) {
> +               disable_irq(host->irq);
> +               sunxi_mmc_disable(host);
> +       }
>         dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
>         mmc_free_host(mmc);
>

Kind regards
Uffe

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

* Re: [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind
  2022-08-15 10:11 ` Ulf Hansson
@ 2023-01-01 19:25   ` Samuel Holland
  2023-01-02 15:07     ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Holland @ 2023-01-01 19:25 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Chen-Yu Tsai, Jernej Skrabec, Wolfram Sang, Andre Przywara,
	Maxime Ripard, linux-arm-kernel, linux-kernel, linux-mmc,
	linux-sunxi

On 8/15/22 05:11, Ulf Hansson wrote:
> On Wed, 10 Aug 2022 at 04:25, Samuel Holland <samuel@sholland.org> wrote:
>>
>> If the controller is suspended by runtime PM, the clock is already
>> disabled, so do not try to disable it again during removal. Use
>> pm_runtime_disable() to flush any pending runtime PM transitions.
>>
>> Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
>> Signed-off-by: Samuel Holland <samuel@sholland.org>
>> ---
>>
>>  drivers/mmc/host/sunxi-mmc.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
>> index b16e12e62e72..3db9f32d6a7b 100644
>> --- a/drivers/mmc/host/sunxi-mmc.c
>> +++ b/drivers/mmc/host/sunxi-mmc.c
>> @@ -1492,9 +1492,11 @@ static int sunxi_mmc_remove(struct platform_device *pdev)
>>         struct sunxi_mmc_host *host = mmc_priv(mmc);
>>
>>         mmc_remove_host(mmc);
>> -       pm_runtime_force_suspend(&pdev->dev);
>> -       disable_irq(host->irq);
>> -       sunxi_mmc_disable(host);
> 
> Perhaps a better option than the below, would just be to drop the
> above calls to disable_irq() and sunxi_mmc_disable(), as that is
> already managed through the call to pm_runtime_force_suspend().

I like the idea, but it will not work for !CONFIG_PM builds, which this
driver currently supports.

Regards,
Samuel

>> +       pm_runtime_disable(&pdev->dev);
>> +       if (!pm_runtime_status_suspended(&pdev->dev)) {
>> +               disable_irq(host->irq);
>> +               sunxi_mmc_disable(host);
>> +       }
>>         dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
>>         mmc_free_host(mmc);
>>
> 
> Kind regards
> Uffe


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

* Re: [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind
  2023-01-01 19:25   ` Samuel Holland
@ 2023-01-02 15:07     ` Ulf Hansson
  0 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2023-01-02 15:07 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Chen-Yu Tsai, Jernej Skrabec, Wolfram Sang, Andre Przywara,
	Maxime Ripard, linux-arm-kernel, linux-kernel, linux-mmc,
	linux-sunxi

On Sun, 1 Jan 2023 at 20:25, Samuel Holland <samuel@sholland.org> wrote:
>
> On 8/15/22 05:11, Ulf Hansson wrote:
> > On Wed, 10 Aug 2022 at 04:25, Samuel Holland <samuel@sholland.org> wrote:
> >>
> >> If the controller is suspended by runtime PM, the clock is already
> >> disabled, so do not try to disable it again during removal. Use
> >> pm_runtime_disable() to flush any pending runtime PM transitions.
> >>
> >> Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
> >> Signed-off-by: Samuel Holland <samuel@sholland.org>
> >> ---
> >>
> >>  drivers/mmc/host/sunxi-mmc.c | 8 +++++---
> >>  1 file changed, 5 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> >> index b16e12e62e72..3db9f32d6a7b 100644
> >> --- a/drivers/mmc/host/sunxi-mmc.c
> >> +++ b/drivers/mmc/host/sunxi-mmc.c
> >> @@ -1492,9 +1492,11 @@ static int sunxi_mmc_remove(struct platform_device *pdev)
> >>         struct sunxi_mmc_host *host = mmc_priv(mmc);
> >>
> >>         mmc_remove_host(mmc);
> >> -       pm_runtime_force_suspend(&pdev->dev);
> >> -       disable_irq(host->irq);
> >> -       sunxi_mmc_disable(host);
> >
> > Perhaps a better option than the below, would just be to drop the
> > above calls to disable_irq() and sunxi_mmc_disable(), as that is
> > already managed through the call to pm_runtime_force_suspend().
>
> I like the idea, but it will not work for !CONFIG_PM builds, which this
> driver currently supports.

Good point! I have applied the patch for fixes and added a stable tag
to it, thanks!

[...]

Kind regards
Uffe

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

end of thread, other threads:[~2023-01-02 15:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10  2:25 [PATCH] mmc: sunxi-mmc: Fix clock refcount imbalance during unbind Samuel Holland
2022-08-14  8:22 ` Jernej Škrabec
2022-08-14 17:56   ` Samuel Holland
2022-08-15 10:11 ` Ulf Hansson
2023-01-01 19:25   ` Samuel Holland
2023-01-02 15:07     ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).