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]
Message-ID: <20220920081911.619ffeef@kernel.org>
Date:   Tue, 20 Sep 2022 08:19:11 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Russell King <linux@...linux.org.uk>
Cc:     Baruch Siach <baruch@...s.co.il>, netdev@...r.kernel.org,
        Andrew Lunn <andrew@...n.ch>,
        Baruch Siach <baruch.siach@...lu.com>
Subject: Re: [PATCH v2] net: sfp: workaround GPIO input signals bounce

On Wed, 14 Sep 2022 08:36:35 +0300 Baruch Siach wrote:
> From: Baruch Siach <baruch.siach@...lu.com>
> 
> Add a trivial debounce to avoid miss of state changes when there is no
> proper hardware debounce on the input signals. Otherwise a GPIO might
> randomly indicate high level when the signal is actually going down,
> and vice versa.
> 
> This fixes observed miss of link up event when LOS signal goes down on
> Armada 8040 based system with an optical SFP module.
> 
> Signed-off-by: Baruch Siach <baruch.siach@...lu.com>
> ---
> v2:
>   Skip delay in the polling case (RMK)

Is this acceptable now, Russell?

> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 63f90fe9a4d2..b0ba144c9633 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -313,7 +313,9 @@ static unsigned long poll_jiffies;
>  static unsigned int sfp_gpio_get_state(struct sfp *sfp)
>  {
>  	unsigned int i, state, v;
> +	int repeat = 10;
>  
> +again:
>  	for (i = state = 0; i < GPIO_MAX; i++) {
>  		if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i])
>  			continue;
> @@ -323,6 +325,16 @@ static unsigned int sfp_gpio_get_state(struct sfp *sfp)
>  			state |= BIT(i);
>  	}
>  
> +	/* Trivial debounce for the interrupt case. When no state change is
> +	 * detected, wait for up to a limited bound time interval for the
> +	 * signal state to settle.
> +	 */
> +	if (state == sfp->state && !sfp->need_poll && repeat > 0) {
> +		udelay(10);
> +		repeat--;
> +		goto again;
> +	}
> +
>  	return state;
>  }
>  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ