Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i8253: Convert i8253_lock to raw_spinlock

i8253_lock needs to be a real spinlock in preempt-rt, i.e. it can
not be converted to a sleeping lock.

Convert it to raw_spinlock and fix up all users.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Takashi Iwai <tiwai@suse.de>
Cc: Jens Axboe <jens.axboe@oracle.com>
LKML-Reference: <20100217163751.030764372@linutronix.de>

+36 -36
+1 -1
arch/mips/include/asm/i8253.h
··· 12 12 #define PIT_CH0 0x40 13 13 #define PIT_CH2 0x42 14 14 15 - extern spinlock_t i8253_lock; 15 + extern raw_spinlock_t i8253_lock; 16 16 17 17 extern void setup_pit_timer(void); 18 18
+7 -7
arch/mips/kernel/i8253.c
··· 15 15 #include <asm/io.h> 16 16 #include <asm/time.h> 17 17 18 - DEFINE_SPINLOCK(i8253_lock); 18 + DEFINE_RAW_SPINLOCK(i8253_lock); 19 19 EXPORT_SYMBOL(i8253_lock); 20 20 21 21 /* ··· 26 26 static void init_pit_timer(enum clock_event_mode mode, 27 27 struct clock_event_device *evt) 28 28 { 29 - spin_lock(&i8253_lock); 29 + raw_spin_lock(&i8253_lock); 30 30 31 31 switch(mode) { 32 32 case CLOCK_EVT_MODE_PERIODIC: ··· 55 55 /* Nothing to do here */ 56 56 break; 57 57 } 58 - spin_unlock(&i8253_lock); 58 + raw_spin_unlock(&i8253_lock); 59 59 } 60 60 61 61 /* ··· 65 65 */ 66 66 static int pit_next_event(unsigned long delta, struct clock_event_device *evt) 67 67 { 68 - spin_lock(&i8253_lock); 68 + raw_spin_lock(&i8253_lock); 69 69 outb_p(delta & 0xff , PIT_CH0); /* LSB */ 70 70 outb(delta >> 8 , PIT_CH0); /* MSB */ 71 - spin_unlock(&i8253_lock); 71 + raw_spin_unlock(&i8253_lock); 72 72 73 73 return 0; 74 74 } ··· 137 137 static int old_count; 138 138 static u32 old_jifs; 139 139 140 - spin_lock_irqsave(&i8253_lock, flags); 140 + raw_spin_lock_irqsave(&i8253_lock, flags); 141 141 /* 142 142 * Although our caller may have the read side of xtime_lock, 143 143 * this is now a seqlock, and we are cheating in this routine ··· 183 183 old_count = count; 184 184 old_jifs = jifs; 185 185 186 - spin_unlock_irqrestore(&i8253_lock, flags); 186 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 187 187 188 188 count = (LATCH - 1) - count; 189 189
+1 -1
arch/x86/include/asm/i8253.h
··· 6 6 #define PIT_CH0 0x40 7 7 #define PIT_CH2 0x42 8 8 9 - extern spinlock_t i8253_lock; 9 + extern raw_spinlock_t i8253_lock; 10 10 11 11 extern struct clock_event_device *global_clock_event; 12 12
+2 -2
arch/x86/kernel/apm_32.c
··· 1224 1224 #ifdef INIT_TIMER_AFTER_SUSPEND 1225 1225 unsigned long flags; 1226 1226 1227 - spin_lock_irqsave(&i8253_lock, flags); 1227 + raw_spin_lock_irqsave(&i8253_lock, flags); 1228 1228 /* set the clock to HZ */ 1229 1229 outb_pit(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */ 1230 1230 udelay(10); ··· 1232 1232 udelay(10); 1233 1233 outb_pit(LATCH >> 8, PIT_CH0); /* MSB */ 1234 1234 udelay(10); 1235 - spin_unlock_irqrestore(&i8253_lock, flags); 1235 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 1236 1236 #endif 1237 1237 } 1238 1238
+7 -7
arch/x86/kernel/i8253.c
··· 16 16 #include <asm/hpet.h> 17 17 #include <asm/smp.h> 18 18 19 - DEFINE_SPINLOCK(i8253_lock); 19 + DEFINE_RAW_SPINLOCK(i8253_lock); 20 20 EXPORT_SYMBOL(i8253_lock); 21 21 22 22 /* ··· 33 33 static void init_pit_timer(enum clock_event_mode mode, 34 34 struct clock_event_device *evt) 35 35 { 36 - spin_lock(&i8253_lock); 36 + raw_spin_lock(&i8253_lock); 37 37 38 38 switch (mode) { 39 39 case CLOCK_EVT_MODE_PERIODIC: ··· 62 62 /* Nothing to do here */ 63 63 break; 64 64 } 65 - spin_unlock(&i8253_lock); 65 + raw_spin_unlock(&i8253_lock); 66 66 } 67 67 68 68 /* ··· 72 72 */ 73 73 static int pit_next_event(unsigned long delta, struct clock_event_device *evt) 74 74 { 75 - spin_lock(&i8253_lock); 75 + raw_spin_lock(&i8253_lock); 76 76 outb_pit(delta & 0xff , PIT_CH0); /* LSB */ 77 77 outb_pit(delta >> 8 , PIT_CH0); /* MSB */ 78 - spin_unlock(&i8253_lock); 78 + raw_spin_unlock(&i8253_lock); 79 79 80 80 return 0; 81 81 } ··· 130 130 int count; 131 131 u32 jifs; 132 132 133 - spin_lock_irqsave(&i8253_lock, flags); 133 + raw_spin_lock_irqsave(&i8253_lock, flags); 134 134 /* 135 135 * Although our caller may have the read side of xtime_lock, 136 136 * this is now a seqlock, and we are cheating in this routine ··· 176 176 old_count = count; 177 177 old_jifs = jifs; 178 178 179 - spin_unlock_irqrestore(&i8253_lock, flags); 179 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 180 180 181 181 count = (LATCH - 1) - count; 182 182
+2 -2
drivers/block/hd.c
··· 165 165 unsigned long t, flags; 166 166 int i; 167 167 168 - spin_lock_irqsave(&i8253_lock, flags); 168 + raw_spin_lock_irqsave(&i8253_lock, flags); 169 169 t = jiffies * 11932; 170 170 outb_p(0, 0x43); 171 171 i = inb_p(0x40); 172 172 i |= inb(0x40) << 8; 173 - spin_unlock_irqrestore(&i8253_lock, flags); 173 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 174 174 return(t - i); 175 175 } 176 176 #endif
+2 -2
drivers/input/gameport/gameport.c
··· 59 59 unsigned long flags; 60 60 unsigned int count; 61 61 62 - spin_lock_irqsave(&i8253_lock, flags); 62 + raw_spin_lock_irqsave(&i8253_lock, flags); 63 63 outb_p(0x00, 0x43); 64 64 count = inb_p(0x40); 65 65 count |= inb_p(0x40) << 8; 66 - spin_unlock_irqrestore(&i8253_lock, flags); 66 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 67 67 68 68 return count; 69 69 }
+2 -2
drivers/input/joystick/analog.c
··· 146 146 unsigned long flags; 147 147 unsigned int count; 148 148 149 - spin_lock_irqsave(&i8253_lock, flags); 149 + raw_spin_lock_irqsave(&i8253_lock, flags); 150 150 outb_p(0x00, 0x43); 151 151 count = inb_p(0x40); 152 152 count |= inb_p(0x40) << 8; 153 - spin_unlock_irqrestore(&i8253_lock, flags); 153 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 154 154 155 155 return count; 156 156 }
+3 -3
drivers/input/misc/pcspkr.c
··· 30 30 #include <asm/i8253.h> 31 31 #else 32 32 #include <asm/8253pit.h> 33 - static DEFINE_SPINLOCK(i8253_lock); 33 + static DEFINE_RAW_SPINLOCK(i8253_lock); 34 34 #endif 35 35 36 36 static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) ··· 50 50 if (value > 20 && value < 32767) 51 51 count = PIT_TICK_RATE / value; 52 52 53 - spin_lock_irqsave(&i8253_lock, flags); 53 + raw_spin_lock_irqsave(&i8253_lock, flags); 54 54 55 55 if (count) { 56 56 /* set command for counter 2, 2 byte write */ ··· 65 65 outb(inb_p(0x61) & 0xFC, 0x61); 66 66 } 67 67 68 - spin_unlock_irqrestore(&i8253_lock, flags); 68 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 69 69 70 70 return 0; 71 71 }
+1 -1
sound/drivers/pcsp/pcsp.h
··· 16 16 #include <asm/i8253.h> 17 17 #else 18 18 #include <asm/8253pit.h> 19 - static DEFINE_SPINLOCK(i8253_lock); 19 + static DEFINE_RAW_SPINLOCK(i8253_lock); 20 20 #endif 21 21 22 22 #define PCSP_SOUND_VERSION 0x400 /* read 4.00 */
+2 -2
sound/drivers/pcsp/pcsp_input.c
··· 21 21 { 22 22 unsigned long flags; 23 23 24 - spin_lock_irqsave(&i8253_lock, flags); 24 + raw_spin_lock_irqsave(&i8253_lock, flags); 25 25 26 26 if (count) { 27 27 /* set command for counter 2, 2 byte write */ ··· 36 36 outb(inb_p(0x61) & 0xFC, 0x61); 37 37 } 38 38 39 - spin_unlock_irqrestore(&i8253_lock, flags); 39 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 40 40 } 41 41 42 42 void pcspkr_stop_sound(void)
+6 -6
sound/drivers/pcsp/pcsp_lib.c
··· 65 65 timer_cnt = val * CUR_DIV() / 256; 66 66 67 67 if (timer_cnt && chip->enable) { 68 - spin_lock_irqsave(&i8253_lock, flags); 68 + raw_spin_lock_irqsave(&i8253_lock, flags); 69 69 if (!nforce_wa) { 70 70 outb_p(chip->val61, 0x61); 71 71 outb_p(timer_cnt, 0x42); ··· 74 74 outb(chip->val61 ^ 2, 0x61); 75 75 chip->thalf = 1; 76 76 } 77 - spin_unlock_irqrestore(&i8253_lock, flags); 77 + raw_spin_unlock_irqrestore(&i8253_lock, flags); 78 78 } 79 79 80 80 chip->ns_rem = PCSP_PERIOD_NS(); ··· 158 158 return -EIO; 159 159 } 160 160 161 - spin_lock(&i8253_lock); 161 + raw_spin_lock(&i8253_lock); 162 162 chip->val61 = inb(0x61) | 0x03; 163 163 outb_p(0x92, 0x43); /* binary, mode 1, LSB only, ch 2 */ 164 - spin_unlock(&i8253_lock); 164 + raw_spin_unlock(&i8253_lock); 165 165 atomic_set(&chip->timer_active, 1); 166 166 chip->thalf = 0; 167 167 ··· 178 178 return; 179 179 180 180 atomic_set(&chip->timer_active, 0); 181 - spin_lock(&i8253_lock); 181 + raw_spin_lock(&i8253_lock); 182 182 /* restore the timer */ 183 183 outb_p(0xb6, 0x43); /* binary, mode 3, LSB/MSB, ch 2 */ 184 184 outb(chip->val61 & 0xFC, 0x61); 185 - spin_unlock(&i8253_lock); 185 + raw_spin_unlock(&i8253_lock); 186 186 } 187 187 188 188 /*