Skip to content

Commit b7fb772

Browse files
Tobias Jakobi (Compleo)kuba-moo
authored andcommitted
net: dsa: microchip: fix register write order in ksz8_ind_write8()
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) <[email protected]> Reviewed-by: Oleksij Rempel <[email protected]> Fixes: 7b6e623 ("net: dsa: microchip: ksz8795: handle eee specif erratum") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 289e922 commit b7fb772

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/dsa/microchip/ksz8795.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ static int ksz8_ind_write8(struct ksz_device *dev, u8 table, u16 addr, u8 data)
4949
mutex_lock(&dev->alu_mutex);
5050

5151
ctrl_addr = IND_ACC_TABLE(table) | addr;
52-
ret = ksz_write8(dev, regs[REG_IND_BYTE], data);
52+
ret = ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr);
5353
if (!ret)
54-
ret = ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr);
54+
ret = ksz_write8(dev, regs[REG_IND_BYTE], data);
5555

5656
mutex_unlock(&dev->alu_mutex);
5757

0 commit comments

Comments
 (0)