🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
5 messages
5 total messages Started by Sebastien Royen Wed, 07 Oct 2026 08:05
[PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection
#199
Author: Sebastien Royen
Date: Wed, 07 Oct 2026 08:05
32 lines
8252 bytes
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
Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection
#101
Author: Nicolai Buchwitz
Date: Wed, 07 Oct 2026 08:14
48 lines
7371 bytes
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
Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection
#200
Author: netdev-bot+sinfo
Date: Wed, 07 Oct 2026 14:10
22 lines
6278 bytes
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.
Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection
#815
Author: patchwork-bot+netdevbpf
Date: Thu, 08 Oct 2026 17:50
26 lines
6230 bytes
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
Re: [PATCH net v2] net: dsa: microchip: fix KSZ8765 fiber detection
#1941
Author: netdev-bot+sashiko
Date: Sun, 11 Oct 2026 14:19
125 lines
9954 bytes
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 commit message does not say what users actually see, and
  its Fixes: tag points at the wrong commit.

Pre-existing issues:
- [Low] This problem wasn't introduced by this patch, but
  ksz_switch_detect() (drivers/net/dsa/microchip/ksz_common.c:2931)…

--

net: dsa: microchip: fix KSZ8765 fiber detection

This commit changes KSZ8_PORT_STATUS_0 from 0x08 to 0x18. With that,
ksz_switch_detect() reads the Port 1 Status 0 register to check the Fiber
Mode bit that tells a KSZ8765 apart from a KSZ8795, instead of reading the
Global Control 6 MIB Control register.

> Fixes: 91a98917a883 ("net: dsa: microchip: move switch chip_id detection to ksz_common")

[Severity: Medium]

Is this the right commit for the Fixes: tag? 91a98917a883 seems to only
move the detection code into ksz_common. Before that commit,
ksz8_switch_detect() already did a global read of the same 0x08 offset:

drivers/net/dsa/microchip/ksz8795.c:ksz8_switch_detect() {
    ...
			id2 = 0x95;
			ksz_read8(dev, REG_PORT_STATUS_0, &val);
			if (val & PORT_FIBER_MODE)
				id2 = 0x65;
    ...
}

The wrong offset appears to come from 4b20a07e103f ("net: dsa: microchip:
ksz8795: add support for ksz88xx chips"). That commit replaced the
REG_PORT_1_STATUS_0 (0x18) read with REG_PORT_STATUS_0 (0x08), which is a
per-port offset.

Stable trees that have 4b20a07e103f but not 91a98917a883 (5.15.y, for
example) also have this bug. Tooling that follows the current tag would
skip them. Should the tag be this instead?

Fixes: 4b20a07e103f ("net: dsa: microchip: ksz8795: add support for ksz88xx chips")

Could the commit message also describe what users see? With the old value,
bit 7 of REG_SW_CTRL_6 (SW_MIB_COUNTER_FLUSH) reads 0 after power-on. A
KSZ8765 is then detected as KSZ8795, and on a board using the
"microchip,ksz8765" compatible, ksz_check_device_id() fails the probe with
-ENODEV:

    Device tree specifies chip KSZ8765 but found KSZ8795, please fix it!

There is also a change in the other direction. Today, a KSZ8765 board
described as "microchip,ksz8795" probes. After this patch it would be
detected as KSZ8765 and fail with -ENODEV. No in-tree DTS uses either
compatible, but would it be worth mentioning this for backporters?

> 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

[Severity: Low]

This isn't a bug introduced by this patch, but the read in
ksz_switch_detect() that uses this register does not check its return
value:

drivers/net/dsa/microchip/ksz_common.c:ksz_switch_detect() {
    ...
			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;
    ...
}

If regmap_read() fails, ksz_read8() logs an error but still copies its
uninitialized local into *val:

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;
}

Could the fiber mode test then use uninitialized stack data to set
dev->chip_id? ksz_check_device_id() would catch any resulting mismatch.
However, the probe would then fail with -ENODEV and the misleading "please
fix it" message instead of returning the real I/O error.

The other register reads in ksz_switch_detect() check for errors. Now that
this read is meaningful, would it make sense to do the same here?

	ret = ksz_read8(dev, KSZ8_PORT_STATUS_0, &val);
	if (ret)
		return ret;

>  #define KSZ8_PORT_FIBER_MODE		BIT(7)
>  
>  #define SW_CHIP_ID_M			GENMASK(7, 4)

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261007080557.15719-1-sebastien.royen%40armadeus.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads