mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
net: phy: Improved PHY error reporting in state machine
When the PHY library calls phy_error() something bad has happened, and we halt the PHY state machine. Calling phy_error() from the main state machine however is not precise enough to know whether the issue is reading the link status or starting auto-negotiation. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c85bd3dacc
commit
323fe43cf9
1 changed files with 24 additions and 9 deletions
|
@ -1169,6 +1169,22 @@ void phy_stop_machine(struct phy_device *phydev)
|
||||||
mutex_unlock(&phydev->lock);
|
mutex_unlock(&phydev->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void phy_process_error(struct phy_device *phydev)
|
||||||
|
{
|
||||||
|
mutex_lock(&phydev->lock);
|
||||||
|
phydev->state = PHY_HALTED;
|
||||||
|
mutex_unlock(&phydev->lock);
|
||||||
|
|
||||||
|
phy_trigger_machine(phydev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void phy_error_precise(struct phy_device *phydev,
|
||||||
|
const void *func, int err)
|
||||||
|
{
|
||||||
|
WARN(1, "%pS: returned: %d\n", func, err);
|
||||||
|
phy_process_error(phydev);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phy_error - enter HALTED state for this PHY device
|
* phy_error - enter HALTED state for this PHY device
|
||||||
* @phydev: target phy_device struct
|
* @phydev: target phy_device struct
|
||||||
|
@ -1181,12 +1197,7 @@ void phy_stop_machine(struct phy_device *phydev)
|
||||||
void phy_error(struct phy_device *phydev)
|
void phy_error(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
WARN_ON(1);
|
WARN_ON(1);
|
||||||
|
phy_process_error(phydev);
|
||||||
mutex_lock(&phydev->lock);
|
|
||||||
phydev->state = PHY_HALTED;
|
|
||||||
mutex_unlock(&phydev->lock);
|
|
||||||
|
|
||||||
phy_trigger_machine(phydev);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(phy_error);
|
EXPORT_SYMBOL(phy_error);
|
||||||
|
|
||||||
|
@ -1378,6 +1389,7 @@ void phy_state_machine(struct work_struct *work)
|
||||||
struct net_device *dev = phydev->attached_dev;
|
struct net_device *dev = phydev->attached_dev;
|
||||||
bool needs_aneg = false, do_suspend = false;
|
bool needs_aneg = false, do_suspend = false;
|
||||||
enum phy_state old_state;
|
enum phy_state old_state;
|
||||||
|
const void *func = NULL;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
@ -1396,6 +1408,7 @@ void phy_state_machine(struct work_struct *work)
|
||||||
case PHY_NOLINK:
|
case PHY_NOLINK:
|
||||||
case PHY_RUNNING:
|
case PHY_RUNNING:
|
||||||
err = phy_check_link_status(phydev);
|
err = phy_check_link_status(phydev);
|
||||||
|
func = &phy_check_link_status;
|
||||||
break;
|
break;
|
||||||
case PHY_CABLETEST:
|
case PHY_CABLETEST:
|
||||||
err = phydev->drv->cable_test_get_status(phydev, &finished);
|
err = phydev->drv->cable_test_get_status(phydev, &finished);
|
||||||
|
@ -1425,16 +1438,18 @@ void phy_state_machine(struct work_struct *work)
|
||||||
|
|
||||||
mutex_unlock(&phydev->lock);
|
mutex_unlock(&phydev->lock);
|
||||||
|
|
||||||
if (needs_aneg)
|
if (needs_aneg) {
|
||||||
err = phy_start_aneg(phydev);
|
err = phy_start_aneg(phydev);
|
||||||
else if (do_suspend)
|
func = &phy_start_aneg;
|
||||||
|
} else if (do_suspend) {
|
||||||
phy_suspend(phydev);
|
phy_suspend(phydev);
|
||||||
|
}
|
||||||
|
|
||||||
if (err == -ENODEV)
|
if (err == -ENODEV)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
phy_error(phydev);
|
phy_error_precise(phydev, func, err);
|
||||||
|
|
||||||
if (old_state != phydev->state) {
|
if (old_state != phydev->state) {
|
||||||
phydev_dbg(phydev, "PHY state change %s -> %s\n",
|
phydev_dbg(phydev, "PHY state change %s -> %s\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue