can: janz-ican3: avoid firmware lockup caused by infinite bus error quota
authorIra W. Snyder <iws@ovro.caltech.edu>
Wed, 18 Jul 2012 22:33:17 +0000 (15:33 -0700)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 20 Jul 2012 15:49:05 +0000 (17:49 +0200)
If the bus error quota is set to infinite and the host CPU cannot keep
up, the Janz VMOD-ICAN3 firmware will stop responding to control
messages until the controller is reset.

The firmware will automatically stop sending bus error messages when the
quota is reached, and will only resume sending bus error messages when
the quota is re-set to a positive value.

This limitation is worked around by setting the bus error quota to one
message, and then re-setting the quota to one message every time a bus
error message is received. By doing this, the firmware never stops
responding to control messages. The CAN bus can be reset without a
hard-reset of the controller card.

Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/janz-ican3.c

index 47f8f6b4fef9f41057a524bee0be5ec3f5ea0259..e06ec403521a14e538cd73e40303ece0decda5e3 100644 (file)
@@ -972,6 +972,16 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
                        stats->rx_errors++;
                }
 
+               /*
+                * The controller automatically disables bus-error interrupts
+                * and therefore we must re-enable them.
+                */
+               ret = ican3_set_buserror(mod, 1);
+               if (ret) {
+                       dev_err(mod->dev, "unable to re-enable bus-error\n");
+                       return ret;
+               }
+
                /* bus error reporting is off, return immediately */
                if (!(mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))
                        return 0;
@@ -1451,7 +1461,7 @@ static int __devinit ican3_startup_module(struct ican3_dev *mod)
        }
 
        /* default to "bus errors enabled" */
-       ret = ican3_set_buserror(mod, ICAN3_BUSERR_QUOTA_MAX);
+       ret = ican3_set_buserror(mod, 1);
        if (ret) {
                dev_err(mod->dev, "unable to set bus-error\n");
                return ret;
This page took 0.069459 seconds and 5 git commands to generate.