]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/can_devrtl.c
The use of chip->chip_data is unnecessary, chip->hostdevice points to corresponding...
[lincan.git] / lincan / src / can_devrtl.c
index 5bbc2c0ff2cf7230d32af9f71fce5bd2bb55a8f6..ad6d6c206327050092c492b64547d98b1fbd033d 100644 (file)
@@ -31,6 +31,7 @@ unsigned int can_rtl_isr( unsigned int irq_num, struct pt_regs *r )
        int board_nr;
        int chip_nr;
        int irq2linux=0;
+       int ret;
        pthread_t thread=NULL;
 
        DEBUGMSG("can_rtl_isr invoked for irq %d\n",irq_num);
@@ -44,18 +45,28 @@ unsigned int can_rtl_isr( unsigned int irq_num, struct pt_regs *r )
                                continue;
                        if(chip->chip_irq!=irq_num) continue;
 
+                       if(chip->chipspecops->irq_accept)
+                               ret=chip->chipspecops->irq_accept(chip->chip_irq,chip);
+
                        set_bit(MSGOBJ_IRQ_REQUEST_b,&chip->pend_flags);
                        set_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags);
                        if(chip->flags & CHIP_IRQ_PCI)
                                irq2linux=1;
+#ifdef CAN_ENABLE_VME_SUPPORT
+                       if (chip->flags & CHIP_IRQ_VME)
+                                tundra_rtl_ack_irq_vector(irq_num);
+#endif
                        if(!chip->worker_thread) continue;
                        thread=chip->worker_thread;
                        pthread_kill(thread,RTL_SIGNAL_WAKEUP);
                }
        }
 
-       if(irq2linux)
-               rtl_global_pend_irq(irq_num);
+        /* The following lines are commented out because of it is not
+         * possible to share level activated (PCI) IRQs between Linux
+         * and RT-Linux. */
+/*     if(irq2linux) */
+/*             rtl_global_pend_irq(irq_num); */
 
        /*if(thread) rtl_reschedule_thread(thread);*/
 
@@ -84,6 +95,7 @@ void * can_chip_worker_thread(void *arg)
        struct msgobj_t *obj;
        int ret, i;
        int loop_cnt;
+       rtl_irqstate_t flags;
        
        if(!chip) return 0;
        
@@ -135,18 +147,29 @@ void * can_chip_worker_thread(void *arg)
                if(chip->chip_irq>=0) {
                        if ((chip->flags & CHIP_IRQ_VME) == 0) can_enable_irq(chip->chip_irq);
                    #ifdef CAN_ENABLE_VME_SUPPORT
-                       else tundra_rtl_enable_pci_irq(); 
+                     #if 0
+                       else tundra_rtl_enable_pci_irq();
+                     #endif
                        /* FIXME: Bad practice. Doesn't work with more
-                        * than one card. */
+                        * than one card.
+                        *
+                        * irq_accept added to the LinCAN driver now,
+                        * and above workaround should not be required.
+                        * Enable rtl_hard_enable_irq() at line 
+                        * ca91c042.c:1045
+                        */
                    #endif /*CAN_ENABLE_VME_SUPPORT*/
 
                }
 
+                rtl_no_interrupts (flags);
                RTL_MARK_SUSPENDED(pthread_self());
                if(test_and_clear_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags)){
                        RTL_MARK_READY(pthread_self());
+                        rtl_restore_interrupts (flags);
                        continue;
                }
+                rtl_restore_interrupts (flags);
                rtl_schedule();
 
        }