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: <CRIP4UR9M4IS.V7ZOZHKV9QRX@den-dk-m31857>
Date:   Wed, 29 Mar 2023 07:41:52 +0000
From:   <Steen.Hegelund@...rochip.com>
To:     <wsa+renesas@...g-engineering.com>, <netdev@...r.kernel.org>
CC:     <linux-renesas-soc@...r.kernel.org>,
        <steve.glendinning@...well.net>, <davem@...emloft.net>,
        <edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <geert+renesas@...der.be>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net v4] smsc911x: only update stats when interface is up

Hi Wolfram,

On Wed Mar 29, 2023 at 8:40 AM CEST, Wolfram Sang wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Otherwise the clocks are not enabled and reading registers will OOPS.
> Copy the behaviour from Renesas SH_ETH and use a custom flag because
> using netif_running() is racy. A generic solution still needs to be
> implemented. Tested on a Renesas APE6-EK.
>
> Fixes: 1e30b8d755b8 ("net: smsc911x: Make Runtime PM handling more fine-grained")
> Signed-off-by: Wolfram Sang <wsa+renesas@...g-engineering.com>
> ---
>
> Changes since v3:
> * broken out of a patch series
> * don't use netif_running() but a custom flag
>
>  drivers/net/ethernet/smsc/smsc911x.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
> index a690d139e177..af96986cbc88 100644
> --- a/drivers/net/ethernet/smsc/smsc911x.c
> +++ b/drivers/net/ethernet/smsc/smsc911x.c
> @@ -140,6 +140,8 @@ struct smsc911x_data {
>
>         /* clock */
>         struct clk *clk;
> +
> +       bool is_open;
>  };
>
>  /* Easy access to information */
> @@ -1738,6 +1740,8 @@ static int smsc911x_open(struct net_device *dev)
>         smsc911x_reg_write(pdata, TX_CFG, TX_CFG_TX_ON_);
>
>         netif_start_queue(dev);
> +       pdata->is_open = true;
> +
>         return 0;
>
>  irq_stop_out:
> @@ -1778,6 +1782,8 @@ static int smsc911x_stop(struct net_device *dev)
>                 dev->phydev = NULL;
>         }
>         netif_carrier_off(dev);
> +       pdata->is_open = false;
> +
>         pm_runtime_put(dev->dev.parent);
>
>         SMSC_TRACE(pdata, ifdown, "Interface stopped");
> @@ -1841,8 +1847,12 @@ smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  static struct net_device_stats *smsc911x_get_stats(struct net_device *dev)
>  {
>         struct smsc911x_data *pdata = netdev_priv(dev);
> -       smsc911x_tx_update_txcounters(dev);
> -       dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
> +
> +       if (pdata->is_open) {

Couldn't you just use netif_carrier_ok() here and drop the is_open
variable?

> +               smsc911x_tx_update_txcounters(dev);
> +               dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
> +       }
> +
>         return &dev->stats;
>  }
>
> --
> 2.30.2

BR
Steen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ