Skip to contentSkip to conversation

m_can: support device-specific interrupt handling

RFC PATCH In review Torin Cooper-Bennun 2 participants 21 messages May 14, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover m_can: support device-specific interrupt handling

Using the TCAN4550, I've had occasions where the m_can driver has fallen over with the "nobody cared" message -- the ISR has returned IRQ_NONE upon "99,900 of the previous 100,000 interrupts" (see kernel/irq/spurious.c, __report_bad_irq()).

While such high numbers certainly indicate some kind of fault, presently, device-specific interrupts are totally ignored -- it may be that such a fault can be handled with a device-specific action.

Comments are welcome. One thing right off the bat: I'm not sure whether the new callback should be added alongside clear_interrupts, or if it should replace it.

I also need to replicate the fault observed with the TCAN4550 - it's unlikely that the handling added in this patchset is effective by itself.

Torin Cooper-Bennun (3):
can: m_can: add handle_dev_interrupts callback to m_can_ops
can: m_can: m_can_isr(): handle device-specific interrupts
can: tcan4x5x: add handle_dev_interrupts callback to ops

 drivers/net/can/m_can/m_can.c         | 13 ++++++++++++-
 drivers/net/can/m_can/m_can.h         |  2 ++
 drivers/net/can/m_can/tcan4x5x-core.c | 25 +++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
#1 lore raw

RFC PATCH 1/3 can: m_can: add handle_dev_interrupts callback to m_can_ops

This callback will allow M_CAN-based devices, e.g. TI TCAN4550, to handle device-specific interrupts which are not part of the M_CAN core, but are signaled on the same interrupt pin.

---
 drivers/net/can/m_can/m_can.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/m_can/m_can.h +2 -0
index ace071c3e58c..99203a37f9cc 100644
@@ -28,6 +28,7 @@
 #include <linux/iopoll.h>
 #include <linux/can/dev.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/irqreturn.h>
 
 /* m_can lec values */
 enum m_can_lec_type {
@@ -62,6 +63,7 @@ struct m_can_classdev;
 struct m_can_ops {
 	/* Device specific call backs */
 	int (*clear_interrupts)(struct m_can_classdev *cdev);
+	irqreturn_t (*handle_dev_interrupts)(struct m_can_classdev *cdev);
 	u32 (*read_reg)(struct m_can_classdev *cdev, int reg);
 	int (*write_reg)(struct m_can_classdev *cdev, int reg, int val);
 	u32 (*read_fifo)(struct m_can_classdev *cdev, int addr_offset);
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH RFC can-next 1/3] can: m_can: add handle_dev_interrupts callback to m_can_ops

Quoted 5 lines · Torin Cooper-Bennun

This callback will allow M_CAN-based devices, e.g. TI TCAN4550, to handle device-specific interrupts which are not part of the M_CAN core, but are signaled on the same interrupt pin.

Another option would be to register a 2nd threaded interrupt handler in the tcan4x5x driver....But this is much simpler.

Quoted 26 lines
---
 drivers/net/can/m_can/m_can.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/m_can/m_can.h +2 -0
index ace071c3e58c..99203a37f9cc 100644
@@ -28,6 +28,7 @@
 #include <linux/iopoll.h>
 #include <linux/can/dev.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/irqreturn.h>
 
 /* m_can lec values */
 enum m_can_lec_type {
@@ -62,6 +63,7 @@ struct m_can_classdev;
 struct m_can_ops {
 	/* Device specific call backs */
 	int (*clear_interrupts)(struct m_can_classdev *cdev);
+	irqreturn_t (*handle_dev_interrupts)(struct m_can_classdev *cdev);
 	u32 (*read_reg)(struct m_can_classdev *cdev, int reg);
 	int (*write_reg)(struct m_can_classdev *cdev, int reg, int val);
 	u32 (*read_fifo)(struct m_can_classdev *cdev, int addr_offset);
Signature · 1 line
2.30.2

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#3 lore raw

Re: [PATCH RFC can-next 1/3] can: m_can: add handle_dev_interrupts callback to m_can_ops

Quoted 9 lines · Marc Kleine-Budde
Quoted 5 lines · Torin Cooper-Bennun

This callback will allow M_CAN-based devices, e.g. TI TCAN4550, to handle device-specific interrupts which are not part of the M_CAN core, but are signaled on the same interrupt pin.

Another option would be to register a 2nd threaded interrupt handler in the tcan4x5x driver....But this is much simpler.

Total separation of the two does make some sense. Events arising from the device-specific interrupt handling would be things like under-/over-voltage faults, CAN stuck dominant, SPI malfunction, etc... things that M_CAN shouldn't have to care about at all.

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#4 lore raw

Re: [PATCH RFC can-next 1/3] can: m_can: add handle_dev_interrupts callback to m_can_ops

Quoted 8 lines · Torin Cooper-Bennun
Quoted 7 lines · Marc Kleine-Budde
Quoted 5 lines · Torin Cooper-Bennun

This callback will allow M_CAN-based devices, e.g. TI TCAN4550, to handle device-specific interrupts which are not part of the M_CAN core, but are signaled on the same interrupt pin.

Quoted 7 lines
Quoted 2 lines

Another option would be to register a 2nd threaded interrupt handler in the tcan4x5x driver....But this is much simpler.

Total separation of the two does make some sense. Events arising from the device-specific interrupt handling would be things like under-/over-voltage faults, CAN stuck dominant, SPI malfunction, etc... things that M_CAN shouldn't have to care about at all.

Technically you could register a 2nd interrupt handler, which is totally independent of the main one. But there are no callbacks for open() and stop() into the tcan4x5x driver to request and free the interrupt handler. So having a single callback is the way to go here.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#5 lore raw

RFC PATCH 2/3 can: m_can: m_can_isr(): handle device-specific interrupts

In reply to Torin Cooper-Bennun

Device-specific interrupts are handled, if applicable (and if no M_CAN interrupts were handled in this ISR call).

---
 drivers/net/can/m_can/m_can.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/can/m_can/m_can.c +12 -1
index 34073cd077e4..af63dd4b8cd5 100644
@@ -1033,20 +1033,31 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	u32 ir;
+	irqreturn_t ret = IRQ_NONE;
 
 	if (pm_runtime_suspended(cdev->dev))
 		return IRQ_NONE;
+
 	ir = m_can_read(cdev, M_CAN_IR);
 	if (!ir)
-		return IRQ_NONE;
+		ret = IRQ_NONE;
 
 	/* ACK all irqs */
 	if (ir & IR_ALL_INT)
 		m_can_write(cdev, M_CAN_IR, ir);
 
+	/* If we have no M_CAN interrupts to handle, we can assume
+	 * device-specific interrupt(s) need handling.
+	 */
+	if (!ir && cdev->ops->handle_dev_interrupts)
+		ret = cdev->ops->handle_dev_interrupts(cdev);
+
 	if (cdev->ops->clear_interrupts)
 		cdev->ops->clear_interrupts(cdev);
 
+	if (!ir)
+		return ret;
+
 	/* schedule NAPI in case of
 	 * - rx IRQ
 	 * - state change IRQ
Signature · 1 line
2.30.2
#6 lore raw

RFC PATCH 3/3 can: tcan4x5x: add handle_dev_interrupts callback to ops

In reply to Torin Cooper-Bennun

Though the TCAN4550's device-specific interrupts are cleared in tcan4x5x_clear_interrupts(), they are ignored, which may cause the m_can driver to stop working due to the ISR becoming disabled (the famous "nobody cared" message).

---
 drivers/net/can/m_can/tcan4x5x-core.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/net/can/m_can/tcan4x5x-core.c +25 -0
index 4147cecfbbd6..cee7dfff381f 100644
@@ -39,6 +39,7 @@
 #define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5)
 #define TCAN4X5X_BUS_FAULT BIT(4)
 #define TCAN4X5X_MCAN_INT BIT(1)
+#define TCAN4X5X_VTWD_INT BIT(0)
 #define TCAN4X5X_ENABLE_TCAN_INT \
 	(TCAN4X5X_MCAN_INT | TCAN4X5X_BUS_FAULT | \
 	 TCAN4X5X_CANBUS_ERR_INT_EN | TCAN4X5X_CANINT_INT_EN)
@@ -190,6 +191,16 @@ static int tcan4x5x_power_enable(struct regulator *reg, int enable)
 		return regulator_disable(reg);
 }
 
+static u32 tcan4x5x_read_tcan_reg(struct m_can_classdev *cdev, int reg)
+{
+	struct tcan4x5x_priv *priv = cdev_to_priv(cdev);
+	u32 val;
+
+	regmap_read(priv->regmap, reg, &val);
+
+	return val;
+}
+
 static int tcan4x5x_write_tcan_reg(struct m_can_classdev *cdev,
 				   int reg, int val)
 {
@@ -221,6 +232,19 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
 				       TCAN4X5X_CLEAR_ALL_INT);
 }
 
+static irqreturn_t tcan4x5x_handle_dev_interrupts(struct m_can_classdev *cdev)
+{
+	irqreturn_t ret = IRQ_NONE;
+	int ir;
+
+	ir = tcan4x5x_read_tcan_reg(cdev, TCAN4X5X_INT_FLAGS);
+
+	if (ir & (TCAN4X5X_CANDOM_INT_EN | TCAN4X5X_VTWD_INT))
+		ret = IRQ_HANDLED;
+
+	return ret;
+}
+
 static int tcan4x5x_init(struct m_can_classdev *cdev)
 {
 	struct tcan4x5x_priv *tcan4x5x = cdev_to_priv(cdev);
@@ -305,6 +329,7 @@ static struct m_can_ops tcan4x5x_ops = {
 	.write_fifo = tcan4x5x_write_fifo,
 	.read_fifo = tcan4x5x_read_fifo,
 	.clear_interrupts = tcan4x5x_clear_interrupts,
+	.handle_dev_interrupts = tcan4x5x_handle_dev_interrupts,
 };
 
 static int tcan4x5x_can_probe(struct spi_device *spi)
Signature · 1 line
2.30.2
#7 lore raw

Re: [PATCH RFC can-next 3/3] can: tcan4x5x: add handle_dev_interrupts callback to ops

Quoted 40 lines · Torin Cooper-Bennun

Though the TCAN4550's device-specific interrupts are cleared in tcan4x5x_clear_interrupts(), they are ignored, which may cause the m_can driver to stop working due to the ISR becoming disabled (the famous "nobody cared" message).

---
 drivers/net/can/m_can/tcan4x5x-core.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/net/can/m_can/tcan4x5x-core.c +11 -0
index 4147cecfbbd6..cee7dfff381f 100644
@@ -39,6 +39,7 @@
 #define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5)
 #define TCAN4X5X_BUS_FAULT BIT(4)
 #define TCAN4X5X_MCAN_INT BIT(1)
+#define TCAN4X5X_VTWD_INT BIT(0)
 #define TCAN4X5X_ENABLE_TCAN_INT \
 	(TCAN4X5X_MCAN_INT | TCAN4X5X_BUS_FAULT | \
 	 TCAN4X5X_CANBUS_ERR_INT_EN | TCAN4X5X_CANINT_INT_EN)
@@ -190,6 +191,16 @@ static int tcan4x5x_power_enable(struct regulator *reg, int enable)
 		return regulator_disable(reg);
 }
 
+static u32 tcan4x5x_read_tcan_reg(struct m_can_classdev *cdev, int reg)
+{
+	struct tcan4x5x_priv *priv = cdev_to_priv(cdev);
+	u32 val;
+
+	regmap_read(priv->regmap, reg, &val);
+
+	return val;
+}
+
 static int tcan4x5x_write_tcan_reg(struct m_can_classdev *cdev,
 				   int reg, int val)
 {

drivers/net/can/m_can/tcan4x5x-core.c static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev) · line 240

Quoted 9 lines
drivers/net/can/m_can/tcan4x5x-core.c +6 -0
@@ -221,6 +232,19 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
 				       TCAN4X5X_CLEAR_ALL_INT);
 }
 
+static irqreturn_t tcan4x5x_handle_dev_interrupts(struct m_can_classdev *cdev)
+{
+	irqreturn_t ret = IRQ_NONE;
+	int ir;
+
+	ir = tcan4x5x_read_tcan_reg(cdev, TCAN4X5X_INT_FLAGS);

For new code, please don't wrap the regmap_*() functions so that the error values are ignored. I know, it's a bit annoying to always do the "if (err) return err" dance.

As this is the interrupt handler there's not much we can do in case of an error. In the mcp251xfd driver I print an error message and shut down the interface. You should at least print an error message at the end of the handle_interrupts() function.

I think it's best to have a single handle_interrupts() callback that combines the existing clear_interrupts and this code. If you want to save an SPI transaction and only read the TCAN4X5X_INT_FLAGS if the M_CAN_IR is unset, pass is as 2nd parameter from the generic interrupt handler.

Quoted 11 lines
drivers/net/can/m_can/tcan4x5x-core.c +7 -0
+
+	if (ir & (TCAN4X5X_CANDOM_INT_EN | TCAN4X5X_VTWD_INT))
+		ret = IRQ_HANDLED;
+
+	return ret;
+}
+
 static int tcan4x5x_init(struct m_can_classdev *cdev)
 {
 	struct tcan4x5x_priv *tcan4x5x = cdev_to_priv(cdev);

drivers/net/can/m_can/tcan4x5x-core.c static struct m_can_ops tcan4x5x_ops = { · line 335

Quoted 7 lines
drivers/net/can/m_can/tcan4x5x-core.c +1 -0
@@ -305,6 +329,7 @@ static struct m_can_ops tcan4x5x_ops = {
 	.write_fifo = tcan4x5x_write_fifo,
 	.read_fifo = tcan4x5x_read_fifo,
 	.clear_interrupts = tcan4x5x_clear_interrupts,
+	.handle_dev_interrupts = tcan4x5x_handle_dev_interrupts,
 };
 
 static int tcan4x5x_can_probe(struct spi_device *spi)

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#8 lore raw

Re: [PATCH RFC can-next 3/3] can: tcan4x5x: add handle_dev_interrupts callback to ops

Quoted 3 lines · Marc Kleine-Budde

For new code, please don't wrap the regmap_*() functions so that the error values are ignored. I know, it's a bit annoying to always do the "if (err) return err" dance.

Will do, thanks.

Quoted 4 lines

As this is the interrupt handler there's not much we can do in case of an error. In the mcp251xfd driver I print an error message and shut down the interface. You should at least print an error message at the end of the handle_interrupts() function.

I assume you mean the handling of errors out of aforementioned regmap_*() functions specifically? I agree we should shut down the interface - I've previously endured serious debugging pain due to SPI errors going unrecognised and causing havoc.

Quoted 5 lines

I think it's best to have a single handle_interrupts() callback that combines the existing clear_interrupts and this code. If you want to save an SPI transaction and only read the TCAN4X5X_INT_FLAGS if the M_CAN_IR is unset, pass is as 2nd parameter from the generic interrupt handler.

Yup, agreed.

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#9 lore raw

Re: [PATCH RFC can-next 3/3] can: tcan4x5x: add handle_dev_interrupts callback to ops

Quoted 7 lines · Torin Cooper-Bennun
Quoted 3 lines · Marc Kleine-Budde

For new code, please don't wrap the regmap_*() functions so that the error values are ignored. I know, it's a bit annoying to always do the "if (err) return err" dance.

Will do, thanks.

Quoted 7 lines
Quoted 4 lines

As this is the interrupt handler there's not much we can do in case of an error. In the mcp251xfd driver I print an error message and shut down the interface. You should at least print an error message at the end of the handle_interrupts() function.

I assume you mean the handling of errors out of aforementioned regmap_*() functions specifically?

ACK, I'm talking about the return value of the regmap_() functions.

Quoted 3 lines

I agree we should shut down the interface - I've previously endured serious debugging pain due to SPI errors going unrecognised and causing havoc.

You can eventually do the same, return negative error value from the tcan4x5x handler and the main IRQ handler will shut down the chip. A return value >= 0 would be the IRQ_*.

Some background information:

You have to keep in mind, the regmap_() functions might fail due to a non permanent problem, e.g. resource shortage (out-of-memory, etc...). I decided it's too complicated to properly recover from those, especially if the driver touches some FIFO pointer.

The mcp251xfd chip offers CRC check summing during read. If the driver detect a CRC read error (that stays even after some retries), I let the regmap_read() function to return an error that is then passed down the call stack. And then chip will be shut down.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#10 lore raw

Re: [PATCH RFC can-next 3/3] can: tcan4x5x: add handle_dev_interrupts callback to ops

Quoted 16 lines · Marc Kleine-Budde
Quoted 3 lines · Torin Cooper-Bennun

I agree we should shut down the interface - I've previously endured serious debugging pain due to SPI errors going unrecognised and causing havoc.

You can eventually do the same, return negative error value from the tcan4x5x handler and the main IRQ handler will shut down the chip. A return value >= 0 would be the IRQ_*.

Some background information:

You have to keep in mind, the regmap_() functions might fail due to a non permanent problem, e.g. resource shortage (out-of-memory, etc...). I decided it's too complicated to properly recover from those, especially if the driver touches some FIFO pointer.

Quoted 4 lines

The mcp251xfd chip offers CRC check summing during read. If the driver detect a CRC read error (that stays even after some retries), I let the regmap_read() function to return an error that is then passed down the call stack. And then chip will be shut down.

Cool, I'll keep this in mind.

Obviously tcan4550 has no such SPI checking, but it does have ECC memory at least. Unrecoverable ECC errors are reported in the device interrupts, so that's a good example of something I'd want to respond to with a shutdown!

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#11 lore raw
In reply to Torin Cooper-Bennun
Quoted 8 lines · Torin Cooper-Bennun

Using the TCAN4550, I've had occasions where the m_can driver has fallen over with the "nobody cared" message -- the ISR has returned IRQ_NONE upon "99,900 of the previous 100,000 interrupts" (see kernel/irq/spurious.c, __report_bad_irq()).

While such high numbers certainly indicate some kind of fault, presently, device-specific interrupts are totally ignored -- it may be that such a fault can be handled with a device-specific action.

Do you know why the tcan4x5x specific interrupts are enabled in the first place? If no-one is handling them, just mask/disable/etc then....

Quoted 3 lines

Comments are welcome. One thing right off the bat: I'm not sure whether the new callback should be added alongside clear_interrupts, or if it should replace it.

I don't see why we need two callbacks from the generic interrupt handler, one should be enough.

Quoted 3 lines

I also need to replicate the fault observed with the TCAN4550 - it's unlikely that the handling added in this patchset is effective by itself.

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#12 lore raw
Quoted 6 lines · Marc Kleine-Budde
Quoted 5 lines · Torin Cooper-Bennun

Using the TCAN4550, I've had occasions where the m_can driver has fallen over with the "nobody cared" message -- the ISR has returned IRQ_NONE upon "99,900 of the previous 100,000 interrupts" (see kernel/irq/spurious.c, __report_bad_irq()).

Quoted 6 lines
Quoted 3 lines

While such high numbers certainly indicate some kind of fault, presently, device-specific interrupts are totally ignored -- it may be that such a fault can be handled with a device-specific action.

Do you know why the tcan4x5x specific interrupts are enabled in the first place? If no-one is handling them, just mask/disable/etc then....

The TCAN4550 has interrupts that cannot be disabled or masked, including those for faults involving SPI, power, and transceiver issues (e.g. CAN stuck dominant).

Quoted 7 lines
Quoted 4 lines

Comments are welcome. One thing right off the bat: I'm not sure whether the new callback should be added alongside clear_interrupts, or if it should replace it.

I don't see why we need two callbacks from the generic interrupt handler, one should be enough.

Fair enough, and it makes sense to always clear the device-specific interrupts when handling them anyway.

tcan4x5x needs some cleanup re interrupt init/handling/clearing anyway, so I'll incorporate that next time!

Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#13 lore raw
Quoted 11 lines · Torin Cooper-Bennun
Quoted 10 lines · Marc Kleine-Budde
Quoted 8 lines · Torin Cooper-Bennun

Using the TCAN4550, I've had occasions where the m_can driver has fallen over with the "nobody cared" message -- the ISR has returned IRQ_NONE upon "99,900 of the previous 100,000 interrupts" (see kernel/irq/spurious.c, __report_bad_irq()).

While such high numbers certainly indicate some kind of fault, presently, device-specific interrupts are totally ignored -- it may be that such a fault can be handled with a device-specific action.

Quoted 6 lines
Quoted 2 lines

Do you know why the tcan4x5x specific interrupts are enabled in the first place? If no-one is handling them, just mask/disable/etc then....

The TCAN4550 has interrupts that cannot be disabled or masked, including those for faults involving SPI, power, and transceiver issues (e.g. CAN stuck dominant).

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Comments are welcome. One thing right off the bat: I'm not sure whether the new callback should be added alongside clear_interrupts, or if it should replace it.

I don't see why we need two callbacks from the generic interrupt handler, one should be enough.

Fair enough, and it makes sense to always clear the device-specific interrupts when handling them anyway.

ACK - and return irqreturn_t.

Quoted 2 lines

tcan4x5x needs some cleanup re interrupt init/handling/clearing anyway, so I'll incorporate that next time!

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#14 lore raw
Quoted 6 lines · Marc Kleine-Budde
Quoted 3 lines

The TCAN4550 has interrupts that cannot be disabled or masked, including those for faults involving SPI, power, and transceiver issues (e.g. CAN stuck dominant).

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

In theory, for any of these, clearing the register should be sufficient for the interrupt pin to go inactive... emphasis on "in theory".

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Comments are welcome. One thing right off the bat: I'm not sure whether the new callback should be added alongside clear_interrupts, or if it should replace it.

I don't see why we need two callbacks from the generic interrupt handler, one should be enough.

Fair enough, and it makes sense to always clear the device-specific interrupts when handling them anyway.

ACK - and return irqreturn_t.

Sounds good!

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#15 lore raw
Quoted 10 lines · Torin Cooper-Bennun
Quoted 6 lines · Marc Kleine-Budde
Quoted 3 lines

The TCAN4550 has interrupts that cannot be disabled or masked, including those for faults involving SPI, power, and transceiver issues (e.g. CAN stuck dominant).

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

In theory, for any of these, clearing the register should be sufficient for the interrupt pin to go inactive... emphasis on "in theory".

Ok, but as you noticed in your patch, if no IRQ is pending in M_CAN_IR, the main driver doesn't call the tcan4x5x handler.

So the IRQ stays active, the IRQ handler is repeatedly called and returns IRQ_NONE. Then you get the nobody cared warning.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#16 lore raw
Quoted 9 lines · Marc Kleine-Budde
Quoted 8 lines · Torin Cooper-Bennun
Quoted 6 lines · Marc Kleine-Budde
Quoted 3 lines

The TCAN4550 has interrupts that cannot be disabled or masked, including those for faults involving SPI, power, and transceiver issues (e.g. CAN stuck dominant).

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

Quoted 8 lines
Quoted 2 lines

In theory, for any of these, clearing the register should be sufficient for the interrupt pin to go inactive... emphasis on "in theory".

Ok, but as you noticed in your patch, if no IRQ is pending in M_CAN_IR, the main driver doesn't call the tcan4x5x handler.

So the IRQ stays active, the IRQ handler is repeatedly called and returns IRQ_NONE. Then you get the nobody cared warning.

I miscommunicated a bit there. I was just referring to the fact that some of these interrupts are really broken, e.g. re-asserting for no reason, despite what the datasheet says, yada yada.

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#17 lore raw
In reply to Marc Kleine-Budde
Quoted 2 lines · Marc Kleine-Budde

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

An extra note on this... most of the faults worth responding to here are serious enough that the interface should just be shut down, or at least, the device will need to be init'd again.

I'm surprised no handling was implemented in the first place - makes it very difficult to debug problems when you're prototyping new kit. The driver is written as though these interrupts are meaningless!

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#18 lore raw
Quoted 9 lines · Torin Cooper-Bennun
Quoted 2 lines · Marc Kleine-Budde

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

An extra note on this... most of the faults worth responding to here are serious enough that the interface should just be shut down, or at least, the device will need to be init'd again.

I'm surprised no handling was implemented in the first place -

At least you should write a warning message that you (as a developer) and your users get noticed when these error hits.

Quoted 2 lines

makes it very difficult to debug problems when you're prototyping new kit. The driver is written as though these interrupts are meaningless!

Proper error handling is not trivial....and from my experience, in most cases the documentation of those kinds of errors and how to recover is quite sparse, I haven't looked deep into the tcan4x5x docs though.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#19 lore raw
Quoted 14 lines · Marc Kleine-Budde
Quoted 9 lines · Torin Cooper-Bennun
Quoted 2 lines · Marc Kleine-Budde

Ah, ok. Do they need any handling/acknowledge? You only read TCAN4X5X_INT_FLAGS, are those clear-or-read?

An extra note on this... most of the faults worth responding to here are serious enough that the interface should just be shut down, or at least, the device will need to be init'd again.

I'm surprised no handling was implemented in the first place -

At least you should write a warning message that you (as a developer) and your users get noticed when these error hits.

Quoted 6 lines
Quoted 2 lines

makes it very difficult to debug problems when you're prototyping new kit. The driver is written as though these interrupts are meaningless!

Proper error handling is not trivial....and from my experience, in most cases the documentation of those kinds of errors and how to recover is quite sparse, I haven't looked deep into the tcan4x5x docs though.

I guess I should give credit where it's due, in that the driver works fine without full error handling for the vast majority of cases. It may just be that the application I'm working on is more sensitive to faults.

The docs are fairly sparse on error handling from a programmer's perspective, yes. I've learned more from experience with this chip than from the datasheet!

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#20 lore raw
Quoted 11 lines · Torin Cooper-Bennun
Quoted 3 lines

Proper error handling is not trivial....and from my experience, in most cases the documentation of those kinds of errors and how to recover is quite sparse, I haven't looked deep into the tcan4x5x docs though.

I guess I should give credit where it's due, in that the driver works fine without full error handling for the vast majority of cases. It may just be that the application I'm working on is more sensitive to faults.

The docs are fairly sparse on error handling from a programmer's perspective, yes. I've learned more from experience with this chip than from the datasheet!

That's exactly what I meant :D

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |