2.5.63: 'Debug: sleeping function called from illegal context
Quoted 4 lines · Alan
Unfortunately ten years ago someone created '
register_and_activate_irq' calling it 'register_irq', and it hasn't yet been fixed.
Then it's time to fix that.
I would propose something like the attached patch - it handles all archs that support disable_irq on an unregistered interrupt. The remaining arch [which one, btw] must implement request_irq_disabled().
--
Manfred
// $Header$
// Kernel Version:
// VERSION = 2 // PATCHLEVEL = 5 // SUBLEVEL = 63 // EXTRAVERSION =
include/linux/interrupt.h +3 -0
@@ -23,6 +23,9 @@extern int request_irq (unsigned int ,void (*handler)(int ,void *,struct pt_regs *),unsigned long ,const char *,void *); +extern int request_irq_disabled (unsigned int , +void (*handler)(int ,void *,struct pt_regs *), +unsigned long ,const char *,void *);extern void free_irq (unsigned int ,void *);/*
kernel/ksyms.c +1 -0
@@ -404,6 +404,7 @@EXPORT_SYMBOL (add_timer);EXPORT_SYMBOL (del_timer);EXPORT_SYMBOL (request_irq); +EXPORT_SYMBOL (request_irq_disabled);EXPORT_SYMBOL (free_irq);EXPORT_SYMBOL (irq_stat);
lib/irq.c +39 -0
@@ -0,0 +1,39 @@ +/* +* linux/lib/irq.c: arch independant helper functions for irq handling. +* +* Copyright (C) 2003 Manfred Spraul +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/ + +#include <linux/config.h> +#include <linux/interrupt.h> + +#ifndef __HAVE_ARCH_REQUEST_IRQ_DISABLED +int request_irq_disabled (unsigned int irq, +void (*handler)(int ,void *,struct pt_regs *), +unsigned long irqflags, +const char * devname, +void *dev_id) +{ +int retval; +disable_irq (irq); + retval =request_irq (irq, handler, irqflags, devname, dev_id); +if (retval <0 ) +enable_irq (irq); +return retval; +} +#endif
lib/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-y := errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \ bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ - kobject.o idr.o + kobject.o idr.o irq.o obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
lib/irq.c line 39
Quoted 13 lines · Manfred Spraul
I would propose something like the attached patch - it handles all archs that support
disable_irqon an unregistered interrupt. The remaining arch [which one, btw] must implementrequest_irq_disabled().
...lib/irq.c +9
-0+{ +int retval; +disable_irq (irq); + retval =request_irq (irq, handler, irqflags, devname, dev_id); +if (retval <0 ) +enable_irq (irq); +return retval; +} +#endif
request_irq() explicitly enables the interrupt source no matter how many times you call disable_irq() before hand.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Quoted 3 lines · Manfred Spraul
I would propose something like the attached patch - it handles all archs that support
disable_irqon an unregistered interrupt. The remaining arch [which one, btw] must implementrequest_irq_disabled().
Some m68k at least and possibly others.