[PATCH 2/7] can: m_can: m_can_rx_handler(): only handle active interrupts

Marc Kleine-Budde posted 7 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 2/7] can: m_can: m_can_rx_handler(): only handle active interrupts
Posted by Marc Kleine-Budde 1 month, 3 weeks ago
Among other things, the M_CAN IP core has an Interrupt Register (IR)
and an Interrupt Enable (IE) register. An interrupt is triggered if at
least 1 bit is set in the bitwise and of IR and IE.

Depending on the configuration not all interrupts are enabled in the
IE register. However the m_can_rx_handler() IRQ handler looks at all
interrupts not just the enabled ones. This may lead to handling of not
activated interrupts.

Fix the problem and mask the irqstatus (IR register) with the
active_interrupts (cache value of IE register).

Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/m_can/m_can.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index fe74dbd2c966..a51dc0bb8124 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1006,6 +1006,7 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)
 	int rx_work_or_err;
 	int work_done = 0;
 
+	irqstatus &= cdev->active_interrupts;
 	if (!irqstatus)
 		goto end;
 

-- 
2.50.1
Re: [PATCH 2/7] can: m_can: m_can_rx_handler(): only handle active interrupts
Posted by Markus Schneider-Pargmann 1 month, 2 weeks ago
On Tue Aug 12, 2025 at 7:36 PM CEST, Marc Kleine-Budde wrote:
> Among other things, the M_CAN IP core has an Interrupt Register (IR)
> and an Interrupt Enable (IE) register. An interrupt is triggered if at
> least 1 bit is set in the bitwise and of IR and IE.
>
> Depending on the configuration not all interrupts are enabled in the
> IE register. However the m_can_rx_handler() IRQ handler looks at all
> interrupts not just the enabled ones. This may lead to handling of not
> activated interrupts.

But isn't that happening for m_can_interrupt_handler() in general then?

Best
Markus

>
> Fix the problem and mask the irqstatus (IR register) with the
> active_interrupts (cache value of IE register).
>
> Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/net/can/m_can/m_can.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index fe74dbd2c966..a51dc0bb8124 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1006,6 +1006,7 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)
>  	int rx_work_or_err;
>  	int work_done = 0;
>  
> +	irqstatus &= cdev->active_interrupts;
>  	if (!irqstatus)
>  		goto end;
>  

Re: [PATCH 2/7] can: m_can: m_can_rx_handler(): only handle active interrupts
Posted by Marc Kleine-Budde 3 weeks, 4 days ago
On 19.08.2025 10:29:09, Markus Schneider-Pargmann wrote:
> On Tue Aug 12, 2025 at 7:36 PM CEST, Marc Kleine-Budde wrote:
> > Among other things, the M_CAN IP core has an Interrupt Register (IR)
> > and an Interrupt Enable (IE) register. An interrupt is triggered if at
> > least 1 bit is set in the bitwise and of IR and IE.
> >
> > Depending on the configuration not all interrupts are enabled in the
> > IE register. However the m_can_rx_handler() IRQ handler looks at all
> > interrupts not just the enabled ones. This may lead to handling of not
> > activated interrupts.
> 
> But isn't that happening for m_can_interrupt_handler() in general then?

Yes, I'll add it to the m_can_interrupt_handler(), too.

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |