linux/drivers/net/dsa/microchip
Marek Vasut 6992a1004d net: dsa: microchip: fix RGMII delay configuration on KSZ8765/KSZ8794/KSZ8795
[ Upstream commit 5ae06327a3 ]

The blamed commit has replaced a ksz_write8() call to address
REG_PORT_5_CTRL_6 (0x56) with a ksz_set_xmii() -> ksz_pwrite8() call to
regs[P_XMII_CTRL_1], which is also defined as 0x56 for ksz8795_regs[].

The trouble is that, when compared to ksz_write8(), ksz_pwrite8() also
adjusts the register offset with the port base address. So in reality,
ksz_pwrite8(offset=0x56) accesses register 0x56 + 0x50 = 0xa6, which in
this switch appears to be unmapped, and the RGMII delay configuration on
the CPU port does nothing.

So if the switch wasn't fine with the RGMII delay configuration done
through pin strapping and relied on Linux to apply a different one in
order to pass traffic, this is now broken.

Using the offset translation logic imposed by ksz_pwrite8(), the correct
value for regs[P_XMII_CTRL_1] should have been 0x6 on ksz8795_regs[], in
order to really end up accessing register 0x56.

Static code analysis shows that, despite there being multiple other
accesses to regs[P_XMII_CTRL_1] in this driver, the only code path that
is applicable to ksz8795_regs[] and ksz8_dev_ops is ksz_set_xmii().
Therefore, the problem is isolated to RGMII delays.

In its current form, ksz8795_regs[] contains the same value for
P_XMII_CTRL_0 and for P_XMII_CTRL_1, and this raises valid suspicions
that writes made by the driver to regs[P_XMII_CTRL_0] might overwrite
writes made to regs[P_XMII_CTRL_1] or vice versa.

Again, static analysis shows that the only accesses to P_XMII_CTRL_0
from the driver are made from code paths which are not reachable with
ksz8_dev_ops. So the accesses made by ksz_set_xmii() are safe for this
switch family.

[ vladimiroltean: rewrote commit message ]

Fixes: c476bede4b ("net: dsa: microchip: ksz8795: use common xmii function")
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230315231916.2998480-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-22 13:33:51 +01:00
..
Kconfig
ksz_common.c net: dsa: microchip: fix RGMII delay configuration on KSZ8765/KSZ8794/KSZ8795 2023-03-22 13:33:51 +01:00
ksz_common.h net: dsa: microchip: use common irq routines for girq and pirq 2022-09-26 12:42:01 -07:00
ksz_spi.c net: dsa: microchip: remove unnecessary set_drvdata() 2022-09-22 19:30:36 -07:00
ksz8.h net: dsa: microchip: allow to pass return values for PHY read/write accesses 2022-08-31 09:41:19 +01:00
ksz8795_reg.h
ksz8795.c net: dsa: microchip: remove unused port phy variable 2022-08-31 09:41:23 +01:00
ksz8863_smi.c net: dsa: microchip: remove unnecessary set_drvdata() 2022-09-22 19:30:36 -07:00
ksz9477_i2c.c net: dsa: microchip: fix probe of I2C-connected KSZ8563 2023-02-01 08:34:45 +01:00
ksz9477_reg.h net: dsa: microchip: add the support for set_ageing_time 2022-09-16 21:51:47 +01:00
ksz9477.c net: dsa: microchip: ksz9477: port map correction in ALU table entry register 2023-02-01 08:34:26 +01:00
ksz9477.h net: dsa: microchip: add the support for set_ageing_time 2022-09-16 21:51:47 +01:00
lan937x_main.c net: dsa: microchip: move interrupt handling logic from lan937x to ksz_common 2022-09-26 12:41:57 -07:00
lan937x_reg.h net: dsa: microchip: add the support for set_ageing_time 2022-09-16 21:51:47 +01:00
lan937x.h net: dsa: microchip: add the support for set_ageing_time 2022-09-16 21:51:47 +01:00
Makefile