diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/sgi-gru/grufile.c | 10 | ||||
-rw-r--r-- | drivers/misc/sgi-gru/grukservices.c | 55 | ||||
-rw-r--r-- | drivers/misc/sgi-gru/grutables.h | 4 |
3 files changed, 41 insertions, 28 deletions
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c index bfc88d1b2a5b..e22012db239e 100644 --- a/drivers/misc/sgi-gru/grufile.c +++ b/drivers/misc/sgi-gru/grufile.c | |||
@@ -287,7 +287,6 @@ static void gru_init_chiplet(struct gru_state *gru, unsigned long paddr, | |||
287 | gru_dbg(grudev, "bid %d, nid %d, gid %d, vaddr %p (0x%lx)\n", | 287 | gru_dbg(grudev, "bid %d, nid %d, gid %d, vaddr %p (0x%lx)\n", |
288 | bid, nid, gru->gs_gid, gru->gs_gru_base_vaddr, | 288 | bid, nid, gru->gs_gid, gru->gs_gru_base_vaddr, |
289 | gru->gs_gru_base_paddr); | 289 | gru->gs_gru_base_paddr); |
290 | gru_kservices_init(gru); | ||
291 | } | 290 | } |
292 | 291 | ||
293 | static int gru_init_tables(unsigned long gru_base_paddr, void *gru_base_vaddr) | 292 | static int gru_init_tables(unsigned long gru_base_paddr, void *gru_base_vaddr) |
@@ -314,6 +313,7 @@ static int gru_init_tables(unsigned long gru_base_paddr, void *gru_base_vaddr) | |||
314 | memset(gru_base[bid], 0, sizeof(struct gru_blade_state)); | 313 | memset(gru_base[bid], 0, sizeof(struct gru_blade_state)); |
315 | gru_base[bid]->bs_lru_gru = &gru_base[bid]->bs_grus[0]; | 314 | gru_base[bid]->bs_lru_gru = &gru_base[bid]->bs_grus[0]; |
316 | spin_lock_init(&gru_base[bid]->bs_lock); | 315 | spin_lock_init(&gru_base[bid]->bs_lock); |
316 | init_rwsem(&gru_base[bid]->bs_kgts_sema); | ||
317 | 317 | ||
318 | dsrbytes = 0; | 318 | dsrbytes = 0; |
319 | cbrs = 0; | 319 | cbrs = 0; |
@@ -426,6 +426,7 @@ static int __init gru_init(void) | |||
426 | printk(KERN_ERR "%s: init tables failed\n", GRU_DRIVER_ID_STR); | 426 | printk(KERN_ERR "%s: init tables failed\n", GRU_DRIVER_ID_STR); |
427 | goto exit3; | 427 | goto exit3; |
428 | } | 428 | } |
429 | gru_kservices_init(); | ||
429 | 430 | ||
430 | printk(KERN_INFO "%s: v%s\n", GRU_DRIVER_ID_STR, | 431 | printk(KERN_INFO "%s: v%s\n", GRU_DRIVER_ID_STR, |
431 | GRU_DRIVER_VERSION_STR); | 432 | GRU_DRIVER_VERSION_STR); |
@@ -444,7 +445,7 @@ exit1: | |||
444 | 445 | ||
445 | static void __exit gru_exit(void) | 446 | static void __exit gru_exit(void) |
446 | { | 447 | { |
447 | int i, bid, gid; | 448 | int i, bid; |
448 | int order = get_order(sizeof(struct gru_state) * | 449 | int order = get_order(sizeof(struct gru_state) * |
449 | GRU_CHIPLETS_PER_BLADE); | 450 | GRU_CHIPLETS_PER_BLADE); |
450 | 451 | ||
@@ -453,10 +454,7 @@ static void __exit gru_exit(void) | |||
453 | 454 | ||
454 | for (i = 0; i < GRU_CHIPLETS_PER_BLADE; i++) | 455 | for (i = 0; i < GRU_CHIPLETS_PER_BLADE; i++) |
455 | free_irq(IRQ_GRU + i, NULL); | 456 | free_irq(IRQ_GRU + i, NULL); |
456 | 457 | gru_kservices_exit(); | |
457 | foreach_gid(gid) | ||
458 | gru_kservices_exit(GID_TO_GRU(gid)); | ||
459 | |||
460 | for (bid = 0; bid < GRU_MAX_BLADES; bid++) | 458 | for (bid = 0; bid < GRU_MAX_BLADES; bid++) |
461 | free_pages((unsigned long)gru_base[bid], order); | 459 | free_pages((unsigned long)gru_base[bid], order); |
462 | 460 | ||
diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c index 7586b89fd0d3..5078f57da882 100644 --- a/drivers/misc/sgi-gru/grukservices.c +++ b/drivers/misc/sgi-gru/grukservices.c | |||
@@ -188,6 +188,34 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * Free all kernel contexts that are not currently in use. | ||
192 | * Returns 0 if all freed, else number of inuse context. | ||
193 | */ | ||
194 | static int gru_free_kernel_contexts(void) | ||
195 | { | ||
196 | struct gru_blade_state *bs; | ||
197 | struct gru_thread_state *kgts; | ||
198 | int bid, ret = 0; | ||
199 | |||
200 | for (bid = 0; bid < GRU_MAX_BLADES; bid++) { | ||
201 | bs = gru_base[bid]; | ||
202 | if (!bs) | ||
203 | continue; | ||
204 | if (down_write_trylock(&bs->bs_kgts_sema)) { | ||
205 | kgts = bs->bs_kgts; | ||
206 | if (kgts && kgts->ts_gru) | ||
207 | gru_unload_context(kgts, 0); | ||
208 | kfree(kgts); | ||
209 | bs->bs_kgts = NULL; | ||
210 | up_write(&bs->bs_kgts_sema); | ||
211 | } else { | ||
212 | ret++; | ||
213 | } | ||
214 | } | ||
215 | return ret; | ||
216 | } | ||
217 | |||
218 | /* | ||
191 | * Lock & load the kernel context for the specified blade. | 219 | * Lock & load the kernel context for the specified blade. |
192 | */ | 220 | */ |
193 | static struct gru_blade_state *gru_lock_kernel_context(int blade_id) | 221 | static struct gru_blade_state *gru_lock_kernel_context(int blade_id) |
@@ -1009,35 +1037,22 @@ int gru_ktest(unsigned long arg) | |||
1009 | case 2: | 1037 | case 2: |
1010 | ret = quicktest2(arg); | 1038 | ret = quicktest2(arg); |
1011 | break; | 1039 | break; |
1040 | case 99: | ||
1041 | ret = gru_free_kernel_contexts(); | ||
1042 | break; | ||
1012 | } | 1043 | } |
1013 | return ret; | 1044 | return ret; |
1014 | 1045 | ||
1015 | } | 1046 | } |
1016 | 1047 | ||
1017 | int gru_kservices_init(struct gru_state *gru) | 1048 | int gru_kservices_init(void) |
1018 | { | 1049 | { |
1019 | struct gru_blade_state *bs; | ||
1020 | |||
1021 | bs = gru->gs_blade; | ||
1022 | if (gru != &bs->bs_grus[0]) | ||
1023 | return 0; | ||
1024 | |||
1025 | init_rwsem(&bs->bs_kgts_sema); | ||
1026 | return 0; | 1050 | return 0; |
1027 | } | 1051 | } |
1028 | 1052 | ||
1029 | void gru_kservices_exit(struct gru_state *gru) | 1053 | void gru_kservices_exit(void) |
1030 | { | 1054 | { |
1031 | struct gru_blade_state *bs; | 1055 | if (gru_free_kernel_contexts()) |
1032 | struct gru_thread_state *kgts; | 1056 | BUG(); |
1033 | |||
1034 | bs = gru->gs_blade; | ||
1035 | if (gru != &bs->bs_grus[0]) | ||
1036 | return; | ||
1037 | |||
1038 | kgts = bs->bs_kgts; | ||
1039 | if (kgts && kgts->ts_gru) | ||
1040 | gru_unload_context(kgts, 0); | ||
1041 | kfree(kgts); | ||
1042 | } | 1057 | } |
1043 | 1058 | ||
diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h index 665704683ab8..9761bfee8669 100644 --- a/drivers/misc/sgi-gru/grutables.h +++ b/drivers/misc/sgi-gru/grutables.h | |||
@@ -638,8 +638,8 @@ extern void gru_unload_context(struct gru_thread_state *gts, int savestate); | |||
638 | extern int gru_update_cch(struct gru_thread_state *gts, int force_unload); | 638 | extern int gru_update_cch(struct gru_thread_state *gts, int force_unload); |
639 | extern void gts_drop(struct gru_thread_state *gts); | 639 | extern void gts_drop(struct gru_thread_state *gts); |
640 | extern void gru_tgh_flush_init(struct gru_state *gru); | 640 | extern void gru_tgh_flush_init(struct gru_state *gru); |
641 | extern int gru_kservices_init(struct gru_state *gru); | 641 | extern int gru_kservices_init(void); |
642 | extern void gru_kservices_exit(struct gru_state *gru); | 642 | extern void gru_kservices_exit(void); |
643 | extern int gru_dump_chiplet_request(unsigned long arg); | 643 | extern int gru_dump_chiplet_request(unsigned long arg); |
644 | extern irqreturn_t gru_intr(int irq, void *dev_id); | 644 | extern irqreturn_t gru_intr(int irq, void *dev_id); |
645 | extern int gru_handle_user_call_os(unsigned long address); | 645 | extern int gru_handle_user_call_os(unsigned long address); |