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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240416101737.GB1411807@electric-eye.fr.zoreil.com>
Date: Tue, 16 Apr 2024 12:17:37 +0200
From: Francois Romieu <romieu@...zoreil.com>
To: Jiawen Wu <jiawenwu@...stnetic.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, rmk+kernel@...linux.org.uk, andrew@...n.ch,
        netdev@...r.kernel.org, mengyuanlou@...-swift.com,
        duanqiangwen@...-swift.com
Subject: Re: [PATCH net 2/5] net: wangxun: fix error statistics when the
 device is reset

Jiawen Wu <jiawenwu@...stnetic.com> :
> Add flag for reset state to avoid reading statistics when hardware
> is reset.
> 
> Fixes: 883b5984a5d2 ("net: wangxun: add ethtool_ops for ring parameters")
> Signed-off-by: Jiawen Wu <jiawenwu@...stnetic.com>
> ---
>  drivers/net/ethernet/wangxun/libwx/wx_hw.c    |  3 +++
>  drivers/net/ethernet/wangxun/libwx/wx_type.h  |  6 +++++
>  .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c  | 24 +++++++++++++++----
>  .../ethernet/wangxun/txgbe/txgbe_ethtool.c    | 24 +++++++++++++++----
>  4 files changed, 47 insertions(+), 10 deletions(-)
> 
[...]
> diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
> index 786a652ae64f..0e85c5a6633e 100644
> --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
> +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
> @@ -52,7 +52,8 @@ static int ngbe_set_ringparam(struct net_device *netdev,
>  	struct wx *wx = netdev_priv(netdev);
>  	u32 new_rx_count, new_tx_count;
>  	struct wx_ring *temp_ring;
> -	int i;
> +	u8 timeout = 50;
> +	int i, err = 0;
>  
>  	new_tx_count = clamp_t(u32, ring->tx_pending, WX_MIN_TXD, WX_MAX_TXD);
>  	new_tx_count = ALIGN(new_tx_count, WX_REQ_TX_DESCRIPTOR_MULTIPLE);
> @@ -64,6 +65,15 @@ static int ngbe_set_ringparam(struct net_device *netdev,
>  	    new_rx_count == wx->rx_ring_count)
>  		return 0;
>  
> +	while (test_and_set_bit(WX_STATE_RESETTING, wx->state)) {
> +		timeout--;
> +		if (!timeout) {
> +			err = -EBUSY;
> +			goto clear_reset;
> +		}
> +		usleep_range(1000, 2000);
> +	}
> +

This code appears twice. It may be factored out.

[...]
> @@ -89,7 +101,9 @@ static int ngbe_set_ringparam(struct net_device *netdev,
>  	wx_configure(wx);
>  	ngbe_up(wx);
>  
> -	return 0;
> +clear_reset:
> +	clear_bit(WX_STATE_RESETTING, wx->state);
> +	return err;
>  }

This function always clears the bit but it does not necessarily owns it.

-- 
Ueimor

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ