From 97a5719eb25552dac9296b0e41ecf104c3ea5c17 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Wed, 25 Jul 2001 23:21:02 +0000 Subject: [PATCH] fix to prevent use of rt interrupt with shared interrupt --- comedi/rt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/comedi/rt.c b/comedi/rt.c index 470cbe21..b481a52c 100644 --- a/comedi/rt.c +++ b/comedi/rt.c @@ -90,13 +90,25 @@ int comedi_request_irq(unsigned irq,void (*handler)(int, void *,struct pt_regs * it->handler=handler; it->irq=irq; it->dev_id=dev_id; - it->flags=flags; it->device=device; - ret=request_irq(irq,handler,flags,device,dev_id); + /* null shared interrupt flag, since rt interrupt handlers do not + * support it, and this version of comedi_request_irq() is only + * called for kernels with rt support */ + it->flags = flags & ~SA_SHIRQ; + + ret=request_irq(irq,handler,it->flags,device,dev_id); if(ret<0){ - kfree(it); - return ret; + // we failed, so fall back on allowing shared interrupt + if(flags & SA_SHIRQ) + { + it->flags = flags; + ret=request_irq(irq,handler,it->flags,device,dev_id); + } + if(ret<0){ + kfree(it); + return ret; + } } comedi_irqs[irq]=it; @@ -127,9 +139,16 @@ void comedi_switch_to_rt(comedi_device *dev) { struct comedi_irq_struct *it=comedi_irqs[dev->irq]; + // this prevents crashes with comedi_rt_timer if(it == NULL) return; + // rt interrupts and shared interrupts don't mix + if(it->flags & SA_SHIRQ){ + rt_printk("comedi: cannot switch shared interrupt to real time priority\n"); + return; + } + spin_lock_irq(&dev->spinlock); RT_protect(); sti(); @@ -147,9 +166,14 @@ void comedi_switch_to_non_rt(comedi_device *dev) { struct comedi_irq_struct *it=comedi_irqs[dev->irq]; + // this prevents crashes with comedi_rt_timer if(it == NULL) return; + // rt interrupts and shared interrupts don't mix + if(it->flags & SA_SHIRQ) + return; + RT_spin_lock_irq(&dev->spinlock); dev->rt--; -- 2.26.2