net: dsa: microchip: Always set regmap stride to 1
PATCH v2 1/1 net: dsa: microchip: Always set regmap stride to 1
The regmap stride is set to 1 for regmap describing 8bit registers already. However, for 16/32/64bit registers, the stride is 2/4/8 respectively. This is not correct, as the switch protocol supports unaligned register reads and writes and the KSZ87xx even uses such unaligned register accesses to read e.g. MIB counter.
This patch fixes MIB counter access on KSZ87xx.
---
V2: Add Fixes: tags
--- drivers/net/dsa/microchip/ksz_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz_common.h +1 -1
@@ -303,7 +303,7 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, { \ .name = #width, \ .val_bits = (width), \ - .reg_stride = (width) / 8, \ + .reg_stride = 1, \ .reg_bits = (regbits) + (regalign), \ .pad_bits = (regpad), \ .max_register = BIT(regbits) - 1, \
Signature · 1 line
2.23.0
Quoted 8 lines · Marek Vasut
The regmap stride is set to 1 for regmap describing 8bit registers already. However, for 16/32/64bit registers, the stride is 2/4/8 respectively. This is not correct, as the switch protocol supports unaligned register reads and writes and the KSZ87xx even uses such unaligned register accesses to read e.g. MIB counter.
This patch fixes MIB counter access on KSZ87xx.
After looking through a couple hundred pages of register documentation for KSZ9477 and KSZ9567 I find only registers that are aligned to their width. In my testing the KSZ9567 works fine with and without the patch. The only downside is that all of the unaligned registers needlessly show up in the debugfs regmap, this doesn't really matter though. As long as it fixes the issues on KSZ87xx this looks fine to me.
Quoted 31 lines
Signed-off-by Marek Vasut <[email protected]>Cc Andrew Lunn <[email protected]>Cc David S. Miller <[email protected]>Cc Florian Fainelli <[email protected]>Cc George McCollister <[email protected]>Cc Tristram Ha <[email protected]>Cc Vivien Didelot <[email protected]>Cc Woojung Huh <[email protected]>Fixes 46558d601cb6 ("net: dsa: microchip: Initial SPI regmap support")Fixes 255b59ad0db2 ("net: dsa: microchip: Factor out regmap config generation into common header")---
V2: Add Fixes: tags--- drivers/net/dsa/microchip/ksz_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/microchip/ksz_common.h +1
-2@@ -303,7 +303,7 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, { \ .name = #width, \ .val_bits = (width), \ - .reg_stride = (width) / 8, \ + .reg_stride = 1, \ .reg_bits = (regbits) + (regalign), \ .pad_bits = (regpad), \ .max_register = BIT(regbits) - 1, \ --
Quoted 2 lines
2.23.0
I tested the patch on the KSZ9567, not anything else FWIW:
Quoted 10 lines · George McCollister
Quoted 8 lines · Marek Vasut
The regmap stride is set to 1 for regmap describing 8bit registers already. However, for 16/32/64bit registers, the stride is 2/4/8 respectively. This is not correct, as the switch protocol supports unaligned register reads and writes and the KSZ87xx even uses such unaligned register accesses to read e.g. MIB counter.
This patch fixes MIB counter access on KSZ87xx.
Quoted 7 lines
After looking through a couple hundred pages of register documentation for KSZ9477 and KSZ9567 I find only registers that are aligned to their width. In my testing the KSZ9567 works fine with and without the patch. The only downside is that all of the unaligned registers needlessly show up in the debugfs regmap, this doesn't really matter though. As long as it fixes the issues on KSZ87xx this looks fine to me.
Right.
To avoid exposing all registers through regmap debugfs entries, we would have to define the regmap constrains for readable/writeable/volatile/precious registers, which we should eventually do anyway, but that's way beyond the scope of this fix.
From: Marek Vasut <[email protected]>
Date: Thu, 26 Sep 2019 00:08:42 +0200
Quoted 11 lines
The regmap stride is set to 1 for regmap describing 8bit registers already. However, for 16/32/64bit registers, the stride is 2/4/8 respectively. This is not correct, as the switch protocol supports unaligned register reads and writes and the KSZ87xx even uses such unaligned register accesses to read e.g. MIB counter.
This patch fixes MIB counter access on KSZ87xx.
Signed-off-by Marek Vasut <[email protected]>Fixes 46558d601cb6 ("net: dsa: microchip: Initial SPI regmap support")Fixes 255b59ad0db2 ("net: dsa: microchip: Factor out regmap config generation into common header")
Applied.