Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 1 | /* |
| 2 | * SPU file system |
| 3 | * |
| 4 | * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 |
| 5 | * |
| 6 | * Author: Arnd Bergmann <arndb@de.ibm.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | */ |
| 22 | #ifndef SPUFS_H |
| 23 | #define SPUFS_H |
| 24 | |
| 25 | #include <linux/kref.h> |
Christoph Hellwig | 650f8b0 | 2007-02-13 21:36:50 +0100 | [diff] [blame] | 26 | #include <linux/mutex.h> |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 27 | #include <linux/spinlock.h> |
| 28 | #include <linux/fs.h> |
Christoph Hellwig | ea1ae59 | 2007-06-29 10:57:56 +1000 | [diff] [blame] | 29 | #include <linux/cpumask.h> |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 30 | |
| 31 | #include <asm/spu.h> |
Mark Nutter | 5473af0 | 2005-11-15 15:53:49 -0500 | [diff] [blame] | 32 | #include <asm/spu_csa.h> |
Dwayne Grant McConnell | b9e3bd7 | 2006-11-20 18:44:58 +0100 | [diff] [blame] | 33 | #include <asm/spu_info.h> |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 34 | |
| 35 | /* The magic number for our file system */ |
| 36 | enum { |
| 37 | SPUFS_MAGIC = 0x23c9b64e, |
| 38 | }; |
| 39 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 40 | struct spu_context_ops; |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 41 | struct spu_gang; |
| 42 | |
Christoph Hellwig | e9f8a0b | 2007-06-29 10:58:03 +1000 | [diff] [blame] | 43 | /* |
| 44 | * This is the state for spu utilization reporting to userspace. |
| 45 | * Because this state is visible to userspace it must never change and needs |
| 46 | * to be kept strictly separate from any internal state kept by the kernel. |
| 47 | */ |
| 48 | enum spuctx_execution_state { |
| 49 | SPUCTX_UTIL_USER = 0, |
| 50 | SPUCTX_UTIL_SYSTEM, |
| 51 | SPUCTX_UTIL_IOWAIT, |
| 52 | SPUCTX_UTIL_LOADED, |
| 53 | SPUCTX_UTIL_MAX |
| 54 | }; |
| 55 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 56 | struct spu_context { |
| 57 | struct spu *spu; /* pointer to a physical SPU */ |
Mark Nutter | 5473af0 | 2005-11-15 15:53:49 -0500 | [diff] [blame] | 58 | struct spu_state csa; /* SPU context save area. */ |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 59 | spinlock_t mmio_lock; /* protects mmio access */ |
Mark Nutter | 6df10a8 | 2006-03-23 00:00:12 +0100 | [diff] [blame] | 60 | struct address_space *local_store; /* local store mapping. */ |
| 61 | struct address_space *mfc; /* 'mfc' area mappings. */ |
Christoph Hellwig | 43c2bbd | 2007-04-23 21:08:07 +0200 | [diff] [blame] | 62 | struct address_space *cntl; /* 'control' area mappings. */ |
| 63 | struct address_space *signal1; /* 'signal1' area mappings. */ |
| 64 | struct address_space *signal2; /* 'signal2' area mappings. */ |
| 65 | struct address_space *mss; /* 'mss' area mappings. */ |
| 66 | struct address_space *psmap; /* 'psmap' area mappings. */ |
Christoph Hellwig | 47d3a5f | 2007-06-04 23:26:51 +1000 | [diff] [blame] | 67 | struct mutex mapping_lock; |
Arnd Bergmann | 8676727 | 2006-10-04 17:26:21 +0200 | [diff] [blame] | 68 | u64 object_id; /* user space pointer for oprofile */ |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 69 | |
| 70 | enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state; |
Christoph Hellwig | 650f8b0 | 2007-02-13 21:36:50 +0100 | [diff] [blame] | 71 | struct mutex state_mutex; |
Christoph Hellwig | e45d48a3 | 2007-04-23 21:08:17 +0200 | [diff] [blame] | 72 | struct mutex run_mutex; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 73 | |
| 74 | struct mm_struct *owner; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 75 | |
| 76 | struct kref kref; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 77 | wait_queue_head_t ibox_wq; |
| 78 | wait_queue_head_t wbox_wq; |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 79 | wait_queue_head_t stop_wq; |
Arnd Bergmann | a33a7d7 | 2006-03-23 00:00:11 +0100 | [diff] [blame] | 80 | wait_queue_head_t mfc_wq; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 81 | struct fasync_struct *ibox_fasync; |
| 82 | struct fasync_struct *wbox_fasync; |
Arnd Bergmann | a33a7d7 | 2006-03-23 00:00:11 +0100 | [diff] [blame] | 83 | struct fasync_struct *mfc_fasync; |
| 84 | u32 tagwait; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 85 | struct spu_context_ops *ops; |
Arnd Bergmann | 2a911f0 | 2005-12-05 22:52:26 -0500 | [diff] [blame] | 86 | struct work_struct reap_work; |
Arnd Bergmann | 9add11d | 2006-10-04 17:26:14 +0200 | [diff] [blame] | 87 | unsigned long flags; |
| 88 | unsigned long event_return; |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 89 | |
| 90 | struct list_head gang_list; |
| 91 | struct spu_gang *gang; |
Christoph Hellwig | 8389998 | 2007-02-13 21:54:22 +0100 | [diff] [blame] | 92 | |
Christoph Hellwig | 476273a | 2007-06-29 10:58:01 +1000 | [diff] [blame] | 93 | /* owner thread */ |
| 94 | pid_t tid; |
| 95 | |
Christoph Hellwig | 8389998 | 2007-02-13 21:54:22 +0100 | [diff] [blame] | 96 | /* scheduler fields */ |
Jeremy Kerr | 7022543 | 2007-06-29 10:58:00 +1000 | [diff] [blame] | 97 | struct list_head rq; |
Christoph Hellwig | 3790180 | 2007-06-29 10:57:51 +1000 | [diff] [blame] | 98 | unsigned int time_slice; |
Christoph Hellwig | 26bec67 | 2007-02-13 21:54:24 +0100 | [diff] [blame] | 99 | unsigned long sched_flags; |
Christoph Hellwig | ea1ae59 | 2007-06-29 10:57:56 +1000 | [diff] [blame] | 100 | cpumask_t cpus_allowed; |
Christoph Hellwig | 2eb1b12 | 2007-02-13 21:54:29 +0100 | [diff] [blame] | 101 | int policy; |
Christoph Hellwig | 8389998 | 2007-02-13 21:54:22 +0100 | [diff] [blame] | 102 | int prio; |
Christoph Hellwig | e9f8a0b | 2007-06-29 10:58:03 +1000 | [diff] [blame] | 103 | |
| 104 | /* statistics */ |
| 105 | struct { |
| 106 | /* updates protected by ctx->state_mutex */ |
| 107 | enum spuctx_execution_state execution_state; |
| 108 | unsigned long tstamp; /* time of last ctx switch */ |
| 109 | unsigned long times[SPUCTX_UTIL_MAX]; |
| 110 | unsigned long long vol_ctx_switch; |
| 111 | unsigned long long invol_ctx_switch; |
| 112 | unsigned long long min_flt; |
| 113 | unsigned long long maj_flt; |
| 114 | unsigned long long hash_flt; |
| 115 | unsigned long long slb_flt; |
| 116 | unsigned long long slb_flt_base; /* # at last ctx switch */ |
| 117 | unsigned long long class2_intr; |
| 118 | unsigned long long class2_intr_base; /* # at last ctx switch */ |
| 119 | unsigned long long libassist; |
| 120 | } stats; |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | struct spu_gang { |
| 124 | struct list_head list; |
| 125 | struct mutex mutex; |
| 126 | struct kref kref; |
| 127 | int contexts; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 128 | }; |
| 129 | |
Arnd Bergmann | a33a7d7 | 2006-03-23 00:00:11 +0100 | [diff] [blame] | 130 | struct mfc_dma_command { |
| 131 | int32_t pad; /* reserved */ |
| 132 | uint32_t lsa; /* local storage address */ |
| 133 | uint64_t ea; /* effective address */ |
| 134 | uint16_t size; /* transfer size */ |
| 135 | uint16_t tag; /* command tag */ |
| 136 | uint16_t class; /* class ID */ |
| 137 | uint16_t cmd; /* command opcode */ |
| 138 | }; |
| 139 | |
| 140 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 141 | /* SPU context query/set operations. */ |
| 142 | struct spu_context_ops { |
| 143 | int (*mbox_read) (struct spu_context * ctx, u32 * data); |
| 144 | u32(*mbox_stat_read) (struct spu_context * ctx); |
Arnd Bergmann | 3a843d7 | 2005-12-05 22:52:27 -0500 | [diff] [blame] | 145 | unsigned int (*mbox_stat_poll)(struct spu_context *ctx, |
| 146 | unsigned int events); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 147 | int (*ibox_read) (struct spu_context * ctx, u32 * data); |
| 148 | int (*wbox_write) (struct spu_context * ctx, u32 data); |
| 149 | u32(*signal1_read) (struct spu_context * ctx); |
| 150 | void (*signal1_write) (struct spu_context * ctx, u32 data); |
| 151 | u32(*signal2_read) (struct spu_context * ctx); |
| 152 | void (*signal2_write) (struct spu_context * ctx, u32 data); |
| 153 | void (*signal1_type_set) (struct spu_context * ctx, u64 val); |
| 154 | u64(*signal1_type_get) (struct spu_context * ctx); |
| 155 | void (*signal2_type_set) (struct spu_context * ctx, u64 val); |
| 156 | u64(*signal2_type_get) (struct spu_context * ctx); |
| 157 | u32(*npc_read) (struct spu_context * ctx); |
| 158 | void (*npc_write) (struct spu_context * ctx, u32 data); |
| 159 | u32(*status_read) (struct spu_context * ctx); |
| 160 | char*(*get_ls) (struct spu_context * ctx); |
Jeremy Kerr | 3960c26 | 2006-11-20 18:45:09 +0100 | [diff] [blame] | 161 | u32 (*runcntl_read) (struct spu_context * ctx); |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 162 | void (*runcntl_write) (struct spu_context * ctx, u32 data); |
Arnd Bergmann | ee2d734 | 2006-11-20 18:45:08 +0100 | [diff] [blame] | 163 | void (*master_start) (struct spu_context * ctx); |
| 164 | void (*master_stop) (struct spu_context * ctx); |
Arnd Bergmann | a33a7d7 | 2006-03-23 00:00:11 +0100 | [diff] [blame] | 165 | int (*set_mfc_query)(struct spu_context * ctx, u32 mask, u32 mode); |
| 166 | u32 (*read_mfc_tagstatus)(struct spu_context * ctx); |
| 167 | u32 (*get_mfc_free_elements)(struct spu_context *ctx); |
Dwayne Grant McConnell | b9e3bd7 | 2006-11-20 18:44:58 +0100 | [diff] [blame] | 168 | int (*send_mfc_command)(struct spu_context * ctx, |
| 169 | struct mfc_dma_command * cmd); |
| 170 | void (*dma_info_read) (struct spu_context * ctx, |
| 171 | struct spu_dma_info * info); |
| 172 | void (*proxydma_info_read) (struct spu_context * ctx, |
| 173 | struct spu_proxydma_info * info); |
Arnd Bergmann | 57dace2 | 2007-04-23 21:08:15 +0200 | [diff] [blame] | 174 | void (*restart_dma)(struct spu_context *ctx); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | extern struct spu_context_ops spu_hw_ops; |
| 178 | extern struct spu_context_ops spu_backing_ops; |
| 179 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 180 | struct spufs_inode_info { |
| 181 | struct spu_context *i_ctx; |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 182 | struct spu_gang *i_gang; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 183 | struct inode vfs_inode; |
Christoph Hellwig | 43c2bbd | 2007-04-23 21:08:07 +0200 | [diff] [blame] | 184 | int i_openers; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 185 | }; |
| 186 | #define SPUFS_I(inode) \ |
| 187 | container_of(inode, struct spufs_inode_info, vfs_inode) |
| 188 | |
| 189 | extern struct tree_descr spufs_dir_contents[]; |
Mark Nutter | 5737edd | 2006-10-24 18:31:16 +0200 | [diff] [blame] | 190 | extern struct tree_descr spufs_dir_nosched_contents[]; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 191 | |
| 192 | /* system call implementation */ |
| 193 | long spufs_run_spu(struct file *file, |
| 194 | struct spu_context *ctx, u32 *npc, u32 *status); |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 195 | long spufs_create(struct nameidata *nd, |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 196 | unsigned int flags, mode_t mode); |
Arjan van de Ven | 9c2e08c | 2007-02-12 00:55:37 -0800 | [diff] [blame] | 197 | extern const struct file_operations spufs_context_fops; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 198 | |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 199 | /* gang management */ |
| 200 | struct spu_gang *alloc_spu_gang(void); |
| 201 | struct spu_gang *get_spu_gang(struct spu_gang *gang); |
| 202 | int put_spu_gang(struct spu_gang *gang); |
| 203 | void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx); |
| 204 | void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx); |
| 205 | |
Arnd Bergmann | 57dace2 | 2007-04-23 21:08:15 +0200 | [diff] [blame] | 206 | /* fault handling */ |
| 207 | int spufs_handle_class1(struct spu_context *ctx); |
| 208 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 209 | /* context management */ |
Christoph Hellwig | 65de66f | 2007-06-29 10:58:02 +1000 | [diff] [blame] | 210 | extern atomic_t nr_spu_contexts; |
Christoph Hellwig | 6a0641e5 | 2007-02-13 21:54:21 +0100 | [diff] [blame] | 211 | static inline void spu_acquire(struct spu_context *ctx) |
| 212 | { |
| 213 | mutex_lock(&ctx->state_mutex); |
| 214 | } |
| 215 | |
| 216 | static inline void spu_release(struct spu_context *ctx) |
| 217 | { |
| 218 | mutex_unlock(&ctx->state_mutex); |
| 219 | } |
| 220 | |
Arnd Bergmann | 6263203 | 2006-10-04 17:26:15 +0200 | [diff] [blame] | 221 | struct spu_context * alloc_spu_context(struct spu_gang *gang); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 222 | void destroy_spu_context(struct kref *kref); |
| 223 | struct spu_context * get_spu_context(struct spu_context *ctx); |
| 224 | int put_spu_context(struct spu_context *ctx); |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 225 | void spu_unmap_mappings(struct spu_context *ctx); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 226 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 227 | void spu_forget(struct spu_context *ctx); |
Christoph Hellwig | 26bec67 | 2007-02-13 21:54:24 +0100 | [diff] [blame] | 228 | int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 229 | void spu_acquire_saved(struct spu_context *ctx); |
Christoph Hellwig | 50b520d | 2007-03-10 00:05:36 +0100 | [diff] [blame] | 230 | |
Christoph Hellwig | 26bec67 | 2007-02-13 21:54:24 +0100 | [diff] [blame] | 231 | int spu_activate(struct spu_context *ctx, unsigned long flags); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 232 | void spu_deactivate(struct spu_context *ctx); |
| 233 | void spu_yield(struct spu_context *ctx); |
Christoph Hellwig | fe443ef | 2007-06-29 10:57:52 +1000 | [diff] [blame] | 234 | void spu_set_timeslice(struct spu_context *ctx); |
Christoph Hellwig | 2cf2b3b | 2007-06-29 10:57:55 +1000 | [diff] [blame] | 235 | void spu_update_sched_info(struct spu_context *ctx); |
| 236 | void __spu_update_sched_info(struct spu_context *ctx); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 237 | int __init spu_sched_init(void); |
Sebastian Siewior | d145031 | 2007-07-20 21:39:29 +0200 | [diff] [blame^] | 238 | void spu_sched_exit(void); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 239 | |
Jeremy Kerr | c6730ed | 2006-11-20 18:45:10 +0100 | [diff] [blame] | 240 | extern char *isolated_loader; |
| 241 | |
Arnd Bergmann | ce8ab85 | 2006-01-04 20:31:29 +0100 | [diff] [blame] | 242 | /* |
| 243 | * spufs_wait |
Jeremy Kerr | 7022543 | 2007-06-29 10:58:00 +1000 | [diff] [blame] | 244 | * Same as wait_event_interruptible(), except that here |
Arnd Bergmann | ce8ab85 | 2006-01-04 20:31:29 +0100 | [diff] [blame] | 245 | * we need to call spu_release(ctx) before sleeping, and |
| 246 | * then spu_acquire(ctx) when awoken. |
| 247 | */ |
| 248 | |
| 249 | #define spufs_wait(wq, condition) \ |
| 250 | ({ \ |
| 251 | int __ret = 0; \ |
| 252 | DEFINE_WAIT(__wait); \ |
| 253 | for (;;) { \ |
| 254 | prepare_to_wait(&(wq), &__wait, TASK_INTERRUPTIBLE); \ |
| 255 | if (condition) \ |
| 256 | break; \ |
Jeremy Kerr | d376439 | 2007-04-23 21:08:24 +0200 | [diff] [blame] | 257 | if (signal_pending(current)) { \ |
| 258 | __ret = -ERESTARTSYS; \ |
| 259 | break; \ |
Arnd Bergmann | ce8ab85 | 2006-01-04 20:31:29 +0100 | [diff] [blame] | 260 | } \ |
Jeremy Kerr | d376439 | 2007-04-23 21:08:24 +0200 | [diff] [blame] | 261 | spu_release(ctx); \ |
| 262 | schedule(); \ |
| 263 | spu_acquire(ctx); \ |
Arnd Bergmann | ce8ab85 | 2006-01-04 20:31:29 +0100 | [diff] [blame] | 264 | } \ |
| 265 | finish_wait(&(wq), &__wait); \ |
| 266 | __ret; \ |
| 267 | }) |
| 268 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 269 | size_t spu_wbox_write(struct spu_context *ctx, u32 data); |
| 270 | size_t spu_ibox_read(struct spu_context *ctx, u32 *data); |
| 271 | |
| 272 | /* irq callback funcs. */ |
| 273 | void spufs_ibox_callback(struct spu *spu); |
| 274 | void spufs_wbox_callback(struct spu *spu); |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 275 | void spufs_stop_callback(struct spu *spu); |
Arnd Bergmann | a33a7d7 | 2006-03-23 00:00:11 +0100 | [diff] [blame] | 276 | void spufs_mfc_callback(struct spu *spu); |
Arnd Bergmann | 9add11d | 2006-10-04 17:26:14 +0200 | [diff] [blame] | 277 | void spufs_dma_callback(struct spu *spu, int type); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 278 | |
Dwayne Grant McConnell | bf1ab97 | 2006-11-23 00:46:37 +0100 | [diff] [blame] | 279 | extern struct spu_coredump_calls spufs_coredump_calls; |
| 280 | struct spufs_coredump_reader { |
| 281 | char *name; |
| 282 | ssize_t (*read)(struct spu_context *ctx, |
| 283 | char __user *buffer, size_t size, loff_t *pos); |
| 284 | u64 (*get)(void *data); |
| 285 | size_t size; |
| 286 | }; |
| 287 | extern struct spufs_coredump_reader spufs_coredump_read[]; |
| 288 | extern int spufs_coredump_num_notes; |
| 289 | |
Christoph Hellwig | e9f8a0b | 2007-06-29 10:58:03 +1000 | [diff] [blame] | 290 | /* |
| 291 | * This function is a little bit too large for an inline, but |
| 292 | * as fault.c is built into the kernel we can't move it out of |
| 293 | * line. |
| 294 | */ |
| 295 | static inline void spuctx_switch_state(struct spu_context *ctx, |
| 296 | enum spuctx_execution_state new_state) |
| 297 | { |
| 298 | WARN_ON(!mutex_is_locked(&ctx->state_mutex)); |
| 299 | |
| 300 | if (ctx->stats.execution_state != new_state) { |
| 301 | unsigned long curtime = jiffies; |
| 302 | |
| 303 | ctx->stats.times[ctx->stats.execution_state] += |
| 304 | curtime - ctx->stats.tstamp; |
| 305 | ctx->stats.tstamp = curtime; |
| 306 | ctx->stats.execution_state = new_state; |
| 307 | } |
| 308 | } |
| 309 | |
Christoph Hellwig | fe2f896 | 2007-06-29 10:58:07 +1000 | [diff] [blame] | 310 | static inline void spu_switch_state(struct spu *spu, |
| 311 | enum spuctx_execution_state new_state) |
| 312 | { |
| 313 | if (spu->stats.utilization_state != new_state) { |
| 314 | unsigned long curtime = jiffies; |
| 315 | |
| 316 | spu->stats.times[spu->stats.utilization_state] += |
| 317 | curtime - spu->stats.tstamp; |
| 318 | spu->stats.tstamp = curtime; |
| 319 | spu->stats.utilization_state = new_state; |
| 320 | } |
| 321 | } |
| 322 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 323 | #endif |