netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "Alvin Šipraga" <ALSI@bang-olufsen.dk>
Cc: "Luiz Angelo Daros de Luca" <luizluca@gmail.com>,
	"Alvin Šipraga" <alvin@pqrs.dk>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Michael Rasmussen" <MIR@bang-olufsen.dk>,
	"Arınç ÜNAL" <arinc.unal@arinc9.com>,
	"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 0/2] net: dsa: realtek: fix PHY register read corruption
Date: Thu, 17 Feb 2022 13:12:19 +0100	[thread overview]
Message-ID: <Yg47o5619InYrs9x@lunn.ch> (raw)
In-Reply-To: <878ruasjd8.fsf@bang-olufsen.dk>

> Thank you Andrew for the clear explanation.
> 
> Somewhat unrelated to this series, but are you able to explain to me the
> difference between:
> 
> 	mutex_lock(&bus->mdio_lock);
> and
> 	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> 
> While looking at other driver examples I noticed the latter form quite a
> few times too.

This is to do with the debug code for checking for deadlocks,
CONFIG_PROVE_LOCKING. When that feature is enables, each lock/unlock
of a mutex is tracked, and a list is made of what other locks are also
taken, and the order. The code can find deadlocks where one thread
takes A then B, while another thread takes B and then A. It can also
detect when a thread takes lock A and then tries to take lock A again.

Rather than track each individual mutex, it uses classes of mutex. So
bus->mdio_lock is a class of mutex. The code simply tracks that a
bus->mdio_lock has been taken, not a specific bus->mdio_lock. That is
generally sufficient, but not always. The mv88e6xxx switch is like
many switches, accessed over MDIO. But the mv88e6xxx switch offers an
MDIO bus, and there is an MDIO bus driver inside the mv88e6xxx
driver. So you have nested MDIO calls. So this debug code seems the
same class of mutex being taken twice, and thinks it is a
deadlock. You can tell it that nested MDIO calls are actually O.K, it
won't deadlock.

      Andrew

  reply	other threads:[~2022-02-17 12:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 16:04 [PATCH net-next 0/2] net: dsa: realtek: fix PHY register read corruption Alvin Šipraga
2022-02-16 16:04 ` [PATCH net-next 1/2] net: dsa: realtek: allow subdrivers to externally lock regmap Alvin Šipraga
2022-02-16 16:05 ` [PATCH net-next 2/2] net: dsa: realtek: rtl8365mb: serialize indirect PHY register access Alvin Šipraga
2022-02-16 23:39   ` Vladimir Oltean
2022-02-17  3:01     ` Luiz Angelo Daros de Luca
2022-02-17  8:16       ` Alvin Šipraga
2022-02-22  0:18         ` Luiz Angelo Daros de Luca
2022-02-17  7:41     ` Alvin Šipraga
2022-02-17 11:17       ` Vladimir Oltean
2022-02-17 12:51         ` Alvin Šipraga
2022-02-21 14:50           ` Alvin Šipraga
2022-02-21 17:15             ` Vladimir Oltean
2022-02-21 18:10               ` Alvin Šipraga
2022-02-16 17:57 ` [PATCH net-next 0/2] net: dsa: realtek: fix PHY register read corruption Luiz Angelo Daros de Luca
2022-02-16 18:23   ` Alvin Šipraga
2022-02-16 19:11     ` Andrew Lunn
2022-02-16 19:26       ` Alvin Šipraga
2022-02-17 12:12         ` Andrew Lunn [this message]
2022-02-17 13:09           ` Alvin Šipraga
2022-02-17 13:32             ` Andrew Lunn
2022-02-17  4:28     ` Luiz Angelo Daros de Luca
2022-02-17  7:53       ` Alvin Šipraga

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=Yg47o5619InYrs9x@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=ALSI@bang-olufsen.dk \
    --cc=MIR@bang-olufsen.dk \
    --cc=alvin@pqrs.dk \
    --cc=arinc.unal@arinc9.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=vivien.didelot@gmail.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).