linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes
@ 2020-06-24  7:00 Sascha Hauer
  2020-06-24  7:00 ` [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sascha Hauer @ 2020-06-24  7:00 UTC (permalink / raw)
  To: netdev
  Cc: kernel, Sascha Hauer, Russell King, linux-kernel,
	Thomas Petazzoni, linux-arm-kernel

In mvneta_config_interface() the RGMII modes are catched by the default
case which is an error return. The RGMII modes are valid modes for the
driver, so instead of returning an error add a break statement to return
successfully.

This avoids this warning for non comphy SoCs which use RGMII, like
SolidRun Clearfog:

WARNING: CPU: 0 PID: 268 at drivers/net/ethernet/marvell/mvneta.c:3512 mvneta_start_dev+0x220/0x23c

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/ethernet/marvell/mvneta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index af60001728481..c4552f868157c 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3571,7 +3571,7 @@ static int mvneta_config_interface(struct mvneta_port *pp,
 				    MVNETA_HSGMII_SERDES_PROTO);
 			break;
 		default:
-			return -EINVAL;
+			break;
 		}
 	}
 
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation
  2020-06-24  7:00 [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Sascha Hauer
@ 2020-06-24  7:00 ` Sascha Hauer
  2020-06-24  9:55   ` Russell King - ARM Linux admin
  2020-06-24 21:48   ` David Miller
  2020-06-24  9:53 ` [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Russell King - ARM Linux admin
  2020-06-24 21:48 ` David Miller
  2 siblings, 2 replies; 6+ messages in thread
From: Sascha Hauer @ 2020-06-24  7:00 UTC (permalink / raw)
  To: netdev
  Cc: kernel, Sascha Hauer, Russell King, linux-kernel,
	Thomas Petazzoni, linux-arm-kernel

When writing the serdes configuration register was moved to
mvneta_config_interface() the whole code block was removed from
mvneta_port_power_up() in the assumption that its only purpose was to
write the serdes configuration register. As mentioned by Russell King
its purpose was also to check for valid interface modes early so that
later in the driver we do not have to care for unexpected interface
modes.
Add back the test to let the driver bail out early on unhandled
interface modes.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/ethernet/marvell/mvneta.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index c4552f868157c..c639e3a293024 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -5009,10 +5009,18 @@ static void mvneta_conf_mbus_windows(struct mvneta_port *pp,
 }
 
 /* Power up the port */
-static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
+static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
 {
 	/* MAC Cause register should be cleared */
 	mvreg_write(pp, MVNETA_UNIT_INTR_CAUSE, 0);
+
+	if (phy_mode != PHY_INTERFACE_MODE_QSGMII &&
+	    phy_mode != PHY_INTERFACE_MODE_SGMII &&
+	    !phy_interface_mode_is_8023z(phy_mode) &&
+	    !phy_interface_mode_is_rgmii(phy_mode))
+		return -EINVAL;
+
+	return 0;
 }
 
 /* Device initialization routine */
@@ -5198,7 +5206,11 @@ static int mvneta_probe(struct platform_device *pdev)
 	if (err < 0)
 		goto err_netdev;
 
-	mvneta_port_power_up(pp, phy_mode);
+	err = mvneta_port_power_up(pp, pp->phy_interface);
+	if (err < 0) {
+		dev_err(&pdev->dev, "can't power up port\n");
+		return err;
+	}
 
 	/* Armada3700 network controller does not support per-cpu
 	 * operation, so only single NAPI should be initialized.
@@ -5352,7 +5364,11 @@ static int mvneta_resume(struct device *device)
 		}
 	}
 	mvneta_defaults_set(pp);
-	mvneta_port_power_up(pp, pp->phy_interface);
+	err = mvneta_port_power_up(pp, pp->phy_interface);
+	if (err < 0) {
+		dev_err(device, "can't power up port\n");
+		return err;
+	}
 
 	netif_device_attach(dev);
 
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes
  2020-06-24  7:00 [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Sascha Hauer
  2020-06-24  7:00 ` [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation Sascha Hauer
@ 2020-06-24  9:53 ` Russell King - ARM Linux admin
  2020-06-24 21:48 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-24  9:53 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: Thomas Petazzoni, netdev, linux-kernel, linux-arm-kernel, kernel

On Wed, Jun 24, 2020 at 09:00:44AM +0200, Sascha Hauer wrote:
> In mvneta_config_interface() the RGMII modes are catched by the default
> case which is an error return. The RGMII modes are valid modes for the
> driver, so instead of returning an error add a break statement to return
> successfully.
> 
> This avoids this warning for non comphy SoCs which use RGMII, like
> SolidRun Clearfog:
> 
> WARNING: CPU: 0 PID: 268 at drivers/net/ethernet/marvell/mvneta.c:3512 mvneta_start_dev+0x220/0x23c
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Fixes: b4748553f53f ("net: ethernet: mvneta: Fix Serdes configuration for SoCs without comphy")
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks.

> ---
>  drivers/net/ethernet/marvell/mvneta.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index af60001728481..c4552f868157c 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -3571,7 +3571,7 @@ static int mvneta_config_interface(struct mvneta_port *pp,
>  				    MVNETA_HSGMII_SERDES_PROTO);
>  			break;
>  		default:
> -			return -EINVAL;
> +			break;
>  		}
>  	}
>  
> -- 
> 2.27.0
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation
  2020-06-24  7:00 ` [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation Sascha Hauer
@ 2020-06-24  9:55   ` Russell King - ARM Linux admin
  2020-06-24 21:48   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-24  9:55 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: Thomas Petazzoni, netdev, linux-kernel, kernel, linux-arm-kernel

On Wed, Jun 24, 2020 at 09:00:45AM +0200, Sascha Hauer wrote:
> When writing the serdes configuration register was moved to
> mvneta_config_interface() the whole code block was removed from
> mvneta_port_power_up() in the assumption that its only purpose was to
> write the serdes configuration register. As mentioned by Russell King
> its purpose was also to check for valid interface modes early so that
> later in the driver we do not have to care for unexpected interface
> modes.
> Add back the test to let the driver bail out early on unhandled
> interface modes.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Fixes: b4748553f53f ("net: ethernet: mvneta: Fix Serdes configuration for SoCs without comphy")
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks.

> ---
>  drivers/net/ethernet/marvell/mvneta.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index c4552f868157c..c639e3a293024 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -5009,10 +5009,18 @@ static void mvneta_conf_mbus_windows(struct mvneta_port *pp,
>  }
>  
>  /* Power up the port */
> -static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
> +static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
>  {
>  	/* MAC Cause register should be cleared */
>  	mvreg_write(pp, MVNETA_UNIT_INTR_CAUSE, 0);
> +
> +	if (phy_mode != PHY_INTERFACE_MODE_QSGMII &&
> +	    phy_mode != PHY_INTERFACE_MODE_SGMII &&
> +	    !phy_interface_mode_is_8023z(phy_mode) &&
> +	    !phy_interface_mode_is_rgmii(phy_mode))
> +		return -EINVAL;
> +
> +	return 0;
>  }
>  
>  /* Device initialization routine */
> @@ -5198,7 +5206,11 @@ static int mvneta_probe(struct platform_device *pdev)
>  	if (err < 0)
>  		goto err_netdev;
>  
> -	mvneta_port_power_up(pp, phy_mode);
> +	err = mvneta_port_power_up(pp, pp->phy_interface);
> +	if (err < 0) {
> +		dev_err(&pdev->dev, "can't power up port\n");
> +		return err;
> +	}
>  
>  	/* Armada3700 network controller does not support per-cpu
>  	 * operation, so only single NAPI should be initialized.
> @@ -5352,7 +5364,11 @@ static int mvneta_resume(struct device *device)
>  		}
>  	}
>  	mvneta_defaults_set(pp);
> -	mvneta_port_power_up(pp, pp->phy_interface);
> +	err = mvneta_port_power_up(pp, pp->phy_interface);
> +	if (err < 0) {
> +		dev_err(device, "can't power up port\n");
> +		return err;
> +	}
>  
>  	netif_device_attach(dev);
>  
> -- 
> 2.27.0

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes
  2020-06-24  7:00 [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Sascha Hauer
  2020-06-24  7:00 ` [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation Sascha Hauer
  2020-06-24  9:53 ` [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Russell King - ARM Linux admin
@ 2020-06-24 21:48 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-06-24 21:48 UTC (permalink / raw)
  To: s.hauer
  Cc: kernel, netdev, linux, linux-kernel, thomas.petazzoni, linux-arm-kernel

From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 24 Jun 2020 09:00:44 +0200

> In mvneta_config_interface() the RGMII modes are catched by the default
> case which is an error return. The RGMII modes are valid modes for the
> driver, so instead of returning an error add a break statement to return
> successfully.
> 
> This avoids this warning for non comphy SoCs which use RGMII, like
> SolidRun Clearfog:
> 
> WARNING: CPU: 0 PID: 268 at drivers/net/ethernet/marvell/mvneta.c:3512 mvneta_start_dev+0x220/0x23c
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Applied.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation
  2020-06-24  7:00 ` [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation Sascha Hauer
  2020-06-24  9:55   ` Russell King - ARM Linux admin
@ 2020-06-24 21:48   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2020-06-24 21:48 UTC (permalink / raw)
  To: s.hauer
  Cc: kernel, netdev, linux, linux-kernel, thomas.petazzoni, linux-arm-kernel

From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 24 Jun 2020 09:00:45 +0200

> When writing the serdes configuration register was moved to
> mvneta_config_interface() the whole code block was removed from
> mvneta_port_power_up() in the assumption that its only purpose was to
> write the serdes configuration register. As mentioned by Russell King
> its purpose was also to check for valid interface modes early so that
> later in the driver we do not have to care for unexpected interface
> modes.
> Add back the test to let the driver bail out early on unhandled
> interface modes.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Applied.

Please submit a proper patch series next time, with a header [PATCH 0/N]
posting.  Thank you.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-06-24 21:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24  7:00 [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Sascha Hauer
2020-06-24  7:00 ` [PATCH 2/2] net: ethernet: mvneta: Add back interface mode validation Sascha Hauer
2020-06-24  9:55   ` Russell King - ARM Linux admin
2020-06-24 21:48   ` David Miller
2020-06-24  9:53 ` [PATCH 1/2] net: ethernet: mvneta: Do not error out in non serdes modes Russell King - ARM Linux admin
2020-06-24 21:48 ` David Miller

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