* [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection
@ 2026-10-06 13:00 Sebastien Royen
2026-10-06 14:20 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Sebastien Royen @ 2026-10-06 13:00 UTC (permalink / raw)
To: Woojung Huh; +Cc: netdev, Sebastien Royen
The KSZ8765 is similar to the KSZ8795 but has two fiber ports.
KSZ8_PORT_STATUS_0 is used to detect fiber mode. It is currently
defined as 0x08, which is the Global Control 6 MIB Control register
and has bit 7 defined as Flush Counter.
Set KSZ8_PORT_STATUS_0 to 0x18, which is the Port 1 Status 0 register
where bit 7 is the Fiber Mode bit.
Signed-off-by: Sebastien Royen <sebastien.royen@armadeus.com>
---
drivers/net/dsa/microchip/ksz_common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index cbe98494578c..f6104f714a8d 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -853,7 +853,7 @@ static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port)
#define KSZ88_FAMILY_ID 0x88
#define KSZ8895_FAMILY_ID 0x95
-#define KSZ8_PORT_STATUS_0 0x08
+#define KSZ8_PORT_STATUS_0 0x18
#define KSZ8_PORT_FIBER_MODE BIT(7)
#define SW_CHIP_ID_M GENMASK(7, 4)
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 13:00 [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection Sebastien Royen @ 2026-10-06 14:20 ` netdev-bot+sinfo 2026-10-06 14:48 ` Sébastien Royen 2026-10-07 8:05 ` [PATCH net v2] " Sebastien Royen 2026-10-07 14:18 ` [PATCH net] " netdev-bot+sashiko 2 siblings, 1 reply; 12+ messages in thread From: netdev-bot+sinfo @ 2026-10-06 14:20 UTC (permalink / raw) To: Sebastien Royen; +Cc: Woojung Huh, netdev Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 14:20 ` netdev-bot+sinfo @ 2026-10-06 14:48 ` Sébastien Royen 2026-10-06 16:16 ` Andrew Lunn 0 siblings, 1 reply; 12+ messages in thread From: Sébastien Royen @ 2026-10-06 14:48 UTC (permalink / raw) To: netdev-bot+sinfo; +Cc: Woojung Huh, netdev Le 06/10/2026 à 16:20, netdev-bot+sinfo@kernel.org a écrit : > Hi! > > This is an automated message. This series looks like a fix, but its > commit messages seem to be missing some information: > > - How the issue was discovered, e.g. hit in production, hit during > development, syzbot report, manual code inspection, LLM or static > analysis tool scan. > > - Whether the issue was actually triggered, or is only theoretical > (e.g. found by code inspection). If it was triggered please include > the symptoms, like the stack trace or error messages. > > Please do not repost the series just to address the above. Instead, > reply to this email with the missing information, so that reviewers > can take it into account. If the series needs another revision for > other reasons, please include the information in the commit messages > then. > > The evaluation is done by an LLM so it may be wrong, if you think > that is the case please reply and explain. Hi, This issue was discovered when upgrading an embedded device from kernel 5.10 to 6.16. The device was using a KSZ8765 device tree configuration and the corresponding hardware, but during boot the kernel incorrectly detected it as a KSZ8795. The issue was reproduced during testing. The relevant boot messages were: ksz-switch spi0.0: found switch: KSZ8795, rev 0 ksz-switch spi0.0: Device tree specifies chip KSZ8765 but found KSZ8795, please fix it! The fix was then tested manually. Thanks, ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 14:48 ` Sébastien Royen @ 2026-10-06 16:16 ` Andrew Lunn 2026-10-06 16:21 ` Nicolai Buchwitz 0 siblings, 1 reply; 12+ messages in thread From: Andrew Lunn @ 2026-10-06 16:16 UTC (permalink / raw) To: Sébastien Royen; +Cc: netdev-bot+sinfo, Woojung Huh, netdev > This issue was discovered when upgrading an embedded device from kernel 5.10 to 6.16. So is this a regression? If it is, please take a read of: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html and consider if this should be backported to stable. You then need to set the tree as 'net' https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html Andrew ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 16:16 ` Andrew Lunn @ 2026-10-06 16:21 ` Nicolai Buchwitz 2026-10-06 18:24 ` Andrew Lunn 0 siblings, 1 reply; 12+ messages in thread From: Nicolai Buchwitz @ 2026-10-06 16:21 UTC (permalink / raw) To: Andrew Lunn, Sébastien Royen; +Cc: netdev-bot+sinfo, Woojung Huh, netdev Hi Andrew On October 6, 2026 6:16:02 PM GMT+02:00, Andrew Lunn <andrew@lunn.ch> wrote: >> This issue was discovered when upgrading an embedded device from kernel 5.10 to 6.16. > >So is this a regression? > >If it is, please take a read of: > >https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html > >and consider if this should be backported to stable. > >You then need to set the tree as 'net' I might be overlooking something, but the target tree is already net? > >https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html > > Andrew > Regards Nicolai ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 16:21 ` Nicolai Buchwitz @ 2026-10-06 18:24 ` Andrew Lunn 2026-10-06 21:28 ` Nicolai Buchwitz 0 siblings, 1 reply; 12+ messages in thread From: Andrew Lunn @ 2026-10-06 18:24 UTC (permalink / raw) To: Nicolai Buchwitz Cc: Sébastien Royen, netdev-bot+sinfo, Woojung Huh, netdev On Tue, Oct 06, 2026 at 06:21:52PM +0200, Nicolai Buchwitz wrote: > Hi Andrew > > On October 6, 2026 6:16:02 PM GMT+02:00, Andrew Lunn <andrew@lunn.ch> wrote: > >> This issue was discovered when upgrading an embedded device from kernel 5.10 to 6.16. > > > >So is this a regression? > > > >If it is, please take a read of: > > > >https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html > > > >and consider if this should be backported to stable. > > > >You then need to set the tree as 'net' > > I might be overlooking something, but the target tree is already net? Oh, yes. Was it a missing Fixes tag which made me think something was wrong? Andrew ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 18:24 ` Andrew Lunn @ 2026-10-06 21:28 ` Nicolai Buchwitz 0 siblings, 0 replies; 12+ messages in thread From: Nicolai Buchwitz @ 2026-10-06 21:28 UTC (permalink / raw) To: Andrew Lunn, Sébastien Royen; +Cc: netdev-bot+sinfo, Woojung Huh, netdev On 6.10.2026 20:24, Andrew Lunn wrote: > On Tue, Oct 06, 2026 at 06:21:52PM +0200, Nicolai Buchwitz wrote: >> Hi Andrew >> >> On October 6, 2026 6:16:02 PM GMT+02:00, Andrew Lunn <andrew@lunn.ch> >> wrote: >> >> This issue was discovered when upgrading an embedded device from kernel 5.10 to 6.16. >> > >> >So is this a regression? >> > >> >If it is, please take a read of: >> > >> >https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html >> > >> >and consider if this should be backported to stable. >> > >> >You then need to set the tree as 'net' >> >> I might be overlooking something, but the target tree is already net? > > Oh, yes. Was it a missing Fixes tag which made me think something was > wrong? Yes. It should be Fixes: 91a98917a883 ("net: dsa: microchip: move switch chip_id detection to ksz_common") Sébastien, can you please resend the patch with the Fixes tag? With this change: Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de> Thanks Nicolai ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 13:00 [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection Sebastien Royen 2026-10-06 14:20 ` netdev-bot+sinfo @ 2026-10-07 8:05 ` Sebastien Royen 2026-10-07 8:14 ` Nicolai Buchwitz ` (2 more replies) 2026-10-07 14:18 ` [PATCH net] " netdev-bot+sashiko 2 siblings, 3 replies; 12+ messages in thread From: Sebastien Royen @ 2026-10-07 8:05 UTC (permalink / raw) To: Woojung Huh; +Cc: netdev, Sebastien Royen, Nicolai Buchwitz The KSZ8765 is similar to the KSZ8795 but has two fiber ports. KSZ8_PORT_STATUS_0 is used to detect fiber mode. It is currently defined as 0x08, which is the Global Control 6 MIB Control register and has bit 7 defined as Flush Counter. Set KSZ8_PORT_STATUS_0 to 0x18, which is the Port 1 Status 0 register where bit 7 is the Fiber Mode bit. Fixes: 91a98917a883 ("net: dsa: microchip: move switch chip_id detection to ksz_common") Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de> Signed-off-by: Sebastien Royen <sebastien.royen@armadeus.com> --- drivers/net/dsa/microchip/ksz_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index cbe98494578c..f6104f714a8d 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -853,7 +853,7 @@ static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port) #define KSZ88_FAMILY_ID 0x88 #define KSZ8895_FAMILY_ID 0x95 -#define KSZ8_PORT_STATUS_0 0x08 +#define KSZ8_PORT_STATUS_0 0x18 #define KSZ8_PORT_FIBER_MODE BIT(7) #define SW_CHIP_ID_M GENMASK(7, 4) -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-07 8:05 ` [PATCH net v2] " Sebastien Royen @ 2026-10-07 8:14 ` Nicolai Buchwitz 2026-10-07 14:10 ` netdev-bot+sinfo 2026-10-08 17:50 ` patchwork-bot+netdevbpf 2 siblings, 0 replies; 12+ messages in thread From: Nicolai Buchwitz @ 2026-10-07 8:14 UTC (permalink / raw) To: Sebastien Royen; +Cc: Woojung Huh, netdev Hi Sébastien On 7.10.2026 10:05, Sebastien Royen wrote: > The KSZ8765 is similar to the KSZ8795 but has two fiber ports. > > KSZ8_PORT_STATUS_0 is used to detect fiber mode. It is currently > defined as 0x08, which is the Global Control 6 MIB Control register > and has bit 7 defined as Flush Counter. > > Set KSZ8_PORT_STATUS_0 to 0x18, which is the Port 1 Status 0 register > where bit 7 is the Fiber Mode bit. > > Fixes: 91a98917a883 ("net: dsa: microchip: move switch chip_id > detection to ksz_common") > Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de> > Signed-off-by: Sebastien Royen <sebastien.royen@armadeus.com> > --- > drivers/net/dsa/microchip/ksz_common.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/microchip/ksz_common.h > b/drivers/net/dsa/microchip/ksz_common.h > index cbe98494578c..f6104f714a8d 100644 > --- a/drivers/net/dsa/microchip/ksz_common.h > +++ b/drivers/net/dsa/microchip/ksz_common.h > @@ -853,7 +853,7 @@ static inline bool ksz_is_sgmii_port(struct > ksz_device *dev, int port) > #define KSZ88_FAMILY_ID 0x88 > #define KSZ8895_FAMILY_ID 0x95 > > -#define KSZ8_PORT_STATUS_0 0x08 > +#define KSZ8_PORT_STATUS_0 0x18 > #define KSZ8_PORT_FIBER_MODE BIT(7) > > #define SW_CHIP_ID_M GENMASK(7, 4) Please do not send new versions in response to the earlier version, but send it like you would send a new patch (with the usual v2 ... prefix). For more details please have a look at the netdev contribution docs [1] [1] https://docs.kernel.org/process/maintainer-netdev.html#resending-after-review Thanks, Nicolai ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-07 8:05 ` [PATCH net v2] " Sebastien Royen 2026-10-07 8:14 ` Nicolai Buchwitz @ 2026-10-07 14:10 ` netdev-bot+sinfo 2026-10-08 17:50 ` patchwork-bot+netdevbpf 2 siblings, 0 replies; 12+ messages in thread From: netdev-bot+sinfo @ 2026-10-07 14:10 UTC (permalink / raw) To: Sebastien Royen; +Cc: Woojung Huh, netdev, Nicolai Buchwitz Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-07 8:05 ` [PATCH net v2] " Sebastien Royen 2026-10-07 8:14 ` Nicolai Buchwitz 2026-10-07 14:10 ` netdev-bot+sinfo @ 2026-10-08 17:50 ` patchwork-bot+netdevbpf 2 siblings, 0 replies; 12+ messages in thread From: patchwork-bot+netdevbpf @ 2026-10-08 17:50 UTC (permalink / raw) To: Sebastien Royen; +Cc: woojung.huh, netdev, nb Hello: This patch was applied to netdev/net.git (main) by Jakub Kicinski <kuba@kernel.org>: On Wed, 7 Oct 2026 10:05:57 +0200 you wrote: > The KSZ8765 is similar to the KSZ8795 but has two fiber ports. > > KSZ8_PORT_STATUS_0 is used to detect fiber mode. It is currently > defined as 0x08, which is the Global Control 6 MIB Control register > and has bit 7 defined as Flush Counter. > > Set KSZ8_PORT_STATUS_0 to 0x18, which is the Port 1 Status 0 register > where bit 7 is the Fiber Mode bit. > > [...] Here is the summary with links: - [net,v2] net: dsa: microchip: fix KSZ8765 fiber detection https://git.kernel.org/netdev/net/c/fc13ba44da19 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection 2026-10-06 13:00 [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection Sebastien Royen 2026-10-06 14:20 ` netdev-bot+sinfo 2026-10-07 8:05 ` [PATCH net v2] " Sebastien Royen @ 2026-10-07 14:18 ` netdev-bot+sashiko 2 siblings, 0 replies; 12+ messages in thread From: netdev-bot+sashiko @ 2026-10-07 14:18 UTC (permalink / raw) To: sebastien.royen; +Cc: woojung.huh, netdev, kuba Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 (1) If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The patch fixes a long-standing, user-visible misdetection but carries no Fixes: tag and no Cc: stable. Pre-existing issues: - [Low] In ksz_switch_detect() (ksz_common.c:2927-2933), `u8 val;` is declared uninitialized and `ksz_read8(dev, KSZ8_PORT_STATUS_0, &val);`… -- net: dsa: microchip: fix KSZ8765 fiber detection This commit changes KSZ8_PORT_STATUS_0 from 0x08 to 0x18, so that ksz_switch_detect() reads the Port 1 Status 0 register when it checks the fiber mode bit. The old address was Global Control 6, where bit 7 is the MIB flush counter bit, so KSZ8765 chips were never identified. > diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h > index cbe98494578c3..f6104f714a8d1 100644 > --- a/drivers/net/dsa/microchip/ksz_common.h > +++ b/drivers/net/dsa/microchip/ksz_common.h > @@ -853,7 +853,7 @@ static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port) > #define KSZ88_FAMILY_ID 0x88 > #define KSZ8895_FAMILY_ID 0x95 > > -#define KSZ8_PORT_STATUS_0 0x08 > +#define KSZ8_PORT_STATUS_0 0x18 > #define KSZ8_PORT_FIBER_MODE BIT(7) [Severity: Medium] Should this patch carry a Fixes: tag and a Cc: stable? Signed-off-by is the only trailer at the moment. With the old value of 0x08, ksz_switch_detect() reads REG_SW_CTRL_6, where BIT(7) is SW_MIB_COUNTER_FLUSH and not the fiber mode bit. A real KSZ8765 stays detected as KSZ8795_CHIP_ID. ksz_check_device_id() then fails the probe with -ENODEV, even with a correct "microchip,ksz8765" DT: ksz_switch_register() ksz_switch_detect() ksz_read8(dev, KSZ8_PORT_STATUS_0, &val) ksz_check_device_id() "Device tree specifies chip %s but found %s, please fix it!" The original driver, commit e66f840c08a237 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver"), read REG_PORT_1_STATUS_0 (0x18), which is correct. The wrong address appears to come from commit 4b20a07e103f ("net: dsa: microchip: ksz8795: add support for ksz88xx chips"). That commit replaced the register with the per-port offset REG_PORT_STATUS_0 (0x08) inside the same global ksz_read8() call. Commit 91a98917a888 ("net: dsa: microchip: move switch chip_id detection to ksz_common") then carried 0x08 into the new KSZ8_PORT_STATUS_0 define. Would something like this fit? Fixes: 4b20a07e103f ("net: dsa: microchip: ksz8795: add support for ksz88xx chips") Cc: stable@vger.kernel.org [Severity: Low] This is a pre-existing issue that this patch did not introduce. Now that this read returns a meaningful bit, should ksz_switch_detect() check the return value of ksz_read8()? drivers/net/dsa/microchip/ksz_common.c:ksz_switch_detect() { ... if (id2 == KSZ87_CHIP_ID_95) { u8 val; dev->chip_id = KSZ8795_CHIP_ID; ksz_read8(dev, KSZ8_PORT_STATUS_0, &val); if (val & KSZ8_PORT_FIBER_MODE) dev->chip_id = KSZ8765_CHIP_ID; ... } ksz_read8() copies its local value into *val even when regmap_read() fails: drivers/net/dsa/microchip/ksz_common.h:ksz_read8() { unsigned int value; int ret = regmap_read(ksz_regmap_8(dev), reg, &value); ... *val = value; return ret; } On a bus error, the choice between KSZ8765 and KSZ8795 is then made from uninitialized stack data. If that picks the wrong chip, ksz_check_device_id() returns -ENODEV with the "please fix it!" message and the real I/O error is lost. The other reads in this function (REG_CHIP_ID0, REG_KSZ8864_CHIP_ID and REG_CHIP_ID4) all check ret and return it. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006130006.134847-1-sebastien.royen%40armadeus.com ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-10-08 17:50 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-06 13:00 [PATCH net] net: dsa: microchip: fix KSZ8765 fiber detection Sebastien Royen 2026-10-06 14:20 ` netdev-bot+sinfo 2026-10-06 14:48 ` Sébastien Royen 2026-10-06 16:16 ` Andrew Lunn 2026-10-06 16:21 ` Nicolai Buchwitz 2026-10-06 18:24 ` Andrew Lunn 2026-10-06 21:28 ` Nicolai Buchwitz 2026-10-07 8:05 ` [PATCH net v2] " Sebastien Royen 2026-10-07 8:14 ` Nicolai Buchwitz 2026-10-07 14:10 ` netdev-bot+sinfo 2026-10-08 17:50 ` patchwork-bot+netdevbpf 2026-10-07 14:18 ` [PATCH net] " netdev-bot+sashiko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox