2023-06-06 14:35:36

by Maxime Chevallier

[permalink] [raw]
Subject: [PATCH net-next v2 0/3] Followup fixes for the dwmac and altera lynx conversion

Following the TSE PCS removal and port of altera_tse and dwmac_socfpga,
this series fixes some issues that slipped through the cracks.

Patch 1 fixes an unitialized struct in altera_tse

Patch 2 uses the correct Kconfig option for altera_tse

Patch 3 makes the Lynx PCS specific to dwmac_socfpga. This patch was
originally written by Russell, my modifications just moves the
#include<linux/pcs-lynx.h> around, to use it only in dwmac_socfpga.

Maxime Chevallier (3):
net: altera-tse: Initialize the regmap_config struct before using it
net: altera_tse: Use the correct Kconfig option for the PCS_LYNX
depenency
net: stmmac: make the pcs_lynx cleanup sequence specific to
dwmac_socfpga

drivers/net/ethernet/altera/Kconfig | 2 +-
drivers/net/ethernet/altera/altera_tse_main.c | 1 +
drivers/net/ethernet/stmicro/stmmac/common.h | 1 -
.../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 15 ++++++++++++++-
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 3 ---
5 files changed, 16 insertions(+), 6 deletions(-)

--
2.40.1



2023-06-06 14:37:47

by Maxime Chevallier

[permalink] [raw]
Subject: [PATCH net-next v2 1/3] net: altera-tse: Initialize the regmap_config struct before using it

The regmap_config needs to be zeroed before using it. This will cause
spurious errors at probe time as config->pad_bits is containing random
uninitialized data.

Fixes: db48abbaa18e ("net: ethernet: altera-tse: Convert to mdio-regmap and use PCS Lynx")
Signed-off-by: Maxime Chevallier <[email protected]>
---
V1->V2: No change

drivers/net/ethernet/altera/altera_tse_main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index d866c0f1b503..df509abcd378 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -1255,6 +1255,7 @@ static int altera_tse_probe(struct platform_device *pdev)
if (ret)
goto err_free_netdev;

+ memset(&pcs_regmap_cfg, 0, sizeof(pcs_regmap_cfg));
/* SGMII PCS address space. The location can vary depending on how the
* IP is integrated. We can have a resource dedicated to it at a specific
* address space, but if it's not the case, we fallback to the mdiophy0
--
2.40.1


2023-06-06 14:56:14

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH net-next v2 0/3] Followup fixes for the dwmac and altera lynx conversion

On Tue, Jun 06, 2023 at 04:21:41PM +0200, Maxime Chevallier wrote:
> Following the TSE PCS removal and port of altera_tse and dwmac_socfpga,
> this series fixes some issues that slipped through the cracks.
>
> Patch 1 fixes an unitialized struct in altera_tse
>
> Patch 2 uses the correct Kconfig option for altera_tse
>
> Patch 3 makes the Lynx PCS specific to dwmac_socfpga. This patch was
> originally written by Russell, my modifications just moves the
> #include<linux/pcs-lynx.h> around, to use it only in dwmac_socfpga.

Hi Maxime,

I'm sorry, but I think you need an extra patch added to this series.
Looking at include/linux/mdio/mdio-regmap.h, that defines:

struct mdio_regmap_config {
struct device *parent;
struct regmap *regmap;
char name[MII_BUS_ID_SIZE];
u8 valid_addr;
bool autoscan;
};

In dwmac-socfpga.c, you have:

struct mdio_regmap_config mrc;

mrc.regmap = pcs_regmap;
mrc.parent = &pdev->dev;
mrc.valid_addr = 0x0;

snprintf(mrc.name, MII_BUS_ID_SIZE, "%s-pcs-mii", ndev->name);

So that's a tick for parent, tick for regmap, tick for name, tick
for valid_addr, but... autoscan is left uninitialised.
devm_mdio_regmap_register() reads this, and uses it to decide
how to set mii->phy_mask, which will be randomly ~0 or ~BIT(0)
depending on the value of mrc.autoscan.

Other than that, the series looks good. Thanks.

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

2023-06-06 15:12:21

by Maxime Chevallier

[permalink] [raw]
Subject: Re: [PATCH net-next v2 0/3] Followup fixes for the dwmac and altera lynx conversion

Hello Russell,

On Tue, 6 Jun 2023 15:32:53 +0100
"Russell King (Oracle)" <[email protected]> wrote:

> On Tue, Jun 06, 2023 at 04:21:41PM +0200, Maxime Chevallier wrote:
> > Following the TSE PCS removal and port of altera_tse and dwmac_socfpga,
> > this series fixes some issues that slipped through the cracks.
> >
> > Patch 1 fixes an unitialized struct in altera_tse
> >
> > Patch 2 uses the correct Kconfig option for altera_tse
> >
> > Patch 3 makes the Lynx PCS specific to dwmac_socfpga. This patch was
> > originally written by Russell, my modifications just moves the
> > #include<linux/pcs-lynx.h> around, to use it only in dwmac_socfpga.
>
> Hi Maxime,
>
> I'm sorry, but I think you need an extra patch added to this series.

Gosh you're right... The same this also goes for altera_tse...

> Other than that, the series looks good. Thanks.

I'll followup shortly then. Nice catch !

Thanks,

Maxime