* [PATCH (net-next.git) 0/2] STMMAC: MDIO settings
@ 2016-03-16 9:52 Giuseppe Cavallaro
2016-03-16 9:52 ` [PATCH (net-next.git) 1/2] Revert "stmmac: Fix 'eth0: No PHY found' regression" Giuseppe Cavallaro
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Giuseppe Cavallaro @ 2016-03-16 9:52 UTC (permalink / raw)
To: netdev
Cc: gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, davem,
preid, Giuseppe Cavallaro
These two patches are to fix the recent regressions raised
when test the stmmac on some platforms due to broken MDIO/PHY
management.
NOTE:
these are the same reviewed patches sent for net.git (version 4).
The patch #2 has been modified to solve a build problem on net-next;
inside the stmmac_init_phy where there is:
869 if (priv->plat->is_fixed_link)
870 phydev->irq = PHY_IGNORE_INTERRUPT;
Note: still on-going for net-next a debug session to solve a recent
regression when use normal descriptors.
This will be sent in a new patch set.
Giuseppe Cavallaro (2):
Revert "stmmac: Fix 'eth0: No PHY found' regression"
stmmac: fix MDIO settings
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +---
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 10 +--
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 91 ++++++++++++++------
include/linux/stmmac.h | 1 -
4 files changed, 72 insertions(+), 46 deletions(-)
--
1.7.4.4
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH (net-next.git) 1/2] Revert "stmmac: Fix 'eth0: No PHY found' regression" 2016-03-16 9:52 [PATCH (net-next.git) 0/2] STMMAC: MDIO settings Giuseppe Cavallaro @ 2016-03-16 9:52 ` Giuseppe Cavallaro 2016-03-16 9:52 ` [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings Giuseppe Cavallaro ` (2 subsequent siblings) 3 siblings, 0 replies; 11+ messages in thread From: Giuseppe Cavallaro @ 2016-03-16 9:52 UTC (permalink / raw) To: netdev Cc: gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, davem, preid, Giuseppe Cavallaro This reverts commit 88f8b1bb41c6208f81b6a480244533ded7b59493. due to problems on GeekBox and Banana Pi M1 board when connected to a real transceiver instead of a switch via fixed-link. Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Cc: Gabriel Fernandez <gabriel.fernandez@linaro.org> Cc: Andreas Färber <afaerber@suse.de> Cc: Frank Schäfer <fschaefer.oss@googlemail.com> Cc: Dinh Nguyen <dinh.linux@gmail.com> Cc: David S. Miller <davem@davemloft.net> --- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 11 ++++++++++- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 9 +-------- include/linux/stmmac.h | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index efb54f3..0faf163 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -199,12 +199,21 @@ int stmmac_mdio_register(struct net_device *ndev) struct stmmac_priv *priv = netdev_priv(ndev); struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; int addr, found; - struct device_node *mdio_node = priv->plat->mdio_node; + struct device_node *mdio_node = NULL; + struct device_node *child_node = NULL; if (!mdio_bus_data) return 0; if (IS_ENABLED(CONFIG_OF)) { + for_each_child_of_node(priv->device->of_node, child_node) { + if (of_device_is_compatible(child_node, + "snps,dwmac-mdio")) { + mdio_node = child_node; + break; + } + } + if (mdio_node) { netdev_dbg(ndev, "FOUND MDIO subnode\n"); } else { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index dcbd2a1..9cf181f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -146,7 +146,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) struct device_node *np = pdev->dev.of_node; struct plat_stmmacenet_data *plat; struct stmmac_dma_cfg *dma_cfg; - struct device_node *child_node = NULL; plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); if (!plat) @@ -177,19 +176,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->phy_node = of_node_get(np); } - for_each_child_of_node(np, child_node) - if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) { - plat->mdio_node = child_node; - break; - } - /* "snps,phy-addr" is not a standard property. Mark it as deprecated * and warn of its use. Remove this when phy node support is added. */ if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); - if ((plat->phy_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node) + if ((plat->phy_node && !of_phy_is_fixed_link(np)) || plat->phy_bus_name) plat->mdio_bus_data = NULL; else plat->mdio_bus_data = diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 4bcf5a6..6e53fa8 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -114,7 +114,6 @@ struct plat_stmmacenet_data { int interface; struct stmmac_mdio_bus_data *mdio_bus_data; struct device_node *phy_node; - struct device_node *mdio_node; struct stmmac_dma_cfg *dma_cfg; int clk_csr; int has_gmac; -- 1.7.4.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings 2016-03-16 9:52 [PATCH (net-next.git) 0/2] STMMAC: MDIO settings Giuseppe Cavallaro 2016-03-16 9:52 ` [PATCH (net-next.git) 1/2] Revert "stmmac: Fix 'eth0: No PHY found' regression" Giuseppe Cavallaro @ 2016-03-16 9:52 ` Giuseppe Cavallaro 2016-03-16 11:01 ` Gabriel Fernandez 2016-03-16 10:47 ` [PATCH (net-next.git) 0/2] STMMAC: " Andreas Färber 2016-03-16 22:09 ` David Miller 3 siblings, 1 reply; 11+ messages in thread From: Giuseppe Cavallaro @ 2016-03-16 9:52 UTC (permalink / raw) To: netdev Cc: gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, davem, preid, Giuseppe Cavallaro Initially the phy_bus_name was added to manipulate the driver name but it was recently just used to manage the fixed-link and then to take some decision at run-time. So the patch uses the is_pseudo_fixed_link and removes the phy_bus_name variable not necessary anymore. The driver can manage the mdio registration by using phy-handle, dwmac-mdio and own parameter e.g. snps,phy-addr. This patch takes care about all these possible configurations and fixes the mdio registration in case of there is a real transceiver or a switch (that needs to be managed by using fixed-link). Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Tested-by: Frank Schäfer <fschaefer.oss@googlemail.com> Cc: Gabriel Fernandez <gabriel.fernandez@linaro.org> Cc: Dinh Nguyen <dinh.linux@gmail.com> Cc: David S. Miller <davem@davemloft.net> Cc: Phil Reid <preid@electromag.com.au> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +--- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 19 +---- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 84 +++++++++++++++---- include/linux/stmmac.h | 2 +- 4 files changed, 73 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4c5ce98..943500b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) */ bool stmmac_eee_init(struct stmmac_priv *priv) { - char *phy_bus_name = priv->plat->phy_bus_name; unsigned long flags; bool ret = false; @@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) goto out; /* Never init EEE in case of a switch is attached */ - if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) + if (priv->phydev->is_pseudo_fixed_link) goto out; /* MAC core supports the EEE feature. */ @@ -827,12 +826,8 @@ static int stmmac_init_phy(struct net_device *dev) phydev = of_phy_connect(dev, priv->plat->phy_node, &stmmac_adjust_link, 0, interface); } else { - if (priv->plat->phy_bus_name) - snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x", - priv->plat->phy_bus_name, priv->plat->bus_id); - else - snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", - priv->plat->bus_id); + snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", + priv->plat->bus_id); snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id, priv->plat->phy_addr); @@ -871,9 +866,8 @@ static int stmmac_init_phy(struct net_device *dev) } /* If attached to a switch, there is no reason to poll phy handler */ - if (priv->plat->phy_bus_name) - if (!strcmp(priv->plat->phy_bus_name, "fixed")) - phydev->irq = PHY_IGNORE_INTERRUPT; + if (priv->phydev->is_pseudo_fixed_link) + phydev->irq = PHY_IGNORE_INTERRUPT; pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" " Link = %d\n", dev->name, phydev->phy_id, phydev->link); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 0faf163..3f5512f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -198,29 +198,12 @@ int stmmac_mdio_register(struct net_device *ndev) struct mii_bus *new_bus; struct stmmac_priv *priv = netdev_priv(ndev); struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; + struct device_node *mdio_node = priv->plat->mdio_node; int addr, found; - struct device_node *mdio_node = NULL; - struct device_node *child_node = NULL; if (!mdio_bus_data) return 0; - if (IS_ENABLED(CONFIG_OF)) { - for_each_child_of_node(priv->device->of_node, child_node) { - if (of_device_is_compatible(child_node, - "snps,dwmac-mdio")) { - mdio_node = child_node; - break; - } - } - - if (mdio_node) { - netdev_dbg(ndev, "FOUND MDIO subnode\n"); - } else { - netdev_warn(ndev, "No MDIO subnode found\n"); - } - } - new_bus = mdiobus_alloc(); if (new_bus == NULL) return -ENOMEM; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 9cf181f..cf37ea5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -132,6 +132,69 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev) } /** + * stmmac_dt_phy - parse device-tree driver parameters to allocate PHY resources + * @plat: driver data platform structure + * @np: device tree node + * @dev: device pointer + * Description: + * The mdio bus will be allocated in case of a phy transceiver is on board; + * it will be NULL if the fixed-link is configured. + * If there is the "snps,dwmac-mdio" sub-node the mdio will be allocated + * in any case (for DSA, mdio must be registered even if fixed-link). + * The table below sums the supported configurations: + * ------------------------------- + * snps,phy-addr | Y + * ------------------------------- + * phy-handle | Y + * ------------------------------- + * fixed-link | N + * ------------------------------- + * snps,dwmac-mdio | + * even if | Y + * fixed-link | + * ------------------------------- + * + * It returns 0 in case of success otherwise -ENODEV. + */ +static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, + struct device_node *np, struct device *dev) +{ + bool mdio = true; + + /* If phy-handle property is passed from DT, use it as the PHY */ + plat->phy_node = of_parse_phandle(np, "phy-handle", 0); + if (plat->phy_node) + dev_dbg(dev, "Found phy-handle subnode\n"); + + /* If phy-handle is not specified, check if we have a fixed-phy */ + if (!plat->phy_node && of_phy_is_fixed_link(np)) { + if ((of_phy_register_fixed_link(np) < 0)) + return -ENODEV; + + dev_dbg(dev, "Found fixed-link subnode\n"); + plat->phy_node = of_node_get(np); + mdio = false; + } + + /* If snps,dwmac-mdio is passed from DT, always register the MDIO */ + for_each_child_of_node(np, plat->mdio_node) { + if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio")) + break; + } + + if (plat->mdio_node) { + dev_dbg(dev, "Found MDIO subnode\n"); + mdio = true; + } + + if (mdio) + plat->mdio_bus_data = + devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), + GFP_KERNEL); + return 0; +} + +/** * stmmac_probe_config_dt - parse device-tree driver parameters * @pdev: platform_device structure * @plat: driver data platform structure @@ -165,30 +228,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) /* Default to phy auto-detection */ plat->phy_addr = -1; - /* If we find a phy-handle property, use it as the PHY */ - plat->phy_node = of_parse_phandle(np, "phy-handle", 0); - - /* If phy-handle is not specified, check if we have a fixed-phy */ - if (!plat->phy_node && of_phy_is_fixed_link(np)) { - if ((of_phy_register_fixed_link(np) < 0)) - return ERR_PTR(-ENODEV); - - plat->phy_node = of_node_get(np); - } - /* "snps,phy-addr" is not a standard property. Mark it as deprecated * and warn of its use. Remove this when phy node support is added. */ if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); - if ((plat->phy_node && !of_phy_is_fixed_link(np)) || plat->phy_bus_name) - plat->mdio_bus_data = NULL; - else - plat->mdio_bus_data = - devm_kzalloc(&pdev->dev, - sizeof(struct stmmac_mdio_bus_data), - GFP_KERNEL); + /* To Configure PHY by using all device-tree supported properties */ + if (stmmac_dt_phy(plat, np, &pdev->dev)) + return ERR_PTR(-ENODEV); of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 6e53fa8..e6bc30a 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -108,12 +108,12 @@ struct stmmac_axi { }; struct plat_stmmacenet_data { - char *phy_bus_name; int bus_id; int phy_addr; int interface; struct stmmac_mdio_bus_data *mdio_bus_data; struct device_node *phy_node; + struct device_node *mdio_node; struct stmmac_dma_cfg *dma_cfg; int clk_csr; int has_gmac; -- 1.7.4.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings 2016-03-16 9:52 ` [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings Giuseppe Cavallaro @ 2016-03-16 11:01 ` Gabriel Fernandez 2016-03-16 11:03 ` Andreas Färber 0 siblings, 1 reply; 11+ messages in thread From: Gabriel Fernandez @ 2016-03-16 11:01 UTC (permalink / raw) To: Giuseppe Cavallaro Cc: netdev, Andreas Färber, fschaefer.oss, Dinh Nguyen, David S. Miller, Phil Reid Hi Pepe, i have a kernel crash [ 2.714097] Unable to handle kernel NULL pointer dereference at virtual address 000001d6 [ 2.722188] pgd = c0204000 [ 2.724886] [000001d6] *pgd=00000000 [ 2.728452] Internal error: Oops: 5 [#1] SMP ARM [ 2.733054] Modules linked in: [ 2.736095] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.5.0-rc7-01768-g3407893 #36 [ 2.743649] Hardware name: STiH415/416 SoC with Flattened Device Tree [ 2.750074] task: ee070000 ti: ee05e000 task.ti: ee05e000 [ 2.755467] PC is at stmmac_open+0xcc/0xc40 [ 2.759641] LR is at of_phy_connect+0x44/0x5c > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 4c5ce98..943500b 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) > */ > bool stmmac_eee_init(struct stmmac_priv *priv) > { > - char *phy_bus_name = priv->plat->phy_bus_name; > unsigned long flags; > bool ret = false; > > @@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) > goto out; > > /* Never init EEE in case of a switch is attached */ > - if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) > + if (priv->phydev->is_pseudo_fixed_link) priv->phydev is not yet affected replace by if (phydev->is_pseudo_fixed_link) instead ? Best Regard Gabriel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings 2016-03-16 11:01 ` Gabriel Fernandez @ 2016-03-16 11:03 ` Andreas Färber 2016-03-16 12:53 ` Giuseppe CAVALLARO 0 siblings, 1 reply; 11+ messages in thread From: Andreas Färber @ 2016-03-16 11:03 UTC (permalink / raw) To: Gabriel Fernandez, Giuseppe Cavallaro Cc: netdev, fschaefer.oss, Dinh Nguyen, David S. Miller, Phil Reid Am 16.03.2016 um 12:01 schrieb Gabriel Fernandez: > Hi Pepe, > > i have a kernel crash > > [ 2.714097] Unable to handle kernel NULL pointer dereference at > virtual address 000001d6 > [ 2.722188] pgd = c0204000 > [ 2.724886] [000001d6] *pgd=00000000 > [ 2.728452] Internal error: Oops: 5 [#1] SMP ARM > [ 2.733054] Modules linked in: > [ 2.736095] CPU: 1 PID: 1 Comm: swapper/0 Not tainted > 4.5.0-rc7-01768-g3407893 #36 > [ 2.743649] Hardware name: STiH415/416 SoC with Flattened Device Tree > [ 2.750074] task: ee070000 ti: ee05e000 task.ti: ee05e000 > [ 2.755467] PC is at stmmac_open+0xcc/0xc40 > [ 2.759641] LR is at of_phy_connect+0x44/0x5c > > >> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >> index 4c5ce98..943500b 100644 >> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >> @@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) >> */ >> bool stmmac_eee_init(struct stmmac_priv *priv) >> { >> - char *phy_bus_name = priv->plat->phy_bus_name; >> unsigned long flags; >> bool ret = false; >> >> @@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) >> goto out; >> >> /* Never init EEE in case of a switch is attached */ >> - if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) >> + if (priv->phydev->is_pseudo_fixed_link) > > priv->phydev is not yet affected > replace by if (phydev->is_pseudo_fixed_link) instead ? Indeed that's how I had it in my own patch before. Thanks for spotting. Regards, Andreas -- SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings 2016-03-16 11:03 ` Andreas Färber @ 2016-03-16 12:53 ` Giuseppe CAVALLARO 0 siblings, 0 replies; 11+ messages in thread From: Giuseppe CAVALLARO @ 2016-03-16 12:53 UTC (permalink / raw) To: Andreas Färber, Gabriel Fernandez Cc: netdev, fschaefer.oss, Dinh Nguyen, David S. Miller, Phil Reid Hello On 3/16/2016 12:03 PM, Andreas Färber wrote: > Am 16.03.2016 um 12:01 schrieb Gabriel Fernandez: >> Hi Pepe, >> >> i have a kernel crash >> >> [ 2.714097] Unable to handle kernel NULL pointer dereference at >> virtual address 000001d6 >> [ 2.722188] pgd = c0204000 >> [ 2.724886] [000001d6] *pgd=00000000 >> [ 2.728452] Internal error: Oops: 5 [#1] SMP ARM >> [ 2.733054] Modules linked in: >> [ 2.736095] CPU: 1 PID: 1 Comm: swapper/0 Not tainted >> 4.5.0-rc7-01768-g3407893 #36 >> [ 2.743649] Hardware name: STiH415/416 SoC with Flattened Device Tree >> [ 2.750074] task: ee070000 ti: ee05e000 task.ti: ee05e000 >> [ 2.755467] PC is at stmmac_open+0xcc/0xc40 >> [ 2.759641] LR is at of_phy_connect+0x44/0x5c >> >> >>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >>> index 4c5ce98..943500b 100644 >>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >>> @@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) >>> */ >>> bool stmmac_eee_init(struct stmmac_priv *priv) >>> { >>> - char *phy_bus_name = priv->plat->phy_bus_name; >>> unsigned long flags; >>> bool ret = false; >>> >>> @@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) >>> goto out; >>> >>> /* Never init EEE in case of a switch is attached */ >>> - if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) >>> + if (priv->phydev->is_pseudo_fixed_link) >> >> priv->phydev is not yet affected >> replace by if (phydev->is_pseudo_fixed_link) instead ? > > Indeed that's how I had it in my own patch before. Thanks for spotting. thanks for spotting and I have just sent the V2 of these patches and I have understood why I did not catch it on my test :-( my fault, sorry ! Cheers Peppe > > Regards, > Andreas > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 0/2] STMMAC: MDIO settings 2016-03-16 9:52 [PATCH (net-next.git) 0/2] STMMAC: MDIO settings Giuseppe Cavallaro 2016-03-16 9:52 ` [PATCH (net-next.git) 1/2] Revert "stmmac: Fix 'eth0: No PHY found' regression" Giuseppe Cavallaro 2016-03-16 9:52 ` [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings Giuseppe Cavallaro @ 2016-03-16 10:47 ` Andreas Färber 2016-03-16 22:09 ` David Miller 3 siblings, 0 replies; 11+ messages in thread From: Andreas Färber @ 2016-03-16 10:47 UTC (permalink / raw) To: Giuseppe Cavallaro Cc: netdev, gabriel.fernandez, fschaefer.oss, dinh.linux, davem, preid Am 16.03.2016 um 10:52 schrieb Giuseppe Cavallaro: > These two patches are to fix the recent regressions raised > when test the stmmac on some platforms due to broken MDIO/PHY > management. > > NOTE: > > these are the same reviewed patches sent for net.git (version 4). > The patch #2 has been modified to solve a build problem on net-next; > inside the stmmac_init_phy where there is: > > 869 if (priv->plat->is_fixed_link) > 870 phydev->irq = PHY_IGNORE_INTERRUPT; On next-20160316 plus the other previously tested normal desc fix with this series I now get: Starting wicked managed network interfaces... eth0: device MAC address e6:6f:12:1b:8f:24 Unable to handle kernel NULL pointer dereference at virtual address 00000322 pgd = ffffffc074e76000 [00000322] *pgd=00000000765d5003, *pud=00000000765d5003, *pmd=0000000000000000 Internal error: Oops: 96000006 [#1] PREEMPT SMP Modules linked in: CPU: 5 PID: 1600 Comm: wickedd Not tainted 4.5.0-next-20160316+ #40 Hardware name: GeekBox on Landingship (DT) task: ffffffc0787ce000 ti: ffffffc0765f4000 task.ti: ffffffc0765f4000 PC is at stmmac_open+0xcc/0xc20 LR is at stmmac_open+0x6a8/0xc20 pc : [<ffffff800856a58c>] lr : [<ffffff800856ab68>] pstate: a0000145 sp : ffffffc0765f7670 x29: ffffffc0765f7670 x28: 0000000000000000 x27: ffffff800889bb40 x26: ffffffc076610100 x25: ffffffc077593810 x24: ffffff8008878898 x23: 00000000fffffffe x22: 0000000000000007 x21: ffffffc0784e4000 x20: ffffffc077e15800 x19: ffffffc0784e4800 x18: 0000000000000002 x17: 0000000000000007 x16: 0000000000000001 x15: ffffffc0765f7703 x14: 0000000000000001 x13: 0000000000000001 x12: ffffffc0770d2000 x11: 0000000000000021 x10: 0000000000001140 x9 : ffffff8008c60014 x8 : ffffffc077e15bb0 x7 : ffffffc07ef8eb80 x6 : ffffffc077e15b98 x5 : 00000000fffee416 x4 : 00000000000000f9 x3 : 0000000000000000 x2 : 00000000000009ba x1 : ffffffc0765f4000 x0 : 0000000000000000 Process wickedd (pid: 1600, stack limit = 0xffffffc0765f4020) Stack: (0xffffffc0765f7670 to 0xffffffc0765f8000) 7660: ffffffc0765f7710 ffffff800869bb38 7680: ffffffc0784e4000 0000000000001003 ffffff8008878898 ffffffc0784e4048 76a0: 0000000000001002 ffffff8008878898 ffffffc077593810 ffffffc076610100 76c0: ffffff800889bb40 0000000000000000 ffffffc0765f76e0 ffffff8008693610 76e0: 302d63616d6d7473 ffffff800869ba00 ffffffc0784e4000 302d63616d6d7473 7700: ffffff800030303a ffffff80080dcb58 ffffffc0765f7750 ffffff800869bdfc 7720: ffffffc0784e4000 0000000000001003 0000000000000001 0000000000000000 7740: ffffffc0784e4000 ffffffc0784e4000 ffffffc0765f7790 ffffff800869bee8 7760: ffffffc0784e4000 0000000000000000 0000000000000000 0000000000001002 7780: ffffffc0765f7958 ffffff80080ef7fc ffffffc0765f77c0 ffffff80086abf48 77a0: 0000000000000000 0000000000000000 ffffffc0784e4000 ffffffc0765f79e0 77c0: ffffffc0765f78d0 ffffff80086aca00 0000000000000000 ffffffc0784e4000 77e0: ffffffc077593800 0000000000000000 0000000000000000 0000000000000000 7800: ffffffc0765f78d0 ffffffc077593810 ffffff800889bb40 0000000000000000 7820: ffffffc0787ce000 0000000000000000 0000000000000000 ffffffc0774b0000 7840: ffffffc0765f7880 ffffff800815b0f0 ffffff80087eb63c ffffffc07ef93180 7860: ffffffc07748bdc0 ffffffc07851bc00 ffffffc0765f78c0 ffffff80080b623c 7880: 0000000000000004 ffffffc07748c070 ffffffc0765f78d0 ffffff80086ac6e8 78a0: ffffffc0765f78d0 ffffff80086ac72c 0000000000000000 ffffffc0784e4000 78c0: ffffffc077593800 0000000000000000 ffffffc0765f7b20 ffffff80086ab5dc 78e0: 0000000000000000 ffffffc077593800 ffffffc076610100 0000000000000000 7900: 0000000000000000 0000000000000020 0000000000000000 0000000000000008 7920: ffffff80087fb000 ffffffc0765f4000 ffffffc076610100 ffffff800889ba98 7940: ffffffc077593820 ffffff8008b71100 ffffffc0765f4000 0000000000000000 7960: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7980: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 79a0: 0000000000000000 ffffff80080daf00 ffffffc0765f7ac0 ffffff80081a8d9c 79c0: ffffffbdc1ddaa00 ffffffc0765f4000 0000000000008145 ffffffc0776aac00 79e0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7a00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7a20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7a40: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7a60: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7a80: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7aa0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7ac0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7ae0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7b00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7b20: ffffffc0765f7b90 ffffff80086be524 ffffffc077593800 ffffffc076610100 7b40: ffffff80086ab4f8 ffffffc076610100 0000000000000000 ffffffc0765f7c2f 7b60: 00000000024000c0 ffffff80086878d4 ffffffc0765f7b90 ffffff80086bba04 7b80: ffffffc077c6af90 0000000000000008 ffffffc0765f7bc0 ffffff80086ab4e4 7ba0: ffffffc076610100 ffffffc077c17800 0000000000000020 ffffff80086bdcac 7bc0: ffffffc0765f7be0 ffffff80086bddc0 ffffffc077c6ac00 ffffffc077c17800 7be0: ffffffc0765f7c30 ffffff80086be290 ffffffc0765f7e68 0000000000000000 7c00: ffffffc076610100 ffffffc077c17800 0000000000000000 00000000ffffffa6 7c20: ffffffc076610100 7fffffffffffffff ffffffc0765f7ca0 ffffff800867d208 7c40: ffffffc0765f7e68 0000000000000000 0000000000000000 0000000000000000 7c60: ffffffc078106300 0000000000000000 0000000000000000 ffffffc0765f7d08 7c80: ffffffc077f4b700 0000000000000000 0000000000000640 0000000000000000 7ca0: ffffffc0765f7cb0 ffffff800867f364 ffffffc0765f7e30 ffffff8008680244 7cc0: ffffffc078106300 0000007fe0a23730 0000000000000000 0000007fb07b9898 7ce0: 0000000060000000 0000000000000015 000000000000011e 00000000000000d3 7d00: 0000000000000000 00000000000000d4 ffffff80087fb000 ffffff8008094964 7d20: 0000000000000000 0000000000000000 0000000000000010 0000000000000000 7d40: 000000009200004f 0000000000000055 0000000000000002 ffffffc0777ea630 7d60: ffffffc0776eb468 0000000000020000 ffffffc0765f7db0 0000000007fb09b3 7d80: ffffffc076f173f8 ffffffc076f17480 ffffffc0765f7dc0 ffffff80080947c0 7da0: ffffffc0765f7ed0 ffffffc0776eb400 000000002571bf40 0000000000000020 7dc0: 0000000025736bf0 0000000000000000 000000009200004f ffffff8008b146f8 7de0: 0000007fb09b3ec0 ffffffc0765f7ed0 0000000080000000 0000000000000024 7e00: ffffffc0765f7e10 ffffff800867cde0 ffffffc0765f7e30 ffffff8008680224 7e20: 0000000000000200 0000007fe0a23730 ffffffc0765f7ec0 ffffff8008680298 7e40: 0000000000000200 00000000256d2920 ffffffffffffffff ffffffc0765f7ed0 7e60: fffffff700000000 ffffffc0765f7d30 000000000000000c 0000000000000001 7e80: 0000000000000000 0000000000000000 ffffffc0765f7dc0 0000000000000000 7ea0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 7ec0: 0000000000000000 ffffff8008084d8c 0000000000000006 0000007fe0a23730 7ee0: 0000000000000000 0000000000000001 0000007fb09e3c68 0000000000000000 7f00: 000000002571bf60 0000000200000000 00000000000000d3 0000000000000004 7f20: 0000000000000076 0000000000000030 6e65706f2e67726f 74654e2e65737573 7f40: 746e492e6b726f77 00315fd0a7af2c02 0000000000000000 0000007fb07b98b0 7f60: 0000000000000001 0000007fb0676000 00000000256d2920 0000000025720910 7f80: 00000000256a5980 0000007fe0a23730 000000002571daa0 00000000256a2810 7fa0: 00000000256a1f50 0000007fe0a239e0 0000000000000003 0000007fe0a23670 7fc0: 0000007fb06593d4 0000007fe0a23660 0000007fb07b9898 0000000060000000 7fe0: 0000000000000006 00000000000000d3 00000000004c944d 0000000000000000 Call trace: Exception stack(0xffffffc0765f74b0 to 0xffffffc0765f75d0) 74a0: ffffffc0784e4800 ffffffc077e15800 74c0: ffffffc0765f7670 ffffff800856a58c 0000000000000000 0000000000000000 74e0: ffffffc077593810 ffffffc076610100 ffffff800889bb40 0000000000000000 7500: ffffffc0765f7550 ffffff800810b95c ffffffc077e15bb0 00000000fffee50f 7520: ffffff8008ae2b80 ffffffc07ef2ab80 ffffffc0765f7540 ffffff80087ef268 7540: ffffffc0765f7550 ffffff800810b8fc 0000000000000000 ffffffc0765f4000 7560: 00000000000009ba 0000000000000000 00000000000000f9 00000000fffee416 7580: ffffffc077e15b98 ffffffc07ef8eb80 ffffffc077e15bb0 ffffff8008c60014 75a0: 0000000000001140 0000000000000021 ffffffc0770d2000 0000000000000001 75c0: 0000000000000001 ffffffc0765f7703 [<ffffff800856a58c>] stmmac_open+0xcc/0xc20 [<ffffff800869bb38>] __dev_open+0xb8/0x128 [<ffffff800869bdfc>] __dev_change_flags+0x8c/0x158 [<ffffff800869bee8>] dev_change_flags+0x20/0x60 [<ffffff80086abf48>] do_setlink+0x288/0x8a0 [<ffffff80086aca00>] rtnl_newlink+0x398/0x6a8 [<ffffff80086ab5dc>] rtnetlink_rcv_msg+0xe4/0x220 [<ffffff80086be524>] netlink_rcv_skb+0xc4/0xf8 [<ffffff80086ab4e4>] rtnetlink_rcv+0x2c/0x40 [<ffffff80086bddc0>] netlink_unicast+0x160/0x238 [<ffffff80086be290>] netlink_sendmsg+0x2f0/0x358 [<ffffff800867d208>] sock_sendmsg+0x18/0x30 [<ffffff800867f364>] ___sys_sendmsg+0x26c/0x280 [<ffffff8008680244>] __sys_sendmsg+0x44/0x88 [<ffffff8008680298>] SyS_sendmsg+0x10/0x20 [<ffffff8008084d8c>] __sys_trace_return+0x0/0x4 Code: f9434260 f9400c00 b4004840 f9410260 (394c8800) ---[ end trace 20896b27fa45a738 ]--- [ OK ] Started wicked managed network interfaces. ping did not work (no eth0 I assume) and doing `ip a` got the system stuck with Ctrl+C not working. Reproducible. Regards, Andreas > > Note: still on-going for net-next a debug session to solve a recent > regression when use normal descriptors. > This will be sent in a new patch set. > > Giuseppe Cavallaro (2): > Revert "stmmac: Fix 'eth0: No PHY found' regression" > stmmac: fix MDIO settings > > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +--- > drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 10 +-- > .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 91 ++++++++++++++------ > include/linux/stmmac.h | 1 - > 4 files changed, 72 insertions(+), 46 deletions(-) > -- SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 0/2] STMMAC: MDIO settings 2016-03-16 9:52 [PATCH (net-next.git) 0/2] STMMAC: MDIO settings Giuseppe Cavallaro ` (2 preceding siblings ...) 2016-03-16 10:47 ` [PATCH (net-next.git) 0/2] STMMAC: " Andreas Färber @ 2016-03-16 22:09 ` David Miller 2016-03-17 13:10 ` Giuseppe CAVALLARO 3 siblings, 1 reply; 11+ messages in thread From: David Miller @ 2016-03-16 22:09 UTC (permalink / raw) To: peppe.cavallaro Cc: netdev, gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, preid Don't _ever_ send the same two sets of patches targetting net and net-next at the same time. Especially right now, as 'net' is basically frozen, and 'net-next' is closed for new features and is only for last minute bug fixes before I send a merge window pull request to Linus. I'm tossing both of these series, figure it how to do this properly. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 0/2] STMMAC: MDIO settings 2016-03-16 22:09 ` David Miller @ 2016-03-17 13:10 ` Giuseppe CAVALLARO 2016-03-18 1:12 ` David Miller 0 siblings, 1 reply; 11+ messages in thread From: Giuseppe CAVALLARO @ 2016-03-17 13:10 UTC (permalink / raw) To: David Miller Cc: netdev, gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, preid On 3/16/2016 11:09 PM, David Miller wrote: > > Don't _ever_ send the same two sets of patches targetting net and > net-next at the same time. cover-letter reports the difference between the two patches for net and next. > Especially right now, as 'net' is basically frozen, and 'net-next' is > closed for new features and is only for last minute bug fixes before I > send a merge window pull request to Linus. I do think that: [PATCH (net-next.git) 0/2] STMMAC: MDIO settings [PATCH (net-next.git)] stmmac: fix TX normal DESC are last minute bug fixes for net-next. Peppe > > I'm tossing both of these series, figure it how to do this properly. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH (net-next.git) 0/2] STMMAC: MDIO settings 2016-03-17 13:10 ` Giuseppe CAVALLARO @ 2016-03-18 1:12 ` David Miller 0 siblings, 0 replies; 11+ messages in thread From: David Miller @ 2016-03-18 1:12 UTC (permalink / raw) To: peppe.cavallaro Cc: netdev, gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, preid From: Giuseppe CAVALLARO <peppe.cavallaro@st.com> Date: Thu, 17 Mar 2016 14:10:17 +0100 > On 3/16/2016 11:09 PM, David Miller wrote: >> >> Don't _ever_ send the same two sets of patches targetting net and >> net-next at the same time. > > cover-letter reports the difference between the two patches for > net and next. Not necessary still. You send me the patch to the tree it should target, and then you tell me what the issues are to handle during merges. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCHv2 (net-next.git) 0/2] STMMAC: MDIO settings
@ 2016-03-16 12:56 Giuseppe Cavallaro
2016-03-16 12:56 ` [PATCH (net-next.git) 2/2] stmmac: fix " Giuseppe Cavallaro
0 siblings, 1 reply; 11+ messages in thread
From: Giuseppe Cavallaro @ 2016-03-16 12:56 UTC (permalink / raw)
To: netdev
Cc: gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, davem,
preid, tomeu, fabrice.gasnier, alexandre.torgue,
Giuseppe Cavallaro
These two patches are to fix the recent regressions raised
when test the stmmac on some platforms due to broken MDIO/PHY
management.
NOTE:
these are the same reviewed patches sent for net.git (version 4).
The patch #2 has been modified to solve a build problem on net-next;
inside the stmmac_init_phy where there is:
869 if (priv->plat->is_fixed_link)
870 phydev->irq = PHY_IGNORE_INTERRUPT;
Note: still on-going for net-next a debug session to solve a recent
regression when use normal descriptors.
This will be sent in a new patch set.
V2: fix runtime problem due to NULL pointer.
Giuseppe Cavallaro (2):
Revert "stmmac: Fix 'eth0: No PHY found' regression"
stmmac: fix MDIO settings
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +---
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 10 +--
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 91 ++++++++++++++------
include/linux/stmmac.h | 1 -
4 files changed, 72 insertions(+), 46 deletions(-)
--
1.7.4.4
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings 2016-03-16 12:56 [PATCHv2 " Giuseppe Cavallaro @ 2016-03-16 12:56 ` Giuseppe Cavallaro 0 siblings, 0 replies; 11+ messages in thread From: Giuseppe Cavallaro @ 2016-03-16 12:56 UTC (permalink / raw) To: netdev Cc: gabriel.fernandez, afaerber, fschaefer.oss, dinh.linux, davem, preid, tomeu, fabrice.gasnier, alexandre.torgue, Giuseppe Cavallaro Initially the phy_bus_name was added to manipulate the driver name but it was recently just used to manage the fixed-link and then to take some decision at run-time. So the patch uses the is_pseudo_fixed_link and removes the phy_bus_name variable not necessary anymore. The driver can manage the mdio registration by using phy-handle, dwmac-mdio and own parameter e.g. snps,phy-addr. This patch takes care about all these possible configurations and fixes the mdio registration in case of there is a real transceiver or a switch (that needs to be managed by using fixed-link). Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Tested-by: Frank Schäfer <fschaefer.oss@googlemail.com> Cc: Gabriel Fernandez <gabriel.fernandez@linaro.org> Cc: Dinh Nguyen <dinh.linux@gmail.com> Cc: David S. Miller <davem@davemloft.net> Cc: Phil Reid <preid@electromag.com.au> --- V2: fix NULL pointer drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +--- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 19 +---- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 84 +++++++++++++++---- include/linux/stmmac.h | 2 +- 4 files changed, 73 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4c5ce98..943500b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) */ bool stmmac_eee_init(struct stmmac_priv *priv) { - char *phy_bus_name = priv->plat->phy_bus_name; unsigned long flags; bool ret = false; @@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) goto out; /* Never init EEE in case of a switch is attached */ - if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) + if (priv->phydev->is_pseudo_fixed_link) goto out; /* MAC core supports the EEE feature. */ @@ -827,12 +826,8 @@ static int stmmac_init_phy(struct net_device *dev) phydev = of_phy_connect(dev, priv->plat->phy_node, &stmmac_adjust_link, 0, interface); } else { - if (priv->plat->phy_bus_name) - snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x", - priv->plat->phy_bus_name, priv->plat->bus_id); - else - snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", - priv->plat->bus_id); + snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", + priv->plat->bus_id); snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id, priv->plat->phy_addr); @@ -871,9 +866,8 @@ static int stmmac_init_phy(struct net_device *dev) } /* If attached to a switch, there is no reason to poll phy handler */ - if (priv->plat->phy_bus_name) - if (!strcmp(priv->plat->phy_bus_name, "fixed")) - phydev->irq = PHY_IGNORE_INTERRUPT; + if (phydev->is_pseudo_fixed_link) + phydev->irq = PHY_IGNORE_INTERRUPT; pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" " Link = %d\n", dev->name, phydev->phy_id, phydev->link); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 0faf163..3f5512f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -198,29 +198,12 @@ int stmmac_mdio_register(struct net_device *ndev) struct mii_bus *new_bus; struct stmmac_priv *priv = netdev_priv(ndev); struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; + struct device_node *mdio_node = priv->plat->mdio_node; int addr, found; - struct device_node *mdio_node = NULL; - struct device_node *child_node = NULL; if (!mdio_bus_data) return 0; - if (IS_ENABLED(CONFIG_OF)) { - for_each_child_of_node(priv->device->of_node, child_node) { - if (of_device_is_compatible(child_node, - "snps,dwmac-mdio")) { - mdio_node = child_node; - break; - } - } - - if (mdio_node) { - netdev_dbg(ndev, "FOUND MDIO subnode\n"); - } else { - netdev_warn(ndev, "No MDIO subnode found\n"); - } - } - new_bus = mdiobus_alloc(); if (new_bus == NULL) return -ENOMEM; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 9cf181f..cf37ea5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -132,6 +132,69 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev) } /** + * stmmac_dt_phy - parse device-tree driver parameters to allocate PHY resources + * @plat: driver data platform structure + * @np: device tree node + * @dev: device pointer + * Description: + * The mdio bus will be allocated in case of a phy transceiver is on board; + * it will be NULL if the fixed-link is configured. + * If there is the "snps,dwmac-mdio" sub-node the mdio will be allocated + * in any case (for DSA, mdio must be registered even if fixed-link). + * The table below sums the supported configurations: + * ------------------------------- + * snps,phy-addr | Y + * ------------------------------- + * phy-handle | Y + * ------------------------------- + * fixed-link | N + * ------------------------------- + * snps,dwmac-mdio | + * even if | Y + * fixed-link | + * ------------------------------- + * + * It returns 0 in case of success otherwise -ENODEV. + */ +static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, + struct device_node *np, struct device *dev) +{ + bool mdio = true; + + /* If phy-handle property is passed from DT, use it as the PHY */ + plat->phy_node = of_parse_phandle(np, "phy-handle", 0); + if (plat->phy_node) + dev_dbg(dev, "Found phy-handle subnode\n"); + + /* If phy-handle is not specified, check if we have a fixed-phy */ + if (!plat->phy_node && of_phy_is_fixed_link(np)) { + if ((of_phy_register_fixed_link(np) < 0)) + return -ENODEV; + + dev_dbg(dev, "Found fixed-link subnode\n"); + plat->phy_node = of_node_get(np); + mdio = false; + } + + /* If snps,dwmac-mdio is passed from DT, always register the MDIO */ + for_each_child_of_node(np, plat->mdio_node) { + if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio")) + break; + } + + if (plat->mdio_node) { + dev_dbg(dev, "Found MDIO subnode\n"); + mdio = true; + } + + if (mdio) + plat->mdio_bus_data = + devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data), + GFP_KERNEL); + return 0; +} + +/** * stmmac_probe_config_dt - parse device-tree driver parameters * @pdev: platform_device structure * @plat: driver data platform structure @@ -165,30 +228,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) /* Default to phy auto-detection */ plat->phy_addr = -1; - /* If we find a phy-handle property, use it as the PHY */ - plat->phy_node = of_parse_phandle(np, "phy-handle", 0); - - /* If phy-handle is not specified, check if we have a fixed-phy */ - if (!plat->phy_node && of_phy_is_fixed_link(np)) { - if ((of_phy_register_fixed_link(np) < 0)) - return ERR_PTR(-ENODEV); - - plat->phy_node = of_node_get(np); - } - /* "snps,phy-addr" is not a standard property. Mark it as deprecated * and warn of its use. Remove this when phy node support is added. */ if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); - if ((plat->phy_node && !of_phy_is_fixed_link(np)) || plat->phy_bus_name) - plat->mdio_bus_data = NULL; - else - plat->mdio_bus_data = - devm_kzalloc(&pdev->dev, - sizeof(struct stmmac_mdio_bus_data), - GFP_KERNEL); + /* To Configure PHY by using all device-tree supported properties */ + if (stmmac_dt_phy(plat, np, &pdev->dev)) + return ERR_PTR(-ENODEV); of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 6e53fa8..e6bc30a 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -108,12 +108,12 @@ struct stmmac_axi { }; struct plat_stmmacenet_data { - char *phy_bus_name; int bus_id; int phy_addr; int interface; struct stmmac_mdio_bus_data *mdio_bus_data; struct device_node *phy_node; + struct device_node *mdio_node; struct stmmac_dma_cfg *dma_cfg; int clk_csr; int has_gmac; -- 1.7.4.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-03-18 1:12 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-16 9:52 [PATCH (net-next.git) 0/2] STMMAC: MDIO settings Giuseppe Cavallaro 2016-03-16 9:52 ` [PATCH (net-next.git) 1/2] Revert "stmmac: Fix 'eth0: No PHY found' regression" Giuseppe Cavallaro 2016-03-16 9:52 ` [PATCH (net-next.git) 2/2] stmmac: fix MDIO settings Giuseppe Cavallaro 2016-03-16 11:01 ` Gabriel Fernandez 2016-03-16 11:03 ` Andreas Färber 2016-03-16 12:53 ` Giuseppe CAVALLARO 2016-03-16 10:47 ` [PATCH (net-next.git) 0/2] STMMAC: " Andreas Färber 2016-03-16 22:09 ` David Miller 2016-03-17 13:10 ` Giuseppe CAVALLARO 2016-03-18 1:12 ` David Miller -- strict thread matches above, loose matches on Subject: below -- 2016-03-16 12:56 [PATCHv2 " Giuseppe Cavallaro 2016-03-16 12:56 ` [PATCH (net-next.git) 2/2] stmmac: fix " Giuseppe Cavallaro
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).