aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/vpe.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2009-09-28 19:52:27 -0400
committerRalf Baechle <ralf@linux-mips.org>2009-09-30 15:47:02 -0400
commit1bbfc20d0161cd94b1b8111566be2fa41b41b608 (patch)
tree53715c15ae796442947fdb0eecb6878f5f4365e3 /arch/mips/kernel/vpe.c
parentc0648e02db689b03564882044f32bc6c6e70c229 (diff)
MIPS: VPE: Get rid of BKL.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/vpe.c')
-rw-r--r--arch/mips/kernel/vpe.c77
1 files changed, 46 insertions, 31 deletions
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index eb6c4c5b7fbe..03092ab2a296 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -144,14 +144,15 @@ struct tc {
144}; 144};
145 145
146struct { 146struct {
147 /* Virtual processing elements */ 147 spinlock_t vpe_list_lock;
148 struct list_head vpe_list; 148 struct list_head vpe_list; /* Virtual processing elements */
149 149 spinlock_t tc_list_lock;
150 /* Thread contexts */ 150 struct list_head tc_list; /* Thread contexts */
151 struct list_head tc_list;
152} vpecontrol = { 151} vpecontrol = {
153 .vpe_list = LIST_HEAD_INIT(vpecontrol.vpe_list), 152 .vpe_list_lock = SPIN_LOCK_UNLOCKED,
154 .tc_list = LIST_HEAD_INIT(vpecontrol.tc_list) 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
157static void release_progmem(void *ptr); 158static void release_progmem(void *ptr);
@@ -159,28 +160,38 @@ static void release_progmem(void *ptr);
159/* get the vpe associated with this minor */ 160/* get the vpe associated with this minor */
160static struct vpe *get_vpe(int minor) 161static struct vpe *get_vpe(int minor)
161{ 162{
162 struct vpe *v; 163 struct vpe *res, *v;
163 164
164 if (!cpu_has_mipsmt) 165 if (!cpu_has_mipsmt)
165 return NULL; 166 return NULL;
166 167
168 res = NULL;
169 spin_lock(&vpecontrol.vpe_list_lock);
167 list_for_each_entry(v, &vpecontrol.vpe_list, list) { 170 list_for_each_entry(v, &vpecontrol.vpe_list, list) {
168 if (v->minor == minor) 171 if (v->minor == minor) {
169 return v; 172 res = v;
173 break;
174 }
170 } 175 }
176 spin_unlock(&vpecontrol.vpe_list_lock);
171 177
172 return NULL; 178 return res;
173} 179}
174 180
175/* get the vpe associated with this minor */ 181/* get the vpe associated with this minor */
176static struct tc *get_tc(int index) 182static struct tc *get_tc(int index)
177{ 183{
178 struct tc *t; 184 struct tc *res, *t;
179 185
186 res = NULL;
187 spin_lock(&vpecontrol.tc_list_lock);
180 list_for_each_entry(t, &vpecontrol.tc_list, list) { 188 list_for_each_entry(t, &vpecontrol.tc_list, list) {
181 if (t->index == index) 189 if (t->index == index) {
182 return t; 190 res = t;
191 break;
192 }
183 } 193 }
194 spin_unlock(&vpecontrol.tc_list_lock);
184 195
185 return NULL; 196 return NULL;
186} 197}
@@ -190,15 +201,17 @@ static struct vpe *alloc_vpe(int minor)
190{ 201{
191 struct vpe *v; 202 struct vpe *v;
192 203
193 if ((v = kzalloc(sizeof(struct vpe), GFP_KERNEL)) == NULL) { 204 if ((v = kzalloc(sizeof(struct vpe), GFP_KERNEL)) == NULL)
194 return NULL; 205 return NULL;
195 }
196 206
197 INIT_LIST_HEAD(&v->tc); 207 INIT_LIST_HEAD(&v->tc);
208 spin_lock(&vpecontrol.vpe_list_lock);
198 list_add_tail(&v->list, &vpecontrol.vpe_list); 209 list_add_tail(&v->list, &vpecontrol.vpe_list);
210 spin_unlock(&vpecontrol.vpe_list_lock);
199 211
200 INIT_LIST_HEAD(&v->notify); 212 INIT_LIST_HEAD(&v->notify);
201 v->minor = minor; 213 v->minor = minor;
214
202 return v; 215 return v;
203} 216}
204 217
@@ -212,7 +225,10 @@ static struct tc *alloc_tc(int index)
212 225
213 INIT_LIST_HEAD(&tc->tc); 226 INIT_LIST_HEAD(&tc->tc);
214 tc->index = index; 227 tc->index = index;
228
229 spin_lock(&vpecontrol.tc_list_lock);
215 list_add_tail(&tc->list, &vpecontrol.tc_list); 230 list_add_tail(&tc->list, &vpecontrol.tc_list);
231 spin_unlock(&vpecontrol.tc_list_lock);
216 232
217out: 233out:
218 return tc; 234 return tc;
@@ -227,7 +243,7 @@ static void release_vpe(struct vpe *v)
227 kfree(v); 243 kfree(v);
228} 244}
229 245
230static void dump_mtregs(void) 246static void __maybe_unused dump_mtregs(void)
231{ 247{
232 unsigned long val; 248 unsigned long val;
233 249
@@ -1048,20 +1064,19 @@ static int vpe_open(struct inode *inode, struct file *filp)
1048 enum vpe_state state; 1064 enum vpe_state state;
1049 struct vpe_notifications *not; 1065 struct vpe_notifications *not;
1050 struct vpe *v; 1066 struct vpe *v;
1051 int ret, err = 0; 1067 int ret;
1052 1068
1053 lock_kernel();
1054 if (minor != iminor(inode)) { 1069 if (minor != iminor(inode)) {
1055 /* assume only 1 device at the moment. */ 1070 /* assume only 1 device at the moment. */
1056 printk(KERN_WARNING "VPE loader: only vpe1 is supported\n"); 1071 pr_warning("VPE loader: only vpe1 is supported\n");
1057 err = -ENODEV; 1072
1058 goto out; 1073 return -ENODEV;
1059 } 1074 }
1060 1075
1061 if ((v = get_vpe(tclimit)) == NULL) { 1076 if ((v = get_vpe(tclimit)) == NULL) {
1062 printk(KERN_WARNING "VPE loader: unable to get vpe\n"); 1077 pr_warning("VPE loader: unable to get vpe\n");
1063 err = -ENODEV; 1078
1064 goto out; 1079 return -ENODEV;
1065 } 1080 }
1066 1081
1067 state = xchg(&v->state, VPE_STATE_INUSE); 1082 state = xchg(&v->state, VPE_STATE_INUSE);
@@ -1101,8 +1116,8 @@ static int vpe_open(struct inode *inode, struct file *filp)
1101 v->shared_ptr = NULL; 1116 v->shared_ptr = NULL;
1102 v->__start = 0; 1117 v->__start = 0;
1103 1118
1104out:
1105 unlock_kernel(); 1119 unlock_kernel();
1120
1106 return 0; 1121 return 0;
1107} 1122}
1108 1123
@@ -1594,14 +1609,14 @@ static void __exit vpe_module_exit(void)
1594{ 1609{
1595 struct vpe *v, *n; 1610 struct vpe *v, *n;
1596 1611
1612 device_del(&vpe_device);
1613 unregister_chrdev(major, module_name);
1614
1615 /* No locking needed here */
1597 list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list) { 1616 list_for_each_entry_safe(v, n, &vpecontrol.vpe_list, list) {
1598 if (v->state != VPE_STATE_UNUSED) { 1617 if (v->state != VPE_STATE_UNUSED)
1599 release_vpe(v); 1618 release_vpe(v);
1600 }
1601 } 1619 }
1602
1603 device_del(&vpe_device);
1604 unregister_chrdev(major, module_name);
1605} 1620}
1606 1621
1607module_init(vpe_module_init); 1622module_init(vpe_module_init);