context.c (8b3d6663c6217e4f50cc3720935a96da9b984117) | context.c (5110459f181ef1f11200bb3dec61953f08cc49e7) |
---|---|
1/* 2 * SPU file system -- SPU context management 3 * 4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 5 * 6 * Author: Arnd Bergmann <arndb@de.ibm.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 31 unchanged lines hidden (view full) --- 40 if (!ctx->csa.lscsa) { 41 goto out_free; 42 } 43 spin_lock_init(&ctx->mmio_lock); 44 kref_init(&ctx->kref); 45 init_rwsem(&ctx->state_sema); 46 init_waitqueue_head(&ctx->ibox_wq); 47 init_waitqueue_head(&ctx->wbox_wq); | 1/* 2 * SPU file system -- SPU context management 3 * 4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 5 * 6 * Author: Arnd Bergmann <arndb@de.ibm.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 31 unchanged lines hidden (view full) --- 40 if (!ctx->csa.lscsa) { 41 goto out_free; 42 } 43 spin_lock_init(&ctx->mmio_lock); 44 kref_init(&ctx->kref); 45 init_rwsem(&ctx->state_sema); 46 init_waitqueue_head(&ctx->ibox_wq); 47 init_waitqueue_head(&ctx->wbox_wq); |
48 init_waitqueue_head(&ctx->stop_wq); |
|
48 ctx->ibox_fasync = NULL; 49 ctx->wbox_fasync = NULL; 50 ctx->state = SPU_STATE_SAVED; 51 ctx->local_store = local_store; 52 ctx->spu = NULL; 53 ctx->ops = &spu_backing_ops; 54 ctx->owner = get_task_mm(current); 55 goto out; --- 44 unchanged lines hidden (view full) --- 100 down_read(&ctx->state_sema); 101} 102 103void spu_release(struct spu_context *ctx) 104{ 105 up_read(&ctx->state_sema); 106} 107 | 49 ctx->ibox_fasync = NULL; 50 ctx->wbox_fasync = NULL; 51 ctx->state = SPU_STATE_SAVED; 52 ctx->local_store = local_store; 53 ctx->spu = NULL; 54 ctx->ops = &spu_backing_ops; 55 ctx->owner = get_task_mm(current); 56 goto out; --- 44 unchanged lines hidden (view full) --- 101 down_read(&ctx->state_sema); 102} 103 104void spu_release(struct spu_context *ctx) 105{ 106 up_read(&ctx->state_sema); 107} 108 |
108static void spu_unmap_mappings(struct spu_context *ctx) | 109void spu_unmap_mappings(struct spu_context *ctx) |
109{ 110 unmap_mapping_range(ctx->local_store, 0, LS_SIZE, 1); 111} 112 113int spu_acquire_runnable(struct spu_context *ctx) 114{ 115 int ret = 0; 116 --- 4 unchanged lines hidden (view full) --- 121 if (!ctx->owner) { 122 ret = -EINVAL; 123 goto out; 124 } 125 up_read(&ctx->state_sema); 126 127 down_write(&ctx->state_sema); 128 if (ctx->state == SPU_STATE_SAVED) { | 110{ 111 unmap_mapping_range(ctx->local_store, 0, LS_SIZE, 1); 112} 113 114int spu_acquire_runnable(struct spu_context *ctx) 115{ 116 int ret = 0; 117 --- 4 unchanged lines hidden (view full) --- 122 if (!ctx->owner) { 123 ret = -EINVAL; 124 goto out; 125 } 126 up_read(&ctx->state_sema); 127 128 down_write(&ctx->state_sema); 129 if (ctx->state == SPU_STATE_SAVED) { |
129 spu_unmap_mappings(ctx); | |
130 ret = spu_activate(ctx, 0); 131 ctx->state = SPU_STATE_RUNNABLE; 132 } 133 downgrade_write(&ctx->state_sema); 134 if (ret) 135 goto out; 136 137 /* On success, we return holding the lock */ --- 11 unchanged lines hidden (view full) --- 149 150 if (ctx->state == SPU_STATE_SAVED) 151 return; 152 153 up_read(&ctx->state_sema); 154 down_write(&ctx->state_sema); 155 156 if (ctx->state == SPU_STATE_RUNNABLE) { | 130 ret = spu_activate(ctx, 0); 131 ctx->state = SPU_STATE_RUNNABLE; 132 } 133 downgrade_write(&ctx->state_sema); 134 if (ret) 135 goto out; 136 137 /* On success, we return holding the lock */ --- 11 unchanged lines hidden (view full) --- 149 150 if (ctx->state == SPU_STATE_SAVED) 151 return; 152 153 up_read(&ctx->state_sema); 154 down_write(&ctx->state_sema); 155 156 if (ctx->state == SPU_STATE_RUNNABLE) { |
157 spu_unmap_mappings(ctx); | |
158 spu_deactivate(ctx); 159 ctx->state = SPU_STATE_SAVED; 160 } 161 162 downgrade_write(&ctx->state_sema); 163} | 157 spu_deactivate(ctx); 158 ctx->state = SPU_STATE_SAVED; 159 } 160 161 downgrade_write(&ctx->state_sema); 162} |