This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3352: AM335x c_can_isr is called with no stop

Part Number: AM3352


Tool/software: Linux

Refer to SDK7.0
【problem description】

Step1、c_can send frames one by one, with no receiver.

Step2、call function c_can_close ( c_can.c) and function c_can_open repeatedly.  Many times later, strange thing has happened as follow:

Program run:  c_can_close(1216) -> c_can_close(1222) -> c_can_stop(758) -> c_can_isr(1156) -> c_can_isr(1164) ->  c_can_isr(1156) -> c_can_isr(1164) -> c_can_isr(1156) -> c_can_isr(1164) -> ......

All interrupts are disabled, but c_can_isr is called with no stop, why??

program:

1216 static int c_can_close(struct net_device *dev)
1217 {
1218 struct c_can_priv *priv = netdev_priv(dev);
1219
1220 netif_stop_queue(dev);
1221 napi_disable(&priv->napi);
1222 c_can_stop(dev);
1223 free_irq(dev->irq, dev);
1224 close_candev(dev);
1225
1226 c_can_reset_ram(priv, false);
1227 c_can_pm_runtime_put_sync(priv);
1228
1229 can_led_event(dev, CAN_LED_EVENT_STOP);
1230
1231 return 0;
1232}

0752 static void c_can_stop(struct net_device *dev)
0753 {
0754 struct c_can_priv *priv = netdev_priv(dev);
0755
0756 /* disable all interrupts */
0757 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
0758
0759 /* set the state as STOPPED */
0760 priv->can.state = CAN_STATE_STOPPED;
0761 }

1156 static irqreturn_t c_can_isr(int irq, void *dev_id)
1157 {
1158 struct net_device *dev = (struct net_device *)dev_id;
1159 struct c_can_priv *priv = netdev_priv(dev);
1160
1161 priv->irqstatus = priv->read_reg(priv, C_CAN_INT_REG);
1162 if (!priv->irqstatus)
1163 {
1164 return IRQ_NONE;
1165 }
1166
1167 /* disable all interrupts and schedule the NAPI */
1168 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
1169 napi_schedule(&priv->napi);
1170 ltrace(priv->irqstatus);
1171 return IRQ_HANDLED;
1172 }

  • Hi,

    Is it possible to share the values of the bellow CAN registers:
    0h CTL CAN Control Register
    4h ES Error and Status Register
    8h ERRC Error Counter Register
    Ch BTR Bit Timing Register
    10h INT Interrupt Register
    1Ch PERR Parity Error Code Register
    80h ABOTR Auto-Bus-On Time Register
    1E0h TIOC CAN TX IO Control Register
    1E4h RIOC CAN RX IO Control Register

    Best Regards,
    Yordan
  • Hi,

    1、code:

    static irqreturn_t c_can_isr(int irq, void *dev_id)
    {
     struct net_device *dev = (struct net_device *)dev_id;
     struct c_can_priv *priv = netdev_priv(dev);

     priv->irqstatus = priv->read_reg(priv, C_CAN_INT_REG);
     if (!priv->irqstatus)
     {
            printk("CTL %04x\n", readw(priv->base + 0x00));
            printk("%04x\n", readw(priv->base + 0x04));
            printk("%04x\n", readw(priv->base + 0x08));
            printk("%04x\n", readw(priv->base + 0x0C));
            printk("%04x\n", readw(priv->base + 0x10));
            printk("%04x\n", readw(priv->base + 0x1C));
            printk("%04x\n", readw(priv->base + 0x80));
            printk("%04x\n", readw(priv->base + 0x1E0));
            printk("%04x\n", readw(priv->base + 0x1E4));
            return IRQ_NONE;
     } /* disable all interrupts and schedule the NAPI */
     c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
     napi_schedule(&priv->napi);

     return IRQ_HANDLED;
    }

    2、result

    [ 5785.940885] CTL 0000
    [ 5785.943177] 0063
    [ 5785.945100] 0080
    [ 5785.947023] 1c0b
    [ 5785.948946] 0000
    [ 5785.950868] 0000
    [ 5785.952796] 0000
    [ 5785.954720] 000e
    [ 5785.956649] 0009
    [ 5785.958597] CTL 0000
    [ 5785.960890] 0063
    [ 5785.962814] 0080
    [ 5785.964740] 1c0b
    [ 5785.966665] 0000
    [ 5785.968589] 0000
    [ 5785.970513] 0000
    [ 5785.972440] 000e
    [ 5785.974365] 0009
    [ 5785.976311] CTL 0000
    [ 5785.978599] 0063
    [ 5785.980523] 0080
    [ 5785.982445] 1c0b
    [ 5785.984368] 0000
    [ 5785.986292] 0000
    [ 5785.988218] 0000
    [ 5785.990142] 000c
    [ 5785.992065] 0008
    [ 5785.994009] CTL 0000
    [ 5785.996302] 0063
    [ 5785.998228] 0080
    [ 5786.000155] 1c0b
    [ 5786.002083] 0000
    [ 5786.004004] 0000
    [ 5786.005925] 0000
    [ 5786.007850] 000e
    [ 5786.009774] 0009

    Thanks