Re: [PATCHv3 (net.git) 2/2] stmmac: fix MDIO settings

2016-03-12 Thread Frank Schäfer
Hi Giuseppe,

Am 11.03.2016 um 14:33 schrieb 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
> inside the main (for example to skip EEE).
> So the patch uses the is_pseudo_fixed_link and removes
> 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 
> Reviewed-by: Andreas Färber 
> Tested-by: Frank Schäfer 
> Cc: Gabriel Fernandez 
> Cc: Dinh Nguyen 
> Cc: David S. Miller 
> Cc: Phil Reid 
> ---
>
> V2: use is_pseudo_fixed_link
> V3: parse device-tree driver parameters to allocate PHY resources considering
> DSA case (+ fixed-link).
>
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |   11 +--
>  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  |   19 +-
>  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   77 
> 
>  include/linux/stmmac.h |2 +-
>  4 files changed, 68 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index c21015b..389d7d0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -271,7 +271,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;
>  
> @@ -283,7 +282,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. */
> @@ -820,12 +819,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);
> 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)
>   r

Re: [PATCH (net.git) 0/2] stmmac: MDIO fixes

2016-03-09 Thread Frank Schäfer

Am 09.03.2016 um 10:00 schrieb Giuseppe Cavallaro:
> These two patches are to fix the recent regressions raised
> when test the stmmac on some platforms.
> Please I kindly ask you to give me the feedback if it actually
> covers all the cases and if the stmmac runs fine on the boxes.
> I have tested on my side the H410 B2120 with an embedded switch
> (so using the fixed-link).
>
> Giuseppe Cavallaro (2):
>   Revert "stmmac: Fix 'eth0: No PHY found' regression"
>   stmmac: fix MDIO settings
>
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |   11 ++---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  |   11 +-
>  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   22 +--
>  include/linux/stmmac.h |3 +-
>  4 files changed, 20 insertions(+), 27 deletions(-)
Works fine on the Banana Pi M1 board.
(Fixes "libphy: PHY stmmac-0: not found")

Regards,
Frank





[4.5-rc7+ regression, bisected] libphy: PHY stmmac-0:ffffffff not found

2016-03-08 Thread Frank Schäfer
commit 88f8b1bb41c6208f81b6a480244533ded7b59493
Author: Gabriel Fernandez 
Date:   Mon Feb 29 17:18:22 2016 +0100

stmmac: Fix 'eth0: No PHY found' regression
   
This patch manages the case when you have an Ethernet MAC with
a "fixed link", and not connected to a normal MDIO-managed PHY device.
   
The test of phy_bus_name was not helpful because it was never affected
and replaced by the mdio test node.
   
Signed-off-by: Gabriel Fernandez 
Acked-by: Giuseppe Cavallaro 
Signed-off-by: David S. Miller 


caused a regression on the Banana Pi M1 board:
...
[1.573419] sun7i-dwmac 1c5.ethernet: no reset control found
[1.583476]  Ring mode enabled
[1.590476]  No HW DMA feature register supported
[1.595153]  Normal descriptors
[1.606075]  TX Checksum insertion supported
...
[9.430047] libphy: PHY stmmac-0: not found
[9.441829] eth0: Could not attach to PHY
[9.452743] stmmac_open: Cannot attach to PHY (error: -19)

Reverting this commit makes it work again:

[1.574459] sun7i-dwmac 1c5.ethernet: no reset control found
[1.584501]  Ring mode enabled
[1.591491]  No HW DMA feature register supported
[1.596169]  Normal descriptors
[1.607076]  TX Checksum insertion supported
[1.615766] sun7i-dwmac 1c5.ethernet eth0: No MDIO subnode found
[1.629108] libphy: stmmac: probed
[1.636267] eth0: PHY ID 001cc915 at 0 IRQ POLL (stmmac-0:00) active
[1.646446] eth0: PHY ID 001cc915 at 1 IRQ POLL (stmmac-0:01)
...
[   10.086423]  RX IPC Checksum Offload disabled
[   10.097628]  No MAC Management Counters available
[   14.084839] sun7i-dwmac 1c5.ethernet eth0: Link is Up -
100Mbps/Full - flow control rx/tx

Regards,
Frank Schäfer