From 813f90728e7d74e9b753e6ef6c6915cd2a047adb Mon Sep 17 00:00:00 2001 From: Christian Krafft Date: Fri, 20 Jul 2007 21:39:18 +0200 Subject: [CELL] pmi: remove support for mutiple devices. The pmi driver got simplified by removing support for multiple devices. As there is no more than one pmi device per maschine, there is no need to specify the device for listening and sending messages. This way the caller (cbe_cpufreq) doesn't need to scan the device tree. When registering the handler on a board without a pmi interface, pmi.c will just return -ENODEV. The patch that fixed the breakage of cell_defconfig has been broken out of the earlier version of this patch. So this is the version that applies cleanly on top of it. Signed-off-by: Christian Krafft Signed-off-by: Arnd Bergmann --- include/asm-powerpc/pmi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/asm-powerpc/pmi.h b/include/asm-powerpc/pmi.h index cb0f8aa430..2259d4ce38 100644 --- a/include/asm-powerpc/pmi.h +++ b/include/asm-powerpc/pmi.h @@ -55,13 +55,13 @@ typedef struct { struct pmi_handler { struct list_head node; u8 type; - void (*handle_pmi_message) (struct of_device *, pmi_message_t); + void (*handle_pmi_message) (pmi_message_t); }; -void pmi_register_handler(struct of_device *, struct pmi_handler *); -void pmi_unregister_handler(struct of_device *, struct pmi_handler *); +int pmi_register_handler(struct pmi_handler *); +void pmi_unregister_handler(struct pmi_handler *); -void pmi_send_message(struct of_device *, pmi_message_t); +int pmi_send_message(pmi_message_t); #endif /* __KERNEL__ */ #endif /* _POWERPC_PMI_H */ -- cgit v1.2.2 From 8d2655e621bfc3c3f925016f881a36739d479f69 Mon Sep 17 00:00:00 2001 From: Andre Detsch Date: Fri, 20 Jul 2007 21:39:27 +0200 Subject: [CELL] saving spus information for kexec crash This patch adds support for investigating spus information after a kernel crash event, through kdump vmcore file. Implementation is based on xmon code, but the new functionality was kept independent from xmon. Signed-off-by: Lucio Jose Herculano Correia Signed-off-by: Andre Detsch Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index eedc828cef..42d88a6d2d 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -188,6 +188,14 @@ int spu_irq_class_0_bottom(struct spu *spu); int spu_irq_class_1_bottom(struct spu *spu); void spu_irq_setaffinity(struct spu *spu, int cpu); +#ifdef CONFIG_KEXEC +void crash_register_spus(struct list_head *list); +#else +static inline void crash_register_spus(struct list_head *list) +{ +} +#endif + extern void spu_invalidate_slbs(struct spu *spu); extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm); -- cgit v1.2.2 From 49776d30aea903fb2f9966c8e9b6f23ae5f7c937 Mon Sep 17 00:00:00 2001 From: Kazunori Asayama Date: Fri, 20 Jul 2007 21:39:30 +0200 Subject: [CELL] spufs: Avoid unexpectedly restaring MFC during context save The current SPU context saving procedure in SPUFS unexpectedly restarts MFC when halting decrementer, because MFC_CNTL[Dh] is set without MFC_CNTL[Sm]. This bug causes, for example, saving broken DMA queues. Here is a patch to fix the problem. Signed-off-by: Kazunori Asayama Signed-off-by: Jeremy Kerr Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index 42d88a6d2d..a034f03b81 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -411,6 +411,7 @@ struct spu_priv2 { #define MFC_CNTL_RESUME_DMA_QUEUE (0ull << 0) #define MFC_CNTL_SUSPEND_DMA_QUEUE (1ull << 0) #define MFC_CNTL_SUSPEND_DMA_QUEUE_MASK (1ull << 0) +#define MFC_CNTL_SUSPEND_MASK (1ull << 4) #define MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION (0ull << 8) #define MFC_CNTL_SUSPEND_IN_PROGRESS (1ull << 8) #define MFC_CNTL_SUSPEND_COMPLETE (3ull << 8) -- cgit v1.2.2 From 27ec41d3a1d4df2b7cd190e93aad22ab86a72aa1 Mon Sep 17 00:00:00 2001 From: Andre Detsch Date: Fri, 20 Jul 2007 21:39:33 +0200 Subject: [CELL] spufs: add spu stats in sysfs and ctx stat file in spufs This patch exports per-context statistics in spufs as long as spu statistics in sysfs. It was formed by merging: "spufs: add spu stats in sysfs" From: Christoph Hellwig "spufs: add stat file to spufs" From: Christoph Hellwig "spufs: fix libassist accounting" From: Jeremy Kerr "spusched: fix spu utilization statistics" From: Luke Browning And some adjustments by myself, after suggestions on cbe-oss-dev. Having separate patches was making the review process harder than it should, as we end up integrating spus and ctx statistics accounting much more than it was on the first implementation. Signed-off-by: Andre Detsch Signed-off-by: Jeremy Kerr Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index a034f03b81..12442acdc7 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -107,10 +107,10 @@ struct spu_runqueue; struct device_node; enum spu_utilization_state { - SPU_UTIL_SYSTEM, SPU_UTIL_USER, + SPU_UTIL_SYSTEM, SPU_UTIL_IOWAIT, - SPU_UTIL_IDLE, + SPU_UTIL_IDLE_LOADED, SPU_UTIL_MAX }; @@ -167,9 +167,9 @@ struct spu { struct { /* protected by interrupt reentrancy */ - enum spu_utilization_state utilization_state; - unsigned long tstamp; /* time of last ctx switch */ - unsigned long times[SPU_UTIL_MAX]; + enum spu_utilization_state util_state; + unsigned long long tstamp; + unsigned long long times[SPU_UTIL_MAX]; unsigned long long vol_ctx_switch; unsigned long long invol_ctx_switch; unsigned long long min_flt; -- cgit v1.2.2 From 1cfc0f86eb0348dd04ace8c2171642ebe9cd87bb Mon Sep 17 00:00:00 2001 From: Masato Noguchi Date: Fri, 20 Jul 2007 21:39:37 +0200 Subject: [CELL] spufs: fix decr_status meanings The decr_status in the LSCSA is confusedly used as two meanings: * SPU decrementer was running * SPU decrementer was wrapped as a result of adjust and the code to set decr_status is missing. This patch fixes these problems by using the decr_status argument as a set of flags. This requires a rebuild of the shipped spu_restore code. Signed-off-by: Masato Noguchi Signed-off-by: Jeremy Kerr Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu_csa.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/asm-powerpc/spu_csa.h b/include/asm-powerpc/spu_csa.h index c48ae185c8..e87794d5d4 100644 --- a/include/asm-powerpc/spu_csa.h +++ b/include/asm-powerpc/spu_csa.h @@ -50,6 +50,12 @@ #define SPU_STOPPED_STATUS_P_I 8 #define SPU_STOPPED_STATUS_R 9 +/* + * Definitions for software decrementer status flag. + */ +#define SPU_DECR_STATUS_RUNNING 0x1 +#define SPU_DECR_STATUS_WRAPPED 0x2 + #ifndef __ASSEMBLY__ /** * spu_reg128 - generic 128-bit register definition. @@ -63,7 +69,7 @@ struct spu_reg128 { * @gprs: Array of saved registers. * @fpcr: Saved floating point status control register. * @decr: Saved decrementer value. - * @decr_status: Indicates decrementer run status. + * @decr_status: Indicates software decrementer status flags. * @ppu_mb: Saved PPU mailbox data. * @ppuint_mb: Saved PPU interrupting mailbox data. * @tag_mask: Saved tag group mask. -- cgit v1.2.2 From aa6d5b20254a21b69092dd839b70ee148303ef25 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 20 Jul 2007 21:39:44 +0200 Subject: [CELL] cell: add per BE structure with info about its SPUs Addition of a spufs-global "cbe_info" array. Each entry contains information about one Cell/B.E. node, namelly: * list of spus (both free and busy spus are in this list); * list of free spus (replacing the static spu_list from spu_base.c) * number of spus; * number of reserved (non scheduleable) spus. SPE affinity implementation actually requires only access to one spu per BE node (since it implements its own pointer to walk through the other spus of the ring) and the number of scheduleable spus (n_spus - non_sched_spus) However having this more general structure can be useful for other functionalities, concentrating per-cbe statistics / data. Signed-off-by: Andre Detsch Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index 12442acdc7..2f2fe9f1c0 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -122,6 +122,7 @@ struct spu { struct spu_problem __iomem *problem; struct spu_priv2 __iomem *priv2; struct list_head list; + struct list_head cbe_list; struct list_head sched_list; struct list_head full_list; int number; @@ -181,6 +182,15 @@ struct spu { } stats; }; +struct cbe_spu_info { + struct list_head spus; + struct list_head free_spus; + int n_spus; + atomic_t reserved_spus; +}; + +extern struct cbe_spu_info cbe_spu_info[]; + struct spu *spu_alloc(void); struct spu *spu_alloc_node(int node); void spu_free(struct spu *spu); -- cgit v1.2.2 From 9d92af621f193c1c889ac8b6fd8c987ccd8aae1f Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 20 Jul 2007 21:39:45 +0200 Subject: [CELL] cell: add vicinity information on spus This patch adds affinity data to each spu instance. A doubly linked list is created, meant to connect the spus in the physical order they are placed in the BE. SPUs near to memory should be marked as having memory affinity. Adjustments of the fields acording to FW properties is done in separate patches, one for CPBW, one for Malta (patch for Malta under testing). Signed-off-by: Andre Detsch Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index 2f2fe9f1c0..18e558bef9 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -166,6 +166,9 @@ struct spu { struct sys_device sysdev; + int has_mem_affinity; + struct list_head aff_list; + struct { /* protected by interrupt reentrancy */ enum spu_utilization_state util_state; -- cgit v1.2.2 From 8e68e2f248332a9c3fd4f08258f488c209bd3e0c Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 20 Jul 2007 21:39:47 +0200 Subject: [CELL] spufs: extension of spu_create to support affinity definition This patch adds support for additional flags at spu_create, which relate to the establishment of affinity between contexts and contexts to memory. A fourth, optional, parameter is supported. This parameter represent a affinity neighbor of the context being created, and is used when defining SPU-SPU affinity. Affinity is represented as a doubly linked list of spu_contexts. Signed-off-by: Andre Detsch Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 8 ++++++-- include/linux/syscalls.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index 18e558bef9..24f352da28 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -196,6 +196,7 @@ extern struct cbe_spu_info cbe_spu_info[]; struct spu *spu_alloc(void); struct spu *spu_alloc_node(int node); +struct spu *spu_alloc_spu(struct spu *spu); void spu_free(struct spu *spu); int spu_irq_class_0_bottom(struct spu *spu); int spu_irq_class_1_bottom(struct spu *spu); @@ -227,7 +228,8 @@ extern long spu_sys_callback(struct spu_syscall_block *s); struct file; extern struct spufs_calls { asmlinkage long (*create_thread)(const char __user *name, - unsigned int flags, mode_t mode); + unsigned int flags, mode_t mode, + struct file *neighbor); asmlinkage long (*spu_run)(struct file *filp, __u32 __user *unpc, __u32 __user *ustatus); struct module *owner; @@ -254,8 +256,10 @@ struct spu_coredump_calls { #define SPU_CREATE_GANG 0x0002 #define SPU_CREATE_NOSCHED 0x0004 #define SPU_CREATE_ISOLATE 0x0008 +#define SPU_CREATE_AFFINITY_SPU 0x0010 +#define SPU_CREATE_AFFINITY_MEM 0x0020 -#define SPU_CREATE_FLAG_ALL 0x000f /* mask of all valid flags */ +#define SPU_CREATE_FLAG_ALL 0x003f /* mask of all valid flags */ #ifdef CONFIG_SPU_FS_MODULE diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 7a8b1e3322..61def7c8fb 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -549,7 +549,7 @@ asmlinkage long sys_inotify_rm_watch(int fd, u32 wd); asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus); asmlinkage long sys_spu_create(const char __user *name, - unsigned int flags, mode_t mode); + unsigned int flags, mode_t mode, int fd); asmlinkage long sys_mknodat(int dfd, const char __user * filename, int mode, unsigned dev); -- cgit v1.2.2 From 1474855d0878cced6f39f51f3c2bd7428b44cb1e Mon Sep 17 00:00:00 2001 From: Bob Nelson Date: Fri, 20 Jul 2007 21:39:53 +0200 Subject: [CELL] oprofile: add support to OProfile for profiling CELL BE SPUs From: Maynard Johnson This patch updates the existing arch/powerpc/oprofile/op_model_cell.c to add in the SPU profiling capabilities. In addition, a 'cell' subdirectory was added to arch/powerpc/oprofile to hold Cell-specific SPU profiling code. Exports spu_set_profile_private_kref and spu_get_profile_private_kref which are used by OProfile to store private profile information in spufs data structures. Also incorporated several fixes from other patches (rrn). Check pointer returned from kzalloc. Eliminated unnecessary cast. Better error handling and cleanup in the related area. 64-bit unsigned long parameter was being demoted to 32-bit unsigned int and eventually promoted back to unsigned long. Signed-off-by: Carl Love Signed-off-by: Maynard Johnson Signed-off-by: Bob Nelson Signed-off-by: Arnd Bergmann Acked-by: Paul Mackerras --- include/asm-powerpc/oprofile_impl.h | 10 ++++++---- include/asm-powerpc/spu.h | 15 +++++++++++++++ include/linux/dcookies.h | 1 + include/linux/elf-em.h | 3 ++- include/linux/oprofile.h | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h index 8d6b47f7b3..938fefb4c4 100644 --- a/include/asm-powerpc/oprofile_impl.h +++ b/include/asm-powerpc/oprofile_impl.h @@ -39,14 +39,16 @@ struct op_system_config { /* Per-arch configuration */ struct op_powerpc_model { - void (*reg_setup) (struct op_counter_config *, + int (*reg_setup) (struct op_counter_config *, struct op_system_config *, int num_counters); - void (*cpu_setup) (struct op_counter_config *); - void (*start) (struct op_counter_config *); - void (*global_start) (struct op_counter_config *); + int (*cpu_setup) (struct op_counter_config *); + int (*start) (struct op_counter_config *); + int (*global_start) (struct op_counter_config *); void (*stop) (void); void (*global_stop) (void); + int (*sync_start)(void); + int (*sync_stop)(void); void (*handle_interrupt) (struct pt_regs *, struct op_counter_config *); int num_counters; diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index 24f352da28..a0f7fc8e23 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -138,6 +138,7 @@ struct spu { struct spu_runqueue *rq; unsigned long long timestamp; pid_t pid; + pid_t tgid; int class_0_pending; spinlock_t register_lock; @@ -217,6 +218,20 @@ extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm); struct mm_struct; extern void spu_flush_all_slbs(struct mm_struct *mm); +/* This interface allows a profiler (e.g., OProfile) to store a ref + * to spu context information that it creates. This caching technique + * avoids the need to recreate this information after a save/restore operation. + * + * Assumes the caller has already incremented the ref count to + * profile_info; then spu_context_destroy must call kref_put + * on prof_info_kref. + */ +void spu_set_profile_private_kref(struct spu_context *ctx, + struct kref *prof_info_kref, + void ( * prof_info_release) (struct kref *kref)); + +void *spu_get_profile_private_kref(struct spu_context *ctx); + /* system callbacks from the SPU */ struct spu_syscall_block { u64 nr_ret; diff --git a/include/linux/dcookies.h b/include/linux/dcookies.h index 0fe7cdf326..98c69ab80c 100644 --- a/include/linux/dcookies.h +++ b/include/linux/dcookies.h @@ -12,6 +12,7 @@ #ifdef CONFIG_PROFILING +#include #include struct dcookie_user; diff --git a/include/linux/elf-em.h b/include/linux/elf-em.h index 0311bad838..5834e843a9 100644 --- a/include/linux/elf-em.h +++ b/include/linux/elf-em.h @@ -20,7 +20,8 @@ #define EM_PARISC 15 /* HPPA */ #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ #define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* PowerPC64 */ +#define EM_PPC64 21 /* PowerPC64 */ +#define EM_SPU 23 /* Cell BE SPU */ #define EM_SH 42 /* SuperH */ #define EM_SPARCV9 43 /* SPARC v9 64-bit */ #define EM_IA_64 50 /* HP/Intel IA-64 */ diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h index 0d514b2524..041bb31100 100644 --- a/include/linux/oprofile.h +++ b/include/linux/oprofile.h @@ -17,6 +17,26 @@ #include #include +/* Each escaped entry is prefixed by ESCAPE_CODE + * then one of the following codes, then the + * relevant data. + * These #defines live in this file so that arch-specific + * buffer sync'ing code can access them. + */ +#define ESCAPE_CODE ~0UL +#define CTX_SWITCH_CODE 1 +#define CPU_SWITCH_CODE 2 +#define COOKIE_SWITCH_CODE 3 +#define KERNEL_ENTER_SWITCH_CODE 4 +#define KERNEL_EXIT_SWITCH_CODE 5 +#define MODULE_LOADED_CODE 6 +#define CTX_TGID_CODE 7 +#define TRACE_BEGIN_CODE 8 +#define TRACE_END_CODE 9 +#define XEN_ENTER_SWITCH_CODE 10 +#define SPU_PROFILING_CODE 11 +#define SPU_CTX_SWITCH_CODE 12 + struct super_block; struct dentry; struct file_operations; @@ -35,6 +55,14 @@ struct oprofile_operations { int (*start)(void); /* Stop delivering interrupts. */ void (*stop)(void); + /* Arch-specific buffer sync functions. + * Return value = 0: Success + * Return value = -1: Failure + * Return value = 1: Run generic sync function + */ + int (*sync_start)(void); + int (*sync_stop)(void); + /* Initiate a stack backtrace. Optional. */ void (*backtrace)(struct pt_regs * const regs, unsigned int depth); /* CPU identification string. */ @@ -55,6 +83,13 @@ int oprofile_arch_init(struct oprofile_operations * ops); */ void oprofile_arch_exit(void); +/** + * Add data to the event buffer. + * The data passed is free-form, but typically consists of + * file offsets, dcookies, context information, and ESCAPE codes. + */ +void add_event_entry(unsigned long data); + /** * Add a sample. This may be called from any context. Pass * smp_processor_id() as cpu. -- cgit v1.2.2 From 486acd4850dde6d2f8c7f431432f3914c4bfb5f5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 20 Jul 2007 21:39:54 +0200 Subject: [CELL] spufs: rework list management and associated locking This sorts out the various lists and related locks in the spu code. In detail: - the per-node free_spus and active_list are gone. Instead struct spu gained an alloc_state member telling whether the spu is free or not - the per-node spus array is now locked by a per-node mutex, which takes over from the global spu_lock and the per-node active_mutex - the spu_alloc* and spu_free function are gone as the state change is now done inline in the spufs code. This allows some more sharing of code for the affinity vs normal case and more efficient locking - some little refactoring in the affinity code for this locking scheme Signed-off-by: Christoph Hellwig Signed-off-by: Arnd Bergmann --- include/asm-powerpc/spu.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h index a0f7fc8e23..8836c0f1f2 100644 --- a/include/asm-powerpc/spu.h +++ b/include/asm-powerpc/spu.h @@ -121,10 +121,9 @@ struct spu { unsigned long problem_phys; struct spu_problem __iomem *problem; struct spu_priv2 __iomem *priv2; - struct list_head list; struct list_head cbe_list; - struct list_head sched_list; struct list_head full_list; + enum { SPU_FREE, SPU_USED } alloc_state; int number; unsigned int irqs[3]; u32 node; @@ -187,18 +186,16 @@ struct spu { }; struct cbe_spu_info { + struct mutex list_mutex; struct list_head spus; - struct list_head free_spus; int n_spus; + int nr_active; atomic_t reserved_spus; }; extern struct cbe_spu_info cbe_spu_info[]; -struct spu *spu_alloc(void); -struct spu *spu_alloc_node(int node); -struct spu *spu_alloc_spu(struct spu *spu); -void spu_free(struct spu *spu); +void spu_init_channels(struct spu *spu); int spu_irq_class_0_bottom(struct spu *spu); int spu_irq_class_1_bottom(struct spu *spu); void spu_irq_setaffinity(struct spu *spu, int cpu); -- cgit v1.2.2