From: Alexander H Duyck <alexander.duyck@gmail.com>
To: "Hans J. Schultz" <netdev@kapio-technology.com>,
davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 net-next 2/3] net: dsa: mv88e6xxx: disable hold of chip lock for handling
Date: Tue, 13 Dec 2022 14:06:33 -0800 [thread overview]
Message-ID: <e94f4967a770b7004686155291c885e61a3403b2.camel@gmail.com> (raw)
In-Reply-To: <20221213174650.670767-3-netdev@kapio-technology.com>
On Tue, 2022-12-13 at 18:46 +0100, Hans J. Schultz wrote:
> As functions called under the interrupt handler will need to take the
> netlink lock, we need to release the chip lock before calling those
> functions as otherwise double lock deadlocks will occur as userspace
> calls towards the driver often take the netlink lock and then the
> chip lock.
>
> The deadlock would look like:
>
> Interrupt handler: chip lock taken, but cannot take netlink lock as
> userspace config call has netlink lock.
> Userspace config: netlink lock taken, but cannot take chip lock as
> the interrupt handler has the chip lock.
>
> Signed-off-by: Hans J. Schultz <netdev@kapio-technology.com>
Just to confirm, in order to see the deadlocks I would imagine you need
something in the tracepoints that is taking the netlink lock?
If so you might want to reference the commit that switched out the
dev_err_ratelimited for the tracepoints 8646384d80f3 ("net: dsa:
mv88e6xxx: replace ATU violation prints with trace points") so that
this patch can be found an applied to any kernels that pull in those
tracepoints.
> ---
> drivers/net/dsa/mv88e6xxx/global1_atu.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c
> index 61ae2d61e25c..34203e112eef 100644
> --- a/drivers/net/dsa/mv88e6xxx/global1_atu.c
> +++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c
> @@ -409,11 +409,11 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
>
> err = mv88e6xxx_g1_read_atu_violation(chip);
> if (err)
> - goto out;
> + goto out_unlock;
>
> err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_OP, &val);
> if (err)
> - goto out;
> + goto out_unlock;
>
> err = mv88e6xxx_g1_atu_fid_read(chip, &fid);
> if (err)
> @@ -421,11 +421,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
>
> err = mv88e6xxx_g1_atu_data_read(chip, &entry);
> if (err)
> - goto out;
> + goto out_unlock;
>
> err = mv88e6xxx_g1_atu_mac_read(chip, &entry);
> if (err)
> - goto out;
> + goto out_unlock;
> +
> + mv88e6xxx_reg_unlock(chip);
>
> spid = entry.state;
>
> @@ -449,13 +451,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
> fid);
> chip->ports[spid].atu_full_violation++;
> }
> - mv88e6xxx_reg_unlock(chip);
>
> return IRQ_HANDLED;
>
> -out:
> +out_unlock:
> mv88e6xxx_reg_unlock(chip);
>
> +out:
> dev_err(chip->dev, "ATU problem: error %d while handling interrupt\n",
> err);
> return IRQ_HANDLED;
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
next prev parent reply other threads:[~2022-12-13 22:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 17:46 [PATCH v2 net-next 0/3] mv88e6xxx: Add MAB offload support Hans J. Schultz
2022-12-13 17:46 ` [PATCH v2 net-next 1/3] net: dsa: mv88e6xxx: change default return of mv88e6xxx_port_bridge_flags Hans J. Schultz
2022-12-13 22:38 ` Alexander H Duyck
2022-12-13 17:46 ` [PATCH v2 net-next 2/3] net: dsa: mv88e6xxx: disable hold of chip lock for handling Hans J. Schultz
2022-12-13 22:06 ` Alexander H Duyck [this message]
2022-12-13 17:46 ` [PATCH v2 net-next 3/3] net: dsa: mv88e6xxx: mac-auth/MAB implementation Hans J. Schultz
2022-12-13 22:33 ` Alexander H Duyck
2022-12-14 1:29 ` [PATCH v2 net-next 0/3] mv88e6xxx: Add MAB offload support Jakub Kicinski
2023-01-04 13:06 Hans J. Schultz
2023-01-04 13:06 ` [PATCH v2 net-next 2/3] net: dsa: mv88e6xxx: disable hold of chip lock for handling Hans J. Schultz
2023-01-04 17:32 ` Vladimir Oltean
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=e94f4967a770b7004686155291c885e61a3403b2.camel@gmail.com \
--to=alexander.duyck@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@kapio-technology.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®