162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * SPU file system
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Arnd Bergmann <arndb@de.ibm.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci#ifndef SPUFS_H
1062306a36Sopenharmony_ci#define SPUFS_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/kref.h>
1362306a36Sopenharmony_ci#include <linux/mutex.h>
1462306a36Sopenharmony_ci#include <linux/spinlock.h>
1562306a36Sopenharmony_ci#include <linux/fs.h>
1662306a36Sopenharmony_ci#include <linux/cpumask.h>
1762306a36Sopenharmony_ci#include <linux/sched/signal.h>
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#include <asm/spu.h>
2062306a36Sopenharmony_ci#include <asm/spu_csa.h>
2162306a36Sopenharmony_ci#include <asm/spu_info.h>
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define SPUFS_PS_MAP_SIZE	0x20000
2462306a36Sopenharmony_ci#define SPUFS_MFC_MAP_SIZE	0x1000
2562306a36Sopenharmony_ci#define SPUFS_CNTL_MAP_SIZE	0x1000
2662306a36Sopenharmony_ci#define SPUFS_SIGNAL_MAP_SIZE	PAGE_SIZE
2762306a36Sopenharmony_ci#define SPUFS_MSS_MAP_SIZE	0x1000
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* The magic number for our file system */
3062306a36Sopenharmony_cienum {
3162306a36Sopenharmony_ci	SPUFS_MAGIC = 0x23c9b64e,
3262306a36Sopenharmony_ci};
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistruct spu_context_ops;
3562306a36Sopenharmony_cistruct spu_gang;
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/* ctx->sched_flags */
3862306a36Sopenharmony_cienum {
3962306a36Sopenharmony_ci	SPU_SCHED_NOTIFY_ACTIVE,
4062306a36Sopenharmony_ci	SPU_SCHED_WAS_ACTIVE,	/* was active upon spu_acquire_saved()  */
4162306a36Sopenharmony_ci	SPU_SCHED_SPU_RUN,	/* context is within spu_run */
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_cienum {
4562306a36Sopenharmony_ci	SWITCH_LOG_BUFSIZE = 4096,
4662306a36Sopenharmony_ci};
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_cienum {
4962306a36Sopenharmony_ci	SWITCH_LOG_START,
5062306a36Sopenharmony_ci	SWITCH_LOG_STOP,
5162306a36Sopenharmony_ci	SWITCH_LOG_EXIT,
5262306a36Sopenharmony_ci};
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_cistruct switch_log {
5562306a36Sopenharmony_ci	wait_queue_head_t	wait;
5662306a36Sopenharmony_ci	unsigned long		head;
5762306a36Sopenharmony_ci	unsigned long		tail;
5862306a36Sopenharmony_ci	struct switch_log_entry {
5962306a36Sopenharmony_ci		struct timespec64 tstamp;
6062306a36Sopenharmony_ci		s32		spu_id;
6162306a36Sopenharmony_ci		u32		type;
6262306a36Sopenharmony_ci		u32		val;
6362306a36Sopenharmony_ci		u64		timebase;
6462306a36Sopenharmony_ci	} log[];
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cistruct spu_context {
6862306a36Sopenharmony_ci	struct spu *spu;		  /* pointer to a physical SPU */
6962306a36Sopenharmony_ci	struct spu_state csa;		  /* SPU context save area. */
7062306a36Sopenharmony_ci	spinlock_t mmio_lock;		  /* protects mmio access */
7162306a36Sopenharmony_ci	struct address_space *local_store; /* local store mapping.  */
7262306a36Sopenharmony_ci	struct address_space *mfc;	   /* 'mfc' area mappings. */
7362306a36Sopenharmony_ci	struct address_space *cntl;	   /* 'control' area mappings. */
7462306a36Sopenharmony_ci	struct address_space *signal1;	   /* 'signal1' area mappings. */
7562306a36Sopenharmony_ci	struct address_space *signal2;	   /* 'signal2' area mappings. */
7662306a36Sopenharmony_ci	struct address_space *mss;	   /* 'mss' area mappings. */
7762306a36Sopenharmony_ci	struct address_space *psmap;	   /* 'psmap' area mappings. */
7862306a36Sopenharmony_ci	struct mutex mapping_lock;
7962306a36Sopenharmony_ci	u64 object_id;		   /* user space pointer for GNU Debugger */
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci	enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
8262306a36Sopenharmony_ci	struct mutex state_mutex;
8362306a36Sopenharmony_ci	struct mutex run_mutex;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	struct mm_struct *owner;
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	struct kref kref;
8862306a36Sopenharmony_ci	wait_queue_head_t ibox_wq;
8962306a36Sopenharmony_ci	wait_queue_head_t wbox_wq;
9062306a36Sopenharmony_ci	wait_queue_head_t stop_wq;
9162306a36Sopenharmony_ci	wait_queue_head_t mfc_wq;
9262306a36Sopenharmony_ci	wait_queue_head_t run_wq;
9362306a36Sopenharmony_ci	u32 tagwait;
9462306a36Sopenharmony_ci	struct spu_context_ops *ops;
9562306a36Sopenharmony_ci	struct work_struct reap_work;
9662306a36Sopenharmony_ci	unsigned long flags;
9762306a36Sopenharmony_ci	unsigned long event_return;
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	struct list_head gang_list;
10062306a36Sopenharmony_ci	struct spu_gang *gang;
10162306a36Sopenharmony_ci	struct kref *prof_priv_kref;
10262306a36Sopenharmony_ci	void ( * prof_priv_release) (struct kref *kref);
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	/* owner thread */
10562306a36Sopenharmony_ci	pid_t tid;
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	/* scheduler fields */
10862306a36Sopenharmony_ci	struct list_head rq;
10962306a36Sopenharmony_ci	unsigned int time_slice;
11062306a36Sopenharmony_ci	unsigned long sched_flags;
11162306a36Sopenharmony_ci	cpumask_t cpus_allowed;
11262306a36Sopenharmony_ci	int policy;
11362306a36Sopenharmony_ci	int prio;
11462306a36Sopenharmony_ci	int last_ran;
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci	/* statistics */
11762306a36Sopenharmony_ci	struct {
11862306a36Sopenharmony_ci		/* updates protected by ctx->state_mutex */
11962306a36Sopenharmony_ci		enum spu_utilization_state util_state;
12062306a36Sopenharmony_ci		unsigned long long tstamp;	/* time of last state switch */
12162306a36Sopenharmony_ci		unsigned long long times[SPU_UTIL_MAX];
12262306a36Sopenharmony_ci		unsigned long long vol_ctx_switch;
12362306a36Sopenharmony_ci		unsigned long long invol_ctx_switch;
12462306a36Sopenharmony_ci		unsigned long long min_flt;
12562306a36Sopenharmony_ci		unsigned long long maj_flt;
12662306a36Sopenharmony_ci		unsigned long long hash_flt;
12762306a36Sopenharmony_ci		unsigned long long slb_flt;
12862306a36Sopenharmony_ci		unsigned long long slb_flt_base; /* # at last ctx switch */
12962306a36Sopenharmony_ci		unsigned long long class2_intr;
13062306a36Sopenharmony_ci		unsigned long long class2_intr_base; /* # at last ctx switch */
13162306a36Sopenharmony_ci		unsigned long long libassist;
13262306a36Sopenharmony_ci	} stats;
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci	/* context switch log */
13562306a36Sopenharmony_ci	struct switch_log *switch_log;
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci	struct list_head aff_list;
13862306a36Sopenharmony_ci	int aff_head;
13962306a36Sopenharmony_ci	int aff_offset;
14062306a36Sopenharmony_ci};
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_cistruct spu_gang {
14362306a36Sopenharmony_ci	struct list_head list;
14462306a36Sopenharmony_ci	struct mutex mutex;
14562306a36Sopenharmony_ci	struct kref kref;
14662306a36Sopenharmony_ci	int contexts;
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci	struct spu_context *aff_ref_ctx;
14962306a36Sopenharmony_ci	struct list_head aff_list_head;
15062306a36Sopenharmony_ci	struct mutex aff_mutex;
15162306a36Sopenharmony_ci	int aff_flags;
15262306a36Sopenharmony_ci	struct spu *aff_ref_spu;
15362306a36Sopenharmony_ci	atomic_t aff_sched_count;
15462306a36Sopenharmony_ci};
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci/* Flag bits for spu_gang aff_flags */
15762306a36Sopenharmony_ci#define AFF_OFFSETS_SET		1
15862306a36Sopenharmony_ci#define AFF_MERGED		2
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_cistruct mfc_dma_command {
16162306a36Sopenharmony_ci	int32_t pad;	/* reserved */
16262306a36Sopenharmony_ci	uint32_t lsa;	/* local storage address */
16362306a36Sopenharmony_ci	uint64_t ea;	/* effective address */
16462306a36Sopenharmony_ci	uint16_t size;	/* transfer size */
16562306a36Sopenharmony_ci	uint16_t tag;	/* command tag */
16662306a36Sopenharmony_ci	uint16_t class;	/* class ID */
16762306a36Sopenharmony_ci	uint16_t cmd;	/* command opcode */
16862306a36Sopenharmony_ci};
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci/* SPU context query/set operations. */
17262306a36Sopenharmony_cistruct spu_context_ops {
17362306a36Sopenharmony_ci	int (*mbox_read) (struct spu_context * ctx, u32 * data);
17462306a36Sopenharmony_ci	 u32(*mbox_stat_read) (struct spu_context * ctx);
17562306a36Sopenharmony_ci	__poll_t (*mbox_stat_poll)(struct spu_context *ctx, __poll_t events);
17662306a36Sopenharmony_ci	int (*ibox_read) (struct spu_context * ctx, u32 * data);
17762306a36Sopenharmony_ci	int (*wbox_write) (struct spu_context * ctx, u32 data);
17862306a36Sopenharmony_ci	 u32(*signal1_read) (struct spu_context * ctx);
17962306a36Sopenharmony_ci	void (*signal1_write) (struct spu_context * ctx, u32 data);
18062306a36Sopenharmony_ci	 u32(*signal2_read) (struct spu_context * ctx);
18162306a36Sopenharmony_ci	void (*signal2_write) (struct spu_context * ctx, u32 data);
18262306a36Sopenharmony_ci	void (*signal1_type_set) (struct spu_context * ctx, u64 val);
18362306a36Sopenharmony_ci	 u64(*signal1_type_get) (struct spu_context * ctx);
18462306a36Sopenharmony_ci	void (*signal2_type_set) (struct spu_context * ctx, u64 val);
18562306a36Sopenharmony_ci	 u64(*signal2_type_get) (struct spu_context * ctx);
18662306a36Sopenharmony_ci	 u32(*npc_read) (struct spu_context * ctx);
18762306a36Sopenharmony_ci	void (*npc_write) (struct spu_context * ctx, u32 data);
18862306a36Sopenharmony_ci	 u32(*status_read) (struct spu_context * ctx);
18962306a36Sopenharmony_ci	char*(*get_ls) (struct spu_context * ctx);
19062306a36Sopenharmony_ci	void (*privcntl_write) (struct spu_context *ctx, u64 data);
19162306a36Sopenharmony_ci	 u32 (*runcntl_read) (struct spu_context * ctx);
19262306a36Sopenharmony_ci	void (*runcntl_write) (struct spu_context * ctx, u32 data);
19362306a36Sopenharmony_ci	void (*runcntl_stop) (struct spu_context * ctx);
19462306a36Sopenharmony_ci	void (*master_start) (struct spu_context * ctx);
19562306a36Sopenharmony_ci	void (*master_stop) (struct spu_context * ctx);
19662306a36Sopenharmony_ci	int (*set_mfc_query)(struct spu_context * ctx, u32 mask, u32 mode);
19762306a36Sopenharmony_ci	u32 (*read_mfc_tagstatus)(struct spu_context * ctx);
19862306a36Sopenharmony_ci	u32 (*get_mfc_free_elements)(struct spu_context *ctx);
19962306a36Sopenharmony_ci	int (*send_mfc_command)(struct spu_context * ctx,
20062306a36Sopenharmony_ci				struct mfc_dma_command * cmd);
20162306a36Sopenharmony_ci	void (*dma_info_read) (struct spu_context * ctx,
20262306a36Sopenharmony_ci			       struct spu_dma_info * info);
20362306a36Sopenharmony_ci	void (*proxydma_info_read) (struct spu_context * ctx,
20462306a36Sopenharmony_ci				    struct spu_proxydma_info * info);
20562306a36Sopenharmony_ci	void (*restart_dma)(struct spu_context *ctx);
20662306a36Sopenharmony_ci};
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ciextern struct spu_context_ops spu_hw_ops;
20962306a36Sopenharmony_ciextern struct spu_context_ops spu_backing_ops;
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_cistruct spufs_inode_info {
21262306a36Sopenharmony_ci	struct spu_context *i_ctx;
21362306a36Sopenharmony_ci	struct spu_gang *i_gang;
21462306a36Sopenharmony_ci	struct inode vfs_inode;
21562306a36Sopenharmony_ci	int i_openers;
21662306a36Sopenharmony_ci};
21762306a36Sopenharmony_ci#define SPUFS_I(inode) \
21862306a36Sopenharmony_ci	container_of(inode, struct spufs_inode_info, vfs_inode)
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistruct spufs_tree_descr {
22162306a36Sopenharmony_ci	const char *name;
22262306a36Sopenharmony_ci	const struct file_operations *ops;
22362306a36Sopenharmony_ci	umode_t mode;
22462306a36Sopenharmony_ci	size_t size;
22562306a36Sopenharmony_ci};
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ciextern const struct spufs_tree_descr spufs_dir_contents[];
22862306a36Sopenharmony_ciextern const struct spufs_tree_descr spufs_dir_nosched_contents[];
22962306a36Sopenharmony_ciextern const struct spufs_tree_descr spufs_dir_debug_contents[];
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci/* system call implementation */
23262306a36Sopenharmony_ciextern struct spufs_calls spufs_calls;
23362306a36Sopenharmony_cistruct coredump_params;
23462306a36Sopenharmony_cilong spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *status);
23562306a36Sopenharmony_cilong spufs_create(const struct path *nd, struct dentry *dentry, unsigned int flags,
23662306a36Sopenharmony_ci			umode_t mode, struct file *filp);
23762306a36Sopenharmony_ci/* ELF coredump callbacks for writing SPU ELF notes */
23862306a36Sopenharmony_ciextern int spufs_coredump_extra_notes_size(void);
23962306a36Sopenharmony_ciextern int spufs_coredump_extra_notes_write(struct coredump_params *cprm);
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ciextern const struct file_operations spufs_context_fops;
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/* gang management */
24462306a36Sopenharmony_cistruct spu_gang *alloc_spu_gang(void);
24562306a36Sopenharmony_cistruct spu_gang *get_spu_gang(struct spu_gang *gang);
24662306a36Sopenharmony_ciint put_spu_gang(struct spu_gang *gang);
24762306a36Sopenharmony_civoid spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx);
24862306a36Sopenharmony_civoid spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx);
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci/* fault handling */
25162306a36Sopenharmony_ciint spufs_handle_class1(struct spu_context *ctx);
25262306a36Sopenharmony_ciint spufs_handle_class0(struct spu_context *ctx);
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/* affinity */
25562306a36Sopenharmony_cistruct spu *affinity_check(struct spu_context *ctx);
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci/* context management */
25862306a36Sopenharmony_ciextern atomic_t nr_spu_contexts;
25962306a36Sopenharmony_cistatic inline int __must_check spu_acquire(struct spu_context *ctx)
26062306a36Sopenharmony_ci{
26162306a36Sopenharmony_ci	return mutex_lock_interruptible(&ctx->state_mutex);
26262306a36Sopenharmony_ci}
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_cistatic inline void spu_release(struct spu_context *ctx)
26562306a36Sopenharmony_ci{
26662306a36Sopenharmony_ci	mutex_unlock(&ctx->state_mutex);
26762306a36Sopenharmony_ci}
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_cistruct spu_context * alloc_spu_context(struct spu_gang *gang);
27062306a36Sopenharmony_civoid destroy_spu_context(struct kref *kref);
27162306a36Sopenharmony_cistruct spu_context * get_spu_context(struct spu_context *ctx);
27262306a36Sopenharmony_ciint put_spu_context(struct spu_context *ctx);
27362306a36Sopenharmony_civoid spu_unmap_mappings(struct spu_context *ctx);
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_civoid spu_forget(struct spu_context *ctx);
27662306a36Sopenharmony_ciint __must_check spu_acquire_saved(struct spu_context *ctx);
27762306a36Sopenharmony_civoid spu_release_saved(struct spu_context *ctx);
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ciint spu_stopped(struct spu_context *ctx, u32 * stat);
28062306a36Sopenharmony_civoid spu_del_from_rq(struct spu_context *ctx);
28162306a36Sopenharmony_ciint spu_activate(struct spu_context *ctx, unsigned long flags);
28262306a36Sopenharmony_civoid spu_deactivate(struct spu_context *ctx);
28362306a36Sopenharmony_civoid spu_yield(struct spu_context *ctx);
28462306a36Sopenharmony_civoid spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,
28562306a36Sopenharmony_ci		u32 type, u32 val);
28662306a36Sopenharmony_civoid spu_set_timeslice(struct spu_context *ctx);
28762306a36Sopenharmony_civoid spu_update_sched_info(struct spu_context *ctx);
28862306a36Sopenharmony_civoid __spu_update_sched_info(struct spu_context *ctx);
28962306a36Sopenharmony_ciint __init spu_sched_init(void);
29062306a36Sopenharmony_civoid spu_sched_exit(void);
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ciextern char *isolated_loader;
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci/*
29562306a36Sopenharmony_ci * spufs_wait
29662306a36Sopenharmony_ci *	Same as wait_event_interruptible(), except that here
29762306a36Sopenharmony_ci *	we need to call spu_release(ctx) before sleeping, and
29862306a36Sopenharmony_ci *	then spu_acquire(ctx) when awoken.
29962306a36Sopenharmony_ci *
30062306a36Sopenharmony_ci * 	Returns with state_mutex re-acquired when successful or
30162306a36Sopenharmony_ci * 	with -ERESTARTSYS and the state_mutex dropped when interrupted.
30262306a36Sopenharmony_ci */
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci#define spufs_wait(wq, condition)					\
30562306a36Sopenharmony_ci({									\
30662306a36Sopenharmony_ci	int __ret = 0;							\
30762306a36Sopenharmony_ci	DEFINE_WAIT(__wait);						\
30862306a36Sopenharmony_ci	for (;;) {							\
30962306a36Sopenharmony_ci		prepare_to_wait(&(wq), &__wait, TASK_INTERRUPTIBLE);	\
31062306a36Sopenharmony_ci		if (condition)						\
31162306a36Sopenharmony_ci			break;						\
31262306a36Sopenharmony_ci		spu_release(ctx);					\
31362306a36Sopenharmony_ci		if (signal_pending(current)) {				\
31462306a36Sopenharmony_ci			__ret = -ERESTARTSYS;				\
31562306a36Sopenharmony_ci			break;						\
31662306a36Sopenharmony_ci		}							\
31762306a36Sopenharmony_ci		schedule();						\
31862306a36Sopenharmony_ci		__ret = spu_acquire(ctx);				\
31962306a36Sopenharmony_ci		if (__ret)						\
32062306a36Sopenharmony_ci			break;						\
32162306a36Sopenharmony_ci	}								\
32262306a36Sopenharmony_ci	finish_wait(&(wq), &__wait);					\
32362306a36Sopenharmony_ci	__ret;								\
32462306a36Sopenharmony_ci})
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_cisize_t spu_wbox_write(struct spu_context *ctx, u32 data);
32762306a36Sopenharmony_cisize_t spu_ibox_read(struct spu_context *ctx, u32 *data);
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci/* irq callback funcs. */
33062306a36Sopenharmony_civoid spufs_ibox_callback(struct spu *spu);
33162306a36Sopenharmony_civoid spufs_wbox_callback(struct spu *spu);
33262306a36Sopenharmony_civoid spufs_stop_callback(struct spu *spu, int irq);
33362306a36Sopenharmony_civoid spufs_mfc_callback(struct spu *spu);
33462306a36Sopenharmony_civoid spufs_dma_callback(struct spu *spu, int type);
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_cistruct spufs_coredump_reader {
33762306a36Sopenharmony_ci	char *name;
33862306a36Sopenharmony_ci	ssize_t (*dump)(struct spu_context *ctx, struct coredump_params *cprm);
33962306a36Sopenharmony_ci	u64 (*get)(struct spu_context *ctx);
34062306a36Sopenharmony_ci	size_t size;
34162306a36Sopenharmony_ci};
34262306a36Sopenharmony_ciextern const struct spufs_coredump_reader spufs_coredump_read[];
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ciextern int spu_init_csa(struct spu_state *csa);
34562306a36Sopenharmony_ciextern void spu_fini_csa(struct spu_state *csa);
34662306a36Sopenharmony_ciextern int spu_save(struct spu_state *prev, struct spu *spu);
34762306a36Sopenharmony_ciextern int spu_restore(struct spu_state *new, struct spu *spu);
34862306a36Sopenharmony_ciextern int spu_switch(struct spu_state *prev, struct spu_state *new,
34962306a36Sopenharmony_ci		      struct spu *spu);
35062306a36Sopenharmony_ciextern int spu_alloc_lscsa(struct spu_state *csa);
35162306a36Sopenharmony_ciextern void spu_free_lscsa(struct spu_state *csa);
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_ciextern void spuctx_switch_state(struct spu_context *ctx,
35462306a36Sopenharmony_ci		enum spu_utilization_state new_state);
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci#endif
357