All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] dpaa2-switch phylink fixes
@ 2021-08-19 14:40 Vladimir Oltean
  2021-08-19 14:40 ` [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock Vladimir Oltean
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-08-19 14:40 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, David S. Miller; +Cc: Ioana Ciornei

This is fixing two regressions introduced by the recent conversion of
the dpaa2-switch driver to phylink.

Vladimir Oltean (2):
  net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock
  net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe
    error path

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

-- 
2.25.1


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

* [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock
  2021-08-19 14:40 [PATCH net-next 0/2] dpaa2-switch phylink fixes Vladimir Oltean
@ 2021-08-19 14:40 ` Vladimir Oltean
  2021-08-19 15:31   ` Ioana Ciornei
  2021-08-19 14:40 ` [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path Vladimir Oltean
  2021-08-20 13:40 ` [PATCH net-next 0/2] dpaa2-switch phylink fixes patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Vladimir Oltean @ 2021-08-19 14:40 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, David S. Miller; +Cc: Ioana Ciornei

There is an ASSERT_RTNL in phylink_disconnect_phy which triggers
whenever dpaa2_switch_port_disconnect_mac is called.

To follow the pattern established by dpaa2_eth_disconnect_mac, take the
rtnl_mutex every time we call dpaa2_switch_port_disconnect_mac.

Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index d260993ab2dc..d27c5b841c84 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -1508,10 +1508,12 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
 	}
 
 	if (status & DPSW_IRQ_EVENT_ENDPOINT_CHANGED) {
+		rtnl_lock();
 		if (dpaa2_switch_port_has_mac(port_priv))
 			dpaa2_switch_port_disconnect_mac(port_priv);
 		else
 			dpaa2_switch_port_connect_mac(port_priv);
+		rtnl_unlock();
 	}
 
 out:
@@ -3199,7 +3201,9 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
 	for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
 		port_priv = ethsw->ports[i];
 		unregister_netdev(port_priv->netdev);
+		rtnl_lock();
 		dpaa2_switch_port_disconnect_mac(port_priv);
+		rtnl_unlock();
 		free_netdev(port_priv->netdev);
 	}
 
-- 
2.25.1


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

* [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path
  2021-08-19 14:40 [PATCH net-next 0/2] dpaa2-switch phylink fixes Vladimir Oltean
  2021-08-19 14:40 ` [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock Vladimir Oltean
@ 2021-08-19 14:40 ` Vladimir Oltean
  2021-08-19 15:32   ` Ioana Ciornei
  2021-08-20 13:40 ` [PATCH net-next 0/2] dpaa2-switch phylink fixes patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Vladimir Oltean @ 2021-08-19 14:40 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, David S. Miller; +Cc: Ioana Ciornei

Currently when probing returns an error, the netdev is freed but
phylink_disconnect is not called.

Create a common function between the unbind path and the error path,
call it the opposite of dpaa2_switch_probe_port: dpaa2_switch_remove_port,
and call it from both the unbind and the error path.

Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Note: the dpaa2_switch_remove_port function is placed so far from
dpaa2_switch_probe_port because I wanted to avoid a trivial conflict
with this patch on "net":
https://patchwork.kernel.org/project/netdevbpf/patch/20210819141755.1931423-1-vladimir.oltean@nxp.com/
which moves dpaa2_switch_ctrl_if_teardown around, and this would appear
in the context of the "net-next" patch.

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index d27c5b841c84..a1a2dc9e4048 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2925,6 +2925,18 @@ static int dpaa2_switch_ctrl_if_setup(struct ethsw_core *ethsw)
 	return err;
 }
 
+static void dpaa2_switch_remove_port(struct ethsw_core *ethsw,
+				     u16 port_idx)
+{
+	struct ethsw_port_priv *port_priv = ethsw->ports[port_idx];
+
+	rtnl_lock();
+	dpaa2_switch_port_disconnect_mac(port_priv);
+	rtnl_unlock();
+	free_netdev(port_priv->netdev);
+	ethsw->ports[port_idx] = NULL;
+}
+
 static int dpaa2_switch_init(struct fsl_mc_device *sw_dev)
 {
 	struct device *dev = &sw_dev->dev;
@@ -3201,10 +3213,7 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
 	for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
 		port_priv = ethsw->ports[i];
 		unregister_netdev(port_priv->netdev);
-		rtnl_lock();
-		dpaa2_switch_port_disconnect_mac(port_priv);
-		rtnl_unlock();
-		free_netdev(port_priv->netdev);
+		dpaa2_switch_remove_port(ethsw, i);
 	}
 
 	kfree(ethsw->fdbs);
@@ -3394,7 +3403,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
 	dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
 err_free_netdev:
 	for (i--; i >= 0; i--)
-		free_netdev(ethsw->ports[i]->netdev);
+		dpaa2_switch_remove_port(ethsw, i);
 	kfree(ethsw->filter_blocks);
 err_free_fdbs:
 	kfree(ethsw->fdbs);
-- 
2.25.1


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

* Re: [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock
  2021-08-19 14:40 ` [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock Vladimir Oltean
@ 2021-08-19 15:31   ` Ioana Ciornei
  0 siblings, 0 replies; 6+ messages in thread
From: Ioana Ciornei @ 2021-08-19 15:31 UTC (permalink / raw)
  To: Vladimir Oltean; +Cc: netdev, Jakub Kicinski, David S. Miller

On Thu, Aug 19, 2021 at 05:40:18PM +0300, Vladimir Oltean wrote:
> There is an ASSERT_RTNL in phylink_disconnect_phy which triggers
> whenever dpaa2_switch_port_disconnect_mac is called.
> 
> To follow the pattern established by dpaa2_eth_disconnect_mac, take the
> rtnl_mutex every time we call dpaa2_switch_port_disconnect_mac.
> 
> Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>

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

* Re: [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path
  2021-08-19 14:40 ` [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path Vladimir Oltean
@ 2021-08-19 15:32   ` Ioana Ciornei
  0 siblings, 0 replies; 6+ messages in thread
From: Ioana Ciornei @ 2021-08-19 15:32 UTC (permalink / raw)
  To: Vladimir Oltean; +Cc: netdev, Jakub Kicinski, David S. Miller

On Thu, Aug 19, 2021 at 05:40:19PM +0300, Vladimir Oltean wrote:
> Currently when probing returns an error, the netdev is freed but
> phylink_disconnect is not called.
> 
> Create a common function between the unbind path and the error path,
> call it the opposite of dpaa2_switch_probe_port: dpaa2_switch_remove_port,
> and call it from both the unbind and the error path.
> 
> Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>

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

* Re: [PATCH net-next 0/2] dpaa2-switch phylink fixes
  2021-08-19 14:40 [PATCH net-next 0/2] dpaa2-switch phylink fixes Vladimir Oltean
  2021-08-19 14:40 ` [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock Vladimir Oltean
  2021-08-19 14:40 ` [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path Vladimir Oltean
@ 2021-08-20 13:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-20 13:40 UTC (permalink / raw)
  To: Vladimir Oltean; +Cc: netdev, kuba, davem, ioana.ciornei

Hello:

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

On Thu, 19 Aug 2021 17:40:17 +0300 you wrote:
> This is fixing two regressions introduced by the recent conversion of
> the dpaa2-switch driver to phylink.
> 
> Vladimir Oltean (2):
>   net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock
>   net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe
>     error path
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock
    https://git.kernel.org/netdev/net-next/c/d52ef12f7d6c
  - [net-next,2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path
    https://git.kernel.org/netdev/net-next/c/860fe1f87eca

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] 6+ messages in thread

end of thread, other threads:[~2021-08-20 13:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 14:40 [PATCH net-next 0/2] dpaa2-switch phylink fixes Vladimir Oltean
2021-08-19 14:40 ` [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock Vladimir Oltean
2021-08-19 15:31   ` Ioana Ciornei
2021-08-19 14:40 ` [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path Vladimir Oltean
2021-08-19 15:32   ` Ioana Ciornei
2021-08-20 13:40 ` [PATCH net-next 0/2] dpaa2-switch phylink fixes 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.