]> git.ipfire.org Git - thirdparty/openwrt.git/commit
realtek: fix mdio parent/child locking issues 18824/head
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sat, 17 May 2025 06:22:09 +0000 (02:22 -0400)
committerRobert Marko <robimarko@gmail.com>
Thu, 22 May 2025 16:58:58 +0000 (18:58 +0200)
commit461fc06f9d72d032b2acc86fbb7662511e07dd3c
tree965dd60f818bd4004e25d9c6ff2f54e07992838b
parent4e7387cebd616d248e69993e164e3855d0b3de17
realtek: fix mdio parent/child locking issues

Since the early beginning of the Realtek DSA driver there is an uncovered
locking issue between the standard (parent) mdio bus and the DSA (child)
mdio bus. This comes from the fact that the DSA bus simply links to the
parent read and write functions and calls them directly. This leads to
the following lock issue.

- Child bus calls phy_read/write functions and uses its internal lock
- Parent bus calls phy_read/write functions and uses its internal lock

It becomes clear that critical section can be accessed twice without
knowing that a operation from the other bus is currently active. This
can lead to critical malfunctions because the mdio driver needs a lot of
internal magic to get page selection done right. Effects are:

- The original page is lost after a phy_write/read_paged() call
- dmesg like "Realtek RTL8218B (external) rtl838x slave mii-0:00:
  Expected external RTL8218B, found PHY-ID 6b23"

Other DSA drivers simply use the read/write functions from the parent bus
and thus avoid locking issues. Do it the same way.

Fixes: 2b88563ee5aafd9 ("realtek: update the tree to the latest refactored version")
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/18824
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.6/drivers/net/dsa/rtl83xx/rtl838x.h