diff options
author | Christoph Hellwig <hch@lst.de> | 2007-02-13 15:54:25 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@klappe.arndb.de> | 2007-02-13 15:55:41 -0500 |
commit | 678b2ff1e65ecccdb15cbfe97081572fc35944b7 (patch) | |
tree | e73037d691dfa63a58d8df5c66b08b74d69c324f /arch/powerpc/platforms/cell/spufs/sched.c | |
parent | 26bec67386dbf6ef887254e815398842e182cdcd (diff) |
[POWERPC] spu sched: simplity spu_remove_from_active_list
If we call spu_remove_from_active_list that spu is always guaranteed
to be on the active list and in runnable state, so we can simply
do a list_del to remove it and unconditionally take the was_active
codepath.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch/powerpc/platforms/cell/spufs/sched.c')
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/sched.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c index 07d0d095c62a..40202a752a7a 100644 --- a/arch/powerpc/platforms/cell/spufs/sched.c +++ b/arch/powerpc/platforms/cell/spufs/sched.c | |||
@@ -83,27 +83,14 @@ static void spu_add_to_active_list(struct spu *spu) | |||
83 | /** | 83 | /** |
84 | * spu_remove_from_active_list - remove spu from active list | 84 | * spu_remove_from_active_list - remove spu from active list |
85 | * @spu: spu to remove from the active list | 85 | * @spu: spu to remove from the active list |
86 | * | ||
87 | * This function removes an spu from the active list. If the spu was | ||
88 | * found on the active list the function returns 1, else it doesn't do | ||
89 | * anything and returns 0. | ||
90 | */ | 86 | */ |
91 | static int spu_remove_from_active_list(struct spu *spu) | 87 | static void spu_remove_from_active_list(struct spu *spu) |
92 | { | 88 | { |
93 | int node = spu->node; | 89 | int node = spu->node; |
94 | struct spu *tmp; | ||
95 | int rc = 0; | ||
96 | 90 | ||
97 | mutex_lock(&spu_prio->active_mutex[node]); | 91 | mutex_lock(&spu_prio->active_mutex[node]); |
98 | list_for_each_entry(tmp, &spu_prio->active_list[node], list) { | 92 | list_del_init(&spu->list); |
99 | if (tmp == spu) { | ||
100 | list_del_init(&spu->list); | ||
101 | rc = 1; | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | mutex_unlock(&spu_prio->active_mutex[node]); | 93 | mutex_unlock(&spu_prio->active_mutex[node]); |
106 | return rc; | ||
107 | } | 94 | } |
108 | 95 | ||
109 | static inline void mm_needs_global_tlbie(struct mm_struct *mm) | 96 | static inline void mm_needs_global_tlbie(struct mm_struct *mm) |
@@ -167,16 +154,13 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx) | |||
167 | * spu_unbind_context - unbind spu context from physical spu | 154 | * spu_unbind_context - unbind spu context from physical spu |
168 | * @spu: physical spu to unbind from | 155 | * @spu: physical spu to unbind from |
169 | * @ctx: context to unbind | 156 | * @ctx: context to unbind |
170 | * | ||
171 | * If the spu was on the active list the function returns 1, else 0. | ||
172 | */ | 157 | */ |
173 | static int spu_unbind_context(struct spu *spu, struct spu_context *ctx) | 158 | static void spu_unbind_context(struct spu *spu, struct spu_context *ctx) |
174 | { | 159 | { |
175 | int was_active = spu_remove_from_active_list(spu); | ||
176 | |||
177 | pr_debug("%s: unbind pid=%d SPU=%d NODE=%d\n", __FUNCTION__, | 160 | pr_debug("%s: unbind pid=%d SPU=%d NODE=%d\n", __FUNCTION__, |
178 | spu->pid, spu->number, spu->node); | 161 | spu->pid, spu->number, spu->node); |
179 | 162 | ||
163 | spu_remove_from_active_list(spu); | ||
180 | spu_switch_notify(spu, NULL); | 164 | spu_switch_notify(spu, NULL); |
181 | spu_unmap_mappings(ctx); | 165 | spu_unmap_mappings(ctx); |
182 | spu_save(&ctx->csa, spu); | 166 | spu_save(&ctx->csa, spu); |
@@ -193,8 +177,6 @@ static int spu_unbind_context(struct spu *spu, struct spu_context *ctx) | |||
193 | ctx->spu = NULL; | 177 | ctx->spu = NULL; |
194 | spu->flags = 0; | 178 | spu->flags = 0; |
195 | spu->ctx = NULL; | 179 | spu->ctx = NULL; |
196 | |||
197 | return was_active; | ||
198 | } | 180 | } |
199 | 181 | ||
200 | /** | 182 | /** |
@@ -340,17 +322,21 @@ int spu_activate(struct spu_context *ctx, unsigned long flags) | |||
340 | return -ERESTARTSYS; | 322 | return -ERESTARTSYS; |
341 | } | 323 | } |
342 | 324 | ||
325 | /** | ||
326 | * spu_deactivate - unbind a context from it's physical spu | ||
327 | * @ctx: spu context to unbind | ||
328 | * | ||
329 | * Unbind @ctx from the physical spu it is running on and schedule | ||
330 | * the highest priority context to run on the freed physical spu. | ||
331 | */ | ||
343 | void spu_deactivate(struct spu_context *ctx) | 332 | void spu_deactivate(struct spu_context *ctx) |
344 | { | 333 | { |
345 | struct spu *spu; | 334 | struct spu *spu = ctx->spu; |
346 | int was_active; | ||
347 | 335 | ||
348 | spu = ctx->spu; | 336 | if (spu) { |
349 | if (!spu) | 337 | spu_unbind_context(spu, ctx); |
350 | return; | ||
351 | was_active = spu_unbind_context(spu, ctx); | ||
352 | if (was_active) | ||
353 | spu_reschedule(spu); | 338 | spu_reschedule(spu); |
339 | } | ||
354 | } | 340 | } |
355 | 341 | ||
356 | void spu_yield(struct spu_context *ctx) | 342 | void spu_yield(struct spu_context *ctx) |