Cell: clean-up cell_spu_exit() code
authorBrian <brian.paul@tungstengraphics.com>
Thu, 10 Jan 2008 16:13:10 +0000 (09:13 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 10 Jan 2008 18:26:20 +0000 (11:26 -0700)
src/mesa/pipe/cell/ppu/cell_context.c
src/mesa/pipe/cell/ppu/cell_spu.c
src/mesa/pipe/cell/ppu/cell_spu.h

index 4fcf804..57178c8 100644 (file)
@@ -148,7 +148,6 @@ cell_destroy_context( struct pipe_context *pipe )
    struct cell_context *cell = cell_context(pipe);
 
    cell_spu_exit(cell);
-   wait_spus(cell->num_spus);
 
    free(cell);
 }
@@ -255,7 +254,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
 
 #if 0
    test_spus(cell);
-   wait_spus();
 #endif
 
    return &cell->pipe;
index a7dbf24..44ad3f2 100644 (file)
@@ -195,31 +195,22 @@ test_spus(struct cell_context *cell)
 
 
 /**
- * Wait for all SPUs to exit/return.
- */
-void
-wait_spus(uint num_spus)
-{
-   uint i;
-   void *value;
-
-   for (i = 0; i < num_spus; i++) {
-      pthread_join(cell_global.spe_threads[i], &value);
-   }
-}
-
-
-/**
  * Tell all the SPUs to stop/exit.
  */
 void
 cell_spu_exit(struct cell_context *cell)
 {
-   unsigned i;
+   uint i;
 
    for (i = 0; i < cell->num_spus; i++) {
       send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_EXIT);
    }
 
-   wait_spus(cell->num_spus);
+   /* wait for threads to exit */
+   for (i = 0; i < cell->num_spus; i++) {
+      void *value;
+      pthread_join(cell_global.spe_threads[i], &value);
+      cell_global.spe_threads[i] = 0;
+      cell_global.spe_contexts[i] = 0;
+   }
 }
index 612cb45..d11001a 100644 (file)
@@ -83,9 +83,6 @@ test_spus(struct cell_context *cell);
 
 
 void
-wait_spus(uint num_spus);
-
-void
 cell_spu_exit(struct cell_context *cell);