mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
net: phy: Avoid deadlock during phy_error()
[ Upstream commiteab127717a] phy_error() is called in the PHY state machine workqueue context, and calls phy_trigger_machine() which does a cancel_delayed_work_sync() of the workqueue we execute from, causing a deadlock situation. Augment phy_trigger_machine() machine with a sync boolean indicating whether we should use cancel_*_sync() or just cancel_*_work(). Fixes:3c293f4e08("net: phy: Trigger state machine on state change and not polling.") Reported-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
837786cbbb
commit
feaa5bab43
@@ -611,14 +611,18 @@ void phy_start_machine(struct phy_device *phydev)
|
|||||||
* phy_trigger_machine - trigger the state machine to run
|
* phy_trigger_machine - trigger the state machine to run
|
||||||
*
|
*
|
||||||
* @phydev: the phy_device struct
|
* @phydev: the phy_device struct
|
||||||
|
* @sync: indicate whether we should wait for the workqueue cancelation
|
||||||
*
|
*
|
||||||
* Description: There has been a change in state which requires that the
|
* Description: There has been a change in state which requires that the
|
||||||
* state machine runs.
|
* state machine runs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void phy_trigger_machine(struct phy_device *phydev)
|
static void phy_trigger_machine(struct phy_device *phydev, bool sync)
|
||||||
{
|
{
|
||||||
cancel_delayed_work_sync(&phydev->state_queue);
|
if (sync)
|
||||||
|
cancel_delayed_work_sync(&phydev->state_queue);
|
||||||
|
else
|
||||||
|
cancel_delayed_work(&phydev->state_queue);
|
||||||
queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0);
|
queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,7 +659,7 @@ static void phy_error(struct phy_device *phydev)
|
|||||||
phydev->state = PHY_HALTED;
|
phydev->state = PHY_HALTED;
|
||||||
mutex_unlock(&phydev->lock);
|
mutex_unlock(&phydev->lock);
|
||||||
|
|
||||||
phy_trigger_machine(phydev);
|
phy_trigger_machine(phydev, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -817,7 +821,7 @@ void phy_change(struct work_struct *work)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* reschedule state queue work to run as soon as possible */
|
/* reschedule state queue work to run as soon as possible */
|
||||||
phy_trigger_machine(phydev);
|
phy_trigger_machine(phydev, true);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ignore:
|
ignore:
|
||||||
@@ -907,7 +911,7 @@ void phy_start(struct phy_device *phydev)
|
|||||||
if (do_resume)
|
if (do_resume)
|
||||||
phy_resume(phydev);
|
phy_resume(phydev);
|
||||||
|
|
||||||
phy_trigger_machine(phydev);
|
phy_trigger_machine(phydev, true);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_start);
|
EXPORT_SYMBOL(phy_start);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user