* [PATCH v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation [not found] <400a6387-a444-4576-af6d-26be5410bce3.ref@yahoo.com> @ 2026-04-19 19:37 ` Mieczyslaw Nalewaj 2026-04-20 2:24 ` Luiz Angelo Daros de Luca 2026-04-23 9:20 ` patchwork-bot+netdevbpf 0 siblings, 2 replies; 3+ messages in thread From: Mieczyslaw Nalewaj @ 2026-04-19 19:37 UTC (permalink / raw) To: netdev@vger.kernel.org The RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK macro was shifting the 4-bit mask (0xF) by only (_extint % 2) bits instead of (_extint % 2) * 4. This caused the mask to overlap with the adjacent nibble when configuring odd-numbered external interfaces, selecting the wrong bits entirely. Align the shift calculation with the existing ...MODE_OFFSET macro. Fixes: 4af2950c50c8 ("net: dsa: realtek-smi: add rtl8365mb subdriver for RTL8365MB-VC") Signed-off-by: Abdulkader Alrezej <alrazj.abdulkader@gmail.com> Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com> Reviewed-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> --- drivers/net/dsa/realtek/rtl8365mb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index ad7044b295ec..b85c99216648 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -216,7 +216,7 @@ (_extint) == 2 ? RTL8365MB_DIGITAL_INTERFACE_SELECT_REG1 : \ 0x0) #define RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(_extint) \ - (0xF << (((_extint) % 2))) + (0xF << (((_extint) % 2) * 4)) #define RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(_extint) \ (((_extint) % 2) * 4) -- 2.53.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation 2026-04-19 19:37 ` [PATCH v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation Mieczyslaw Nalewaj @ 2026-04-20 2:24 ` Luiz Angelo Daros de Luca 2026-04-23 9:20 ` patchwork-bot+netdevbpf 1 sibling, 0 replies; 3+ messages in thread From: Luiz Angelo Daros de Luca @ 2026-04-20 2:24 UTC (permalink / raw) To: Mieczyslaw Nalewaj, Alvin Šipraga; +Cc: netdev@vger.kernel.org > The RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK macro was shifting > the 4-bit mask (0xF) by only (_extint % 2) bits instead of > (_extint % 2) * 4. This caused the mask to overlap with the adjacent > nibble when configuring odd-numbered external interfaces, selecting > the wrong bits entirely. > > Align the shift calculation with the existing ...MODE_OFFSET macro. > > Fixes: 4af2950c50c8 ("net: dsa: realtek-smi: add rtl8365mb subdriver for RTL8365MB-VC") > Signed-off-by: Abdulkader Alrezej <alrazj.abdulkader@gmail.com> > Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com> > Reviewed-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> This bug specifically affected ext1 (Port 6) for all digital interface modes except DISABLED (0x0) and RGMII (0x1). The error caused the mask for ext1 to overlap with the adjacent nibble of ext0. Since ext0 is currently unused by all supported devices in this family, the incorrect mask was zeroing bits that were already expected to be zero, masking the failure. However, for ext1, the incorrect shift left the effective mask with only a single bit (bit 4) instead of the full 4-bit nibble (bits 4-7). This meant the driver could only successfully write values 0x0 or 0x1. Any mode requiring bits [7:5] (such as MII, RMII, or HSGMII) would have been effectively written as 0x0 or 0x1, breaking those configurations. The original chip for this driver, RTL8365MB-VC, does utilize ext1, but as the driver currently only implements RGMII mode, the hardware result remained coincidentally correct: Before patch: (0x0001 << 4) & 0x001E = 0x0010 After patch: (0x0001 << 4) & 0x00F0 = 0x0010 Tests on my device, TP-Link Archer C5v4, show no problem before and no regressions, as ext1/port6 is not connected on that specific hardware. Backporting note: There is no strict need to backport this fix to stable trees, as only the RGMII mode was actually implemented and it happened to work despite the logical error. Regards, Luiz ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation 2026-04-19 19:37 ` [PATCH v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation Mieczyslaw Nalewaj 2026-04-20 2:24 ` Luiz Angelo Daros de Luca @ 2026-04-23 9:20 ` patchwork-bot+netdevbpf 1 sibling, 0 replies; 3+ messages in thread From: patchwork-bot+netdevbpf @ 2026-04-23 9:20 UTC (permalink / raw) To: Mieczyslaw Nalewaj; +Cc: netdev Hello: This patch was applied to netdev/net.git (main) by Paolo Abeni <pabeni@redhat.com>: On Sun, 19 Apr 2026 21:37:07 +0200 you wrote: > The RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK macro was shifting > the 4-bit mask (0xF) by only (_extint % 2) bits instead of > (_extint % 2) * 4. This caused the mask to overlap with the adjacent > nibble when configuring odd-numbered external interfaces, selecting > the wrong bits entirely. > > Align the shift calculation with the existing ...MODE_OFFSET macro. > > [...] Here is the summary with links: - [v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation https://git.kernel.org/netdev/net/c/0c078021d386 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] 3+ messages in thread
end of thread, other threads:[~2026-04-23 9:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <400a6387-a444-4576-af6d-26be5410bce3.ref@yahoo.com>
2026-04-19 19:37 ` [PATCH v2] net: dsa: realtek: rtl8365mb: fix mode mask calculation Mieczyslaw Nalewaj
2026-04-20 2:24 ` Luiz Angelo Daros de Luca
2026-04-23 9:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox