u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] DSA cleanups
@ 2021-09-18 11:49 Vladimir Oltean
  2021-09-18 11:49 ` [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable Vladimir Oltean
  2021-09-18 11:49 ` [PATCH 2/2] net: dsa: remove unused variables Vladimir Oltean
  0 siblings, 2 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-09-18 11:49 UTC (permalink / raw)
  To: u-boot; +Cc: Joe Hershberger, Ramon Fried, Tim Harvey, Michael Walle

This series contains a bug fix and a cleanup for W=1 builds.

Vladimir Oltean (2):
  net: dsa: pass CPU port fixed PHY to .port_disable
  net: dsa: remove unused variables

 net/dsa-uclass.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

-- 
2.25.1


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

* [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable
  2021-09-18 11:49 [PATCH 0/2] DSA cleanups Vladimir Oltean
@ 2021-09-18 11:49 ` Vladimir Oltean
  2021-09-28 13:27   ` Ramon Fried
  2021-09-28 15:10   ` Tim Harvey
  2021-09-18 11:49 ` [PATCH 2/2] net: dsa: remove unused variables Vladimir Oltean
  1 sibling, 2 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-09-18 11:49 UTC (permalink / raw)
  To: u-boot; +Cc: Joe Hershberger, Ramon Fried, Tim Harvey, Michael Walle

While adding the logic for DSA to register a fixed-link PHY for the CPU
port, I forgot to pass it to the .port_disable method too, just
.port_enable.

Bug had no impact for felix_switch.c, due to the phy argument not being
used, but ksz9477.c does use it => NULL pointer dereference.

Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/dsa-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
index 9b8ae1e82b92..d1c6c78acd6c 100644
--- a/net/dsa-uclass.c
+++ b/net/dsa-uclass.c
@@ -100,7 +100,7 @@ static void dsa_port_stop(struct udevice *pdev)
 
 		port_pdata = dev_get_parent_plat(pdev);
 		ops->port_disable(dev, port_pdata->index, port_pdata->phy);
-		ops->port_disable(dev, priv->cpu_port, NULL);
+		ops->port_disable(dev, priv->cpu_port, priv->cpu_port_fixed_phy);
 	}
 
 	eth_get_ops(master)->stop(master);
-- 
2.25.1


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

* [PATCH 2/2] net: dsa: remove unused variables
  2021-09-18 11:49 [PATCH 0/2] DSA cleanups Vladimir Oltean
  2021-09-18 11:49 ` [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable Vladimir Oltean
@ 2021-09-18 11:49 ` Vladimir Oltean
  2021-09-28 13:28   ` Ramon Fried
  1 sibling, 1 reply; 6+ messages in thread
From: Vladimir Oltean @ 2021-09-18 11:49 UTC (permalink / raw)
  To: u-boot; +Cc: Joe Hershberger, Ramon Fried, Tim Harvey, Michael Walle

"dev" and "dsa_pdata" are unused inside dsa_port_of_to_pdata.

"dsa_priv" is unused inside dsa_port_probe.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/dsa-uclass.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
index d1c6c78acd6c..8a2918816e30 100644
--- a/net/dsa-uclass.c
+++ b/net/dsa-uclass.c
@@ -199,9 +199,7 @@ static int dsa_port_free_pkt(struct udevice *pdev, uchar *packet, int length)
 static int dsa_port_of_to_pdata(struct udevice *pdev)
 {
 	struct dsa_port_pdata *port_pdata;
-	struct dsa_pdata *dsa_pdata;
 	struct eth_pdata *eth_pdata;
-	struct udevice *dev;
 	const char *label;
 	u32 index;
 	int err;
@@ -213,9 +211,6 @@ static int dsa_port_of_to_pdata(struct udevice *pdev)
 	if (err)
 		return err;
 
-	dev = dev_get_parent(pdev);
-	dsa_pdata = dev_get_uclass_plat(dev);
-
 	port_pdata = dev_get_parent_plat(pdev);
 	port_pdata->index = index;
 
@@ -272,12 +267,10 @@ static int dsa_port_probe(struct udevice *pdev)
 	struct udevice *dev = dev_get_parent(pdev);
 	struct dsa_ops *ops = dsa_get_ops(dev);
 	struct dsa_port_pdata *port_pdata;
-	struct dsa_priv *dsa_priv;
 	struct udevice *master;
 	int err;
 
 	port_pdata = dev_get_parent_plat(pdev);
-	dsa_priv = dev_get_uclass_priv(dev);
 
 	port_pdata->phy = dm_eth_phy_connect(pdev);
 	if (!port_pdata->phy)
@@ -312,12 +305,7 @@ static int dsa_port_probe(struct udevice *pdev)
 
 static int dsa_port_remove(struct udevice *pdev)
 {
-	struct udevice *dev = dev_get_parent(pdev);
-	struct dsa_port_pdata *port_pdata;
-	struct dsa_priv *dsa_priv;
-
-	port_pdata = dev_get_parent_plat(pdev);
-	dsa_priv = dev_get_uclass_priv(dev);
+	struct dsa_port_pdata *port_pdata = dev_get_parent_plat(pdev);
 
 	port_pdata->phy = NULL;
 
-- 
2.25.1


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

* Re: [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable
  2021-09-18 11:49 ` [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable Vladimir Oltean
@ 2021-09-28 13:27   ` Ramon Fried
  2021-09-28 15:10   ` Tim Harvey
  1 sibling, 0 replies; 6+ messages in thread
From: Ramon Fried @ 2021-09-28 13:27 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: U-Boot Mailing List, Joe Hershberger, Tim Harvey, Michael Walle

On Sat, Sep 18, 2021 at 2:50 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> While adding the logic for DSA to register a fixed-link PHY for the CPU
> port, I forgot to pass it to the .port_disable method too, just
> .port_enable.
>
> Bug had no impact for felix_switch.c, due to the phy argument not being
> used, but ksz9477.c does use it => NULL pointer dereference.
>
> Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/dsa-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index 9b8ae1e82b92..d1c6c78acd6c 100644
> --- a/net/dsa-uclass.c
> +++ b/net/dsa-uclass.c
> @@ -100,7 +100,7 @@ static void dsa_port_stop(struct udevice *pdev)
>
>                 port_pdata = dev_get_parent_plat(pdev);
>                 ops->port_disable(dev, port_pdata->index, port_pdata->phy);
> -               ops->port_disable(dev, priv->cpu_port, NULL);
> +               ops->port_disable(dev, priv->cpu_port, priv->cpu_port_fixed_phy);
>         }
>
>         eth_get_ops(master)->stop(master);
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

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

* Re: [PATCH 2/2] net: dsa: remove unused variables
  2021-09-18 11:49 ` [PATCH 2/2] net: dsa: remove unused variables Vladimir Oltean
@ 2021-09-28 13:28   ` Ramon Fried
  0 siblings, 0 replies; 6+ messages in thread
From: Ramon Fried @ 2021-09-28 13:28 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: U-Boot Mailing List, Joe Hershberger, Tim Harvey, Michael Walle

On Sat, Sep 18, 2021 at 2:50 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> "dev" and "dsa_pdata" are unused inside dsa_port_of_to_pdata.
>
> "dsa_priv" is unused inside dsa_port_probe.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/dsa-uclass.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index d1c6c78acd6c..8a2918816e30 100644
> --- a/net/dsa-uclass.c
> +++ b/net/dsa-uclass.c
> @@ -199,9 +199,7 @@ static int dsa_port_free_pkt(struct udevice *pdev, uchar *packet, int length)
>  static int dsa_port_of_to_pdata(struct udevice *pdev)
>  {
>         struct dsa_port_pdata *port_pdata;
> -       struct dsa_pdata *dsa_pdata;
>         struct eth_pdata *eth_pdata;
> -       struct udevice *dev;
>         const char *label;
>         u32 index;
>         int err;
> @@ -213,9 +211,6 @@ static int dsa_port_of_to_pdata(struct udevice *pdev)
>         if (err)
>                 return err;
>
> -       dev = dev_get_parent(pdev);
> -       dsa_pdata = dev_get_uclass_plat(dev);
> -
>         port_pdata = dev_get_parent_plat(pdev);
>         port_pdata->index = index;
>
> @@ -272,12 +267,10 @@ static int dsa_port_probe(struct udevice *pdev)
>         struct udevice *dev = dev_get_parent(pdev);
>         struct dsa_ops *ops = dsa_get_ops(dev);
>         struct dsa_port_pdata *port_pdata;
> -       struct dsa_priv *dsa_priv;
>         struct udevice *master;
>         int err;
>
>         port_pdata = dev_get_parent_plat(pdev);
> -       dsa_priv = dev_get_uclass_priv(dev);
>
>         port_pdata->phy = dm_eth_phy_connect(pdev);
>         if (!port_pdata->phy)
> @@ -312,12 +305,7 @@ static int dsa_port_probe(struct udevice *pdev)
>
>  static int dsa_port_remove(struct udevice *pdev)
>  {
> -       struct udevice *dev = dev_get_parent(pdev);
> -       struct dsa_port_pdata *port_pdata;
> -       struct dsa_priv *dsa_priv;
> -
> -       port_pdata = dev_get_parent_plat(pdev);
> -       dsa_priv = dev_get_uclass_priv(dev);
> +       struct dsa_port_pdata *port_pdata = dev_get_parent_plat(pdev);
>
>         port_pdata->phy = NULL;
>
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

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

* Re: [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable
  2021-09-18 11:49 ` [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable Vladimir Oltean
  2021-09-28 13:27   ` Ramon Fried
@ 2021-09-28 15:10   ` Tim Harvey
  1 sibling, 0 replies; 6+ messages in thread
From: Tim Harvey @ 2021-09-28 15:10 UTC (permalink / raw)
  To: Vladimir Oltean; +Cc: u-boot, Joe Hershberger, Ramon Fried, Michael Walle

On Sat, Sep 18, 2021 at 4:50 AM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> While adding the logic for DSA to register a fixed-link PHY for the CPU
> port, I forgot to pass it to the .port_disable method too, just
> .port_enable.
>
> Bug had no impact for felix_switch.c, due to the phy argument not being
> used, but ksz9477.c does use it => NULL pointer dereference.
>
> Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/dsa-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index 9b8ae1e82b92..d1c6c78acd6c 100644
> --- a/net/dsa-uclass.c
> +++ b/net/dsa-uclass.c
> @@ -100,7 +100,7 @@ static void dsa_port_stop(struct udevice *pdev)
>
>                 port_pdata = dev_get_parent_plat(pdev);
>                 ops->port_disable(dev, port_pdata->index, port_pdata->phy);
> -               ops->port_disable(dev, priv->cpu_port, NULL);
> +               ops->port_disable(dev, priv->cpu_port, priv->cpu_port_fixed_phy);
>         }
>
>         eth_get_ops(master)->stop(master);
> --
> 2.25.1
>

Turns out ksz9477.c only used it if debug was enabled as right after
the debug print it would return for cpu port.

Tested on imx8mm-venice-gw7901 with ksz9477 switch.

Tested-By: Tim Harvey <tharvey@gateworks.com>

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

end of thread, other threads:[~2021-09-28 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18 11:49 [PATCH 0/2] DSA cleanups Vladimir Oltean
2021-09-18 11:49 ` [PATCH 1/2] net: dsa: pass CPU port fixed PHY to .port_disable Vladimir Oltean
2021-09-28 13:27   ` Ramon Fried
2021-09-28 15:10   ` Tim Harvey
2021-09-18 11:49 ` [PATCH 2/2] net: dsa: remove unused variables Vladimir Oltean
2021-09-28 13:28   ` Ramon Fried

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).