net: dsa: microchip: fix wrong register write when masking interrupt
PATCH 1/1 net: dsa: microchip: fix wrong register write when masking interrupt
From: Tristram Ha <[email protected]>
Initially the macro REG_SW_PORT_INT_MASK__4 is defined as 0x001C in ksz9477_reg.h and REG_PORT_INT_MASK is defined as 0x#01F. Because the global and port interrupt handling is about the same the new REG_SW_PORT_INT_MASK__1 is defined as 0x1F in ksz_common.h. This works as only the least significant bits have effect. As a result the 32-bit write needs to be changed to 8-bit.
---
v1
- clarify the reason to change the code
drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz_common.c +1 -1
@@ -2185,7 +2185,7 @@ static void ksz_irq_bus_sync_unlock(struct irq_data *d)struct ksz_device *dev = kirq->dev;int ret; - ret =ksz_write32 (dev, kirq->reg_mask, kirq->masked); + ret =ksz_write8 (dev, kirq->reg_mask, kirq->masked);if (ret)dev_err (dev->dev,"failed to change IRQ mask\n" );
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerQuoted 9 lines · On Thu, May 30, 2024 at 06:39:13PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Initially the macro
REG_SW_PORT_INT_MASK__4is defined as0x001Cinksz9477_reg.handREG_PORT_INT_MASKis defined as 0x#01F. Because the global and port interrupt handling is about the same the newREG_SW_PORT_INT_MASK__1is defined as0x1Finksz_common.h. This works as only the least significant bits have effect. As a result the 32-bit write needs to be changed to 8-bit.
Quoted 5 lines
Fixes e1add7dd6183 ("net: dsa: microchip: use common irq routines for girq and pirq")Signed-off-by Tristram Ha <[email protected]>---
v1
- clarify the reason to change the code
After v1 comes v2.
Quoted 20 lines
drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/microchip/ksz_common.c +1
-1@@ -2185,7 +2185,7 @@ static void ksz_irq_bus_sync_unlock(struct irq_data *d)struct ksz_device *dev = kirq->dev;int ret; - ret =ksz_write32 (dev, kirq->reg_mask, kirq->masked); + ret =ksz_write8 (dev, kirq->reg_mask, kirq->masked);if (ret)dev_err (dev->dev,"failed to change IRQ mask\n" );Signature · 1 line
2.34.1
What is the user-visible functional impact of the 32-bit access? Justify why this is a bug worth sending to stable kernels please.
FWIW, struct ksz_irq operates on 16-bit registers.
Quoted 16 lines
Subject: Re: [PATCH v1 net] net: dsa: microchip: fix wrong register write when masking interrupt
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 9 lines · On Thu, May 30, 2024 at 06:39:13PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Initially the macro
REG_SW_PORT_INT_MASK__4is defined as0x001Cinksz9477_reg.handREG_PORT_INT_MASKis defined as 0x#01F. Because the global and port interrupt handling is about the same the newREG_SW_PORT_INT_MASK__1is defined as0x1Finksz_common.h. This works as only the least significant bits have effect. As a result the 32-bit write needs to be changed to 8-bit.
Quoted 8 lines
Quoted 1 line
Fixes e1add7dd6183 ("net: dsa: microchip: use common irq routines for girq andpirq")
Quoted 4 lines
Signed-off-by Tristram Ha <[email protected]>---
v1
- clarify the reason to change the codeAfter v1 comes v2.
I thought the initial version starts at index 0?
Quoted 18 lines
Review
Quoted 5 lines
drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/dsa/microchip/ksz_common.cQuoted 12 lines
index
1e0085cd9a9a..3ad0879b00cd100644drivers/net/dsa/microchip/ksz_common.c +1
-1@@ -2185,7 +2185,7 @@ static void ksz_irq_bus_sync_unlock(struct irq_data *d)struct ksz_device *dev = kirq->dev;int ret; - ret =ksz_write32 (dev, kirq->reg_mask, kirq->masked); + ret =ksz_write8 (dev, kirq->reg_mask, kirq->masked);if (ret)dev_err (dev->dev,"failed to change IRQ mask\n" );
Quoted 8 lines
Quoted 3 lines
--
2.34.1What is the user-visible functional impact of the 32-bit access? Justify why this is a bug worth sending to stable kernels please.
FWIW, struct
ksz_irqoperates on 16-bit registers.
As explained before the initial code uses register 0x1C but now it is changed to 0x1F.
See the real operating code if not modified:
ret = ksz_write32(dev, 0x1F, 0x0000007F);
The original code looks like this:
ret = ksz_write32(dev, 0x1C, 0x0000007F);
BTW, all other KSZ switches except KSZ9897/KSZ9893 and LAN937X families use only 8-bit access.
Vladimir Oltean
maintainerQuoted 22 lines · On Tue, Jun 18, 2024 at 11:55:22PM +0000, [email protected] wrote:
Quoted 22 lines
Subject: Re: [PATCH v1 net] net: dsa: microchip: fix wrong register write when masking interrupt
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 14 lines · On Thu, May 30, 2024 at 06:39:13PM -0700, [email protected] wrote:
From: Tristram Ha <[email protected]>
Initially the macro
REG_SW_PORT_INT_MASK__4is defined as0x001Cinksz9477_reg.handREG_PORT_INT_MASKis defined as 0x#01F. Because the global and port interrupt handling is about the same the newREG_SW_PORT_INT_MASK__1is defined as0x1Finksz_common.h. This works as only the least significant bits have effect. As a result the 32-bit write needs to be changed to 8-bit.Fixes e1add7dd6183 ("net: dsa: microchip: use common irq routines for girq and pirq")Signed-off-by Tristram Ha <[email protected]>---
v1
- clarify the reason to change the code
Quoted 3 lines
Quoted 1 line
After v1 comes v2.
I thought the initial version starts at index 0?
Nope - you can cross-check with other posts on the list. Both RFCs and normal patch submissions on the same topic start from v1 (either explicitly specified or not) and increment for each submitted version, regardless of whether RFC or not (the first proper submission after 3 RFC iterations is a v4).
Quoted 32 lines
Quoted 18 lines
Review
Quoted 5 lines
drivers/net/dsa/microchip/ksz_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/net/dsa/microchip/ksz_common.cQuoted 12 lines
index
1e0085cd9a9a..3ad0879b00cd100644drivers/net/dsa/microchip/ksz_common.c +1
-1@@ -2185,7 +2185,7 @@ static void ksz_irq_bus_sync_unlock(struct irq_data *d)struct ksz_device *dev = kirq->dev;int ret; - ret =ksz_write32 (dev, kirq->reg_mask, kirq->masked); + ret =ksz_write8 (dev, kirq->reg_mask, kirq->masked);if (ret)dev_err (dev->dev,"failed to change IRQ mask\n" );Quoted 8 lines
Quoted 3 lines
--
2.34.1What is the user-visible functional impact of the 32-bit access? Justify why this is a bug worth sending to stable kernels please.
FWIW, struct
ksz_irqoperates on 16-bit registers.As explained before the initial code uses register
0x1Cbut now it is changed to0x1F.See the real operating code if not modified:
Quoted 9 lines
ret =
ksz_write32(dev, 0x1F, 0x0000007F);The original code looks like this:
ret =
ksz_write32(dev, 0x1C, 0x0000007F);BTW, all other KSZ switches except KSZ9897/KSZ9893 and LAN937X families use only 8-bit access.
So you're saying that the original code made a 32-bit access to address 0x1c (aka byte-wise accesses to 0x1c, 0x1d, 0x1e, 0x1f) and then the blamed commit changed the address of the 32-bit access to 0x1f (aka misaligned byte-wise accesses to 0x1f, 0x20, 0x21, 0x22), leading to a failure to mask the correct IRQ? And that only the byte-wise access to 0x1f is actually required, so instead of restoring the 32-bit access to address 0x1c as would be expected from a trivial fix, we can just perform an 8-bit write to 0x1f directly?
Sorry, but if this is the case, it isn't clear at all from the commit message and later explanations, at least it isn't to me.