All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: ravb: Fix release of refclk
@ 2021-04-17 13:23 Adam Ford
  2021-04-19  8:02 ` Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Adam Ford @ 2021-04-17 13:23 UTC (permalink / raw)
  To: netdev
  Cc: aford, geert, Adam Ford, Sergei Shtylyov, David S. Miller,
	Jakub Kicinski, Andrew Lunn, linux-renesas-soc, linux-kernel

The call to clk_disable_unprepare() can happen before priv is
initialized. This means moving clk_disable_unprepare out of
out_release into a new label.

Fixes: 8ef7adc6beb2("net: ethernet: ravb: Enable optional refclk")
Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8c84c40ab9a0..64a545c98ff2 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2173,7 +2173,7 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Set GTI value */
 	error = ravb_set_gti(ndev);
 	if (error)
-		goto out_release;
+		goto out_unprepare_refclk;
 
 	/* Request GTI loading */
 	ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
@@ -2192,7 +2192,7 @@ static int ravb_probe(struct platform_device *pdev)
 			"Cannot allocate desc base address table (size %d bytes)\n",
 			priv->desc_bat_size);
 		error = -ENOMEM;
-		goto out_release;
+		goto out_unprepare_refclk;
 	}
 	for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++)
 		priv->desc_bat[q].die_dt = DT_EOS;
@@ -2252,8 +2252,9 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Stop PTP Clock driver */
 	if (chip_id != RCAR_GEN2)
 		ravb_ptp_stop(ndev);
-out_release:
+out_unprepare_refclk:
 	clk_disable_unprepare(priv->refclk);
+out_release:
 	free_netdev(ndev);
 
 	pm_runtime_put(&pdev->dev);
-- 
2.25.1


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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-17 13:23 [PATCH] net: ethernet: ravb: Fix release of refclk Adam Ford
@ 2021-04-19  8:02 ` Geert Uytterhoeven
  2021-04-19  9:38 ` Sergei Shtylyov
  2021-04-19 22:45 ` David Miller
  2 siblings, 0 replies; 9+ messages in thread
From: Geert Uytterhoeven @ 2021-04-19  8:02 UTC (permalink / raw)
  To: Adam Ford
  Cc: netdev, Adam Ford-BE, Sergei Shtylyov, David S. Miller,
	Jakub Kicinski, Andrew Lunn, Linux-Renesas,
	Linux Kernel Mailing List

On Sat, Apr 17, 2021 at 3:23 PM Adam Ford <aford173@gmail.com> wrote:
> The call to clk_disable_unprepare() can happen before priv is
> initialized. This means moving clk_disable_unprepare out of
> out_release into a new label.
>
> Fixes: 8ef7adc6beb2("net: ethernet: ravb: Enable optional refclk")
> Signed-off-by: Adam Ford <aford173@gmail.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-17 13:23 [PATCH] net: ethernet: ravb: Fix release of refclk Adam Ford
  2021-04-19  8:02 ` Geert Uytterhoeven
@ 2021-04-19  9:38 ` Sergei Shtylyov
  2021-04-19 22:45 ` David Miller
  2 siblings, 0 replies; 9+ messages in thread
From: Sergei Shtylyov @ 2021-04-19  9:38 UTC (permalink / raw)
  To: Adam Ford, netdev
  Cc: aford, geert, David S. Miller, Jakub Kicinski, Andrew Lunn,
	linux-renesas-soc, linux-kernel

Hello!

On 17.04.2021 16:23, Adam Ford wrote:

> The call to clk_disable_unprepare() can happen before priv is
> initialized.

    Mhm, how's that? :-/

> This means moving clk_disable_unprepare out of
> out_release into a new label.
> 
> Fixes: 8ef7adc6beb2("net: ethernet: ravb: Enable optional refclk")
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 8c84c40ab9a0..64a545c98ff2 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -2252,8 +2252,9 @@ static int ravb_probe(struct platform_device *pdev)
>   	/* Stop PTP Clock driver */
>   	if (chip_id != RCAR_GEN2)
>   		ravb_ptp_stop(ndev);
> -out_release:
> +out_unprepare_refclk:

    I'd really prefer out_disable_refclk.

>   	clk_disable_unprepare(priv->refclk);
> +out_release:
>   	free_netdev(ndev);
>   
>   	pm_runtime_put(&pdev->dev);

MBR, Sergei

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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-17 13:23 [PATCH] net: ethernet: ravb: Fix release of refclk Adam Ford
  2021-04-19  8:02 ` Geert Uytterhoeven
  2021-04-19  9:38 ` Sergei Shtylyov
@ 2021-04-19 22:45 ` David Miller
  2021-04-20  3:33   ` Adam Ford
  2 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2021-04-19 22:45 UTC (permalink / raw)
  To: aford173
  Cc: netdev, aford, geert, sergei.shtylyov, kuba, andrew,
	linux-renesas-soc, linux-kernel

From: Adam Ford <aford173@gmail.com>
Date: Sat, 17 Apr 2021 08:23:29 -0500

> The call to clk_disable_unprepare() can happen before priv is
> initialized. This means moving clk_disable_unprepare out of
> out_release into a new label.
> 
> Fixes: 8ef7adc6beb2("net: ethernet: ravb: Enable optional refclk")
> Signed-off-by: Adam Ford <aford173@gmail.com>
Thjis does not apply cleanly, please rebbase and resubmit.

Please fix the formatting of your Fixes tag while you are at it, thank you.

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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-19 22:45 ` David Miller
@ 2021-04-20  3:33   ` Adam Ford
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Ford @ 2021-04-20  3:33 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Adam Ford-BE, Geert Uytterhoeven, Sergei Shtylyov,
	Jakub Kicinski, Andrew Lunn, Linux-Renesas,
	Linux Kernel Mailing List

On Mon, Apr 19, 2021 at 5:45 PM David Miller <davem@davemloft.net> wrote:
>
> From: Adam Ford <aford173@gmail.com>
> Date: Sat, 17 Apr 2021 08:23:29 -0500
>
> > The call to clk_disable_unprepare() can happen before priv is
> > initialized. This means moving clk_disable_unprepare out of
> > out_release into a new label.
> >
> > Fixes: 8ef7adc6beb2("net: ethernet: ravb: Enable optional refclk")
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> Thjis does not apply cleanly, please rebbase and resubmit.

Which branch should I use as the rebase?  I used net-next because
that's where the bug is, but I know it changes frequently.

>
> Please fix the formatting of your Fixes tag while you are at it, thank you.

no problem.  Sorry about that

adam

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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-21 14:05 Adam Ford
  2021-04-21 14:25 ` Sergei Shtylyov
@ 2021-04-21 18:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-21 18:20 UTC (permalink / raw)
  To: Adam Ford
  Cc: netdev, aford, sergei.shtylyov, davem, kuba, andrew,
	linux-renesas-soc, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Wed, 21 Apr 2021 09:05:05 -0500 you wrote:
> The call to clk_disable_unprepare() can happen before priv is
> initialized. This means moving clk_disable_unprepare out of
> out_release into a new label.
> 
> Fixes: 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> [...]

Here is the summary with links:
  - net: ethernet: ravb: Fix release of refclk
    https://git.kernel.org/netdev/net-next/c/36e69da892f1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-21 14:25 ` Sergei Shtylyov
@ 2021-04-21 16:03   ` Adam Ford
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Ford @ 2021-04-21 16:03 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: netdev, Adam Ford-BE, David S. Miller, Jakub Kicinski,
	Andrew Lunn, Linux-Renesas, Linux Kernel Mailing List

On Wed, Apr 21, 2021 at 9:25 AM Sergei Shtylyov
<sergei.shtylyov@gmail.com> wrote:
>
> On 4/21/21 5:05 PM, Adam Ford wrote:
>
> > The call to clk_disable_unprepare() can happen before priv is
> > initialized.
>
>    This still doesn't make sense for me...
>
I need an external reference clock enabled by a programmable clock so
I added functionality to turn it on.  [1] When I did it, I was
reminded to disable the clock in the event of an the error condition.
I originally added a call to clk_disable_unprepare(priv->refclk)
under the label called out_release, but a bot responded to me that we
may jump to this error condition before priv is initialized.

This fix is supposed to create a new label so the errors that happen
after the refclk is initialized will get disabled, but any errors that
happen before the clock is initialized will handle errors like they
did before.

Does that help explain things better?

adam

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2

> > This means moving clk_disable_unprepare out of
>                                          ^ call
> > out_release into a new label.
> >
> > Fixes: 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")
> > Signed-off-by: Adam Ford <aford173@gmail.com>
>
> Reviewed-by: Sergei Shtylyov <sergei.shtylyov@gmail.com>
>
>
> [...]
>
> MBR, Sergei

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

* Re: [PATCH] net: ethernet: ravb: Fix release of refclk
  2021-04-21 14:05 Adam Ford
@ 2021-04-21 14:25 ` Sergei Shtylyov
  2021-04-21 16:03   ` Adam Ford
  2021-04-21 18:20 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2021-04-21 14:25 UTC (permalink / raw)
  To: Adam Ford, netdev
  Cc: aford, David S. Miller, Jakub Kicinski, Andrew Lunn,
	linux-renesas-soc, linux-kernel

On 4/21/21 5:05 PM, Adam Ford wrote:

> The call to clk_disable_unprepare() can happen before priv is
> initialized.

   This still doesn't make sense for me...

> This means moving clk_disable_unprepare out of
                                         ^ call
> out_release into a new label.
> 
> Fixes: 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")
> Signed-off-by: Adam Ford <aford173@gmail.com>

Reviewed-by: Sergei Shtylyov <sergei.shtylyov@gmail.com>


[...]

MBR, Sergei

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

* [PATCH] net: ethernet: ravb: Fix release of refclk
@ 2021-04-21 14:05 Adam Ford
  2021-04-21 14:25 ` Sergei Shtylyov
  2021-04-21 18:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 9+ messages in thread
From: Adam Ford @ 2021-04-21 14:05 UTC (permalink / raw)
  To: netdev
  Cc: aford, Adam Ford, Sergei Shtylyov, David S. Miller,
	Jakub Kicinski, Andrew Lunn, linux-renesas-soc, linux-kernel

The call to clk_disable_unprepare() can happen before priv is
initialized. This means moving clk_disable_unprepare out of
out_release into a new label.

Fixes: 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")
Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  Rebase on net-next/master, fix fixes tag, change name of label
     from out_unprepare_refclk to out_disable_refclk

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8c84c40ab9a0..9e5dad41cdc9 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2173,7 +2173,7 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Set GTI value */
 	error = ravb_set_gti(ndev);
 	if (error)
-		goto out_release;
+		goto out_disable_refclk;
 
 	/* Request GTI loading */
 	ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
@@ -2192,7 +2192,7 @@ static int ravb_probe(struct platform_device *pdev)
 			"Cannot allocate desc base address table (size %d bytes)\n",
 			priv->desc_bat_size);
 		error = -ENOMEM;
-		goto out_release;
+		goto out_disable_refclk;
 	}
 	for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++)
 		priv->desc_bat[q].die_dt = DT_EOS;
@@ -2252,8 +2252,9 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Stop PTP Clock driver */
 	if (chip_id != RCAR_GEN2)
 		ravb_ptp_stop(ndev);
-out_release:
+out_disable_refclk:
 	clk_disable_unprepare(priv->refclk);
+out_release:
 	free_netdev(ndev);
 
 	pm_runtime_put(&pdev->dev);
-- 
2.25.1


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

end of thread, other threads:[~2021-04-21 18:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-17 13:23 [PATCH] net: ethernet: ravb: Fix release of refclk Adam Ford
2021-04-19  8:02 ` Geert Uytterhoeven
2021-04-19  9:38 ` Sergei Shtylyov
2021-04-19 22:45 ` David Miller
2021-04-20  3:33   ` Adam Ford
2021-04-21 14:05 Adam Ford
2021-04-21 14:25 ` Sergei Shtylyov
2021-04-21 16:03   ` Adam Ford
2021-04-21 18:20 ` patchwork-bot+netdevbpf

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.