sgi-gru: fix bugs related to module unload of the GRU driver
authorJack Steiner <steiner@sgi.com>
Thu, 2 Apr 2009 23:59:11 +0000 (16:59 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 Apr 2009 02:05:07 +0000 (19:05 -0700)
Fix bugs related to module unload of the GRU driver.

Signed-off-by: Jack Steiner <steiner@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/misc/sgi-gru/grufile.c
drivers/misc/sgi-gru/grukservices.c
drivers/misc/sgi-gru/grutables.h

index b7a21ce914966820c0c50145c42c6b289a7296a3..3e6e42d2f01b559c93d5396852e2830a3cc9316a 100644 (file)
@@ -440,7 +440,7 @@ exit1:
 
 static void __exit gru_exit(void)
 {
-       int i, bid;
+       int i, bid, gid;
        int order = get_order(sizeof(struct gru_state) *
                              GRU_CHIPLETS_PER_BLADE);
 
@@ -450,6 +450,9 @@ static void __exit gru_exit(void)
        for (i = 0; i < GRU_CHIPLETS_PER_BLADE; i++)
                free_irq(IRQ_GRU + i, NULL);
 
+       foreach_gid(gid)
+               gru_kservices_exit(GID_TO_GRU(gid));
+
        for (bid = 0; bid < GRU_MAX_BLADES; bid++)
                free_pages((unsigned long)gru_base[bid], order);
 
index a371284311552197794ad7da0492980d9668822b..6b1efe4472741a82b95809e0bfb2236db7aa16d4 100644 (file)
@@ -690,3 +690,22 @@ int gru_kservices_init(struct gru_state *gru)
                quicktest(gru);
        return 0;
 }
+
+void gru_kservices_exit(struct gru_state *gru)
+{
+       struct gru_context_configuration_handle *cch;
+       struct gru_blade_state *bs;
+
+       bs = gru->gs_blade;
+       if (gru != &bs->bs_grus[1])
+               return;
+
+       cch = get_cch(gru->gs_gru_base_vaddr, KERNEL_CTXNUM);
+       lock_cch_handle(cch);
+       if (cch_interrupt_sync(cch))
+               BUG();
+       if (cch_deallocate(cch))
+               BUG();
+       unlock_cch_handle(cch);
+}
+
index c6e0e3de07f3ddcc9552830580364e1af6a8b2d9..8e5c8e5bb5338211c5e2dc7492f3899cf5ee8a95 100644 (file)
@@ -600,6 +600,7 @@ extern void gru_unload_context(struct gru_thread_state *gts, int savestate);
 extern void gts_drop(struct gru_thread_state *gts);
 extern void gru_tgh_flush_init(struct gru_state *gru);
 extern int gru_kservices_init(struct gru_state *gru);
+extern void gru_kservices_exit(struct gru_state *gru);
 extern irqreturn_t gru_intr(int irq, void *dev_id);
 extern int gru_handle_user_call_os(unsigned long address);
 extern int gru_user_flush_tlb(unsigned long arg);