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

MIPS: VPE: Get rid of BKL.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

+51 -43
+4 -11
arch/mips/kernel/rtlx.c
··· 72 72 */ 73 73 static irqreturn_t rtlx_interrupt(int irq, void *dev_id) 74 74 { 75 + unsigned int vpeflags; 76 + unsigned long flags; 75 77 int i; 76 - unsigned int flags, vpeflags; 77 78 78 79 /* Ought not to be strictly necessary for SMTC builds */ 79 80 local_irq_save(flags); ··· 393 392 394 393 static int file_open(struct inode *inode, struct file *filp) 395 394 { 396 - int minor = iminor(inode); 397 - int err; 398 - 399 - lock_kernel(); 400 - err = rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1); 401 - unlock_kernel(); 402 - return err; 395 + return rtlx_open(iminor(inode), (filp->f_flags & O_NONBLOCK) ? 0 : 1); 403 396 } 404 397 405 398 static int file_release(struct inode *inode, struct file *filp) 406 399 { 407 - int minor = iminor(inode); 408 - 409 - return rtlx_release(minor); 400 + return rtlx_release(iminor(inode)); 410 401 } 411 402 412 403 static unsigned int file_poll(struct file *file, poll_table * wait)
+47 -32
arch/mips/kernel/vpe.c
··· 144 144 }; 145 145 146 146 struct { 147 - /* Virtual processing elements */ 148 - struct list_head vpe_list; 149 - 150 - /* Thread contexts */ 151 - struct list_head tc_list; 147 + spinlock_t vpe_list_lock; 148 + struct list_head vpe_list; /* Virtual processing elements */ 149 + spinlock_t tc_list_lock; 150 + struct list_head tc_list; /* Thread contexts */ 152 151 } vpecontrol = { 153 - .vpe_list = LIST_HEAD_INIT(vpecontrol.vpe_list), 154 - .tc_list = LIST_HEAD_INIT(vpecontrol.tc_list) 152 + .vpe_list_lock = SPIN_LOCK_UNLOCKED, 153 + .vpe_list = LIST_HEAD_INIT(vpecontrol.vpe_list), 154 + .tc_list_lock = SPIN_LOCK_UNLOCKED, 155 + .tc_list = LIST_HEAD_INIT(vpecontrol.tc_list) 155 156 }; 156 157 157 158 static void release_progmem(void *ptr); ··· 160 159 /* get the vpe associated with this minor */ 161 160 static struct vpe *get_vpe(int minor) 162 161 { 163 - struct vpe *v; 162 + struct vpe *res, *v; 164 163 165 164 if (!cpu_has_mipsmt) 166 165 return NULL; 167 166 167 + res = NULL; 168 + spin_lock(&vpecontrol.vpe_list_lock); 168 169 list_for_each_entry(v, &vpecontrol.vpe_list, list) { 169 - if (v->minor == minor) 170 - return v; 170 + if (v->minor == minor) { 171 + res = v; 172 + break; 173 + } 171 174 } 175 + spin_unlock(&vpecontrol.vpe_list_lock); 172 176 173 - return NULL; 177 + return res; 174 178 } 175 179 176 180 /* get the vpe associated with this minor */ 177 181 static struct tc *get_tc(int index) 178 182 { 179 - struct tc *t; 183 + struct tc *res, *t; 180 184 185 + res = NULL; 186 + spin_lock(&vpecontrol.tc_list_lock); 181 187 list_for_each_entry(t, &vpecontrol.tc_list, list) { 182 - if (t->index == index) 183 - return t; 188 + if (t->index == index) { 189 + res = t; 190 + break; 191 + } 184 192 } 193 + spin_unlock(&vpecontrol.tc_list_lock); 185 194 186 195 return NULL; 187 196 } ··· 201 190 { 202 191 struct vpe *v; 203 192 204 - if ((v = kzalloc(sizeof(struct vpe), GFP_KERNEL)) == NULL) { 193 + if ((v = kzalloc(sizeof(struct vpe), GFP_KERNEL)) == NULL) 205 194 return NULL; 206 - } 207 195 208 196 INIT_LIST_HEAD(&v->tc); 197 + spin_lock(&vpecontrol.vpe_list_lock); 209 198 list_add_tail(&v->list, &vpecontrol.vpe_list); 199 + spin_unlock(&vpecontrol.vpe_list_lock); 210 200 211 201 INIT_LIST_HEAD(&v->notify); 212 202 v->minor = minor; 203 + 213 204 return v; 214 205 } 215 206 ··· 225 212 226 213 INIT_LIST_HEAD(&tc->tc); 227 214 tc->index = index; 215 + 216 + spin_lock(&vpecontrol.tc_list_lock); 228 217 list_add_tail(&tc->list, &vpecontrol.tc_list); 218 + spin_unlock(&vpecontrol.tc_list_lock); 229 219 230 220 out: 231 221 return tc; ··· 243 227 kfree(v); 244 228 } 245 229 246 - static void dump_mtregs(void) 230 + static void __maybe_unused dump_mtregs(void) 247 231 { 248 232 unsigned long val; 249 233 ··· 1064 1048 enum vpe_state state; 1065 1049 struct vpe_notifications *not; 1066 1050 struct vpe *v; 1067 - int ret, err = 0; 1051 + int ret; 1068 1052 1069 - lock_kernel(); 1070 1053 if (minor != iminor(inode)) { 1071 1054 /* assume only 1 device at the moment. */ 1072 - printk(KERN_WARNING "VPE loader: only vpe1 is supported\n"); 1073 - err = -ENODEV; 1074 - goto out; 1055 + pr_warning("VPE loader: only vpe1 is supported\n"); 1056 + 1057 + return -ENODEV; 1075 1058 } 1076 1059 1077 1060 if ((v = get_vpe(tclimit)) == NULL) { 1078 - printk(KERN_WARNING "VPE loader: unable to get vpe\n"); 1079 - err = -ENODEV; 1080 - goto out; 1061 + pr_warning("VPE loader: unable to get vpe\n"); 1062 + 1063 + return -ENODEV; 1081 1064 } 1082 1065 1083 1066 state = xchg(&v->state, VPE_STATE_INUSE); ··· 1116 1101 v->shared_ptr = NULL; 1117 1102 v->__start = 0; 1118 1103 1119 - out: 1120 1104 unlock_kernel(); 1105 + 1121 1106 return 0; 1122 1107 } 1123 1108 ··· 1609 1594 { 1610 1595 struct vpe *v, *n; 1611 1596 1612 - list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list) { 1613 - if (v->state != VPE_STATE_UNUSED) { 1614 - release_vpe(v); 1615 - } 1616 - } 1617 - 1618 1597 device_del(&vpe_device); 1619 1598 unregister_chrdev(major, module_name); 1599 + 1600 + /* No locking needed here */ 1601 + list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list) { 1602 + if (v->state != VPE_STATE_UNUSED) 1603 + release_vpe(v); 1604 + } 1620 1605 } 1621 1606 1622 1607 module_init(vpe_module_init);