lkml.org 
[lkml]   [2022]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH net-next] net: macb: In shared MDIO usecase make MDIO producer ethernet node to probe first
    Date
    In shared MDIO suspend/resume usecase for ex. with MDIO producer
    (0xff0c0000) eth1 and MDIO consumer(0xff0b0000) eth0 there is a
    constraint that ethernet interface(ff0c0000) MDIO bus producer
    has to be resumed before the consumer ethernet interface(ff0b0000).

    However above constraint is not met when GEM0(ff0b0000) is resumed first.
    There is phy_error on GEM0 and interface becomes non-functional on resume.

    suspend:
    [ 46.477795] macb ff0c0000.ethernet eth1: Link is Down
    [ 46.483058] macb ff0c0000.ethernet: gem-ptp-timer ptp clock unregistered.
    [ 46.490097] macb ff0b0000.ethernet eth0: Link is Down
    [ 46.495298] macb ff0b0000.ethernet: gem-ptp-timer ptp clock unregistered.

    resume:
    [ 46.633840] macb ff0b0000.ethernet eth0: configuring for phy/sgmii link mode
    macb_mdio_read -> pm_runtime_get_sync(GEM1) it return -EACCES error.

    The suspend/resume is dependent on probe order so to fix this dependency
    ensure that MDIO producer ethernet node is always probed first followed
    by MDIO consumer ethernet node.

    During MDIO registration find out if MDIO bus is shared and check if MDIO
    producer platform node(traverse by 'phy-handle' property) is bound. If not
    bound then defer the MDIO consumer ethernet node probe. Doing it ensures
    that in suspend/resume MDIO producer is resumed followed by MDIO consumer
    ethernet node.

    Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
    ---
    As an alternative to this defer probe approach i also explored using
    devicelink framework in ndo_open and create a link between consumer and
    producer and that solves suspend/resume issue but incase MDIO producer
    probe fails MDIO consumer ethernet node remain non-functional. So a
    simpler solution seem to defer MDIO consumer ethernet probe till all
    dependencies are met.
    ---
    drivers/net/ethernet/cadence/macb_main.c | 26 +++++++++++++++++++++++-
    1 file changed, 25 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
    index d0ea8dbfa213..5c903d566bc7 100644
    --- a/drivers/net/ethernet/cadence/macb_main.c
    +++ b/drivers/net/ethernet/cadence/macb_main.c
    @@ -853,7 +853,8 @@ static int macb_mii_probe(struct net_device *dev)

    static int macb_mdiobus_register(struct macb *bp)
    {
    - struct device_node *child, *np = bp->pdev->dev.of_node;
    + struct device_node *child, *np = bp->pdev->dev.of_node, *mdio_np, *dev_np;
    + struct platform_device *mdio_pdev;

    /* If we have a child named mdio, probe it instead of looking for PHYs
    * directly under the MAC node
    @@ -884,6 +885,29 @@ static int macb_mdiobus_register(struct macb *bp)
    return of_mdiobus_register(bp->mii_bus, np);
    }

    + /* For shared MDIO usecases find out MDIO producer platform
    + * device node by traversing through phy-handle DT property.
    + */
    + np = of_parse_phandle(np, "phy-handle", 0);
    + mdio_np = of_get_parent(np);
    + of_node_put(np);
    + dev_np = of_get_parent(mdio_np);
    + of_node_put(mdio_np);
    + mdio_pdev = of_find_device_by_node(dev_np);
    + of_node_put(dev_np);
    +
    + /* Check if the MDIO producer device is probed */
    + device_lock(&mdio_pdev->dev);
    + if (mdio_pdev && !device_is_bound(&mdio_pdev->dev)) {
    + device_unlock(&mdio_pdev->dev);
    + platform_device_put(mdio_pdev);
    + netdev_info(bp->dev, "Defer probe as mdio producer %s is not probed\n",
    + dev_name(&mdio_pdev->dev));
    + return -EPROBE_DEFER;
    + }
    +
    + device_unlock(&mdio_pdev->dev);
    + platform_device_put(mdio_pdev);
    return mdiobus_register(bp->mii_bus);
    }

    --
    2.25.1
    \
     
     \ /
      Last update: 2022-06-28 20:10    [W:7.057 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site