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:   Tue, 28 May 2019 11:02:49 +0100
From:   Russell King - ARM Linux admin <linux@...linux.org.uk>
To:     "David S. Miller" <davem@...emloft.net>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 2/5] net: phylink: support for link gpio
 interrupt

Hi David,

I was intending to add a note to this patch indicating that it
depends on "net: phylink: ensure consistent phy interface mode" but
failed to do before sending it out - sorry!  If you'd prefer a patch
that doesn't depend on that, please ask.  The only difference is the
first two lines of context of the first hunk.

Russell.

On Tue, May 28, 2019 at 10:57:23AM +0100, Russell King wrote:
> Add support for using GPIO interrupts with a fixed-link GPIO rather than
> polling the GPIO every second and invoking the phylink resolution.  This
> avoids unnecessary calls to mac_config().
> 
> Reviewed-by: Florian Fainelli <f.fainelli@...il.com>
> Signed-off-by: Russell King <rmk+kernel@...linux.org.uk>
> ---
>  drivers/net/phy/phylink.c | 36 ++++++++++++++++++++++++++++++++----
>  1 file changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 219a061572d2..00cd0ed7ff3d 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -56,6 +56,7 @@ struct phylink {
>  	phy_interface_t cur_interface;
>  
>  	struct gpio_desc *link_gpio;
> +	unsigned int link_irq;
>  	struct timer_list link_poll;
>  	void (*get_fixed_state)(struct net_device *dev,
>  				struct phylink_link_state *s);
> @@ -612,7 +613,7 @@ void phylink_destroy(struct phylink *pl)
>  {
>  	if (pl->sfp_bus)
>  		sfp_unregister_upstream(pl->sfp_bus);
> -	if (!IS_ERR_OR_NULL(pl->link_gpio))
> +	if (pl->link_gpio)
>  		gpiod_put(pl->link_gpio);
>  
>  	cancel_work_sync(&pl->resolve);
> @@ -875,6 +876,15 @@ void phylink_mac_change(struct phylink *pl, bool up)
>  }
>  EXPORT_SYMBOL_GPL(phylink_mac_change);
>  
> +static irqreturn_t phylink_link_handler(int irq, void *data)
> +{
> +	struct phylink *pl = data;
> +
> +	phylink_run_resolve(pl);
> +
> +	return IRQ_HANDLED;
> +}
> +
>  /**
>   * phylink_start() - start a phylink instance
>   * @pl: a pointer to a &struct phylink returned from phylink_create()
> @@ -910,7 +920,22 @@ void phylink_start(struct phylink *pl)
>  	clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
>  	phylink_run_resolve(pl);
>  
> -	if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
> +	if (pl->link_an_mode == MLO_AN_FIXED && pl->link_gpio) {
> +		int irq = gpiod_to_irq(pl->link_gpio);
> +
> +		if (irq > 0) {
> +			if (!request_irq(irq, phylink_link_handler,
> +					 IRQF_TRIGGER_RISING |
> +					 IRQF_TRIGGER_FALLING,
> +					 "netdev link", pl))
> +				pl->link_irq = irq;
> +			else
> +				irq = 0;
> +		}
> +		if (irq <= 0)
> +			mod_timer(&pl->link_poll, jiffies + HZ);
> +	}
> +	if (pl->link_an_mode == MLO_AN_FIXED && pl->get_fixed_state)
>  		mod_timer(&pl->link_poll, jiffies + HZ);
>  	if (pl->sfp_bus)
>  		sfp_upstream_start(pl->sfp_bus);
> @@ -936,8 +961,11 @@ void phylink_stop(struct phylink *pl)
>  		phy_stop(pl->phydev);
>  	if (pl->sfp_bus)
>  		sfp_upstream_stop(pl->sfp_bus);
> -	if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio))
> -		del_timer_sync(&pl->link_poll);
> +	del_timer_sync(&pl->link_poll);
> +	if (pl->link_irq) {
> +		free_irq(pl->link_irq, pl);
> +		pl->link_irq = 0;
> +	}
>  
>  	phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_STOPPED);
>  }
> -- 
> 2.7.4
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

Powered by blists - more mailing lists