Hello community,
here is the log from the commit of package libspe2
checked in at Fri Oct 24 17:14:26 CEST 2008.
--------
--- arch/ppc/libspe2/libspe2.changes 2008-10-21 15:40:33.000000000 +0200
+++ /mounts/work_src_done/STABLE/libspe2/libspe2.changes 2008-10-24 15:24:40.000000000 +0200
@@ -1,0 +2,6 @@
+Fri Oct 24 09:12:44 CEST 2008 - sassmann@suse.de
+
+- update libspe2 to version 2.3.0 (bnc#438245)
+- register elfspe directly after install (bnc#438247)
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
libspe2-2.2.80.tar.bz2
New:
----
libspe2-2.3.0.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libspe2.spec ++++++
--- /var/tmp/diff_new_pack.X25439/_old 2008-10-24 17:14:13.000000000 +0200
+++ /var/tmp/diff_new_pack.X25439/_new 2008-10-24 17:14:13.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package libspe2 (Version 2.2.80)
+# spec file for package libspe2 (Version 2.3.0)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -22,14 +22,14 @@
License: GPL v2 or later; LGPL v2.1 or later
Group: Development/Libraries/Cross
AutoReqProv: on
-Version: 2.2.80
-Release: 14
+Version: 2.3.0
+Release: 1
Summary: Helper for standalone SPE applications
Url: http://www.bsc.es/plantillaH.php?cat_id=253
PreReq: %insserv_prereq grep
Provides: libspe
Obsoletes: libspe
-Source0: libspe2-2.2.80.tar.bz2
+Source0: %{name}-%{version}.tar.bz2
Source1: elfspe
Patch0: libspe2.ps.patch
Patch1: libspe2.binfmt.patch
@@ -70,6 +70,13 @@
if grep -q 'Cell Broadband Engine' < /proc/cpuinfo ; then
%{fillup_and_insserv -y elfspe }
fi
+# check that we are not in chroot
+if [ $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) ] ; then
+ # start elfspe if it's not running
+ if [ ! -e /proc/sys/fs/binfmt_misc/spe ] ; then
+ /etc/init.d/elfspe start
+ fi
+fi
%postun
/sbin/ldconfig
@@ -104,6 +111,9 @@
/usr/include/*
%changelog
+* Fri Oct 24 2008 sassmann@suse.de
+- update libspe2 to version 2.3.0 (bnc#438245)
+- register elfspe directly after install (bnc#438247)
* Tue Oct 21 2008 ro@suse.de
- add libspe2-devel to baselibs.conf
* Wed Jul 23 2008 sassmann@suse.de
++++++ libspe2-2.2.80.tar.bz2 -> libspe2-2.3.0.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/libspe2.c new/libspe2-2.3.0/libspe2.c
--- old/libspe2-2.2.80/libspe2.c 2007-07-17 15:09:31.000000000 +0200
+++ new/libspe2-2.3.0/libspe2.c 2008-08-29 13:11:47.000000000 +0200
@@ -60,6 +60,10 @@
*/
spe_context_ptr_t spe_context_create_affinity(unsigned int flags, spe_context_ptr_t affinity_neighbor, spe_gang_context_ptr_t gang)
{
+ if ( gang == NULL ) {
+ errno = ESRCH;
+ return NULL;
+ }
spe_context_ptr_t spe = _base_spe_context_create(flags, gang, affinity_neighbor);
if ( spe == NULL ) {
return NULL;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/libspe2.spec new/libspe2-2.3.0/libspe2.spec
--- old/libspe2-2.2.80/libspe2.spec 2008-03-27 04:39:13.000000000 +0100
+++ new/libspe2-2.3.0/libspe2.spec 2008-10-17 14:00:54.000000000 +0200
@@ -1,12 +1,12 @@
%define release %{_version}
%define build_all 1
Name: libspe2
-Version: 2.2.80
+Version: 2.3.0
Release: %{release}
License: LGPL
Group: System Environment/Base
URL: http://www.bsc.es/projects/deepcomputing/linuxoncell
-Source: http://www.bsc.es/projects/deepcomputing/linuxoncell/development/release2.0/libspe/%{name}-%{version}-%{release}.tar.gz
+Source: http://www.bsc.es/projects/deepcomputing/linuxoncell/development/release2.0/libspe/%{name}-%{version}.%{release}.tar.gz
Buildroot: %{_tmppath}/libspe
Exclusivearch: ppc ppc64 noarch
Summary: SPE Runtime Management Library
@@ -197,6 +197,7 @@
%if %{build_common}
%preun -n elfspe2
[ -f %{_initdir}/elfspe ] && /sbin/chkconfig --del elfspe
+[ -f %{_bindir}/elfspe-unregister ] && %{_bindir}/elfspe-unregister
%post -n elfspe2
[ -f %{_initdir}/elfspe ] && /sbin/chkconfig --add elfspe
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/libspe2-types.h new/libspe2-2.3.0/libspe2-types.h
--- old/libspe2-2.2.80/libspe2-types.h 2007-10-15 08:28:49.000000000 +0200
+++ new/libspe2-2.3.0/libspe2-types.h 2008-10-01 14:47:32.000000000 +0200
@@ -180,6 +180,7 @@
#define SPE_ISOLATE_EMULATE 0x00000100
#define SPE_EVENTS_ENABLE 0x00001000
#define SPE_AFFINITY_MEMORY 0x00002000
+#define SPE_NOSCHED 0x00004000
/**
@@ -261,10 +262,13 @@
#define SPE_CALLBACK_UPDATE 2
-
#define SPE_COUNT_PHYSICAL_CPU_NODES 1
#define SPE_COUNT_PHYSICAL_SPES 2
#define SPE_COUNT_USABLE_SPES 3
+#define SPE_CPU_TYPE 4
+
+#define SPE_CPU_IS_CELLBE 1
+#define SPE_CPU_IS_CELLEDP 2
/**
* Signal Targets
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/make.defines new/libspe2-2.3.0/make.defines
--- old/libspe2-2.2.80/make.defines 2008-03-27 04:42:48.000000000 +0100
+++ new/libspe2-2.3.0/make.defines 2008-10-17 14:00:54.000000000 +0200
@@ -109,7 +109,7 @@
INSTALL_DIR := ${INSTALL} -d -m 755
MAJOR_VERSION := 2
-MINOR_VERSION := 2.80
+MINOR_VERSION := 3.0
libspe2_A := libspe2.a
libspe2_SO := libspe2.so.${MAJOR_VERSION}.${MINOR_VERSION}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/Makefile new/libspe2-2.3.0/Makefile
--- old/libspe2-2.2.80/Makefile 2008-03-27 04:42:48.000000000 +0100
+++ new/libspe2-2.3.0/Makefile 2008-10-17 14:00:54.000000000 +0200
@@ -30,7 +30,7 @@
VERSION := $(MAJOR_VERSION).$(MINOR_VERSION)
RELEASE := $(shell svnversion)
FULLNAME := $(PACKAGE)-$(VERSION)
-PACKAGE_VER := $(FULLNAME)-$(RELEASE)
+PACKAGE_VER := $(FULLNAME).$(RELEASE)
TARBALL := $(SOURCES)$(PACKAGE_VER).tar.gz
SOURCEFILES := $(TARBALL)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/create.c new/libspe2-2.3.0/spebase/create.c
--- old/libspe2-2.2.80/spebase/create.c 2008-03-10 14:45:17.000000000 +0100
+++ new/libspe2-2.3.0/spebase/create.c 2008-09-02 18:10:59.000000000 +0200
@@ -231,6 +231,9 @@
}
/* initialise spu_createflags */
+ if (flags & SPE_NOSCHED)
+ spu_createflags |= SPU_CREATE_NOSCHED;
+
if (flags & SPE_ISOLATE) {
flags |= SPE_MAP_PS;
spu_createflags |= SPU_CREATE_ISOLATE | SPU_CREATE_NOSCHED;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/default_c99_handler.c new/libspe2-2.3.0/spebase/default_c99_handler.c
--- old/libspe2-2.2.80/spebase/default_c99_handler.c 2007-11-22 14:51:06.000000000 +0100
+++ new/libspe2-2.3.0/spebase/default_c99_handler.c 2008-08-29 13:11:47.000000000 +0200
@@ -29,6 +29,7 @@
#include "default_c99_handler.h"
#include "handler_utils.h"
+#include "spebase.h"
/* SPE C99 Handlers - Overview:
* This file implements handlers for SPE C99 library operations such
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/default_libea_handler.c new/libspe2-2.3.0/spebase/default_libea_handler.c
--- old/libspe2-2.2.80/spebase/default_libea_handler.c 2008-04-18 15:21:29.000000000 +0200
+++ new/libspe2-2.3.0/spebase/default_libea_handler.c 2008-08-29 13:11:47.000000000 +0200
@@ -1,6 +1,7 @@
#define _GNU_SOURCE
#include "default_libea_handler.h"
+#include "spebase.h"
#include "handler_utils.h"
#include
#include
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/default_posix1_handler.c new/libspe2-2.3.0/spebase/default_posix1_handler.c
--- old/libspe2-2.2.80/spebase/default_posix1_handler.c 2008-03-10 14:45:17.000000000 +0100
+++ new/libspe2-2.3.0/spebase/default_posix1_handler.c 2008-08-29 13:11:47.000000000 +0200
@@ -42,6 +42,7 @@
#include "default_posix1_handler.h"
#include "handler_utils.h"
+#include "spebase.h"
/* SPE POSIX.1 Handlers - Overview:
* This file implements handlers for SPE POSIX.1 library calls such as
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/elf_loader.c new/libspe2-2.3.0/spebase/elf_loader.c
--- old/libspe2-2.2.80/spebase/elf_loader.c 2008-04-14 16:38:44.000000000 +0200
+++ new/libspe2-2.3.0/spebase/elf_loader.c 2008-06-05 16:25:53.000000000 +0200
@@ -219,15 +219,17 @@
for (; r < r_end; ++r)
{
if (r->r_info == ELF32_R_INFO(0,R_SPU_PPU32)) {
+ /* v is in ._ea */
Elf32_Word *loc = reloc_base + r->r_offset;
- Elf32_Word v = (Elf32_Word)(long)start + r->r_addend;
+ Elf32_Word v = (unsigned long)start + r->r_addend;
/* Don't dirty pages unnecessarily. */
if (*loc != v)
*loc = v;
DEBUG_PRINTF("PPU32(%p) = %#x\n", loc, v);
} else if (r->r_info == ELF32_R_INFO(0,R_SPU_PPU64)) {
+ /* v is in ._ea */
Elf64_Xword *loc = reloc_base + r->r_offset;
- Elf64_Xword v = (Elf64_Xword)(long)start + r->r_addend;
+ Elf64_Xword v = (unsigned long)start + r->r_addend;
if (*loc != v)
*loc = v;
DEBUG_PRINTF("PPU64(%p) = %#llx\n", loc, v);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/handler_utils.h new/libspe2-2.3.0/spebase/handler_utils.h
--- old/libspe2-2.2.80/spebase/handler_utils.h 2007-03-21 15:49:59.000000000 +0100
+++ new/libspe2-2.3.0/spebase/handler_utils.h 2008-08-29 13:11:47.000000000 +0200
@@ -20,15 +20,6 @@
#ifndef __HANDLER_UTILS_H__
#define __HANDLER_UTILS_H__
-struct spe_reg128 {
- unsigned int slot[4];
-};
-
-#ifndef LS_SIZE
-#define LS_SIZE 0x40000 /* 256K (in bytes) */
-#define LS_ADDR_MASK (LS_SIZE - 1)
-#endif /* LS_SIZE */
-
#define __PRINTF(fmt, args...) { fprintf(stderr,fmt , ## args); }
#ifdef DEBUG
#define DEBUG_PRINTF(fmt, args...) __PRINTF(fmt , ## args)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/info.c new/libspe2-2.3.0/spebase/info.c
--- old/libspe2-2.2.80/spebase/info.c 2007-05-31 12:15:33.000000000 +0200
+++ new/libspe2-2.3.0/spebase/info.c 2008-10-01 14:47:32.000000000 +0200
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include "info.h"
@@ -31,7 +32,7 @@
{
const char *buff = "/sys/devices/system/cpu";
DIR *dirp;
- int ret = -2;
+ int ret = 0;
struct dirent *dptr;
DEBUG_PRINTF ("spe_count_physical_cpus()\n");
@@ -50,7 +51,8 @@
return -1;
}
while((dptr=readdir(dirp))) {
- ret++;
+ if(strncmp("cpu",dptr->d_name,3) == 0)
+ ret++;
}
closedir(dirp);
return ret/THREADS_PER_BE;
@@ -101,6 +103,24 @@
return ret;
}
+/* Since there are no mixed-type CPU systems at this time the cpu node
+ * is currently ignored, and a result is generated that returns the
+ * feature set of the currently running CPU.
+ */
+int _base_spe_read_cpu_type(int cpu_node)
+{
+ unsigned long pvr;
+ int i=0;
+
+ asm volatile ("mfpvr %0" : "=r"(pvr));
+
+ while (pvr_list_edp[i] != 0) {
+ if (pvr_list_edp[i++] == pvr)
+ return SPE_CPU_IS_CELLEDP;
+ }
+
+ return SPE_CPU_IS_CELLBE;
+}
int _base_spe_cpu_info_get(int info_requested, int cpu_node) {
int ret = 0;
@@ -116,6 +136,9 @@
case SPE_COUNT_USABLE_SPES:
ret = _base_spe_count_usable_spes(cpu_node);
break;
+ case SPE_CPU_TYPE:
+ ret = _base_spe_read_cpu_type(cpu_node);
+ break;
default:
errno = EINVAL;
ret = -1;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/info.h new/libspe2-2.3.0/spebase/info.h
--- old/libspe2-2.2.80/spebase/info.h 2007-03-21 15:49:59.000000000 +0100
+++ new/libspe2-2.3.0/spebase/info.h 2008-10-01 14:47:32.000000000 +0200
@@ -27,5 +27,12 @@
int _base_spe_count_physical_cpus(int cpu_node);
int _base_spe_count_physical_spes(int cpu_node);
int _base_spe_count_usable_spes(int cpu_node);
+int _base_spe_read_cpu_type(int cpu_node);
+
+/* Here is a list of edp capable PVRs
+ * Known non-EDP are: 0x0070 0501 ( PS3, QS20, QS21 )
+ * Known EPD capable: 0x0070 3000 ( QS22 )
+ */
+unsigned long pvr_list_edp[] = {0x00703000, 0};
#endif
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/Makefile new/libspe2-2.3.0/spebase/Makefile
--- old/libspe2-2.2.80/spebase/Makefile 2008-02-04 13:53:20.000000000 +0100
+++ new/libspe2-2.3.0/spebase/Makefile 2008-08-29 13:11:47.000000000 +0200
@@ -31,7 +31,7 @@
libspebase_OBJS := create.o elf_loader.o load.o run.o image.o lib_builtin.o \
default_c99_handler.o default_posix1_handler.o default_libea_handler.o \
- dma.o mbox.o accessors.o info.o
+ dma.o mbox.o accessors.o info.o regs.o
CFLAGS += -I..
CFLAGS += -D_ATFILE_SOURCE
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/regs.c new/libspe2-2.3.0/spebase/regs.c
--- old/libspe2-2.2.80/spebase/regs.c 1970-01-01 01:00:00.000000000 +0100
+++ new/libspe2-2.3.0/spebase/regs.c 2008-08-29 15:32:17.000000000 +0200
@@ -0,0 +1,104 @@
+/*
+ * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
+ * Copyright (C) 2008 IBM Corp.
+ *
+ * Author: Jeremy Kerr
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include
+#include
+
+#include "spebase.h"
+#include "regs.h"
+
+/**
+ * A little PIC trampoline that is written to the end of local store, which
+ * will later be overwritten by the stack.
+ *
+ * This trampoline provides an area for a struct spe_reg_state, and a little
+ * code to load the appropriate areas of the reg_state into the actual regs,
+ * then branch to the entry point of the program
+ *
+ * After loading this trampoline, we need to copy the spe_reg_state struct
+ * into the base address of the trampoline.
+ */
+
+#if 0
+reg_state:
+ .space 80 /* sizeof(spe_reg_state) */
+_start:
+ lqr r3,reg_state + 0 /* r3 = spe_reg_state.r3 */
+ lqr r4,reg_state + 16 /* r4 = spe_reg_state.r4 */
+ lqr r5,reg_state + 32 /* r5 = spe_reg_state.r5 */
+
+ /* we have two alignment requirements here: reg_state needs to sit
+ * on a quadword boundary, and the bisl instruction needs to be
+ * the last word before the backchain pointer. So, align here, then
+ * add three instructions after the alignment, leaving bisl on the
+ * 4th word. */
+ .balign 16
+
+ lqr r6,reg_state + 48 /* r6 = spe_reg_state.r6 */
+ lqr r1,reg_state + 64 /* r1 = spe_reg_state.entry */
+ il r2,0 /* stack size: 0 = default */
+
+ bisl r1,r1 /* branch to the program entry, and
+ set the stack pointer to the
+ following word */
+backchain:
+ /* initial stack backchain pointer - NULL*/
+ .long 0x0
+ .long 0x0
+ .long 0x0
+ .long 0x0
+#endif
+static uint32_t reg_setup_trampoline[] = {
+/* reg_state: */
+ [sizeof(struct spe_reg_state) / sizeof(uint32_t)] =
+/* _start: */
+ 0x33fff603, /* lqr r3,0 */
+ 0x33fff784, /* lqr r4,10 */
+ 0x33fff905, /* lqr r5,20 */
+ 0x00200000, /* lnop */
+ 0x33fffa06, /* lqr r6,30 */
+ 0x33fffb81, /* lqr r1,40 */
+ 0x40800002, /* il r2,0 */
+ 0x35200081, /* bisl r1,r1 */
+/* backchain: */
+ 0x00000000, /* stop */
+ 0x00000000, /* stop */
+ 0x00000000, /* stop */
+ 0x00000000, /* stop */
+};
+
+int _base_spe_setup_registers(struct spe_context *spe,
+ struct spe_reg_state *regs,
+ unsigned int *entry)
+{
+ unsigned int base_addr = LS_SIZE - sizeof(reg_setup_trampoline);
+
+ memcpy(spe->base_private->mem_mmap_base + base_addr,
+ reg_setup_trampoline, sizeof(reg_setup_trampoline));
+
+ memcpy(spe->base_private->mem_mmap_base + base_addr,
+ regs, sizeof(*regs));
+
+ *entry = base_addr + sizeof(struct spe_reg_state);
+
+ return 0;
+}
+
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/regs.h new/libspe2-2.3.0/spebase/regs.h
--- old/libspe2-2.2.80/spebase/regs.h 1970-01-01 01:00:00.000000000 +0100
+++ new/libspe2-2.3.0/spebase/regs.h 2008-08-29 15:32:17.000000000 +0200
@@ -0,0 +1,36 @@
+/*
+ * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
+ * Copyright (C) 2008 IBM Corp.
+ *
+ * Author: Jeremy Kerr
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License,
+ * or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _regs_h_
+#define _regs_h_
+
+#include "spebase.h"
+
+struct spe_reg_state {
+ struct spe_reg128 r3, r4, r5, r6;
+ struct spe_reg128 entry;
+};
+
+int _base_spe_setup_registers(struct spe_context *spe,
+ struct spe_reg_state *regs,
+ unsigned int *entry);
+
+#endif
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/run.c new/libspe2-2.3.0/spebase/run.c
--- old/libspe2-2.2.80/spebase/run.c 2007-11-19 03:26:02.000000000 +0100
+++ new/libspe2-2.3.0/spebase/run.c 2008-08-29 13:11:47.000000000 +0200
@@ -35,6 +35,7 @@
#include "elf_loader.h"
#include "lib_builtin.h"
#include "spebase.h"
+#include "regs.h"
/*Thread-local variable for use by the debugger*/
__thread struct spe_context_info {
@@ -51,27 +52,6 @@
__spe_current_active_context = tmp;
}
-static int set_regs(struct spe_context *spe, void *regs)
-{
- int fd_regs, rc;
-
- fd_regs = openat(spe->base_private->fd_spe_dir, "regs", O_RDWR);
- if (fd_regs < 0) {
- DEBUG_PRINTF("Could not open SPE regs file.\n");
- errno = EFAULT;
- return -1;
- }
-
- rc = write(fd_regs, regs, 2048);
-
- close(fd_regs);
-
- if (rc < 0)
- return -1;
-
- return 0;
-}
-
static int issue_isolated_exit(struct spe_context *spe)
{
struct spe_spu_control_area *cntl_area =
@@ -128,43 +108,41 @@
(SPE_ISOLATE | SPE_ISOLATE_EMULATE))) {
addr64 argp64, envp64, tid64, ls64;
- unsigned int regs[128][4];
+ struct spe_reg_state reg_state;
/* setup parameters */
argp64.ull = (uint64_t)(unsigned long)argp;
envp64.ull = (uint64_t)(unsigned long)envp;
tid64.ull = (uint64_t)(unsigned long)spe;
+ ls64.ull = (uint64_t)(unsigned long)
+ spe->base_private->mem_mmap_base;
/* make sure the register values are 0 */
- memset(regs, 0, sizeof(regs));
-
- /* set sensible values for stack_ptr and stack_size */
- regs[1][0] = (unsigned int) LS_SIZE - 16; /* stack_ptr */
- regs[2][0] = 0; /* stack_size ( 0 = default ) */
+ memset(®_state, 0, sizeof(reg_state));
if (runflags & SPE_RUN_USER_REGS) {
/* When SPE_USER_REGS is set, argp points to an array
* of 3x128b registers to be passed directly to the SPE
* program.
*/
- memcpy(regs[3], argp, sizeof(unsigned int) * 12);
+ memcpy(®_state, argp, 3 * sizeof(struct spe_reg128));
} else {
- regs[3][0] = tid64.ui[0];
- regs[3][1] = tid64.ui[1];
+ reg_state.r3.slot[0] = tid64.ui[0];
+ reg_state.r3.slot[1] = tid64.ui[1];
- regs[4][0] = argp64.ui[0];
- regs[4][1] = argp64.ui[1];
+ reg_state.r4.slot[0] = argp64.ui[0];
+ reg_state.r4.slot[1] = argp64.ui[1];
+
+ reg_state.r5.slot[0] = envp64.ui[0];
+ reg_state.r5.slot[1] = envp64.ui[1];
- regs[5][0] = envp64.ui[0];
- regs[5][1] = envp64.ui[1];
}
-
- /* Store the LS base address in R6 */
- ls64.ull = (uint64_t)(unsigned long)spe->base_private->mem_mmap_base;
- regs[6][0] = ls64.ui[0];
- regs[6][1] = ls64.ui[1];
+ reg_state.r6.slot[0] = ls64.ui[0];
+ reg_state.r6.slot[1] = ls64.ui[1];
+
+ reg_state.entry.slot[0] = tmp_entry;
- if (set_regs(spe, regs))
+ if (_base_spe_setup_registers(spe, ®_state, &tmp_entry))
return -1;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/spebase/spebase.h new/libspe2-2.3.0/spebase/spebase.h
--- old/libspe2-2.2.80/spebase/spebase.h 2007-08-15 13:25:55.000000000 +0200
+++ new/libspe2-2.3.0/spebase/spebase.h 2008-08-29 13:11:47.000000000 +0200
@@ -108,6 +108,10 @@
int active_tagmask;
};
+struct spe_reg128 {
+ unsigned int slot[4];
+};
+
/* spe related sizes
*/
@@ -125,6 +129,8 @@
#define SIGNAL1_OFFSET 0x14000
#define SIGNAL2_OFFSET 0x1c000
+#define LS_ADDR_MASK (LS_SIZE - 1)
+
/**
* Location of the PPE-assisted library call buffer
* for emulated isolation contexts.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/speevent/spe_event.c new/libspe2-2.3.0/speevent/spe_event.c
--- old/libspe2-2.2.80/speevent/spe_event.c 2007-06-27 03:56:42.000000000 +0200
+++ new/libspe2-2.3.0/speevent/spe_event.c 2008-06-11 03:09:10.000000000 +0200
@@ -22,6 +22,7 @@
#include
#include "speevent.h"
+#include
#include
#include
#include
@@ -56,6 +57,75 @@
pthread_mutex_unlock(&__SPE_EVENT_CONTEXT_PRIV_GET(spe)->lock);
}
+static void stop_event_lock(spe_context_event_priv_ptr_t evctx)
+{
+ pthread_mutex_lock(&evctx->stop_event_lock);
+}
+
+static void stop_event_unlock(spe_context_event_priv_ptr_t evctx)
+{
+ pthread_mutex_unlock(&evctx->stop_event_lock);
+}
+
+static int stop_event_pipe_close(spe_context_event_priv_ptr_t evctx)
+{
+ if (evctx->stop_event_pipe[0] != -1) {
+ close(evctx->stop_event_pipe[0]);
+ evctx->stop_event_pipe[0] = -1;
+ }
+ if (evctx->stop_event_pipe[1] != -1) {
+ close(evctx->stop_event_pipe[1]);
+ evctx->stop_event_pipe[1] = -1;
+ }
+
+ return 0;
+}
+
+static int stop_event_pipe_open(spe_context_event_priv_ptr_t evctx)
+{
+ int rc;
+
+ rc = pipe(evctx->stop_event_pipe);
+ if (rc == -1) {
+ return -1;
+ }
+ rc = fcntl(evctx->stop_event_pipe[0], F_GETFL);
+ if (rc != -1) {
+ rc = fcntl(evctx->stop_event_pipe[0], F_SETFL, rc | O_NONBLOCK);
+ }
+ if (rc == -1) {
+ stop_event_pipe_close(evctx);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int stop_event_pipe_acquire(spe_context_event_priv_ptr_t evctx)
+{
+ if (evctx->stop_event_handler_count == 0) {
+ if (stop_event_pipe_open(evctx) == -1) {
+ return -1;
+ }
+ evctx->stop_event_buffer_count = 0; /* invalidate the buffer */
+ }
+
+ evctx->stop_event_handler_count++;
+
+ return 0;
+}
+
+static int stop_event_pipe_release(spe_context_event_priv_ptr_t evctx)
+{
+ evctx->stop_event_handler_count--;
+
+ if (evctx->stop_event_handler_count == 0) {
+ stop_event_pipe_close(evctx);
+ }
+
+ return 0;
+}
+
int _event_spe_stop_info_read (spe_context_ptr_t spe, spe_stop_info_t *stopinfo)
{
spe_context_event_priv_ptr_t evctx;
@@ -64,13 +134,32 @@
size_t total;
evctx = __SPE_EVENT_CONTEXT_PRIV_GET(spe);
+
+ stop_event_lock(evctx); /* for atomic read */
+
fd = evctx->stop_event_pipe[0];
- pthread_mutex_lock(&evctx->stop_event_read_lock); /* for atomic read */
+ if (fd == -1) { /* no stop event handler */
+ if (evctx->stop_event_buffer_count) {
+ /* return the last stop info for backward compatibility */
+ memcpy(stopinfo, &evctx->stop_event_buffer, sizeof(*stopinfo));
+ evctx->stop_event_buffer_count--;
+ rc = 0;
+ }
+ else {
+ /* there is no valid stop info in the buffer */
+ errno = EAGAIN;
+ rc = -1;
+ }
+ stop_event_unlock(evctx);
+ return rc;
+ }
+
+ /* any stop event handler. */
rc = read(fd, stopinfo, sizeof(*stopinfo));
if (rc == -1) {
- pthread_mutex_unlock(&evctx->stop_event_read_lock);
+ stop_event_unlock(evctx);
return -1;
}
@@ -98,7 +187,7 @@
}
}
- pthread_mutex_unlock(&evctx->stop_event_read_lock);
+ stop_event_unlock(evctx);
return rc == -1 ? -1 : 0;
}
@@ -248,6 +337,15 @@
}
if (event->events & SPE_EVENT_SPE_STOPPED) {
+ /* prevent reading stop info while registering */
+ stop_event_lock(evctx);
+
+ if (stop_event_pipe_acquire(evctx) == -1) {
+ stop_event_unlock(evctx);
+ _event_spe_context_unlock(event->spe);
+ return -1;
+ }
+
fd = evctx->stop_event_pipe[0];
ev_buf = &evctx->events[__SPE_EVENT_SPE_STOPPED];
@@ -257,9 +355,13 @@
ep_event.events = EPOLLIN;
ep_event.data.ptr = ev_buf;
if (epoll_ctl(epfd, ep_op, fd, &ep_event) == -1) {
+ stop_event_pipe_release(evctx);
+ stop_event_unlock(evctx);
_event_spe_context_unlock(event->spe);
return -1;
}
+
+ stop_event_unlock(evctx);
}
_event_spe_context_unlock(event->spe);
@@ -340,12 +442,20 @@
}
if (event->events & SPE_EVENT_SPE_STOPPED) {
+ /* prevent reading stop info while unregistering */
+ stop_event_lock(evctx);
+
fd = evctx->stop_event_pipe[0];
if (epoll_ctl(epfd, ep_op, fd, NULL) == -1) {
+ stop_event_unlock(evctx);
_event_spe_context_unlock(event->spe);
return -1;
}
evctx->events[__SPE_EVENT_SPE_STOPPED].events = 0;
+
+ stop_event_pipe_release(evctx);
+
+ stop_event_unlock(evctx);
}
_event_spe_context_unlock(event->spe);
@@ -424,12 +534,11 @@
evctx = __SPE_EVENT_CONTEXT_PRIV_GET(spe);
__SPE_EVENT_CONTEXT_PRIV_SET(spe, NULL);
-
- close(evctx->stop_event_pipe[0]);
- close(evctx->stop_event_pipe[1]);
+
+ stop_event_pipe_close(evctx);
pthread_mutex_destroy(&evctx->lock);
- pthread_mutex_destroy(&evctx->stop_event_read_lock);
+ pthread_mutex_destroy(&evctx->stop_event_lock);
free(evctx);
@@ -439,7 +548,6 @@
struct spe_context_event_priv * _event_spe_context_initialize(spe_context_ptr_t spe)
{
spe_context_event_priv_ptr_t evctx;
- int rc;
int i;
evctx = calloc(1, sizeof(*evctx));
@@ -447,29 +555,16 @@
return NULL;
}
- rc = pipe(evctx->stop_event_pipe);
- if (rc == -1) {
- free(evctx);
- return NULL;
- }
- rc = fcntl(evctx->stop_event_pipe[0], F_GETFL);
- if (rc != -1) {
- rc = fcntl(evctx->stop_event_pipe[0], F_SETFL, rc | O_NONBLOCK);
- }
- if (rc == -1) {
- close(evctx->stop_event_pipe[0]);
- close(evctx->stop_event_pipe[1]);
- free(evctx);
- errno = EIO;
- return NULL;
- }
+ /* the pipe will be created when any stop event handler is registered */
+ evctx->stop_event_pipe[0] = -1;
+ evctx->stop_event_pipe[1] = -1;
for (i = 0; i < sizeof(evctx->events) / sizeof(evctx->events[0]); i++) {
evctx->events[i].spe = spe;
}
pthread_mutex_init(&evctx->lock, NULL);
- pthread_mutex_init(&evctx->stop_event_read_lock, NULL);
+ pthread_mutex_init(&evctx->stop_event_lock, NULL);
return evctx;
}
@@ -479,17 +574,44 @@
spe_context_event_priv_ptr_t evctx;
spe_stop_info_t stopinfo_buf;
int rc;
+ int errno_saved;
+ int fd;
if (!stopinfo) {
stopinfo = &stopinfo_buf;
}
rc = _base_spe_context_run(spe, entry, runflags, argp, envp, stopinfo);
+ errno_saved = errno;
evctx = __SPE_EVENT_CONTEXT_PRIV_GET(spe);
- if (write(evctx->stop_event_pipe[1], stopinfo, sizeof(*stopinfo)) != sizeof(*stopinfo)) {
+
+ stop_event_lock(evctx);
+
+ fd = evctx->stop_event_pipe[1];
+ /* don't write stop info to the pipe if no stop event handler is registered */
+ if (fd == -1) {
+ /* store the last stop info in the internal buffer for backward
+ * compatibility */
+ memcpy(&evctx->stop_event_buffer, stopinfo, sizeof(*stopinfo));
+ evctx->stop_event_buffer_count = 1; /* overwrite the buffer */
+ stop_event_unlock(evctx);
+ return rc;
+ }
+
+ stop_event_pipe_acquire(evctx); /* to avoid closing the pipe after unlocked */
+ stop_event_unlock(evctx); /* unlock here to avoid deadlocks */
+
+ if (write(fd, stopinfo, sizeof(*stopinfo)) != sizeof(*stopinfo)) {
/* error check. */
}
+ /* release the pipe */
+ stop_event_lock(evctx);
+ stop_event_pipe_release(evctx);
+ stop_event_unlock(evctx);
+
+ errno = errno_saved;
+
return rc;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/speevent/speevent.h new/libspe2-2.3.0/speevent/speevent.h
--- old/libspe2-2.2.80/speevent/speevent.h 2007-04-16 07:01:20.000000000 +0200
+++ new/libspe2-2.3.0/speevent/speevent.h 2008-06-11 03:09:10.000000000 +0200
@@ -35,8 +35,11 @@
typedef struct spe_context_event_priv
{
pthread_mutex_t lock;
- pthread_mutex_t stop_event_read_lock;
+ pthread_mutex_t stop_event_lock;
int stop_event_pipe[2];
+ int stop_event_handler_count;
+ int stop_event_buffer_count;
+ spe_stop_info_t stop_event_buffer;
spe_event_unit_t events[__NUM_SPE_EVENT_TYPES];
} spe_context_event_priv_t, *spe_context_event_priv_ptr_t;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tests/libspe2.event/Makefile new/libspe2-2.3.0/tests/libspe2.event/Makefile
--- old/libspe2-2.2.80/tests/libspe2.event/Makefile 2008-04-25 15:36:02.000000000 +0200
+++ new/libspe2-2.3.0/tests/libspe2.event/Makefile 2008-06-11 03:14:52.000000000 +0200
@@ -29,7 +29,9 @@
test_event_tag_group.elf \
test_event_wbox.elf \
test_event.elf \
- test_event_error.elf
+ test_event_error.elf \
+ test_event_stop_no_read.elf \
+ test_event_stop_no_handler.elf
include $(TEST_TOP)/make.rules
@@ -44,6 +46,10 @@
test_event.elf: spu_event.embed.o
+test_event_stop_no_read.elf: spu_event_stop.embed.o
+
+test_event_stop_no_handler.elf: spu_event_stop.embed.o
+
spu_ibox.c: ../libspe2.mfc/spu_ibox.c
ln -sf $< $@
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tests/libspe2.event/test_event_stop.c new/libspe2-2.3.0/tests/libspe2.event/test_event_stop.c
--- old/libspe2-2.2.80/tests/libspe2.event/test_event_stop.c 2008-04-25 15:36:02.000000000 +0200
+++ new/libspe2-2.3.0/tests/libspe2.event/test_event_stop.c 2008-06-11 03:14:52.000000000 +0200
@@ -209,6 +209,14 @@
for (i = 0; i < NUM_SPES; i++) {
pthread_join(params[i].tid, NULL);
+ event[0].spe = params[i].spe;
+ event[0].events = SPE_EVENT_SPE_STOPPED;
+ ret = spe_event_handler_deregister(evhandler, event);
+ if (ret == -1) {
+ eprintf("spe_event_handler_deregister: %s\n", strerror(errno));
+ fatal();
+ }
+
if (params[i].num_stop > COUNT) {
eprintf("spe[%u]: too many events (%u/%u).\n", i, params[i].num_stop, COUNT);
failed();
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tests/libspe2.event/test_event_stop_no_handler.c new/libspe2-2.3.0/tests/libspe2.event/test_event_stop_no_handler.c
--- old/libspe2-2.2.80/tests/libspe2.event/test_event_stop_no_handler.c 1970-01-01 01:00:00.000000000 +0100
+++ new/libspe2-2.3.0/tests/libspe2.event/test_event_stop_no_handler.c 2008-06-11 03:14:52.000000000 +0200
@@ -0,0 +1,123 @@
+/*
+ * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
+ *
+ * Copyright (C) 2008 Sony Computer Entertainment Inc.
+ * Copyright 2008 Sony Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* This test checks that the libspe2 doesn't stall even if no stop
+ * event handler is registered.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ppu_libspe2_test.h"
+
+#define COUNT 50000
+
+extern spe_program_handle_t spu_event_stop;
+
+static const spe_stop_info_t expected_stop_info = {
+ .stop_reason = SPE_STOP_AND_SIGNAL,
+ .result.spe_signal_code = STOP_DATA,
+};
+
+static void *spe_thread_proc(void *arg)
+{
+ ppe_thread_t *ppe = (ppe_thread_t*)arg;
+ spe_context_ptr_t spe;
+ unsigned int entry = SPE_DEFAULT_ENTRY;
+ spe_stop_info_t stop_info, stop_info2;
+ int ret;
+ unsigned int i;
+
+ spe = spe_context_create(SPE_EVENTS_ENABLE, NULL);
+ if (!spe) {
+ eprintf("spe_context_create: %s\n", strerror(errno));
+ fatal();
+ }
+
+ if (spe_program_load(spe, &spu_event_stop)) {
+ eprintf("spe[%d]: spe_program_load: %s\n", ppe->index, strerror(errno));
+ fatal();
+ }
+
+ global_sync(NUM_SPES);
+
+ for (i = 0; ; i++) { /* run until the SPE exits */
+ ret = spe_context_run(spe, &entry, 0,
+ (void*)STOP_DATA, (void*)COUNT, &stop_info);
+ if (ret == 0) { /* exit */
+ if (i != COUNT) {
+ eprintf("spe[%d]: spe_context_run: Unexpected exit\n", ppe->index);
+ fatal();
+ }
+ if (check_exit_code(&stop_info, 0)) {
+ fatal();
+ }
+ break;
+ }
+ else if (ret > 0) { /* user stop code */
+ if (check_stop_info(&stop_info, &expected_stop_info)) {
+ fatal();
+ }
+ }
+ else { /* error */
+ eprintf("spe[%d]: spe_context_run: %s\n", ppe->index, strerror(errno));
+ fatal();
+ }
+
+ ret = spe_stop_info_read(spe, &stop_info2);
+ if (ret != 0) {
+ eprintf("spe[%d]: spe_stop_info_read: Unexpected return code\n", ppe->index, ret);
+ fatal();
+ }
+ if (check_stop_info(&stop_info2, &expected_stop_info)) {
+ fatal();
+ }
+ }
+
+ ret = spe_context_destroy(spe);
+ if (ret) {
+ eprintf("spe_context_destroy(%p): %s\n", spe, strerror(errno));
+ fatal();
+ }
+
+ return NULL;
+}
+
+static int test(int argc, char **argv)
+{
+ int ret;
+
+ ret = ppe_thread_group_run(NUM_SPES, spe_thread_proc, NULL, NULL);
+ if (ret) {
+ fatal();
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ return ppu_main(argc, argv, test);
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tests/libspe2.event/test_event_stop_no_read.c new/libspe2-2.3.0/tests/libspe2.event/test_event_stop_no_read.c
--- old/libspe2-2.2.80/tests/libspe2.event/test_event_stop_no_read.c 1970-01-01 01:00:00.000000000 +0100
+++ new/libspe2-2.3.0/tests/libspe2.event/test_event_stop_no_read.c 2008-06-11 03:14:52.000000000 +0200
@@ -0,0 +1,114 @@
+/*
+ * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
+ *
+ * Copyright (C) 2008 Sony Computer Entertainment Inc.
+ * Copyright 2008 Sony Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* This test checks that the libspe2 doesn't stall even if
+ * spe_stop_info_read is never called.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ppu_libspe2_test.h"
+
+#define COUNT 50000
+
+extern spe_program_handle_t spu_event_stop;
+
+static const spe_stop_info_t expected_stop_info = {
+ .stop_reason = SPE_STOP_AND_SIGNAL,
+ .result.spe_signal_code = STOP_DATA,
+};
+
+static void *spe_thread_proc(void *arg)
+{
+ ppe_thread_t *ppe = (ppe_thread_t*)arg;
+ spe_context_ptr_t spe;
+ unsigned int entry = SPE_DEFAULT_ENTRY;
+ spe_stop_info_t stop_info;
+ int ret;
+ unsigned int i;
+
+ spe = spe_context_create(SPE_EVENTS_ENABLE, NULL);
+ if (!spe) {
+ eprintf("spe_context_create: %s\n", strerror(errno));
+ fatal();
+ }
+
+ if (spe_program_load(spe, &spu_event_stop)) {
+ eprintf("spe[%d]: spe_program_load: %s\n", ppe->index, strerror(errno));
+ fatal();
+ }
+
+ global_sync(NUM_SPES);
+
+ for (i = 0; ; i++) { /* run until the SPE exits */
+ ret = spe_context_run(spe, &entry, 0,
+ (void*)STOP_DATA, (void*)COUNT, &stop_info);
+ if (ret == 0) { /* exit */
+ if (i != COUNT) {
+ eprintf("spe[%d]: spe_context_run: Unexpected exit\n", ppe->index);
+ fatal();
+ }
+ if (check_exit_code(&stop_info, 0)) {
+ fatal();
+ }
+ break;
+ }
+ else if (ret > 0) { /* user stop code */
+ if (check_stop_info(&stop_info, &expected_stop_info)) {
+ fatal();
+ }
+ }
+ else { /* error */
+ eprintf("spe[%d]: spe_context_run: %s\n", ppe->index, strerror(errno));
+ fatal();
+ }
+ }
+
+ ret = spe_context_destroy(spe);
+ if (ret) {
+ eprintf("spe_context_destroy(%p): %s\n", spe, strerror(errno));
+ fatal();
+ }
+
+ return NULL;
+}
+
+static int test(int argc, char **argv)
+{
+ int ret;
+
+ ret = ppe_thread_group_run(NUM_SPES, spe_thread_proc, NULL, NULL);
+ if (ret) {
+ fatal();
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ return ppu_main(argc, argv, test);
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tests/libspe2.run/Makefile new/libspe2-2.3.0/tests/libspe2.run/Makefile
--- old/libspe2-2.2.80/tests/libspe2.run/Makefile 2008-04-25 15:37:43.000000000 +0200
+++ new/libspe2-2.3.0/tests/libspe2.run/Makefile 2008-09-12 05:50:38.000000000 +0200
@@ -30,6 +30,7 @@
test_run_image.elf \
test_stop.elf \
test_multiple_context.elf \
+ test_nosched_context.elf \
test_single_gang_context.elf \
test_context_create_error.elf \
test_run_error.elf \
@@ -61,6 +62,8 @@
test_multiple_context.elf: spu_arg.embed.o
+test_nosched_context.elf: spu_arg.embed.o
+
test_single_gang_context.elf: spu_arg.embed.o
test_affinity.elf: spu_arg.embed.o
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tests/libspe2.run/test_nosched_context.c new/libspe2-2.3.0/tests/libspe2.run/test_nosched_context.c
--- old/libspe2-2.2.80/tests/libspe2.run/test_nosched_context.c 1970-01-01 01:00:00.000000000 +0100
+++ new/libspe2-2.3.0/tests/libspe2.run/test_nosched_context.c 2008-09-12 05:50:38.000000000 +0200
@@ -0,0 +1,110 @@
+/*
+ * libspe2 - A wrapper library to adapt the JSRE SPU usage model to SPUFS
+ *
+ * Copyright (C) 2008 Sony Computer Entertainment Inc.
+ * Copyright 2008 Sony Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* This test checks if multiple SPE contexts can be created and be run
+ * at the same time correctly.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "ppu_libspe2_test.h"
+
+extern spe_program_handle_t spu_arg;
+
+static int num_spes;
+
+static void *spe_thread_proc(void *arg)
+{
+ spe_context_ptr_t spe;
+ unsigned int entry = SPE_DEFAULT_ENTRY;
+ int ret;
+ spe_stop_info_t stop_info;
+
+ /* synchronize all threads to check whether the library is
+ * thread-safe.
+ */
+ global_sync(num_spes);
+
+ spe = spe_context_create(SPE_NOSCHED, 0);
+ if (!spe) {
+ eprintf("spe_context_create(0, NULL): %s\n", strerror(errno));
+ fatal();
+ }
+
+ if (spe_program_load(spe, &spu_arg)) {
+ eprintf("spe_program_load(%p, &spu_arg): %s\n", spe, strerror(errno));
+ fatal();
+ }
+
+ ret = spe_context_run(spe, &entry, 0,
+ (void*)RUN_ARGP_DATA, (void*)RUN_ENVP_DATA, &stop_info);
+ if (ret == 0) {
+ if (check_exit_code(&stop_info, 0)) {
+ fatal();
+ }
+ }
+ else {
+ eprintf("spe_context_run(%p, ...): %s\n", spe, strerror(errno));
+ fatal();
+ }
+
+ ret = spe_context_destroy(spe);
+ if (ret) {
+ eprintf("spe_context_destroy(%p): %s\n", spe, strerror(errno));
+ fatal();
+ }
+
+ return NULL;
+}
+
+static int test(int argc, char **argv)
+{
+ int ret;
+
+ num_spes = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
+ if (num_spes <= 0) {
+ eprintf("Could not get # of physical SPEs\n");
+ fatal();
+ }
+
+ /* this test case works only as root */
+ if (getuid() == 0) {
+ ret = ppe_thread_group_run(num_spes, spe_thread_proc, NULL, NULL);
+ if (ret) {
+ fatal();
+ }
+ }
+ else {
+ eprintf("Root privilege is required. Ignored.\n");
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ return ppu_main(argc, argv, test);
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tools/spu-tools/spu-tools.spec new/libspe2-2.3.0/tools/spu-tools/spu-tools.spec
--- old/libspe2-2.2.80/tools/spu-tools/spu-tools.spec 2008-05-08 15:18:51.000000000 +0200
+++ new/libspe2-2.3.0/tools/spu-tools/spu-tools.spec 2008-07-17 09:33:51.000000000 +0200
@@ -1,7 +1,7 @@
Summary: user space tools for Cell/B.E.
Name: spu-tools
Version: 1.1
-Release: 3
+Release: 5
License: GPL
Group: Applications/System
Source0: spu-tools.tar.bz2
@@ -42,6 +42,12 @@
%dir /%{_prefix}/share/man/man1/spu-ps.1.gz
%changelog
+* Fri Jul 04 2008 Andre Detsch 1.1-5
+- Support for spu threads with arbitrary spufs entry names.
+
+* Wed May 28 2008 Andre Detsch 1.1-4
+- Added TID field to SPU view of spu-top.
+
* Fri Apr 11 2008 Andre Detsch 1.1-3
- Fix escape sequences handling on spu-top.
- Fixed help example for spu-ps.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tools/spu-tools/src/ChangeLog new/libspe2-2.3.0/tools/spu-tools/src/ChangeLog
--- old/libspe2-2.2.80/tools/spu-tools/src/ChangeLog 2008-05-08 15:18:51.000000000 +0200
+++ new/libspe2-2.3.0/tools/spu-tools/src/ChangeLog 2008-07-17 09:33:51.000000000 +0200
@@ -1,3 +1,9 @@
+2008-07-04 Andre Detsch
+ * ctx-info.c: Support for spu threads with arbitrary spufs entry names.
+
+2008-05-28 Andre Detsch
+ * spu-top: Added TID field to SPU view.
+
2008-04-11 Andre Detsch
* spu-top.c: Fix escape sequences handling.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tools/spu-tools/src/ctx-info.c new/libspe2-2.3.0/tools/spu-tools/src/ctx-info.c
--- old/libspe2-2.2.80/tools/spu-tools/src/ctx-info.c 2007-10-12 15:55:44.000000000 +0200
+++ new/libspe2-2.3.0/tools/spu-tools/src/ctx-info.c 2008-07-17 09:33:51.000000000 +0200
@@ -279,39 +279,70 @@
}
-static struct ctx *ctxs_get_ctx(int pid, int cid)
+static struct ctx *ctxs_get_ctx(int thread_id)
{
int i;
/* This could be optimized by using a hash table */
for (i = 0; i < ctxs_n; i++) {
- if (ctxs[i]->ppu_pid == pid &&
- cid == ctxs[i]->context_id)
+ if (ctxs[i]->thread_id == thread_id)
return ctxs[i];
}
return NULL;
}
+static int find_thread_pid(int thread_id)
+{
+ DIR* proc_dir;
+ struct dirent *entry;
+ static char buf[PATH_MAX];
+ int pid = -1;
+
+ proc_dir = opendir(PROCFS_PATH);
+ if (proc_dir) {
+ while ((entry = readdir(proc_dir)) != NULL) {
+ sprintf(buf, "%s/%s/task/%d", PROCFS_PATH, entry->d_name, thread_id);
+ if (access(buf, F_OK) == 0) {
+ sscanf(entry->d_name, "%d", &pid);
+ break;
+ }
+ }
+ closedir(proc_dir);
+ }
+ return pid;
+}
+
static int
process_ctx_entry(struct dirent *entry, const char *gang_name, u64 last_period)
{
- char buf[PATH_MAX];
+ static char buf[PATH_MAX];
FILE *fp;
- int uid, pid;
- u64 context_id;
+ int uid, thread_id;
struct ctx *ctx;
- sscanf(entry->d_name, "spethread-%d-%llu", &pid, &context_id);
+ if (gang_name)
+ sprintf(buf, "%s/%s/%s", SPUFS_PATH, gang_name, entry->d_name);
+ else
+ sprintf(buf, "%s/%s", SPUFS_PATH, entry->d_name);
+ chdir(buf);
- ctx = ctxs_get_ctx(pid, context_id);
+ fp = fopen("tid", "r");
+ if (fp) {
+ fscanf(fp, "%d", &thread_id);
+ fclose(fp);
+ } else {
+ return 0;
+ }
+
+ ctx = ctxs_get_ctx(thread_id);
if (!ctx) {
ctxs_ensure_capacity(ctxs_n + 1);
ctx = alloc_ctx();
ctxs[ctxs_n] = ctx;
ctxs_n++;
- ctx->ppu_pid = pid;
- ctx->context_id = context_id;
+ ctx->thread_id = thread_id;
+ ctx->ppu_pid = find_thread_pid(thread_id);
}
sprintf(buf, "%s/%d/stat", PROCFS_PATH, ctx->ppu_pid);
@@ -338,12 +369,6 @@
fclose(fp);
}
- if (gang_name)
- sprintf(buf, "%s/%s/%s", SPUFS_PATH, gang_name, entry->d_name);
- else
- sprintf(buf, "%s/%s", SPUFS_PATH, entry->d_name);
- chdir(buf);
-
if (access("phys-id", R_OK) != 0) {
ctx->spe = SPE_UNKNOWN;
} else {
@@ -354,14 +379,6 @@
}
}
- fp = fopen("tid", "r");
- if (fp) {
- fscanf(fp, "%d", &ctx->thread_id);
- fclose(fp);
- } else {
- ctx->thread_id = -1;
- }
-
fp = fopen("stat", "r");
if (fp) {
u64 last_time;
@@ -428,7 +445,7 @@
struct dirent *entry, *gang_entry;
DIR *ctxs_dir, *gang_dir;
int i;
- char buf[PATH_MAX];
+ static char buf[PATH_MAX];
ctxs_dir = opendir(SPUFS_PATH);
if (!ctxs_dir)
@@ -438,15 +455,17 @@
ctxs[i]->updated = 0;
while ((entry = readdir(ctxs_dir)) != NULL) {
- if (!strncmp(entry->d_name, "spethread-", 10)) {
+ sprintf(buf, "%s/%s/stat", SPUFS_PATH, entry->d_name);
+ if (access(buf, F_OK) == 0) {
process_ctx_entry(entry, NULL, last_period);
- } else if (!strncmp(entry->d_name, "gang-", 5)) {
+ } else {
/* contexts within a gang */
sprintf(buf, "%s/%s", SPUFS_PATH, entry->d_name);
gang_dir = opendir(buf);
if (gang_dir) {
while ((gang_entry = readdir(gang_dir)) != NULL) {
- if (!strncmp(gang_entry->d_name, "spethread-", 10))
+ sprintf(buf, "%s/%s/%s/stat", SPUFS_PATH, entry->d_name, gang_entry->d_name);
+ if (access(buf, F_OK) == 0)
process_ctx_entry(gang_entry, entry->d_name, last_period);
}
closedir(gang_dir);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tools/spu-tools/src/spu-info.c new/libspe2-2.3.0/tools/spu-tools/src/spu-info.c
--- old/libspe2-2.2.80/tools/spu-tools/src/spu-info.c 2008-03-14 15:35:36.000000000 +0100
+++ new/libspe2-2.3.0/tools/spu-tools/src/spu-info.c 2008-06-05 16:22:49.000000000 +0200
@@ -105,6 +105,9 @@
case SPU_PPE_LIBRARY:
ret = p1->ppe_library - p2->ppe_library; break;
+ case SPU_CTX_THREAD_ID:
+ ret = p1->ctx_thread_id - p2->ctx_thread_id; break;
+
default :
ret = 0; break;
}
@@ -218,6 +221,8 @@
{ SPU_CLASS2_INTERRUPTS, "IRQ2", "%6s", "%6llu", "Number of Class2 Interrupts Received", 1, "" },
{ SPU_PPE_LIBRARY, "PPE_LIB", "%8s", "%8llu", "Number of PPE Assisted Library Calls Performed", 1, "" },
+ { SPU_CTX_THREAD_ID, "TID", "%6s", "%6d", "SPE Controlling Thread ID", 0, "" },
+
{ 0, NULL, NULL, NULL, NULL, 0 }
};
@@ -253,9 +258,33 @@
return sprintf(buf, format, spu->class2_interrupts);
case SPU_PPE_LIBRARY:
return sprintf(buf, format, spu->ppe_library);
+
+ case SPU_CTX_THREAD_ID:
+ return sprintf(buf, format, spu->ctx_thread_id);
+
default:
return 0;
}
}
+void fill_spus_tids(struct spu** spus, struct ctx** ctxs)
+{
+ int i, j;
+
+ for (j = 0; spus[j]; j++)
+ spus[j]->ctx_thread_id = 0;
+
+ for (i = 0; ctxs[i]; i++) {
+ int spe = ctxs[i]->spe;
+ if (spe < 0)
+ continue;
+
+ for (j = 0; spus[j]; j++) {
+ if (spus[j]->number == spe) {
+ spus[j]->ctx_thread_id = ctxs[i]->thread_id;
+ break;
+ }
+ }
+ }
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tools/spu-tools/src/spu-tools.h new/libspe2-2.3.0/tools/spu-tools/src/spu-tools.h
--- old/libspe2-2.2.80/tools/spu-tools/src/spu-tools.h 2007-10-12 15:55:44.000000000 +0200
+++ new/libspe2-2.3.0/tools/spu-tools/src/spu-tools.h 2008-07-17 09:33:51.000000000 +0200
@@ -91,7 +91,6 @@
};
struct ctx {
- u64 context_id;
int ppu_pid;
int thread_id;
const char *user;
@@ -148,6 +147,7 @@
SPU_MAJOR_PAGE_FAULTS,
SPU_CLASS2_INTERRUPTS,
SPU_PPE_LIBRARY,
+ SPU_CTX_THREAD_ID,
SPU_MAX_FIELD
};
@@ -169,6 +169,8 @@
u64 ppe_library;
float percent[TIME_MAX];
+
+ int ctx_thread_id;
};
@@ -183,6 +185,7 @@
inline void set_spu_sort_field(enum spu_field_id field);
void set_spu_sort_descending(int descending);
+void fill_spus_tids(struct spu** spus, struct ctx** ctxs);
/*
* PER_PROC
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libspe2-2.2.80/tools/spu-tools/src/spu-top.c new/libspe2-2.3.0/tools/spu-tools/src/spu-top.c
--- old/libspe2-2.2.80/tools/spu-tools/src/spu-top.c 2008-05-08 15:18:51.000000000 +0200
+++ new/libspe2-2.3.0/tools/spu-tools/src/spu-top.c 2008-06-05 16:22:49.000000000 +0200
@@ -443,6 +443,7 @@
spus = get_spus();
ctxs = get_spu_contexts(period);
procs = get_procs(ctxs);
+ fill_spus_tids(spus, ctxs);
last_time = current_time;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org