WSL2-Linux-Kernel/drivers/net/dsa/sja1105
Vladimir Oltean eb016afd83 net: dsa: sja1105: serialize access to the dynamic config interface
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@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-10-25 12:59:41 +01:00
..
Kconfig ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
Makefile net: dsa: sja1105: register the MDIO buses for 100base-T1 and 100base-TX 2021-06-08 14:37:16 -07:00
sja1105.h net: dsa: sja1105: serialize access to the dynamic config interface 2021-10-25 12:59:41 +01:00
sja1105_clocking.c net: dsa: sja1105: parse {rx, tx}-internal-delay-ps properties for RGMII delays 2021-10-20 11:32:28 +01:00
sja1105_devlink.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
sja1105_dynamic_config.c net: dsa: sja1105: serialize access to the dynamic config interface 2021-10-25 12:59:41 +01:00
sja1105_dynamic_config.h net: dsa: sja1105: add support for the SJA1110 switch family 2021-06-08 14:37:16 -07:00
sja1105_ethtool.c net: dsa: sja1105: don't use burst SPI reads for port statistics 2021-05-21 14:01:41 -07:00
sja1105_flower.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
sja1105_main.c net: dsa: sja1105: serialize access to the dynamic config interface 2021-10-25 12:59:41 +01:00
sja1105_mdio.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
sja1105_ptp.c net: dsa: move sja1110_process_meta_tstamp inside the tagging protocol driver 2021-09-23 12:45:07 +01:00
sja1105_ptp.h net: dsa: move sja1110_process_meta_tstamp inside the tagging protocol driver 2021-09-23 12:45:07 +01:00
sja1105_spi.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
sja1105_static_config.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
sja1105_static_config.h net: update NXP copyright text 2021-09-17 13:52:17 +01:00
sja1105_tas.c net: dsa: sja1105: parameterize the number of ports 2021-05-24 13:59:03 -07:00
sja1105_tas.h net: dsa: sja1105: dimension the data structures for a larger port count 2021-05-24 13:59:03 -07:00
sja1105_vl.c net: dsa: tag_8021q: make dsa_8021q_{rx,tx}_vid take dp as argument 2021-10-21 12:44:07 +01:00
sja1105_vl.h net: update NXP copyright text 2021-09-17 13:52:17 +01:00