diff options
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/context.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c index 1758cec58bc7..903c35d19577 100644 --- a/arch/powerpc/platforms/cell/spufs/context.c +++ b/arch/powerpc/platforms/cell/spufs/context.c | |||
@@ -120,27 +120,29 @@ int spu_acquire_runnable(struct spu_context *ctx) | |||
120 | ctx->spu->prio = current->prio; | 120 | ctx->spu->prio = current->prio; |
121 | return 0; | 121 | return 0; |
122 | } | 122 | } |
123 | up_read(&ctx->state_sema); | ||
124 | |||
125 | down_write(&ctx->state_sema); | ||
123 | /* ctx is about to be freed, can't acquire any more */ | 126 | /* ctx is about to be freed, can't acquire any more */ |
124 | if (!ctx->owner) { | 127 | if (!ctx->owner) { |
125 | ret = -EINVAL; | 128 | ret = -EINVAL; |
126 | goto out; | 129 | goto out; |
127 | } | 130 | } |
128 | up_read(&ctx->state_sema); | ||
129 | 131 | ||
130 | down_write(&ctx->state_sema); | ||
131 | if (ctx->state == SPU_STATE_SAVED) { | 132 | if (ctx->state == SPU_STATE_SAVED) { |
132 | ret = spu_activate(ctx, 0); | 133 | ret = spu_activate(ctx, 0); |
133 | ctx->state = SPU_STATE_RUNNABLE; | 134 | ctx->state = SPU_STATE_RUNNABLE; |
134 | } | 135 | } |
135 | downgrade_write(&ctx->state_sema); | ||
136 | if (ret) | 136 | if (ret) |
137 | goto out; | 137 | goto out; |
138 | 138 | ||
139 | downgrade_write(&ctx->state_sema); | ||
139 | /* On success, we return holding the lock */ | 140 | /* On success, we return holding the lock */ |
141 | |||
140 | return ret; | 142 | return ret; |
141 | out: | 143 | out: |
142 | /* Release here, to simplify calling code. */ | 144 | /* Release here, to simplify calling code. */ |
143 | up_read(&ctx->state_sema); | 145 | up_write(&ctx->state_sema); |
144 | 146 | ||
145 | return ret; | 147 | return ret; |
146 | } | 148 | } |