Web lists-archives.com

Re: [linux-usb-devel] RT-friendly IRQ management in USB




Alan Stern wrote:
> On Tue, 3 Jul 2007, Steven Rostedt wrote:
> 

> You never answered my second question.  Is this sort of thing
> acceptable?

Doh! I never noticed your second question. Sorry about that.

> 
> DECLARE_SPINLOCK(lock);
> 
> static void irq_handler()
> {
> 	spin_lock_irqsave(&lock, flags);
> 	...
> 	internal_func();
> 	...
> 	spin_lock_irqrestore(&lock, flags);
> }
> 
> static void internal_func()
> {
> 	...
> 	spin_unlock(&lock);
> 	invoke_callback();
> 	spin_lock(&lock);
> 	...
> }

Perfectly fine! No problems, we do it too.

> 
> For that matter, would it be okay to use spin_lock_irq() rather than
> spin_lock_irqsave() in the IRQ handler?  Assume the handler was
> registered without IRQF_DISABLED.

If it works on vanilla, it should work with RT.  That is, if you use all 
the spin_lock variants.  In RT, spin_lock(), spin_lock_irqsave(), and 
spin_lock_irq() are simply all the same. No difference.


from -rt patch include/linux/spinlock.h:

#ifdef CONFIG_PREEMPT_RT
# define _spin_lock(l)			rt_spin_lock(l)
# define _spin_lock_nested(l, s)	rt_spin_lock_nested(l, s)
# define _spin_lock_bh(l)		rt_spin_lock(l)
# define _spin_lock_irq(l)		rt_spin_lock(l)
# define _spin_unlock(l)		rt_spin_unlock(l)
# define _spin_unlock_no_resched(l)	rt_spin_unlock(l)
# define _spin_unlock_bh(l)		rt_spin_unlock(l)
# define _spin_unlock_irq(l)		rt_spin_unlock(l)
# define _spin_unlock_irqrestore(l, f)	rt_spin_unlock(l)
static inline unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
{
	rt_spin_lock(lock);
	return 0;
}
static inline unsigned long __lockfunc
_spin_lock_irqsave_nested(spinlock_t *lock, int subclass)
{
	rt_spin_lock_nested(lock, subclass);
	return 0;
}
#else

The nesting is for lockdep.

:-)

-- Steve


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@xxxxxxxxxxxxxxxxxxxxx
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel