lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 14 Aug 2015 10:01:49 -0700
From:	Florian Fainelli <f.fainelli@...il.com>
To:	shh.xie@...il.com, netdev@...r.kernel.org, davem@...emloft.net
CC:	Shaohui Xie <Shaohui.Xie@...escale.com>
Subject: Re: [PATCH] net: phy: fix PHY_RUNNING in phy_state_machine

Le 08/13/15 21:23, shh.xie@...il.com a écrit :
> From: Shaohui Xie <Shaohui.Xie@...escale.com>
> 
> Currently, if phy state is PHY_RUNNING, we always register a CHANGE
> when phy works in polling or interrupt ignored, this will make the
> adjust_link being called even the phy link did Not changed.

Right, which is why most drivers do implement a caching scheme.

> 
> checking the phy link to make sure the link did changed before we
> register a CHANGE, if link did not changed, we do nothing.

With your change we will end-up with virtually polling a PHY twice as
fast as we used to with the RUNNING -> CHANGELINK -> RUNNING transition
(current state transitions), which is probably fine, but puts a bit more
pressure on the (slow) MDIO bus since we end-up with two additional
reads to latch the link status register.

PS: I would appreciate if you could CC me on future libphy submissions.

> 
> Signed-off-by: Shaohui Xie <Shaohui.Xie@...escale.com>
> ---
>  drivers/net/phy/phy.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 84b1fba..d972851 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -814,6 +814,7 @@ void phy_state_machine(struct work_struct *work)
>  	bool needs_aneg = false, do_suspend = false;
>  	enum phy_state old_state;
>  	int err = 0;
> +	int old_link;
>  
>  	mutex_lock(&phydev->lock);
>  
> @@ -899,11 +900,18 @@ void phy_state_machine(struct work_struct *work)
>  		phydev->adjust_link(phydev->attached_dev);
>  		break;
>  	case PHY_RUNNING:
> -		/* Only register a CHANGE if we are
> -		 * polling or ignoring interrupts
> +		/* Only register a CHANGE if we are polling or ignoring
> +		 * interrupts and link changed since latest checking.
>  		 */
> -		if (!phy_interrupt_is_valid(phydev))
> -			phydev->state = PHY_CHANGELINK;
> +		if (!phy_interrupt_is_valid(phydev)) {
> +			old_link = phydev->link;
> +			err = phy_read_status(phydev);
> +			if (err)
> +				break;
> +
> +			if (old_link != phydev->link)
> +				phydev->state = PHY_CHANGELINK;
> +		}
>  		break;
>  	case PHY_CHANGELINK:
>  		err = phy_read_status(phydev);
> 


-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ