Re: [PATCH net-next v6 1/9] net: dsa: microchip: Add support for KSZ8463 global irq

From: Bastien Curutchet

Date: Thu Mar 05 2026 - 07:39:46 EST


Hi Vladimir,

On 3/5/26 10:56 AM, Vladimir Oltean wrote:
On Wed, Mar 04, 2026 at 11:18:52AM +0100, Bastien Curutchet (Schneider Electric) wrote:
@@ -2890,14 +2899,18 @@ static irqreturn_t ksz_irq_thread_fn(int irq, void *dev_id)
unsigned int nhandled = 0;
struct ksz_device *dev;
unsigned int sub_irq;
- u8 data;
+ u16 data;
int ret;
u8 n;
dev = kirq->dev;
- /* Read interrupt status register */
- ret = ksz_read8(dev, kirq->reg_status, &data);
+ /*
+ * Most of the KSZ switches have a 8-bits long interrupt status
+ * register, but the KSZ8463 has a 16-bits long one. The overread here
+ * is safe because we only iterate over kirq->nirqs in the below loop.

FWIW, this isn't the only thing making an overread "safe".
If the adjacent register also has "clear on read" semantics, that's not
good.

I can't tell whether that's the case here, though. There are just too
many hardware variations to check for. I just wanted to point out that
the reasoning is incomplete.

You're right, I hadn't thought about the 'clear on read' case.

I'll use ksz_read16() only for the KSZ8463 to be 100% sure it won't break anything for other switches.


Best regards,
Bastien