All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks
@ 2020-10-28  5:22 Greg Ungerer
  2020-10-28  5:28 ` [EXT] " Andy Duan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Greg Ungerer @ 2020-10-28  5:22 UTC (permalink / raw)
  To: netdev; +Cc: andrew, fugang.duan, cphealy, dkarr, clemens.gruber, Greg Ungerer

Some (apparently older) versions of the FEC hardware block do not like
the MMFR register being cleared to avoid generation of MII events at
initialization time. The action of clearing this register results in no
future MII events being generated at all on the problem block. This means
the probing of the MDIO bus will find no PHYs.

Create a quirk that can be checked at the FECs MII init time so that
the right thing is done. The quirk is set as appropriate for the FEC
hardware blocks that are known to need this.

Fixes: f166f890c8f0 ("net: ethernet: fec: Replace interrupt driven MDIO with polled IO")
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
---
 drivers/net/ethernet/freescale/fec.h      |  6 +++++
 drivers/net/ethernet/freescale/fec_main.c | 29 +++++++++++++----------
 2 files changed, 22 insertions(+), 13 deletions(-)

v2: use quirk for imx28 as well

Resending for consideration based on Andy's last comment that this fix
is enough on its own for all hardware types.

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 832a2175636d..c527f4ee1d3a 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -456,6 +456,12 @@ struct bufdesc_ex {
  */
 #define FEC_QUIRK_HAS_FRREG		(1 << 16)
 
+/* Some FEC hardware blocks need the MMFR cleared at setup time to avoid
+ * the generation of an MII event. This must be avoided in the older
+ * FEC blocks where it will stop MII events being generated.
+ */
+#define FEC_QUIRK_CLEAR_SETUP_MII	(1 << 17)
+
 struct bufdesc_prop {
 	int qid;
 	/* Address of Rx and Tx buffers */
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index fb37816a74db..65784d3e54a5 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -100,14 +100,14 @@ static const struct fec_devinfo fec_imx27_info = {
 static const struct fec_devinfo fec_imx28_info = {
 	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
 		  FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC |
-		  FEC_QUIRK_HAS_FRREG,
+		  FEC_QUIRK_HAS_FRREG | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static const struct fec_devinfo fec_imx6q_info = {
 	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
 		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
 		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358 |
-		  FEC_QUIRK_HAS_RACC,
+		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static const struct fec_devinfo fec_mvf600_info = {
@@ -119,7 +119,8 @@ static const struct fec_devinfo fec_imx6x_info = {
 		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
 		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
 		  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
-		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE,
+		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
+		  FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static const struct fec_devinfo fec_imx6ul_info = {
@@ -127,7 +128,7 @@ static const struct fec_devinfo fec_imx6ul_info = {
 		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
 		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR007885 |
 		  FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_HAS_RACC |
-		  FEC_QUIRK_HAS_COALESCE,
+		  FEC_QUIRK_HAS_COALESCE | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static struct platform_device_id fec_devtype[] = {
@@ -2114,15 +2115,17 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	if (suppress_preamble)
 		fep->phy_speed |= BIT(7);
 
-	/* Clear MMFR to avoid to generate MII event by writing MSCR.
-	 * MII event generation condition:
-	 * - writing MSCR:
-	 *	- mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
-	 *	  mscr_reg_data_in[7:0] != 0
-	 * - writing MMFR:
-	 *	- mscr[7:0]_not_zero
-	 */
-	writel(0, fep->hwp + FEC_MII_DATA);
+	if (fep->quirks & FEC_QUIRK_CLEAR_SETUP_MII) {
+		/* Clear MMFR to avoid to generate MII event by writing MSCR.
+		 * MII event generation condition:
+		 * - writing MSCR:
+		 *	- mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
+		 *	  mscr_reg_data_in[7:0] != 0
+		 * - writing MMFR:
+		 *	- mscr[7:0]_not_zero
+		 */
+		writel(0, fep->hwp + FEC_MII_DATA);
+	}
 
 	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
 
-- 
2.25.1


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

* RE: [EXT] [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks
  2020-10-28  5:22 [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks Greg Ungerer
@ 2020-10-28  5:28 ` Andy Duan
  2020-10-30  0:02 ` Andrew Lunn
  2020-10-30 10:53 ` Clemens Gruber
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Duan @ 2020-10-28  5:28 UTC (permalink / raw)
  To: Greg Ungerer, netdev; +Cc: andrew, cphealy, dkarr, clemens.gruber

From: Greg Ungerer <gerg@linux-m68k.org> Sent: Wednesday, October 28, 2020 1:23 PM
> Some (apparently older) versions of the FEC hardware block do not like the
> MMFR register being cleared to avoid generation of MII events at initialization
> time. The action of clearing this register results in no future MII events being
> generated at all on the problem block. This means the probing of the MDIO bus
> will find no PHYs.
> 
> Create a quirk that can be checked at the FECs MII init time so that the right
> thing is done. The quirk is set as appropriate for the FEC hardware blocks that
> are known to need this.
> 
> Fixes: f166f890c8f0 ("net: ethernet: fec: Replace interrupt driven MDIO with
> polled IO")
> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
Thanks!

Acked-by: Fugang Duan <fugand.duan@nxp.com>
> ---
>  drivers/net/ethernet/freescale/fec.h      |  6 +++++
>  drivers/net/ethernet/freescale/fec_main.c | 29 +++++++++++++----------
>  2 files changed, 22 insertions(+), 13 deletions(-)
> 
> v2: use quirk for imx28 as well
> 
> Resending for consideration based on Andy's last comment that this fix is enough
> on its own for all hardware types.
> 
> diff --git a/drivers/net/ethernet/freescale/fec.h
> b/drivers/net/ethernet/freescale/fec.h
> index 832a2175636d..c527f4ee1d3a 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -456,6 +456,12 @@ struct bufdesc_ex {
>   */
>  #define FEC_QUIRK_HAS_FRREG            (1 << 16)
> 
> +/* Some FEC hardware blocks need the MMFR cleared at setup time to
> +avoid
> + * the generation of an MII event. This must be avoided in the older
> + * FEC blocks where it will stop MII events being generated.
> + */
> +#define FEC_QUIRK_CLEAR_SETUP_MII      (1 << 17)
> +
>  struct bufdesc_prop {
>         int qid;
>         /* Address of Rx and Tx buffers */ diff --git
> a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index fb37816a74db..65784d3e54a5 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -100,14 +100,14 @@ static const struct fec_devinfo fec_imx27_info =
> {  static const struct fec_devinfo fec_imx28_info = {
>         .quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
>                   FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC |
> -                 FEC_QUIRK_HAS_FRREG,
> +                 FEC_QUIRK_HAS_FRREG |
> FEC_QUIRK_CLEAR_SETUP_MII,
>  };
> 
>  static const struct fec_devinfo fec_imx6q_info = {
>         .quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
>                   FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM
> |
>                   FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358 |
> -                 FEC_QUIRK_HAS_RACC,
> +                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_CLEAR_SETUP_MII,
>  };
> 
>  static const struct fec_devinfo fec_mvf600_info = { @@ -119,7 +119,8 @@
> static const struct fec_devinfo fec_imx6x_info = {
>                   FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM
> |
>                   FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
>                   FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
> -                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE,
> +                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
> +                 FEC_QUIRK_CLEAR_SETUP_MII,
>  };
> 
>  static const struct fec_devinfo fec_imx6ul_info = { @@ -127,7 +128,7 @@
> static const struct fec_devinfo fec_imx6ul_info = {
>                   FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM
> |
>                   FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR007885 |
>                   FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_HAS_RACC |
> -                 FEC_QUIRK_HAS_COALESCE,
> +                 FEC_QUIRK_HAS_COALESCE |
> FEC_QUIRK_CLEAR_SETUP_MII,
>  };
> 
>  static struct platform_device_id fec_devtype[] = { @@ -2114,15 +2115,17 @@
> static int fec_enet_mii_init(struct platform_device *pdev)
>         if (suppress_preamble)
>                 fep->phy_speed |= BIT(7);
> 
> -       /* Clear MMFR to avoid to generate MII event by writing MSCR.
> -        * MII event generation condition:
> -        * - writing MSCR:
> -        *      - mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
> -        *        mscr_reg_data_in[7:0] != 0
> -        * - writing MMFR:
> -        *      - mscr[7:0]_not_zero
> -        */
> -       writel(0, fep->hwp + FEC_MII_DATA);
> +       if (fep->quirks & FEC_QUIRK_CLEAR_SETUP_MII) {
> +               /* Clear MMFR to avoid to generate MII event by writing
> MSCR.
> +                * MII event generation condition:
> +                * - writing MSCR:
> +                *      - mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
> +                *        mscr_reg_data_in[7:0] != 0
> +                * - writing MMFR:
> +                *      - mscr[7:0]_not_zero
> +                */
> +               writel(0, fep->hwp + FEC_MII_DATA);
> +       }
> 
>         writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
> 
> --
> 2.25.1


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

* Re: [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks
  2020-10-28  5:22 [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks Greg Ungerer
  2020-10-28  5:28 ` [EXT] " Andy Duan
@ 2020-10-30  0:02 ` Andrew Lunn
  2020-10-30 15:26   ` Jakub Kicinski
  2020-10-30 10:53 ` Clemens Gruber
  2 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2020-10-30  0:02 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: netdev, fugang.duan, cphealy, dkarr, clemens.gruber

On Wed, Oct 28, 2020 at 03:22:32PM +1000, Greg Ungerer wrote:
> Some (apparently older) versions of the FEC hardware block do not like
> the MMFR register being cleared to avoid generation of MII events at
> initialization time. The action of clearing this register results in no
> future MII events being generated at all on the problem block. This means
> the probing of the MDIO bus will find no PHYs.
> 
> Create a quirk that can be checked at the FECs MII init time so that
> the right thing is done. The quirk is set as appropriate for the FEC
> hardware blocks that are known to need this.
> 
> Fixes: f166f890c8f0 ("net: ethernet: fec: Replace interrupt driven MDIO with polled IO")
> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>

Tested-by: Andrew Lunn <andrew@lunn.ch>

I tested this on Vybrid, which is not the best of platforms, since i
never had any of these problems on this platform.

Jakub, this is for net.

    Andrew

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

* Re: [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks
  2020-10-28  5:22 [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks Greg Ungerer
  2020-10-28  5:28 ` [EXT] " Andy Duan
  2020-10-30  0:02 ` Andrew Lunn
@ 2020-10-30 10:53 ` Clemens Gruber
  2 siblings, 0 replies; 5+ messages in thread
From: Clemens Gruber @ 2020-10-30 10:53 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: netdev, andrew, fugang.duan, cphealy, dkarr

On Wed, Oct 28, 2020 at 03:22:32PM +1000, Greg Ungerer wrote:
> Some (apparently older) versions of the FEC hardware block do not like
> the MMFR register being cleared to avoid generation of MII events at
> initialization time. The action of clearing this register results in no
> future MII events being generated at all on the problem block. This means
> the probing of the MDIO bus will find no PHYs.
> 
> Create a quirk that can be checked at the FECs MII init time so that
> the right thing is done. The quirk is set as appropriate for the FEC
> hardware blocks that are known to need this.
> 
> Fixes: f166f890c8f0 ("net: ethernet: fec: Replace interrupt driven MDIO with polled IO")
> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
> ---
>  drivers/net/ethernet/freescale/fec.h      |  6 +++++
>  drivers/net/ethernet/freescale/fec_main.c | 29 +++++++++++++----------
>  2 files changed, 22 insertions(+), 13 deletions(-)
> 
> v2: use quirk for imx28 as well
> 
> Resending for consideration based on Andy's last comment that this fix
> is enough on its own for all hardware types.
> 
> diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
> index 832a2175636d..c527f4ee1d3a 100644
> --- a/drivers/net/ethernet/freescale/fec.h
> +++ b/drivers/net/ethernet/freescale/fec.h
> @@ -456,6 +456,12 @@ struct bufdesc_ex {
>   */
>  #define FEC_QUIRK_HAS_FRREG		(1 << 16)
>  
> +/* Some FEC hardware blocks need the MMFR cleared at setup time to avoid
> + * the generation of an MII event. This must be avoided in the older
> + * FEC blocks where it will stop MII events being generated.
> + */
> +#define FEC_QUIRK_CLEAR_SETUP_MII	(1 << 17)
> +
>  struct bufdesc_prop {
>  	int qid;
>  	/* Address of Rx and Tx buffers */
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index fb37816a74db..65784d3e54a5 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -100,14 +100,14 @@ static const struct fec_devinfo fec_imx27_info = {
>  static const struct fec_devinfo fec_imx28_info = {
>  	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
>  		  FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC |
> -		  FEC_QUIRK_HAS_FRREG,
> +		  FEC_QUIRK_HAS_FRREG | FEC_QUIRK_CLEAR_SETUP_MII,
>  };
>  
>  static const struct fec_devinfo fec_imx6q_info = {
>  	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
>  		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
>  		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358 |
> -		  FEC_QUIRK_HAS_RACC,
> +		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_CLEAR_SETUP_MII,
>  };
>  
>  static const struct fec_devinfo fec_mvf600_info = {
> @@ -119,7 +119,8 @@ static const struct fec_devinfo fec_imx6x_info = {
>  		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
>  		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
>  		  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
> -		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE,
> +		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
> +		  FEC_QUIRK_CLEAR_SETUP_MII,
>  };
>  
>  static const struct fec_devinfo fec_imx6ul_info = {
> @@ -127,7 +128,7 @@ static const struct fec_devinfo fec_imx6ul_info = {
>  		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
>  		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR007885 |
>  		  FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_HAS_RACC |
> -		  FEC_QUIRK_HAS_COALESCE,
> +		  FEC_QUIRK_HAS_COALESCE | FEC_QUIRK_CLEAR_SETUP_MII,
>  };
>  
>  static struct platform_device_id fec_devtype[] = {
> @@ -2114,15 +2115,17 @@ static int fec_enet_mii_init(struct platform_device *pdev)
>  	if (suppress_preamble)
>  		fep->phy_speed |= BIT(7);
>  
> -	/* Clear MMFR to avoid to generate MII event by writing MSCR.
> -	 * MII event generation condition:
> -	 * - writing MSCR:
> -	 *	- mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
> -	 *	  mscr_reg_data_in[7:0] != 0
> -	 * - writing MMFR:
> -	 *	- mscr[7:0]_not_zero
> -	 */
> -	writel(0, fep->hwp + FEC_MII_DATA);
> +	if (fep->quirks & FEC_QUIRK_CLEAR_SETUP_MII) {
> +		/* Clear MMFR to avoid to generate MII event by writing MSCR.
> +		 * MII event generation condition:
> +		 * - writing MSCR:
> +		 *	- mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
> +		 *	  mscr_reg_data_in[7:0] != 0
> +		 * - writing MMFR:
> +		 *	- mscr[7:0]_not_zero
> +		 */
> +		writel(0, fep->hwp + FEC_MII_DATA);
> +	}
>  
>  	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
>  
> -- 
> 2.25.1
> 

This fixes the problem on i.MX6Q!

Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com>

Best regards,
Clemens

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

* Re: [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks
  2020-10-30  0:02 ` Andrew Lunn
@ 2020-10-30 15:26   ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-10-30 15:26 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Greg Ungerer, netdev, fugang.duan, cphealy, dkarr, clemens.gruber

On Fri, 30 Oct 2020 01:02:47 +0100 Andrew Lunn wrote:
> On Wed, Oct 28, 2020 at 03:22:32PM +1000, Greg Ungerer wrote:
> > Some (apparently older) versions of the FEC hardware block do not like
> > the MMFR register being cleared to avoid generation of MII events at
> > initialization time. The action of clearing this register results in no
> > future MII events being generated at all on the problem block. This means
> > the probing of the MDIO bus will find no PHYs.
> > 
> > Create a quirk that can be checked at the FECs MII init time so that
> > the right thing is done. The quirk is set as appropriate for the FEC
> > hardware blocks that are known to need this.
> > 
> > Fixes: f166f890c8f0 ("net: ethernet: fec: Replace interrupt driven MDIO with polled IO")
> > Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>  
> 
> Tested-by: Andrew Lunn <andrew@lunn.ch>
> 
> I tested this on Vybrid, which is not the best of platforms, since i
> never had any of these problems on this platform.
> 
> Jakub, this is for net.

Applied, thanks everyone!

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

end of thread, other threads:[~2020-10-30 15:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28  5:22 [PATCH v2] net: fec: fix MDIO probing for some FEC hardware blocks Greg Ungerer
2020-10-28  5:28 ` [EXT] " Andy Duan
2020-10-30  0:02 ` Andrew Lunn
2020-10-30 15:26   ` Jakub Kicinski
2020-10-30 10:53 ` Clemens Gruber

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.