netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: "Florian Fainelli" <f.fainelli@gmail.com>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>,
	netdev@vger.kernel.org,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	UNGLinuxDriver@microchip.com, "DENG Qingfang" <dqfext@gmail.com>,
	"Kurt Kanzenbach" <kurt@linutronix.de>,
	"Hauke Mehrtens" <hauke@hauke-m.de>,
	"Woojung Huh" <woojung.huh@microchip.com>,
	"Sean Wang" <sean.wang@mediatek.com>,
	"Landen Chao" <Landen.Chao@mediatek.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"George McCollister" <george.mccollister@gmail.com>,
	"John Crispin" <john@phrozen.org>,
	"Aleksander Jan Bajkowski" <olek2@wp.pl>,
	"Egil Hjelmeland" <privat@egil-hjelmeland.no>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	"Prasanna Vengateshan" <prasanna.vengateshan@microchip.com>,
	"Ansuel Smith" <ansuelsmth@gmail.com>,
	"Alvin Šipraga" <alsi@bang-olufsen.dk>
Subject: Re: [PATCH v3 net-next 3/9] net: mscc: ocelot: serialize access to the MAC table
Date: Fri, 22 Oct 2021 21:04:47 +0200	[thread overview]
Message-ID: <YXMLT4McTTuCb098@lunn.ch> (raw)
In-Reply-To: <20211022180052.5dqafsdv7sa2bckw@skbuf>

On Fri, Oct 22, 2021 at 09:00:52PM +0300, Vladimir Oltean wrote:
> On Fri, Oct 22, 2021 at 10:34:04AM -0700, Florian Fainelli wrote:
> > On 10/22/21 10:27 AM, Vladimir Oltean wrote:
> > > DSA would like to remove the rtnl_lock from its
> > > SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE handlers, and the felix driver uses
> > > the same MAC table functions as ocelot.
> > > 
> > > This means that the MAC table functions will no longer be implicitly
> > > serialized with respect to each other by the rtnl_mutex, we need to add
> > > a dedicated lock in ocelot for the non-atomic operations of selecting a
> > > MAC table row, reading/writing what we want and polling for completion.
> > > 
> > > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > > ---
> > >  drivers/net/ethernet/mscc/ocelot.c | 53 +++++++++++++++++++++++-------
> > >  include/soc/mscc/ocelot.h          |  3 ++
> > >  2 files changed, 44 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
> > > index 4e5ae687d2e2..72925529b27c 100644
> > > --- a/drivers/net/ethernet/mscc/ocelot.c
> > > +++ b/drivers/net/ethernet/mscc/ocelot.c
> > > @@ -20,11 +20,13 @@ struct ocelot_mact_entry {
> > >  	enum macaccess_entry_type type;
> > >  };
> > >  
> > > +/* Must be called with &ocelot->mact_lock held */
> > 
> > I don't know if the sparse annotations: __must_hold() would work here,
> > but if they do, they serve as both comment and static verification,
> > might as well use them?
> 
> I've never come across that annotation before, thanks.
> I'll fix this and the other issue and resend once the build tests for
> this series finish.

If sparse cannot figure it out, mv88e6xxx has:

static void assert_reg_lock(struct mv88e6xxx_chip *chip)
{
        if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
                dev_err(chip->dev, "Switch registers lock not held!\n");
                dump_stack();
        }
}

which is a bit heavier in weight, but the MDIO bus transaction will
dominate the time for such operations, not checking a mutex.

	 Andrew

  reply	other threads:[~2021-10-22 19:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 17:27 [PATCH v3 net-next 0/9] Drop rtnl_lock from DSA .port_fdb_{add,del} Vladimir Oltean
2021-10-22 17:27 ` [PATCH v3 net-next 1/9] net: dsa: sja1105: wait for dynamic config command completion on writes too Vladimir Oltean
2021-10-22 17:27 ` [PATCH v3 net-next 2/9] net: dsa: sja1105: serialize access to the dynamic config interface Vladimir Oltean
2021-10-22 17:35   ` Florian Fainelli
2021-10-22 17:27 ` [PATCH v3 net-next 3/9] net: mscc: ocelot: serialize access to the MAC table Vladimir Oltean
2021-10-22 17:34   ` Florian Fainelli
2021-10-22 18:00     ` Vladimir Oltean
2021-10-22 19:04       ` Andrew Lunn [this message]
2021-10-22 20:50         ` Vladimir Oltean
2021-10-22 17:27 ` [PATCH v3 net-next 4/9] net: dsa: b53: serialize access to the ARL table Vladimir Oltean
2021-10-22 17:27 ` [PATCH v3 net-next 5/9] net: dsa: lantiq_gswip: serialize access to the PCE table Vladimir Oltean
2021-10-22 17:31   ` Florian Fainelli
2021-10-22 17:27 ` [PATCH v3 net-next 6/9] net: dsa: introduce locking for the address lists on CPU and DSA ports Vladimir Oltean
2021-10-22 17:37   ` Florian Fainelli
2021-10-22 17:27 ` [PATCH v3 net-next 7/9] net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work Vladimir Oltean
2021-10-22 17:37   ` Florian Fainelli
2021-10-22 17:27 ` [PATCH v3 net-next 8/9] selftests: lib: forwarding: allow tests to not require mz and jq Vladimir Oltean
2021-10-22 17:39   ` Florian Fainelli
2021-10-22 17:27 ` [PATCH v3 net-next 9/9] selftests: net: dsa: add a stress test for unlocked FDB operations Vladimir Oltean
2021-10-22 17:40   ` Florian Fainelli

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=YXMLT4McTTuCb098@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Landen.Chao@mediatek.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alsi@bang-olufsen.dk \
    --cc=ansuelsmth@gmail.com \
    --cc=dqfext@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=george.mccollister@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=john@phrozen.org \
    --cc=kurt@linutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olek2@wp.pl \
    --cc=olteanv@gmail.com \
    --cc=prasanna.vengateshan@microchip.com \
    --cc=privat@egil-hjelmeland.no \
    --cc=sean.wang@mediatek.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=woojung.huh@microchip.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).