aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spufs/sched.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2007-12-20 02:39:59 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-21 03:46:19 -0500
commit7cd58e43810852eeb7af5a0c803f3890bd08b581 (patch)
treed9ea5c0102d70c26c4a9b18aaf4db4e3b6d48fc1 /arch/powerpc/platforms/cell/spufs/sched.c
parent9b1d21f858e8bad750ab19cac23dcbf79d099be3 (diff)
[POWERPC] spufs: move fault, lscsa_alloc and switch code to spufs module
Currently, part of the spufs code (switch.o, lscsa_alloc.o and fault.o) is compiled directly into the kernel. This change moves these components of spufs into the kernel. The lscsa and switch objects are fairly straightforward to move in. For the fault.o module, we split the fault-handling code into two parts: a/p/p/c/spu_fault.c and a/p/p/c/spufs/fault.c. The former is for the in-kernel spu_handle_mm_fault function, and we move the rest of the fault-handling code into spufs. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/cell/spufs/sched.c')
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 0117eb8f6a91..ee80de07c0bc 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -892,6 +892,38 @@ static int spusched_thread(void *unused)
892 return 0; 892 return 0;
893} 893}
894 894
895void spuctx_switch_state(struct spu_context *ctx,
896 enum spu_utilization_state new_state)
897{
898 unsigned long long curtime;
899 signed long long delta;
900 struct timespec ts;
901 struct spu *spu;
902 enum spu_utilization_state old_state;
903
904 ktime_get_ts(&ts);
905 curtime = timespec_to_ns(&ts);
906 delta = curtime - ctx->stats.tstamp;
907
908 WARN_ON(!mutex_is_locked(&ctx->state_mutex));
909 WARN_ON(delta < 0);
910
911 spu = ctx->spu;
912 old_state = ctx->stats.util_state;
913 ctx->stats.util_state = new_state;
914 ctx->stats.tstamp = curtime;
915
916 /*
917 * Update the physical SPU utilization statistics.
918 */
919 if (spu) {
920 ctx->stats.times[old_state] += delta;
921 spu->stats.times[old_state] += delta;
922 spu->stats.util_state = new_state;
923 spu->stats.tstamp = curtime;
924 }
925}
926
895#define LOAD_INT(x) ((x) >> FSHIFT) 927#define LOAD_INT(x) ((x) >> FSHIFT)
896#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) 928#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
897 929