All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: boon.leong.ong@intel.com
Cc: netdev@vger.kernel.org, tee.min.tan@intel.com,
	weifeng.voon@intel.com, peppe.cavallaro@st.com,
	alexandre.torgue@st.com, Jose.Abreu@synopsys.com,
	mcoquelin.stm32@gmail.com, Joao.Pinto@synopsys.com,
	arnd@arndb.de, alexandru.ardelean@analog.com,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v4 1/6] net: stmmac: Fix incorrect location to set real_num_rx|tx_queues
Date: Wed, 05 Feb 2020 14:39:24 +0100 (CET)	[thread overview]
Message-ID: <20200205.143924.1875004608052019375.davem@davemloft.net> (raw)
In-Reply-To: <20200205085510.32353-2-boon.leong.ong@intel.com>

From: Ong Boon Leong <boon.leong.ong@intel.com>
Date: Wed,  5 Feb 2020 16:55:05 +0800

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 5836b21edd7e..4d9afa13eeb9 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2657,6 +2657,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
>  		stmmac_enable_tbs(priv, priv->ioaddr, enable, chan);
>  	}
>  
> +	/* Configure real RX and TX queues */
> +	netif_set_real_num_rx_queues(dev, priv->plat->rx_queues_to_use);
> +	netif_set_real_num_tx_queues(dev, priv->plat->tx_queues_to_use);
> +
>  	/* Start the ball rolling... */
>  	stmmac_start_all_dma(priv);
>  

It is only safe to ignore the return values from
netif_set_real_num_{rx,tx}_queues() if you call them before the
network device is registered.  Because only in that case are these
functions guaranteed to succeed.

But now that you have moved these calls here, they can fail.

Therefore you must check the return value and unwind the state
completely upon failures.

Honestly, I think this change will have several undesirable side effects:

1) Lots of added new code complexity

2) A new failure mode when resuming the device, users will find this
   very hard to diagnose and recover from

What real value do you get from doing these calls after probe?

If you can't come up with a suitable answer to that question, you
should reconsider this change.

Thanks.

WARNING: multiple messages have this Message-ID (diff)
From: David Miller <davem@davemloft.net>
To: boon.leong.ong@intel.com
Cc: Jose.Abreu@synopsys.com, Joao.Pinto@synopsys.com,
	alexandre.torgue@st.com, weifeng.voon@intel.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	arnd@arndb.de, mcoquelin.stm32@gmail.com, tee.min.tan@intel.com,
	peppe.cavallaro@st.com, alexandru.ardelean@analog.com,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net v4 1/6] net: stmmac: Fix incorrect location to set real_num_rx|tx_queues
Date: Wed, 05 Feb 2020 14:39:24 +0100 (CET)	[thread overview]
Message-ID: <20200205.143924.1875004608052019375.davem@davemloft.net> (raw)
In-Reply-To: <20200205085510.32353-2-boon.leong.ong@intel.com>

From: Ong Boon Leong <boon.leong.ong@intel.com>
Date: Wed,  5 Feb 2020 16:55:05 +0800

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 5836b21edd7e..4d9afa13eeb9 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2657,6 +2657,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
>  		stmmac_enable_tbs(priv, priv->ioaddr, enable, chan);
>  	}
>  
> +	/* Configure real RX and TX queues */
> +	netif_set_real_num_rx_queues(dev, priv->plat->rx_queues_to_use);
> +	netif_set_real_num_tx_queues(dev, priv->plat->tx_queues_to_use);
> +
>  	/* Start the ball rolling... */
>  	stmmac_start_all_dma(priv);
>  

It is only safe to ignore the return values from
netif_set_real_num_{rx,tx}_queues() if you call them before the
network device is registered.  Because only in that case are these
functions guaranteed to succeed.

But now that you have moved these calls here, they can fail.

Therefore you must check the return value and unwind the state
completely upon failures.

Honestly, I think this change will have several undesirable side effects:

1) Lots of added new code complexity

2) A new failure mode when resuming the device, users will find this
   very hard to diagnose and recover from

What real value do you get from doing these calls after probe?

If you can't come up with a suitable answer to that question, you
should reconsider this change.

Thanks.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-02-05 13:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05  8:55 [PATCH net v4 0/6] net: stmmac: general fixes for Ethernet functionality Ong Boon Leong
2020-02-05  8:55 ` Ong Boon Leong
2020-02-05  8:55 ` [PATCH net v4 1/6] net: stmmac: Fix incorrect location to set real_num_rx|tx_queues Ong Boon Leong
2020-02-05  8:55   ` Ong Boon Leong
2020-02-05 13:39   ` David Miller [this message]
2020-02-05 13:39     ` David Miller
2020-02-07  7:21     ` Ong, Boon Leong
2020-02-07  7:21       ` Ong, Boon Leong
2020-02-05  8:55 ` [PATCH net v4 2/6] net: stmmac: fix incorrect GMAC_VLAN_TAG register writting in GMAC4+ Ong Boon Leong
2020-02-05  8:55   ` Ong Boon Leong
2020-02-05  8:55 ` [PATCH net v4 3/6] net: stmmac: xgmac: fix incorrect XGMAC_VLAN_TAG register writting Ong Boon Leong
2020-02-05  8:55   ` Ong Boon Leong
2020-02-05  8:55 ` [PATCH net v4 4/6] net: stmmac: fix missing IFF_MULTICAST check in dwmac4_set_filter Ong Boon Leong
2020-02-05  8:55   ` Ong Boon Leong
2020-02-05  8:55 ` [PATCH net v4 5/6] net: stmmac: xgmac: fix missing IFF_MULTICAST checki in dwxgmac2_set_filter Ong Boon Leong
2020-02-05  8:55   ` Ong Boon Leong
2020-02-05  8:55 ` [PATCH net v4 6/6] net: stmmac: update pci platform data to use phy_interface Ong Boon Leong
2020-02-05  8:55   ` Ong Boon Leong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200205.143924.1875004608052019375.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=Joao.Pinto@synopsys.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=alexandre.torgue@st.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=arnd@arndb.de \
    --cc=boon.leong.ong@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=tee.min.tan@intel.com \
    --cc=weifeng.voon@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.