Commit 27b1ea09 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Arnd Bergmann

[CELL] spufs: make sure context are scheduled again after spu_acquire_saved

Currently a process is removed from the physical spu when spu_acquire_saved
is saved but never put back.  This patch adds a new spu_release_saved
that is to be paired with spu_acquire_saved and put the process back if
it has been in RUNNABLE state before.

Niether Jeremy not be are entirely happy about this exact patch because
it adds another spu_activate call outside of the owner thread, but I
feel this is the best short-term fix we can come up with.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
Signed-off-by: default avatarArnd Bergmann <arnd.bergmann@de.ibm.com>
parent 27ec41d3
...@@ -165,6 +165,22 @@ int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags) ...@@ -165,6 +165,22 @@ int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags)
void spu_acquire_saved(struct spu_context *ctx) void spu_acquire_saved(struct spu_context *ctx)
{ {
spu_acquire(ctx); spu_acquire(ctx);
if (ctx->state != SPU_STATE_SAVED) if (ctx->state != SPU_STATE_SAVED) {
set_bit(SPU_SCHED_WAS_ACTIVE, &ctx->sched_flags);
spu_deactivate(ctx); spu_deactivate(ctx);
}
}
/**
* spu_release_saved - unlock spu context and return it to the runqueue
* @ctx: context to unlock
*/
void spu_release_saved(struct spu_context *ctx)
{
BUG_ON(ctx->state != SPU_STATE_SAVED);
if (test_and_clear_bit(SPU_SCHED_WAS_ACTIVE, &ctx->sched_flags))
spu_activate(ctx, 0);
spu_release(ctx);
} }
...@@ -226,7 +226,7 @@ static void spufs_arch_write_notes(struct file *file) ...@@ -226,7 +226,7 @@ static void spufs_arch_write_notes(struct file *file)
spu_acquire_saved(ctx_info->ctx); spu_acquire_saved(ctx_info->ctx);
for (j = 0; j < spufs_coredump_num_notes; j++) for (j = 0; j < spufs_coredump_num_notes; j++)
spufs_arch_write_note(ctx_info, j, file); spufs_arch_write_note(ctx_info, j, file);
spu_release(ctx_info->ctx); spu_release_saved(ctx_info->ctx);
list_del(&ctx_info->list); list_del(&ctx_info->list);
kfree(ctx_info); kfree(ctx_info);
} }
......
...@@ -370,7 +370,7 @@ spufs_regs_read(struct file *file, char __user *buffer, ...@@ -370,7 +370,7 @@ spufs_regs_read(struct file *file, char __user *buffer,
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_regs_read(ctx, buffer, size, pos); ret = __spufs_regs_read(ctx, buffer, size, pos);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -392,7 +392,7 @@ spufs_regs_write(struct file *file, const char __user *buffer, ...@@ -392,7 +392,7 @@ spufs_regs_write(struct file *file, const char __user *buffer,
ret = copy_from_user(lscsa->gprs + *pos - size, ret = copy_from_user(lscsa->gprs + *pos - size,
buffer, size) ? -EFAULT : size; buffer, size) ? -EFAULT : size;
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -421,7 +421,7 @@ spufs_fpcr_read(struct file *file, char __user * buffer, ...@@ -421,7 +421,7 @@ spufs_fpcr_read(struct file *file, char __user * buffer,
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_fpcr_read(ctx, buffer, size, pos); ret = __spufs_fpcr_read(ctx, buffer, size, pos);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -443,7 +443,7 @@ spufs_fpcr_write(struct file *file, const char __user * buffer, ...@@ -443,7 +443,7 @@ spufs_fpcr_write(struct file *file, const char __user * buffer,
ret = copy_from_user((char *)&lscsa->fpcr + *pos - size, ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
buffer, size) ? -EFAULT : size; buffer, size) ? -EFAULT : size;
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -868,7 +868,7 @@ static ssize_t spufs_signal1_read(struct file *file, char __user *buf, ...@@ -868,7 +868,7 @@ static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_signal1_read(ctx, buf, len, pos); ret = __spufs_signal1_read(ctx, buf, len, pos);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -999,7 +999,7 @@ static ssize_t spufs_signal2_read(struct file *file, char __user *buf, ...@@ -999,7 +999,7 @@ static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_signal2_read(ctx, buf, len, pos); ret = __spufs_signal2_read(ctx, buf, len, pos);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -1626,7 +1626,7 @@ static void spufs_decr_set(void *data, u64 val) ...@@ -1626,7 +1626,7 @@ static void spufs_decr_set(void *data, u64 val)
struct spu_lscsa *lscsa = ctx->csa.lscsa; struct spu_lscsa *lscsa = ctx->csa.lscsa;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
lscsa->decr.slot[0] = (u32) val; lscsa->decr.slot[0] = (u32) val;
spu_release(ctx); spu_release_saved(ctx);
} }
static u64 __spufs_decr_get(void *data) static u64 __spufs_decr_get(void *data)
...@@ -1642,7 +1642,7 @@ static u64 spufs_decr_get(void *data) ...@@ -1642,7 +1642,7 @@ static u64 spufs_decr_get(void *data)
u64 ret; u64 ret;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_decr_get(data); ret = __spufs_decr_get(data);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set, DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
...@@ -1654,7 +1654,7 @@ static void spufs_decr_status_set(void *data, u64 val) ...@@ -1654,7 +1654,7 @@ static void spufs_decr_status_set(void *data, u64 val)
struct spu_lscsa *lscsa = ctx->csa.lscsa; struct spu_lscsa *lscsa = ctx->csa.lscsa;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
lscsa->decr_status.slot[0] = (u32) val; lscsa->decr_status.slot[0] = (u32) val;
spu_release(ctx); spu_release_saved(ctx);
} }
static u64 __spufs_decr_status_get(void *data) static u64 __spufs_decr_status_get(void *data)
...@@ -1670,7 +1670,7 @@ static u64 spufs_decr_status_get(void *data) ...@@ -1670,7 +1670,7 @@ static u64 spufs_decr_status_get(void *data)
u64 ret; u64 ret;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_decr_status_get(data); ret = __spufs_decr_status_get(data);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get, DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
...@@ -1682,7 +1682,7 @@ static void spufs_event_mask_set(void *data, u64 val) ...@@ -1682,7 +1682,7 @@ static void spufs_event_mask_set(void *data, u64 val)
struct spu_lscsa *lscsa = ctx->csa.lscsa; struct spu_lscsa *lscsa = ctx->csa.lscsa;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
lscsa->event_mask.slot[0] = (u32) val; lscsa->event_mask.slot[0] = (u32) val;
spu_release(ctx); spu_release_saved(ctx);
} }
static u64 __spufs_event_mask_get(void *data) static u64 __spufs_event_mask_get(void *data)
...@@ -1698,7 +1698,7 @@ static u64 spufs_event_mask_get(void *data) ...@@ -1698,7 +1698,7 @@ static u64 spufs_event_mask_get(void *data)
u64 ret; u64 ret;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_event_mask_get(data); ret = __spufs_event_mask_get(data);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get, DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
...@@ -1722,7 +1722,7 @@ static u64 spufs_event_status_get(void *data) ...@@ -1722,7 +1722,7 @@ static u64 spufs_event_status_get(void *data)
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_event_status_get(data); ret = __spufs_event_status_get(data);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get, DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
...@@ -1734,7 +1734,7 @@ static void spufs_srr0_set(void *data, u64 val) ...@@ -1734,7 +1734,7 @@ static void spufs_srr0_set(void *data, u64 val)
struct spu_lscsa *lscsa = ctx->csa.lscsa; struct spu_lscsa *lscsa = ctx->csa.lscsa;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
lscsa->srr0.slot[0] = (u32) val; lscsa->srr0.slot[0] = (u32) val;
spu_release(ctx); spu_release_saved(ctx);
} }
static u64 spufs_srr0_get(void *data) static u64 spufs_srr0_get(void *data)
...@@ -1744,7 +1744,7 @@ static u64 spufs_srr0_get(void *data) ...@@ -1744,7 +1744,7 @@ static u64 spufs_srr0_get(void *data)
u64 ret; u64 ret;
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = lscsa->srr0.slot[0]; ret = lscsa->srr0.slot[0];
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set, DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
...@@ -1800,7 +1800,7 @@ static u64 spufs_lslr_get(void *data) ...@@ -1800,7 +1800,7 @@ static u64 spufs_lslr_get(void *data)
spu_acquire_saved(ctx); spu_acquire_saved(ctx);
ret = __spufs_lslr_get(data); ret = __spufs_lslr_get(data);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -1864,7 +1864,7 @@ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf, ...@@ -1864,7 +1864,7 @@ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
spin_lock(&ctx->csa.register_lock); spin_lock(&ctx->csa.register_lock);
ret = __spufs_mbox_info_read(ctx, buf, len, pos); ret = __spufs_mbox_info_read(ctx, buf, len, pos);
spin_unlock(&ctx->csa.register_lock); spin_unlock(&ctx->csa.register_lock);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -1902,7 +1902,7 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf, ...@@ -1902,7 +1902,7 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
spin_lock(&ctx->csa.register_lock); spin_lock(&ctx->csa.register_lock);
ret = __spufs_ibox_info_read(ctx, buf, len, pos); ret = __spufs_ibox_info_read(ctx, buf, len, pos);
spin_unlock(&ctx->csa.register_lock); spin_unlock(&ctx->csa.register_lock);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -1943,7 +1943,7 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf, ...@@ -1943,7 +1943,7 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
spin_lock(&ctx->csa.register_lock); spin_lock(&ctx->csa.register_lock);
ret = __spufs_wbox_info_read(ctx, buf, len, pos); ret = __spufs_wbox_info_read(ctx, buf, len, pos);
spin_unlock(&ctx->csa.register_lock); spin_unlock(&ctx->csa.register_lock);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -1993,7 +1993,7 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf, ...@@ -1993,7 +1993,7 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
spin_lock(&ctx->csa.register_lock); spin_lock(&ctx->csa.register_lock);
ret = __spufs_dma_info_read(ctx, buf, len, pos); ret = __spufs_dma_info_read(ctx, buf, len, pos);
spin_unlock(&ctx->csa.register_lock); spin_unlock(&ctx->csa.register_lock);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
...@@ -2044,7 +2044,7 @@ static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf, ...@@ -2044,7 +2044,7 @@ static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
spin_lock(&ctx->csa.register_lock); spin_lock(&ctx->csa.register_lock);
ret = __spufs_proxydma_info_read(ctx, buf, len, pos); ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
spin_unlock(&ctx->csa.register_lock); spin_unlock(&ctx->csa.register_lock);
spu_release(ctx); spu_release_saved(ctx);
return ret; return ret;
} }
......
...@@ -40,6 +40,10 @@ enum { ...@@ -40,6 +40,10 @@ enum {
struct spu_context_ops; struct spu_context_ops;
struct spu_gang; struct spu_gang;
enum {
SPU_SCHED_WAS_ACTIVE, /* was active upon spu_acquire_saved() */
};
struct spu_context { struct spu_context {
struct spu *spu; /* pointer to a physical SPU */ struct spu *spu; /* pointer to a physical SPU */
struct spu_state csa; /* SPU context save area. */ struct spu_state csa; /* SPU context save area. */
...@@ -214,6 +218,7 @@ void spu_unmap_mappings(struct spu_context *ctx); ...@@ -214,6 +218,7 @@ void spu_unmap_mappings(struct spu_context *ctx);
void spu_forget(struct spu_context *ctx); void spu_forget(struct spu_context *ctx);
int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags); int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags);
void spu_acquire_saved(struct spu_context *ctx); void spu_acquire_saved(struct spu_context *ctx);
void spu_release_saved(struct spu_context *ctx);
int spu_activate(struct spu_context *ctx, unsigned long flags); int spu_activate(struct spu_context *ctx, unsigned long flags);
void spu_deactivate(struct spu_context *ctx); void spu_deactivate(struct spu_context *ctx);
......
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