From: Antoine Tenart <antoine.tenart@bootlin.com>
To: Matteo Croce <mcroce@redhat.com>
Cc: netdev@vger.kernel.org,
Antoine Tenart <antoine.tenart@bootlin.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Marcin Wojtas <mw@semihalf.com>,
Stefan Chulski <stefanc@marvell.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] mvpp2: refactor MTU change code
Date: Fri, 26 Jul 2019 14:50:53 +0200 [thread overview]
Message-ID: <20190726125053.GA5031@kwain> (raw)
In-Reply-To: <20190725231931.24073-1-mcroce@redhat.com>
Hi Matteo,
On Fri, Jul 26, 2019 at 01:19:31AM +0200, Matteo Croce wrote:
> The MTU change code can call napi_disable() with the device already down,
> leading to a deadlock. Also, lot of code is duplicated unnecessarily.
>
> Rework mvpp2_change_mtu() to avoid the deadlock and remove duplicated code.
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
As this is a fix sent to net, you could add a Fixes: tag.
Otherwise this looks good,
Acked-by: Antoine Tenart <antoine.tenart@bootlin.com>
Thanks!
Antoine
> ---
> .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 41 ++++++-------------
> 1 file changed, 13 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 2f7286bd203b..60eb98f99571 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -3612,6 +3612,7 @@ static int mvpp2_set_mac_address(struct net_device *dev, void *p)
> static int mvpp2_change_mtu(struct net_device *dev, int mtu)
> {
> struct mvpp2_port *port = netdev_priv(dev);
> + bool running = netif_running(dev);
> int err;
>
> if (!IS_ALIGNED(MVPP2_RX_PKT_SIZE(mtu), 8)) {
> @@ -3620,40 +3621,24 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu)
> mtu = ALIGN(MVPP2_RX_PKT_SIZE(mtu), 8);
> }
>
> - if (!netif_running(dev)) {
> - err = mvpp2_bm_update_mtu(dev, mtu);
> - if (!err) {
> - port->pkt_size = MVPP2_RX_PKT_SIZE(mtu);
> - return 0;
> - }
> -
> - /* Reconfigure BM to the original MTU */
> - err = mvpp2_bm_update_mtu(dev, dev->mtu);
> - if (err)
> - goto log_error;
> - }
> -
> - mvpp2_stop_dev(port);
> + if (running)
> + mvpp2_stop_dev(port);
>
> err = mvpp2_bm_update_mtu(dev, mtu);
> - if (!err) {
> + if (err) {
> + netdev_err(dev, "failed to change MTU\n");
> + /* Reconfigure BM to the original MTU */
> + mvpp2_bm_update_mtu(dev, dev->mtu);
> + } else {
> port->pkt_size = MVPP2_RX_PKT_SIZE(mtu);
> - goto out_start;
> }
>
> - /* Reconfigure BM to the original MTU */
> - err = mvpp2_bm_update_mtu(dev, dev->mtu);
> - if (err)
> - goto log_error;
> -
> -out_start:
> - mvpp2_start_dev(port);
> - mvpp2_egress_enable(port);
> - mvpp2_ingress_enable(port);
> + if (running) {
> + mvpp2_start_dev(port);
> + mvpp2_egress_enable(port);
> + mvpp2_ingress_enable(port);
> + }
>
> - return 0;
> -log_error:
> - netdev_err(dev, "failed to change MTU\n");
> return err;
> }
>
> --
> 2.21.0
>
--
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2019-07-26 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-25 23:19 [PATCH net] mvpp2: refactor MTU change code Matteo Croce
2019-07-26 12:50 ` Antoine Tenart [this message]
2019-07-26 14:26 ` Matteo Croce
2019-07-27 20:24 ` David Miller
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=20190726125053.GA5031@kwain \
--to=antoine.tenart@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mcroce@redhat.com \
--cc=mw@semihalf.com \
--cc=netdev@vger.kernel.org \
--cc=stefanc@marvell.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).