Commit 8837d921 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Paul Mackerras

[PATCH] spufs: clean up use of bitops

checking bits manually might not be synchonized with
the use of set_bit/clear_bit. Make sure we always use
the correct bitops by removing the unnecessary
identifiers.
Signed-off-by: default avatarArnd Bergmann <arndb@de.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 3f51dd91
...@@ -63,7 +63,7 @@ static void spu_restart_dma(struct spu *spu) ...@@ -63,7 +63,7 @@ static void spu_restart_dma(struct spu *spu)
{ {
struct spu_priv2 __iomem *priv2 = spu->priv2; struct spu_priv2 __iomem *priv2 = spu->priv2;
if (!test_bit(SPU_CONTEXT_SWITCH_PENDING_nr, &spu->flags)) if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags))
out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND); out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
} }
...@@ -75,7 +75,7 @@ static int __spu_trap_data_seg(struct spu *spu, unsigned long ea) ...@@ -75,7 +75,7 @@ static int __spu_trap_data_seg(struct spu *spu, unsigned long ea)
pr_debug("%s\n", __FUNCTION__); pr_debug("%s\n", __FUNCTION__);
if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE_nr, &spu->flags)) { if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags)) {
/* SLBs are pre-loaded for context switch, so /* SLBs are pre-loaded for context switch, so
* we should never get here! * we should never get here!
*/ */
...@@ -122,7 +122,7 @@ static int __spu_trap_data_map(struct spu *spu, unsigned long ea, u64 dsisr) ...@@ -122,7 +122,7 @@ static int __spu_trap_data_map(struct spu *spu, unsigned long ea, u64 dsisr)
return 0; return 0;
} }
if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE_nr, &spu->flags)) { if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags)) {
printk("%s: invalid access during switch!\n", __func__); printk("%s: invalid access during switch!\n", __func__);
return 1; return 1;
} }
......
...@@ -214,14 +214,14 @@ static void spu_reaper(void *data) ...@@ -214,14 +214,14 @@ static void spu_reaper(void *data)
down_write(&ctx->state_sema); down_write(&ctx->state_sema);
spu = ctx->spu; spu = ctx->spu;
if (spu && (ctx->flags & SPU_CONTEXT_PREEMPT)) { if (spu && test_bit(SPU_CONTEXT_PREEMPT, &ctx->flags)) {
if (atomic_read(&spu->rq->prio.nr_blocked)) { if (atomic_read(&spu->rq->prio.nr_blocked)) {
pr_debug("%s: spu=%d\n", __func__, spu->number); pr_debug("%s: spu=%d\n", __func__, spu->number);
ctx->ops->runcntl_stop(ctx); ctx->ops->runcntl_stop(ctx);
spu_deactivate(ctx); spu_deactivate(ctx);
wake_up_all(&ctx->stop_wq); wake_up_all(&ctx->stop_wq);
} else { } else {
clear_bit(SPU_CONTEXT_PREEMPT_nr, &ctx->flags); clear_bit(SPU_CONTEXT_PREEMPT, &ctx->flags);
} }
} }
up_write(&ctx->state_sema); up_write(&ctx->state_sema);
...@@ -234,7 +234,7 @@ static void schedule_spu_reaper(struct spu_runqueue *rq, struct spu *spu) ...@@ -234,7 +234,7 @@ static void schedule_spu_reaper(struct spu_runqueue *rq, struct spu *spu)
unsigned long now = jiffies; unsigned long now = jiffies;
unsigned long expire = spu->timestamp + SPU_MIN_TIMESLICE; unsigned long expire = spu->timestamp + SPU_MIN_TIMESLICE;
set_bit(SPU_CONTEXT_PREEMPT_nr, &ctx->flags); set_bit(SPU_CONTEXT_PREEMPT, &ctx->flags);
INIT_WORK(&ctx->reap_work, spu_reaper, ctx); INIT_WORK(&ctx->reap_work, spu_reaper, ctx);
if (time_after(now, expire)) if (time_after(now, expire))
schedule_work(&ctx->reap_work); schedule_work(&ctx->reap_work);
...@@ -250,7 +250,7 @@ static void check_preempt_active(struct spu_runqueue *rq) ...@@ -250,7 +250,7 @@ static void check_preempt_active(struct spu_runqueue *rq)
list_for_each(p, &rq->active_list) { list_for_each(p, &rq->active_list) {
struct spu *spu = list_entry(p, struct spu, sched_list); struct spu *spu = list_entry(p, struct spu, sched_list);
struct spu_context *ctx = spu->ctx; struct spu_context *ctx = spu->ctx;
if (!(ctx->flags & SPU_CONTEXT_PREEMPT)) { if (!test_bit(SPU_CONTEXT_PREEMPT, &ctx->flags)) {
if (!worst || (spu->prio > worst->prio)) { if (!worst || (spu->prio > worst->prio)) {
worst = spu; worst = spu;
} }
......
...@@ -37,8 +37,7 @@ enum { ...@@ -37,8 +37,7 @@ enum {
struct spu_context_ops; struct spu_context_ops;
#define SPU_CONTEXT_PREEMPT_nr 0UL #define SPU_CONTEXT_PREEMPT 0UL
#define SPU_CONTEXT_PREEMPT (1UL << SPU_CONTEXT_PREEMPT_nr)
struct spu_context { struct spu_context {
struct spu *spu; /* pointer to a physical SPU */ struct spu *spu; /* pointer to a physical SPU */
......
...@@ -165,7 +165,7 @@ static inline void set_switch_pending(struct spu_state *csa, struct spu *spu) ...@@ -165,7 +165,7 @@ static inline void set_switch_pending(struct spu_state *csa, struct spu *spu)
* Restore, Step 5: * Restore, Step 5:
* Set a software context switch pending flag. * Set a software context switch pending flag.
*/ */
set_bit(SPU_CONTEXT_SWITCH_PENDING_nr, &spu->flags); set_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
mb(); mb();
} }
...@@ -767,8 +767,8 @@ static inline void set_switch_active(struct spu_state *csa, struct spu *spu) ...@@ -767,8 +767,8 @@ static inline void set_switch_active(struct spu_state *csa, struct spu *spu)
* Change the software context switch pending flag * Change the software context switch pending flag
* to context switch active. * to context switch active.
*/ */
set_bit(SPU_CONTEXT_SWITCH_ACTIVE_nr, &spu->flags); set_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags);
clear_bit(SPU_CONTEXT_SWITCH_PENDING_nr, &spu->flags); clear_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
mb(); mb();
} }
...@@ -1786,7 +1786,7 @@ static inline void reset_switch_active(struct spu_state *csa, struct spu *spu) ...@@ -1786,7 +1786,7 @@ static inline void reset_switch_active(struct spu_state *csa, struct spu *spu)
/* Restore, Step 74: /* Restore, Step 74:
* Reset the "context switch active" flag. * Reset the "context switch active" flag.
*/ */
clear_bit(SPU_CONTEXT_SWITCH_ACTIVE_nr, &spu->flags); clear_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags);
mb(); mb();
} }
......
...@@ -102,10 +102,8 @@ ...@@ -102,10 +102,8 @@
#define MFC_MULTI_SRC_EVENT 0x00001000 #define MFC_MULTI_SRC_EVENT 0x00001000
/* Flags indicating progress during context switch. */ /* Flags indicating progress during context switch. */
#define SPU_CONTEXT_SWITCH_PENDING_nr 0UL #define SPU_CONTEXT_SWITCH_PENDING 0UL
#define SPU_CONTEXT_SWITCH_ACTIVE_nr 1UL #define SPU_CONTEXT_SWITCH_ACTIVE 1UL
#define SPU_CONTEXT_SWITCH_PENDING (1UL << SPU_CONTEXT_SWITCH_PENDING_nr)
#define SPU_CONTEXT_SWITCH_ACTIVE (1UL << SPU_CONTEXT_SWITCH_ACTIVE_nr)
struct spu_context; struct spu_context;
struct spu_runqueue; struct spu_runqueue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment