openwrt/target/linux/generic
Mark Mentovai 249b949a26 kernel: rtl8366s: don't handle unsupported MMD register operations
This is a backport of netdev/net [1]/[2], expected to be in kernel 6.11
(if not backported to a stable branch).

Since 4fdc7bb8f1 (2024-06-14, switching ath79 from kernel 6.1 to 6.6),
the rtl8366s driver was made to write to bogus PHY MII registers on
ath79/netgear,wndr3800 and family, and likely on other systems using
this switch in a similar manner. The writes were directed to PHY 4 MII
registers 0x0d (13) and 0x0e (14). The rtl8366s data sheet claims these
registers are reserved. These register writes were causing the device to
not maintain link, track link status, or pass traffic on eth1 (labeled
WAN), as eth1 is connected to PHY 4.

0x0d is MII_MMD_CTRL, and 0x0e is MII_MMD_DATA. rtl8366s doesn't appear
to support MMD in any way, and certainly not via the IEEE 802.3 annex
22D "clause 45 over clause 22" protocol implemented by mmd_phy_indirect.
This patch intercepts those attempted register accesses and returns
-EOPNOTSUPP without touching the switch chip. This is implemented by
defining phy_driver::{read,write}_mmd as
genphy_{read,write}_mmd_unsupported for this PHY. A new PHY driver for
this PHY is introduced to achieve that, because this PHY was previously
using genphy_driver, and there is otherwise no clean way to declare lack
of support for these operations.

This was caused by kernel 9b01c885be36 (2023-02-13, in 6.3). The new
genphy_c45_read_eee_abilities call in genphy_read_abilities (called
during phy_probe) was causing an attempted MMD read of (MMIO_MMD_PCS,
MDIO_PCS_EEE_ABLE), which was transformed into an annex 22D
mmd_phy_indirect operation that performed MII register writes to
MII_MMD_CTRL, MII_MMD_DATA, and MII_MMD_CTRL again, followed by another
read from MII_MMD_DATA. This was enough to "scramble" the state of those
two MII registers, which are in fact not used for annex 22D MMD register
access on this device but are reserved and have some other function,
rendering the PHY unusable while so configured. The result of the
bungled MMD read attempt caused the genphy driver to incorrectly believe
that the PHY supported standard EEE, which led to several more attempted
MMD writes and reads, in turn being transformed into writes to these two
MII registers.

rtl8366s does support some pre-IEEE 802.3az EEE standard form of "Green
Ethernet" which the switch driver (local to OpenWrt) already has some
support for. No attempt is made to map the standard operations for this
device.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=225990c487c1
[2] https://lore.kernel.org/netdev/20240725204147.69730-1-mark@mentovai.com/

Fixes: https://github.com/openwrt/openwrt/issues/15981
Link: https://github.com/openwrt/openwrt/issues/15739
Reported-by: Russell Senior <russell@personaltelco.net>
Signed-off-by: Mark Mentovai <mark@mentovai.com>
Link: https://github.com/openwrt/openwrt/pull/16012
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2024-07-29 23:22:59 +02:00
..
backport-5.15 kernel: bump 5.15 to 5.15.161 2024-07-01 00:22:09 +02:00
backport-6.1 kernel: bump 6.1 to 6.1.100 2024-07-19 16:50:11 +02:00
backport-6.6 kernel: rtl8366s: don't handle unsupported MMD register operations 2024-07-29 23:22:59 +02:00
files kernel: mtdsplit: fix fit rootfs_data split 2024-07-07 20:58:56 +08:00
hack-5.15 kernel: bump 5.15 to 5.15.161 2024-07-01 00:22:09 +02:00
hack-6.1 kernel: bump 6.1 to 6.1.102 2024-07-28 20:23:29 +02:00
hack-6.6 kernel: bump 6.6 to 6.6.43 2024-07-28 19:46:16 +02:00
image target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
other-files initramfs: switch to tmpfs to fix ujail 2020-11-27 01:23:43 +00:00
pending-5.15 kernel: bump 5.15 to 5.15.161 2024-07-01 00:22:09 +02:00
pending-6.1 kernel: bump 6.1 to 6.1.100 2024-07-19 16:50:11 +02:00
pending-6.6 kernel: bump 6.6 to 6.6.41 2024-07-19 16:53:24 +02:00
config-5.15 kernel: bump 5.15 to 5.15.157 2024-05-11 18:30:30 +02:00
config-6.1 kernel: Add missing config option 2024-04-15 22:50:34 +02:00
config-6.6 generic: 6.6: backport upstream r8169 patches 2024-06-24 05:36:14 +02:00
config-filter generic: filter out CONFIG_FRAME_WARN 2023-07-01 11:52:07 +02:00
PATCHES