[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bb0eb6f3-a5db-0966-5564-b53d3a6073c6@gmail.com>
Date: Fri, 22 Oct 2021 10:35:41 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: Vladimir Oltean <vladimir.oltean@....com>, netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
UNGLinuxDriver@...rochip.com, DENG Qingfang <dqfext@...il.com>,
Kurt Kanzenbach <kurt@...utronix.de>,
Hauke Mehrtens <hauke@...ke-m.de>,
Woojung Huh <woojung.huh@...rochip.com>,
Sean Wang <sean.wang@...iatek.com>,
Landen Chao <Landen.Chao@...iatek.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
George McCollister <george.mccollister@...il.com>,
John Crispin <john@...ozen.org>,
Aleksander Jan Bajkowski <olek2@...pl>,
Egil Hjelmeland <privat@...l-hjelmeland.no>,
Oleksij Rempel <o.rempel@...gutronix.de>,
Prasanna Vengateshan <prasanna.vengateshan@...rochip.com>,
Ansuel Smith <ansuelsmth@...il.com>,
Alvin Šipraga <alsi@...g-olufsen.dk>
Subject: Re: [PATCH v3 net-next 2/9] net: dsa: sja1105: serialize access to
the dynamic config interface
On 10/22/21 10:27 AM, Vladimir Oltean wrote:
> The sja1105 hardware seems as concurrent as can be, but when we create a
> background script that adds/removes a rain of FDB entries without the
> rtnl_mutex taken, then in parallel we do another operation like run
> 'bridge fdb show', we can notice these errors popping up:
>
> sja1105 spi2.0: port 2 failed to read back entry for 00:01:02:03:00:40 vid 0: -ENOENT
> sja1105 spi2.0: port 2 failed to add 00:01:02:03:00:40 vid 0 to fdb: -2
> sja1105 spi2.0: port 2 failed to read back entry for 00:01:02:03:00:46 vid 0: -ENOENT
> sja1105 spi2.0: port 2 failed to add 00:01:02:03:00:46 vid 0 to fdb: -2
>
> Luckily what is going on does not require a major rework in the driver.
> The sja1105_dynamic_config_read() function sends multiple SPI buffers to
> the peripheral until the operation completes. We should not do anything
> until the hardware clears the VALID bit.
>
> But since there is no locking (i.e. right now we are implicitly
> serialized by the rtnl_mutex, but if we remove that), it might be
> possible that the process which performs the dynamic config read is
> preempted and another one performs a dynamic config write.
>
> What will happen in that case is that sja1105_dynamic_config_read(),
> when it resumes, expects to see VALIDENT set for the entry it reads
> back. But it won't.
>
> This can be corrected by introducing a mutex for serializing SPI
> accesses to the dynamic config interface which should be atomic with
> respect to each other.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
Reviewed-by: Florian Fainelli <f.fainelli@...il.com>
--
Florian
Powered by blists - more mailing lists