]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: dsa: microchip: fix register write order in ksz8_ind_write8()
authorTobias Jakobi (Compleo) <tobias.jakobi.compleo@gmail.com>
Mon, 4 Mar 2024 15:41:35 +0000 (16:41 +0100)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:20 +0000 (10:48 -0400)
commit063faf44ef46fead3bbef8e59d3414a651c39c77
treec57002bad3836315e10c7415ff091fad98e977b7
parenteaa7cb836659ced2d9f814ac32aa3ec193803ed6
net: dsa: microchip: fix register write order in ksz8_ind_write8()

[ Upstream commit b7fb7729c94fb2d23c79ff44f7a2da089c92d81c ]

This bug was noticed while re-implementing parts of the kernel
driver in userspace using spidev. The goal was to enable some
of the errata workarounds that Microchip describes in their
errata sheet [1].

Both the errata sheet and the regular datasheet of e.g. the KSZ8795
imply that you need to do this for indirect register accesses:
- write a 16-bit value to a control register pair (this value
  consists of the indirect register table, and the offset inside
  the table)
- either read or write an 8-bit value from the data storage
  register (indicated by REG_IND_BYTE in the kernel)

The current implementation has the order swapped. It can be
proven, by reading back some indirect register with known content
(the EEE register modified in ksz8_handle_global_errata() is one of
these), that this implementation does not work.

Private discussion with Oleksij Rempel of Pengutronix has revealed
that the workaround was apparantly never tested on actual hardware.

[1] https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/Errata/KSZ87xx-Errata-DS80000687C.pdf

Signed-off-by: Tobias Jakobi (Compleo) <tobias.jakobi.compleo@gmail.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Fixes: 7b6e6235b664 ("net: dsa: microchip: ksz8795: handle eee specif erratum")
Link: https://lore.kernel.org/r/20240304154135.161332-1-tobias.jakobi.compleo@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/microchip/ksz8795.c