Skip to content

Commit

Permalink
net: macb: Use pm_runtime_force_resume/suspend APIs in MDIO helper fu…
Browse files Browse the repository at this point in the history
…nctions

In usecase like SOM KR260 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.
The suspend/resume is dependent on probe order which can also be modified
in DT but it seems less scalable and might not work with defer probe and
overlays.

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.

To fix this dependency - we make use of pm_runtime_force_resume/suspend
APIs variants. This seems to be a temporary fix till we discuss about the
usecase in mainline and see on how can these dependencies are defined
and resume of consumer is deferred until the producer interface is up.

Signed-off-by: Radhey Shyam Pandey <[email protected]>
Reviewed-by: Harini Katakam <[email protected]>
  • Loading branch information
radheyxilinx authored and Michal Simek committed Mar 25, 2022
1 parent d12b7cf commit 417cf40
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions drivers/net/ethernet/cadence/macb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,13 @@ static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
{
struct macb *bp = bus->priv;
int status;
bool force_resume;

status = pm_runtime_get_sync(&bp->pdev->dev);
if (status < 0) {
pm_runtime_put_noidle(&bp->pdev->dev);
goto mdio_pm_exit;
force_resume = pm_runtime_status_suspended(&bp->pdev->dev);
if (force_resume) {
status = pm_runtime_force_resume(&bp->pdev->dev);
if (status < 0)
goto mdio_pm_exit;
}

status = macb_mdio_wait_for_idle(bp);
Expand Down Expand Up @@ -384,8 +386,8 @@ static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
status = MACB_BFEXT(DATA, macb_readl(bp, MAN));

mdio_read_exit:
pm_runtime_mark_last_busy(&bp->pdev->dev);
pm_runtime_put_autosuspend(&bp->pdev->dev);
if (force_resume)
pm_runtime_force_suspend(&bp->pdev->dev);
mdio_pm_exit:
return status;
}
Expand All @@ -395,11 +397,13 @@ static int macb_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
{
struct macb *bp = bus->priv;
int status;
bool force_resume;

status = pm_runtime_get_sync(&bp->pdev->dev);
if (status < 0) {
pm_runtime_put_noidle(&bp->pdev->dev);
goto mdio_pm_exit;
force_resume = pm_runtime_status_suspended(&bp->pdev->dev);
if (force_resume) {
status = pm_runtime_force_resume(&bp->pdev->dev);
if (status < 0)
goto mdio_pm_exit;
}

status = macb_mdio_wait_for_idle(bp);
Expand Down Expand Up @@ -438,8 +442,8 @@ static int macb_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
goto mdio_write_exit;

mdio_write_exit:
pm_runtime_mark_last_busy(&bp->pdev->dev);
pm_runtime_put_autosuspend(&bp->pdev->dev);
if (force_resume)
pm_runtime_force_suspend(&bp->pdev->dev);
mdio_pm_exit:
return status;
}
Expand Down

0 comments on commit 417cf40

Please sign in to comment.