Re: 2.5.63: 'Debug: sleeping function called from illegal context

Manfred Spraul (manfred@colorfullife.com)
Sun, 02 Mar 2003 16:15:25 +0100


This is a MIME-formatted message. If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--=_courier-1072-1046618852-0001-2
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Alan wrote:

>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

--=_courier-1072-1046618852-0001-2 Content-Type: text/plain; name=patch-rqd; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-rqd"

// $Header$ // Kernel Version: // VERSION = 2 // PATCHLEVEL = 5 // SUBLEVEL = 63 // EXTRAVERSION = --- 2.5/include/linux/interrupt.h 2002-11-26 17:25:18.000000000 +0100 +++ build-2.5/include/linux/interrupt.h 2003-03-02 15:48:40.000000000 +0100 @@ -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 *); /* --- 2.5/kernel/ksyms.c 2003-02-26 19:08:44.000000000 +0100 +++ build-2.5/kernel/ksyms.c 2003-03-02 15:54:06.000000000 +0100 @@ -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); diff -urN --exclude='*.cmd' --exclude crc32table.h --exclude '*.orig' 2.5/lib/irq.c build-2.5/lib/irq.c --- 2.5/lib/irq.c 1970-01-01 01:00:00.000000000 +0100 +++ build-2.5/lib/irq.c 2003-03-02 16:10:58.000000000 +0100 @@ -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 diff -urN --exclude='*.cmd' --exclude crc32table.h --exclude '*.orig' 2.5/lib/Makefile build-2.5/lib/Makefile --- 2.5/lib/Makefile 2003-02-26 19:08:44.000000000 +0100 +++ build-2.5/lib/Makefile 2003-03-02 15:54:30.000000000 +0100 @@ -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

--=_courier-1072-1046618852-0001-2--