From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S266517AbUJIGBY (ORCPT ); Sat, 9 Oct 2004 02:01:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S266560AbUJIGBY (ORCPT ); Sat, 9 Oct 2004 02:01:24 -0400 Received: from gateway-1237.mvista.com ([12.44.186.158]:57588 "EHLO av.mvista.com") by vger.kernel.org with ESMTP id S266517AbUJIFsH (ORCPT ); Sat, 9 Oct 2004 01:48:07 -0400 Message-ID: <41677E87.9060400@mvista.com> Date: Fri, 08 Oct 2004 23:00:39 -0700 From: Sven-Thorsten Dietrich User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 X-Accept-Language: en-us, en MIME-Version: 1.0 To: linux-kernel@vger.kernel.org CC: ext-rt-dev@mvista.com Subject: [ANNOUNCE] Linux 2.6 Real Time Kernel - 3 (Spinlock Patch 1) Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org RT Prototype 2004 (C) MontaVista Software, Inc. This file is licensed under the terms of the GNU General Public License version 2. This program is licensed "as is" without any warranty of any kind, whether express or implied. Linux-2.6.9-rc3_RT_spinlock[12].patch ===================================== These are 2 patches substituting mutexes with spinlocks in the RT kernel. A number of spinlocks, especially those protecting scheduler run queues, and some protecting hardware, notably the system timer, cannot be substituted with mutexes. These patches create a partitioning between low-level spinlocks and mutexes in the kernel. There are some holes existing in this partitioning in the current release. As discussed in the introductory email, this can result in deadlock situations, if a process first locks a spinlock, and then suspends on a contended mutex. We are in the process of resolving these issues. New configuration options include: CONFIG_KMUTEX Substitutes mutexes for the spinlock_t, and remaps corresponding operations to mutex_lock, and mutex_unlock. CONFIG_KMUTEX_STATS This enables locking time tracing and other (incomplete) analysis features. CONFIG_KMUTEX_DEBUG Enables additional debugging output CONFIG_KMUTEX_ATOMIC_DEBUG Warns while locking a mutex when the process is running with preemption disabled ("bad: scheduling while atomic") PMutex configuration: CONFIG_PMUTEX Enable PMutex subsystem CONFIG_PMUTEX_PI Enable priority inheritance CONFIG_PMUTEX_PI_DEBUG Report PI events (noisy) Sign-off: Sven-Thorsten Dietrich (sdietrich@mvista.com) diff -pruN a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c --- a/arch/i386/kernel/apic.c 2004-10-08 22:39:58.000000000 +0400 +++ b/arch/i386/kernel/apic.c 2004-10-09 01:26:54.000000000 +0400 @@ -39,6 +39,8 @@ #include "io_ports.h" +#include + /* * Debug level */ diff -pruN a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c --- a/arch/i386/kernel/apm.c 2004-10-08 22:39:58.000000000 +0400 +++ b/arch/i386/kernel/apm.c 2004-10-09 01:26:54.000000000 +0400 @@ -231,7 +231,7 @@ #include "io_ports.h" -extern spinlock_t i8253_lock; +extern _spinlock_t i8253_lock; extern unsigned long get_cmos_time(void); extern void machine_real_restart(unsigned char *, int); @@ -1169,9 +1169,8 @@ static void reinit_timer(void) { #ifdef INIT_TIMER_AFTER_SUSPEND unsigned long flags; - extern spinlock_t i8253_lock; - spin_lock_irqsave(&i8253_lock, flags); + _spin_lock_irqsave(&i8253_lock, flags); /* set the clock to 100 Hz */ outb_p(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */ udelay(10); @@ -1179,7 +1178,7 @@ static void reinit_timer(void) udelay(10); outb(LATCH >> 8, PIT_CH0); /* MSB */ udelay(10); - spin_unlock_irqrestore(&i8253_lock, flags); + _spin_unlock_irqrestore(&i8253_lock, flags); #endif } @@ -1208,14 +1207,14 @@ static int suspend(int vetoable) write_seqlock_irq(&xtime_lock); /* protect against access to timer chip registers */ - spin_lock(&i8253_lock); + _spin_lock(&i8253_lock); get_time_diff(); /* * Irq spinlock must be dropped around set_system_power_state. * We'll undo any timer changes due to interrupts below. */ - spin_unlock(&i8253_lock); + _spin_unlock(&i8253_lock); write_sequnlock_irq(&xtime_lock); save_processor_state(); @@ -1223,12 +1222,12 @@ static int suspend(int vetoable) restore_processor_state(); write_seqlock_irq(&xtime_lock); - spin_lock(&i8253_lock); + _spin_lock(&i8253_lock); reinit_timer(); set_time(); ignore_normal_resume = 1; - spin_unlock(&i8253_lock); + _spin_unlock(&i8253_lock); write_sequnlock_irq(&xtime_lock); if (err == APM_NO_ERROR) diff -pruN a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c --- a/arch/i386/kernel/i8259.c 2004-10-09 00:36:39.000000000 +0400 +++ b/arch/i386/kernel/i8259.c 2004-10-09 01:26:54.000000000 +0400 @@ -38,7 +38,7 @@ * moves to arch independent land */ -spinlock_t i8259A_lock = SPIN_LOCK_UNLOCKED; +_spinlock_t i8259A_lock = _SPIN_LOCK_UNLOCKED; static void end_8259A_irq (unsigned int irq) { @@ -93,13 +93,13 @@ void disable_8259A_irq(unsigned int irq) unsigned int mask = 1 << irq; unsigned long flags; - spin_lock_irqsave(&i8259A_lock, flags); + _spin_lock_irqsave(&i8259A_lock, flags); cached_irq_mask |= mask; if (irq & 8) outb(cached_slave_mask, PIC_SLAVE_IMR); else outb(cached_master_mask, PIC_MASTER_IMR); - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); } void enable_8259A_irq(unsigned int irq) @@ -107,13 +107,13 @@ void enable_8259A_irq(unsigned int irq) unsigned int mask = ~(1 << irq); unsigned long flags; - spin_lock_irqsave(&i8259A_lock, flags); + _spin_lock_irqsave(&i8259A_lock, flags); cached_irq_mask &= mask; if (irq & 8) outb(cached_slave_mask, PIC_SLAVE_IMR); else outb(cached_master_mask, PIC_MASTER_IMR); - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); } int i8259A_irq_pending(unsigned int irq) @@ -122,12 +122,12 @@ int i8259A_irq_pending(unsigned int irq) unsigned long flags; int ret; - spin_lock_irqsave(&i8259A_lock, flags); + _spin_lock_irqsave(&i8259A_lock, flags); if (irq < 8) ret = inb(PIC_MASTER_CMD) & mask; else ret = inb(PIC_SLAVE_CMD) & (mask >> 8); - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); return ret; } @@ -174,7 +174,7 @@ void mask_and_ack_8259A(unsigned int irq unsigned int irqmask = 1 << irq; unsigned long flags; - spin_lock_irqsave(&i8259A_lock, flags); + _spin_lock_irqsave(&i8259A_lock, flags); /* * Lightweight spurious IRQ detection. We do not want * to overdo spurious IRQ handling - it's usually a sign @@ -205,7 +205,7 @@ handle_real_irq: outb(cached_master_mask, PIC_MASTER_IMR); outb(0x60+irq,PIC_MASTER_CMD); /* 'Specific EOI to master */ } - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); return; spurious_8259A_irq: @@ -294,7 +294,7 @@ void init_8259A(int auto_eoi) { unsigned long flags; - spin_lock_irqsave(&i8259A_lock, flags); + _spin_lock_irqsave(&i8259A_lock, flags); outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */ outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */ @@ -328,7 +328,7 @@ void init_8259A(int auto_eoi) outb(cached_master_mask, PIC_MASTER_IMR); /* restore master IRQ mask */ outb(cached_slave_mask, PIC_SLAVE_IMR); /* restore slave IRQ mask */ - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); } /* diff -pruN a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c --- a/arch/i386/kernel/io_apic.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/io_apic.c 2004-10-09 01:26:54.000000000 +0400 @@ -42,6 +42,8 @@ #include "io_ports.h" +# include + static spinlock_t ioapic_lock = SPIN_LOCK_UNLOCKED; /* diff -pruN a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c --- a/arch/i386/kernel/irq.c 2004-10-09 00:36:39.000000000 +0400 +++ b/arch/i386/kernel/irq.c 2004-10-09 01:26:54.000000000 +0400 @@ -47,6 +47,8 @@ static DECLARE_MUTEX(probe_sem); +#include + /* * Linux has a controller-independent x86 interrupt architecture. * every controller has a 'controller-template', that is used diff -pruN a/arch/i386/kernel/semaphore.c b/arch/i386/kernel/semaphore.c --- a/arch/i386/kernel/semaphore.c 2004-08-14 09:36:56.000000000 +0400 +++ b/arch/i386/kernel/semaphore.c 2004-10-09 01:26:54.000000000 +0400 @@ -18,6 +18,8 @@ #include #include +#include + /* * Semaphores are implemented using a two-way counter: * The "count" variable is decremented for each process diff -pruN a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c --- a/arch/i386/kernel/signal.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/signal.c 2004-10-09 01:26:54.000000000 +0400 @@ -41,11 +41,11 @@ sys_sigsuspend(int history0, int history sigset_t saveset; mask &= _BLOCKABLE; - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); saveset = current->blocked; siginitset(¤t->blocked, mask); recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); regs->eax = -EINTR; while (1) { @@ -69,11 +69,11 @@ sys_rt_sigsuspend(struct pt_regs regs) return -EFAULT; sigdelsetmask(&newset, ~_BLOCKABLE); - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); saveset = current->blocked; current->blocked = newset; recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); regs.eax = -EINTR; while (1) { @@ -216,10 +216,10 @@ asmlinkage int sys_sigreturn(unsigned lo goto badframe; sigdelsetmask(&set, ~_BLOCKABLE); - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); current->blocked = set; recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); if (restore_sigcontext(regs, &frame->sc, &eax)) goto badframe; @@ -243,10 +243,10 @@ asmlinkage int sys_rt_sigreturn(unsigned goto badframe; sigdelsetmask(&set, ~_BLOCKABLE); - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); current->blocked = set; recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &eax)) goto badframe; @@ -557,11 +557,11 @@ handle_signal(unsigned long sig, siginfo setup_frame(sig, ka, oldset, regs); if (!(ka->sa.sa_flags & SA_NODEFER)) { - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); sigaddset(¤t->blocked,sig); recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); } } diff -pruN a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c --- a/arch/i386/kernel/time.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/time.c 2004-10-09 01:26:54.000000000 +0400 @@ -67,7 +67,8 @@ #include "io_ports.h" -extern spinlock_t i8259A_lock; +extern _spinlock_t i8259A_lock; + int pit_latch_buggy; /* extern */ #include "do_timer.h" @@ -82,7 +83,7 @@ extern unsigned long wall_jiffies; spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; -spinlock_t i8253_lock = SPIN_LOCK_UNLOCKED; +_spinlock_t i8253_lock = _SPIN_LOCK_UNLOCKED; EXPORT_SYMBOL(i8253_lock); struct timer_opts *cur_timer = &timer_none; @@ -228,11 +229,11 @@ static inline void do_timer_interrupt(in * This will also deassert NMI lines for the watchdog if run * on an 82489DX-based system. */ - spin_lock(&i8259A_lock); + _spin_lock(&i8259A_lock); outb(0x0c, PIC_MASTER_OCW3); /* Ack the IRQ; AEOI will end it automatically. */ inb(PIC_MASTER_POLL); - spin_unlock(&i8259A_lock); + _spin_unlock(&i8259A_lock); } #endif diff -pruN a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c --- a/arch/i386/kernel/timers/timer_cyclone.c 2004-08-14 09:37:26.000000000 +0400 +++ b/arch/i386/kernel/timers/timer_cyclone.c 2004-10-09 01:26:54.000000000 +0400 @@ -19,7 +19,7 @@ #include #include "io_ports.h" -extern spinlock_t i8253_lock; +extern _spinlock_t i8253_lock; /* Number of usecs that the last interrupt was delayed */ static int delay_at_last_interrupt; @@ -55,7 +55,7 @@ static void mark_offset_cyclone(void) write_seqlock(&monotonic_lock); last_offset = ((unsigned long long)last_cyclone_high<<32)|last_cyclone_low; - spin_lock(&i8253_lock); + _spin_lock(&i8253_lock); read_cyclone_counter(last_cyclone_low,last_cyclone_high); /* read values for delay_at_last_interrupt */ @@ -74,7 +74,7 @@ static void mark_offset_cyclone(void) outb(LATCH >> 8, PIT_CH0); count = LATCH - 1; } - spin_unlock(&i8253_lock); + _spin_unlock(&i8253_lock); /* lost tick compensation */ delta = last_cyclone_low - delta; diff -pruN a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c --- a/arch/i386/kernel/timers/timer_pit.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/timers/timer_pit.c 2004-10-09 01:26:54.000000000 +0400 @@ -16,8 +16,8 @@ #include #include -extern spinlock_t i8259A_lock; -extern spinlock_t i8253_lock; +extern _spinlock_t i8259A_lock; +extern _spinlock_t i8253_lock; #include "do_timer.h" #include "io_ports.h" @@ -100,7 +100,7 @@ static unsigned long get_offset_pit(void */ unsigned long jiffies_t; - spin_lock_irqsave(&i8253_lock, flags); + _spin_lock_irqsave(&i8253_lock, flags); /* timer count may underflow right here */ outb_p(0x00, PIT_MODE); /* latch the count ASAP */ @@ -141,7 +141,7 @@ static unsigned long get_offset_pit(void count_p = count; - spin_unlock_irqrestore(&i8253_lock, flags); + _spin_unlock_irqrestore(&i8253_lock, flags); count = ((LATCH-1) - count) * TICK_SIZE; count = (count + LATCH/2) / LATCH; @@ -162,16 +162,16 @@ struct timer_opts timer_pit = { void setup_pit_timer(void) { - extern spinlock_t i8253_lock; + extern _spinlock_t i8253_lock; unsigned long flags; - spin_lock_irqsave(&i8253_lock, flags); + _spin_lock_irqsave(&i8253_lock, flags); outb_p(0x34,PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */ udelay(10); outb_p(LATCH & 0xff , PIT_CH0); /* LSB */ udelay(10); outb(LATCH >> 8 , PIT_CH0); /* MSB */ - spin_unlock_irqrestore(&i8253_lock, flags); + _spin_unlock_irqrestore(&i8253_lock, flags); } static int timer_resume(struct sys_device *dev) diff -pruN a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c --- a/arch/i386/kernel/timers/timer_tsc.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/timers/timer_tsc.c 2004-10-09 01:26:54.000000000 +0400 @@ -35,7 +35,7 @@ static inline void cpufreq_delayed_get(v int tsc_disable __initdata = 0; -extern spinlock_t i8253_lock; +extern _spinlock_t i8253_lock; static int use_tsc; /* Number of usecs that the last interrupt was delayed */ @@ -348,7 +348,7 @@ static void mark_offset_tsc(void) rdtsc(last_tsc_low, last_tsc_high); - spin_lock(&i8253_lock); + _spin_lock(&i8253_lock); outb_p(0x00, PIT_MODE); /* latch the count ASAP */ count = inb_p(PIT_CH0); /* read the latched count */ @@ -365,7 +365,7 @@ static void mark_offset_tsc(void) count = LATCH - 1; } - spin_unlock(&i8253_lock); + _spin_unlock(&i8253_lock); if (pit_latch_buggy) { /* get center value of last 3 time lutch */ diff -pruN a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c --- a/arch/i386/kernel/traps.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/traps.c 2004-10-09 01:26:55.000000000 +0400 @@ -311,11 +311,11 @@ bug: void die(const char * str, struct pt_regs * regs, long err) { static struct { - spinlock_t lock; + _spinlock_t lock; u32 lock_owner; int lock_owner_depth; } die = { - .lock = SPIN_LOCK_UNLOCKED, + .lock = _SPIN_LOCK_UNLOCKED, .lock_owner = -1, .lock_owner_depth = 0 }; @@ -323,7 +323,7 @@ void die(const char * str, struct pt_reg if (die.lock_owner != smp_processor_id()) { console_verbose(); - spin_lock_irq(&die.lock); + _spin_lock_irq(&die.lock); die.lock_owner = smp_processor_id(); die.lock_owner_depth = 0; bust_spinlocks(1); @@ -354,7 +354,7 @@ void die(const char * str, struct pt_reg bust_spinlocks(0); die.lock_owner = -1; - spin_unlock_irq(&die.lock); + _spin_unlock_irq(&die.lock); if (in_interrupt()) panic("Fatal exception in interrupt"); diff -pruN a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c --- a/arch/i386/kernel/vm86.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/kernel/vm86.c 2004-10-09 01:26:55.000000000 +0400 @@ -142,7 +142,7 @@ static void mark_screen_rdonly(struct ta int i; preempt_disable(); - spin_lock(&tsk->mm->page_table_lock); + _spin_lock(&tsk->mm->page_table_lock); pgd = pgd_offset(tsk->mm, 0xA0000); if (pgd_none(*pgd)) goto out; @@ -167,7 +167,7 @@ static void mark_screen_rdonly(struct ta } pte_unmap(mapped); out: - spin_unlock(&tsk->mm->page_table_lock); + _spin_unlock(&tsk->mm->page_table_lock); preempt_enable(); flush_tlb(); } @@ -532,10 +532,10 @@ int handle_vm86_trap(struct kernel_vm86_ return 1; /* we let this handle by the calling routine */ if (current->ptrace & PT_PTRACED) { unsigned long flags; - spin_lock_irqsave(¤t->sighand->siglock, flags); + _spin_lock_irqsave(¤t->sighand->siglock, flags); sigdelset(¤t->blocked, SIGTRAP); recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + _spin_unlock_irqrestore(¤t->sighand->siglock, flags); } send_sig(SIGTRAP, current, 1); current->thread.trap_no = trapno; diff -pruN a/arch/i386/lib/dec_and_lock.c b/arch/i386/lib/dec_and_lock.c --- a/arch/i386/lib/dec_and_lock.c 2004-08-14 09:36:32.000000000 +0400 +++ b/arch/i386/lib/dec_and_lock.c 2004-10-09 01:26:55.000000000 +0400 @@ -10,7 +10,7 @@ #include #include -int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) +int _atomic_dec_and_lock(atomic_t *atomic, _spinlock_t *lock) { int counter; int newcount; @@ -32,9 +32,11 @@ repeat: return 0; slow_path: - spin_lock(lock); + _spin_lock(lock); if (atomic_dec_and_test(atomic)) return 1; - spin_unlock(lock); + _spin_unlock(lock); return 0; } + + diff -pruN a/arch/i386/mach-visws/visws_apic.c b/arch/i386/mach-visws/visws_apic.c --- a/arch/i386/mach-visws/visws_apic.c 2004-08-14 09:36:13.000000000 +0400 +++ b/arch/i386/mach-visws/visws_apic.c 2004-10-09 01:26:55.000000000 +0400 @@ -199,7 +199,7 @@ static irqreturn_t piix4_master_intr(int irq_desc_t *desc; unsigned long flags; - spin_lock_irqsave(&i8259A_lock, flags); + _spin_lock_irqsave(&i8259A_lock, flags); /* Find out what's interrupting in the PIIX4 master 8259 */ outb(0x0c, 0x20); /* OCW3 Poll command */ @@ -236,7 +236,7 @@ static irqreturn_t piix4_master_intr(int outb(0x60 + realirq, 0x20); } - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); desc = irq_desc + realirq; @@ -254,7 +254,7 @@ static irqreturn_t piix4_master_intr(int return IRQ_HANDLED; out_unlock: - spin_unlock_irqrestore(&i8259A_lock, flags); + _spin_unlock_irqrestore(&i8259A_lock, flags); return IRQ_NONE; } diff -pruN a/arch/i386/mach-voyager/voyager_basic.c b/arch/i386/mach-voyager/voyager_basic.c --- a/arch/i386/mach-voyager/voyager_basic.c 2004-08-14 09:36:32.000000000 +0400 +++ b/arch/i386/mach-voyager/voyager_basic.c 2004-10-09 01:26:55.000000000 +0400 @@ -31,6 +31,8 @@ #include #include + +# include /* * Power off function, if any */ diff -pruN a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c --- a/arch/i386/mm/hugetlbpage.c 2004-08-14 09:37:42.000000000 +0400 +++ b/arch/i386/mm/hugetlbpage.c 2004-10-09 01:26:55.000000000 +0400 @@ -19,6 +19,8 @@ #include static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) + # include + { pgd_t *pgd; pmd_t *pmd = NULL; diff -pruN a/arch/i386/mm/ioremap.c b/arch/i386/mm/ioremap.c --- a/arch/i386/mm/ioremap.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/mm/ioremap.c 2004-10-09 01:26:55.000000000 +0400 @@ -18,6 +18,8 @@ #include static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, +# include + unsigned long phys_addr, unsigned long flags) { unsigned long end; diff -pruN a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c --- a/arch/i386/mm/pageattr.c 2004-10-08 22:39:59.000000000 +0400 +++ b/arch/i386/mm/pageattr.c 2004-10-09 01:26:55.000000000 +0400 @@ -13,7 +13,7 @@ #include #include -static spinlock_t cpa_lock = SPIN_LOCK_UNLOCKED; +static _spinlock_t cpa_lock = _SPIN_LOCK_UNLOCKED; static struct list_head df_list = LIST_HEAD_INIT(df_list); @@ -38,9 +38,9 @@ static struct page *split_large_page(uns struct page *base; pte_t *pbase; - spin_unlock_irq(&cpa_lock); + _spin_unlock_irq(&cpa_lock); base = alloc_pages(GFP_KERNEL, 0); - spin_lock_irq(&cpa_lock); + _spin_lock_irq(&cpa_lock); if (!base) return NULL; @@ -74,7 +74,7 @@ static void set_pmd_pte(pte_t *kpte, uns if (PTRS_PER_PMD > 1) return; - spin_lock_irqsave(&pgd_lock, flags); + _spin_lock_irqsave(&pgd_lock, flags); for (page = pgd_list; page; page = (struct page *)page->index) { pgd_t *pgd; pmd_t *pmd; @@ -82,7 +82,7 @@ static void set_pmd_pte(pte_t *kpte, uns pmd = pmd_offset(pgd, address); set_pte_atomic((pte_t *)pmd, pte); } - spin_unlock_irqrestore(&pgd_lock, flags); + _spin_unlock_irqrestore(&pgd_lock, flags); } /* @@ -165,13 +165,13 @@ int change_page_attr(struct page *page, int i; unsigned long flags; - spin_lock_irqsave(&cpa_lock, flags); + _spin_lock_irqsave(&cpa_lock, flags); for (i = 0; i < numpages; i++, page++) { err = __change_page_attr(page, prot); if (err) break; } - spin_unlock_irqrestore(&cpa_lock, flags); + _spin_unlock_irqrestore(&cpa_lock, flags); return err; } @@ -182,9 +182,9 @@ void global_flush_tlb(void) BUG_ON(irqs_disabled()); - spin_lock_irq(&cpa_lock); + _spin_lock_irq(&cpa_lock); list_splice_init(&df_list, &l); - spin_unlock_irq(&cpa_lock); + _spin_unlock_irq(&cpa_lock); flush_map(); n = l.next; while (n != &l) { diff -pruN a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c --- a/arch/i386/mm/pgtable.c 2004-08-14 09:38:11.000000000 +0400 +++ b/arch/i386/mm/pgtable.c 2004-10-09 01:26:55.000000000 +0400 @@ -171,7 +171,7 @@ void pmd_ctor(void *pmd, kmem_cache_t *c * manfred's recommendations and having no core impact whatsoever. * -- wli */ -spinlock_t pgd_lock = SPIN_LOCK_UNLOCKED; +_spinlock_t pgd_lock = _SPIN_LOCK_UNLOCKED; struct page *pgd_list; static inline void pgd_list_add(pgd_t *pgd) @@ -199,7 +199,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *c unsigned long flags; if (PTRS_PER_PMD == 1) - spin_lock_irqsave(&pgd_lock, flags); + _spin_lock_irqsave(&pgd_lock, flags); memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD, swapper_pg_dir + USER_PTRS_PER_PGD, @@ -209,7 +209,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *c return; pgd_list_add(pgd); - spin_unlock_irqrestore(&pgd_lock, flags); + _spin_unlock_irqrestore(&pgd_lock, flags); memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t)); } @@ -218,9 +218,9 @@ void pgd_dtor(void *pgd, kmem_cache_t *c { unsigned long flags; /* can be called from interrupt context */ - spin_lock_irqsave(&pgd_lock, flags); + _spin_lock_irqsave(&pgd_lock, flags); pgd_list_del(pgd); - spin_unlock_irqrestore(&pgd_lock, flags); + _spin_unlock_irqrestore(&pgd_lock, flags); } pgd_t *pgd_alloc(struct mm_struct *mm) diff -pruN a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c --- a/arch/ppc64/kernel/process.c 2004-10-08 22:40:07.000000000 +0400 +++ b/arch/ppc64/kernel/process.c 2004-10-09 01:26:55.000000000 +0400 @@ -62,7 +62,7 @@ struct mm_struct ioremap_mm = { .mm_users = ATOMIC_INIT(2), .mm_count = ATOMIC_INIT(1), .cpu_vm_mask = CPU_MASK_ALL, - .page_table_lock = SPIN_LOCK_UNLOCKED, + .page_table_lock = _SPIN_LOCK_UNLOCKED, }; /* diff -pruN a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c --- a/arch/x86_64/kernel/time.c 2004-10-08 22:40:10.000000000 +0400 +++ b/arch/x86_64/kernel/time.c 2004-10-09 01:26:55.000000000 +0400 @@ -48,7 +48,7 @@ static void cpufreq_delayed_get(void); extern int using_apic_timer; spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; -spinlock_t i8253_lock = SPIN_LOCK_UNLOCKED; +old_spinlock_t i8253_lock = OLD_SPIN_LOCK_UNLOCKED; static int nohpet __initdata = 0; @@ -365,11 +365,11 @@ static irqreturn_t timer_interrupt(int i offset = hpet_readl(HPET_T0_CMP) - hpet_tick; delay = hpet_readl(HPET_COUNTER) - offset; } else { - spin_lock(&i8253_lock); + old_spin_lock(&i8253_lock); outb_p(0x00, 0x43); delay = inb_p(0x40); delay |= inb(0x40) << 8; - spin_unlock(&i8253_lock); + old_spin_unlock(&i8253_lock); delay = LATCH - 1 - delay; } @@ -694,7 +694,7 @@ static unsigned int __init pit_calibrate unsigned long start, end; unsigned long flags; - spin_lock_irqsave(&i8253_lock, flags); + old_spin_lock_irqsave(&i8253_lock, flags); outb((inb(0x61) & ~0x02) | 0x01, 0x61); @@ -707,7 +707,7 @@ static unsigned int __init pit_calibrate sync_core(); rdtscll(end); - spin_unlock_irqrestore(&i8253_lock, flags); + old_spin_unlock_irqrestore(&i8253_lock, flags); return (end - start) / 50; } @@ -772,11 +772,11 @@ void __init pit_init(void) { unsigned long flags; - spin_lock_irqsave(&i8253_lock, flags); + old_spin_lock_irqsave(&i8253_lock, flags); outb_p(0x34, 0x43); /* binary, mode 2, LSB/MSB, ch 0 */ outb_p(LATCH & 0xff, 0x40); /* LSB */ outb_p(LATCH >> 8, 0x40); /* MSB */ - spin_unlock_irqrestore(&i8253_lock, flags); + old_spin_unlock_irqrestore(&i8253_lock, flags); } int __init time_setup(char *str) diff -pruN a/drivers/block/nbd.c b/drivers/block/nbd.c --- a/drivers/block/nbd.c 2004-10-08 22:40:10.000000000 +0400 +++ b/drivers/block/nbd.c 2004-10-09 01:26:55.000000000 +0400 @@ -154,12 +154,12 @@ static int sock_xmit(struct socket *sock /* Allow interception of SIGKILL only * Don't allow other signals to interrupt the transmission */ - spin_lock_irqsave(¤t->sighand->siglock, flags); + _spin_lock_irqsave(¤t->sighand->siglock, flags); oldset = current->blocked; sigfillset(¤t->blocked); sigdelsetmask(¤t->blocked, sigmask(SIGKILL)); recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + _spin_unlock_irqrestore(¤t->sighand->siglock, flags); do { sock->sk->sk_allocation = GFP_NOIO; @@ -179,11 +179,11 @@ static int sock_xmit(struct socket *sock if (signal_pending(current)) { siginfo_t info; - spin_lock_irqsave(¤t->sighand->siglock, flags); + _spin_lock_irqsave(¤t->sighand->siglock, flags); printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n", current->pid, current->comm, dequeue_signal(current, ¤t->blocked, &info)); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + _spin_unlock_irqrestore(¤t->sighand->siglock, flags); result = -EINTR; break; } @@ -197,10 +197,10 @@ static int sock_xmit(struct socket *sock buf += result; } while (size > 0); - spin_lock_irqsave(¤t->sighand->siglock, flags); + _spin_lock_irqsave(¤t->sighand->siglock, flags); current->blocked = oldset; recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); + _spin_unlock_irqrestore(¤t->sighand->siglock, flags); return result; } diff -pruN a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c --- a/drivers/ide/ide-io.c 2004-10-08 22:40:12.000000000 +0400 +++ b/drivers/ide/ide-io.c 2004-10-09 01:26:55.000000000 +0400 @@ -6,6 +6,9 @@ * This code was split off from ide.c. See ide.c for history and original * copyrights. * + * 2004-07-16 Modified by Eugeny S. Mints for RT Prototype. + * RT Prototype 2004 (C) MontaVista Software, Inc. + * * 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, or (at your option) any @@ -1007,8 +1010,16 @@ void ide_do_request (ide_hwgroup_t *hwgr ide_get_lock(ide_intr, hwgroup); /* caller must own ide_lock */ + /* XXX: emints: since irqs in threads patch is employed only routines + * executed from do_IRQ() are executed from a real interrupt context. + * For others holding a lock should be enough. Thus while irqs in + * threads, !irqs_disabled() doesn't a sign that we are not protected + * properly. May be substituted by checking corresponding lock later + * if paranoja. + */ +#ifndef CONFIG_KMUTEX BUG_ON(!irqs_disabled()); - +#endif while (!hwgroup->busy) { hwgroup->busy = 1; drive = choose_drive(hwgroup); diff -pruN a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c --- a/drivers/ide/legacy/hd.c 2004-08-14 09:36:10.000000000 +0400 +++ b/drivers/ide/legacy/hd.c 2004-10-09 01:26:55.000000000 +0400 @@ -160,16 +160,16 @@ unsigned long last_req; unsigned long read_timer(void) { - extern spinlock_t i8253_lock; + extern _spinlock_t i8253_lock; unsigned long t, flags; int i; - spin_lock_irqsave(&i8253_lock, flags); + _spin_lock_irqsave(&i8253_lock, flags); t = jiffies * 11932; outb_p(0, 0x43); i = inb_p(0x40); i |= inb(0x40) << 8; - spin_unlock_irqrestore(&i8253_lock, flags); + _spin_unlock_irqrestore(&i8253_lock, flags); return(t - i); } #endif diff -pruN a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c --- a/drivers/input/gameport/gameport.c 2004-08-14 09:36:58.000000000 +0400 +++ b/drivers/input/gameport/gameport.c 2004-10-09 01:26:55.000000000 +0400 @@ -19,6 +19,9 @@ #include #include +# include + + MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("Generic gameport layer"); MODULE_LICENSE("GPL"); @@ -42,15 +45,15 @@ static LIST_HEAD(gameport_dev_list); static unsigned int get_time_pit(void) { - extern spinlock_t i8253_lock; + extern _spinlock_t i8253_lock; unsigned long flags; unsigned int count; - spin_lock_irqsave(&i8253_lock, flags); + _spin_lock_irqsave(&i8253_lock, flags); outb_p(0x00, 0x43); count = inb_p(0x40); count |= inb_p(0x40) << 8; - spin_unlock_irqrestore(&i8253_lock, flags); + _spin_unlock_irqrestore(&i8253_lock, flags); return count; } diff -pruN a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c --- a/drivers/input/serio/i8042.c 2004-10-09 00:36:39.000000000 +0400 +++ b/drivers/input/serio/i8042.c 2004-10-09 01:26:55.000000000 +0400 @@ -24,6 +24,8 @@ #include #include +# include + #include MODULE_AUTHOR("Vojtech Pavlik "); diff -pruN a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c --- a/drivers/media/video/saa5249.c 2004-08-14 09:37:37.000000000 +0400 +++ b/drivers/media/video/saa5249.c 2004-10-09 01:26:56.000000000 +0400 @@ -12,7 +12,7 @@ * * Copyright (c) 1998 Richard Guenther * - * $Id: saa5249.c,v 1.1 1998/03/30 22:23:23 alan Exp $ + * $Id$ * * Derived From * @@ -269,17 +269,17 @@ static void jdelay(unsigned long delay) { sigset_t oldblocked = current->blocked; - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); sigfillset(¤t->blocked); recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); current->state = TASK_INTERRUPTIBLE; schedule_timeout(delay); - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); current->blocked = oldblocked; recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); } diff -pruN a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c --- a/drivers/mtd/mtd_blkdevs.c 2004-08-14 09:36:11.000000000 +0400 +++ b/drivers/mtd/mtd_blkdevs.c 2004-10-09 01:26:56.000000000 +0400 @@ -1,5 +1,5 @@ /* - * $Id: mtd_blkdevs.c,v 1.22 2004/07/12 12:35:28 dwmw2 Exp $ + * $Id$ * * (C) 2003 David Woodhouse * @@ -89,10 +89,10 @@ static int mtd_blktrans_thread(void *arg actually want to deal with signals. We can't just call exit_sighand() since that'll cause an oops when we finally do exit. */ - spin_lock_irq(¤t->sighand->siglock); + _spin_lock_irq(¤t->sighand->siglock); sigfillset(¤t->blocked); recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); + _spin_unlock_irq(¤t->sighand->siglock); spin_lock_irq(rq->queue_lock); diff -pruN a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c --- a/drivers/scsi/dpt_i2o.c 2004-08-14 09:37:38.000000000 +0400 +++ b/drivers/scsi/dpt_i2o.c 2004-10-09 01:26:56.000000000 +0400 @@ -1159,9 +1159,9 @@ static int adpt_i2o_post_wait(adpt_hba* // this code is taken from kernel/sched.c:interruptible_sleep_on_timeout wait.task = current; init_waitqueue_entry(&wait, current); - spin_lock_irqsave(&adpt_wq_i2o_post.lock, flags); + _spin_lock_irqsave(&adpt_wq_i2o_post.lock, flags); __add_wait_queue(&adpt_wq_i2o_post, &wait); - spin_unlock(&adpt_wq_i2o_post.lock); + _spin_unlock(&adpt_wq_i2o_post.lock); msg[2] |= 0x80000000 | ((u32)wait_data->id); timeout *= HZ; @@ -1184,9 +1184,9 @@ static int adpt_i2o_post_wait(adpt_hba* if(pHba->host) spin_lock_irq(pHba->host->host_lock); } - spin_lock_irq(&adpt_wq_i2o_post.lock); + _spin_lock_irq(&adpt_wq_i2o_post.lock); __remove_wait_queue(&adpt_wq_i2o_post, &wait); - spin_unlock_irqrestore(&adpt_wq_i2o_post.lock, flags); + _spin_unlock_irqrestore(&adpt_wq_i2o_post.lock, flags); if(status == -ETIMEDOUT){ printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit); diff -pruN a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c --- a/drivers/video/console/vgacon.c 2004-08-14 09:36:57.000000000 +0400 +++ b/drivers/video/console/vgacon.c 2004-10-09 01:26:56.000000000 +0400 @@ -52,6 +52,8 @@ #include