[Cbe-oss-dev] [PATCH/RFC] libspe2: add support for multi source sync

Gerhard Stenzel stenzel at de.ibm.com
Thu Jun 28 19:50:29 EST 2007


The following patch/RFC adds and implements two API functions
to support the MFC Multisource Synchronization facility.

Comments are appreciated.

Signed-off-by: Gerhard Stenzel <stenzel at de.ibm.com>

===================================================================
Index: libspe2/libspe2.c
===================================================================
--- libspe2/libspe2.c	(revision 57)
+++ libspe2/libspe2.c	(working copy)
@@ -363,6 +363,29 @@ int spe_out_intr_mbox_status (spe_contex
 }
 
 /*
+ * Multisource Sync Facility
+ */
+
+int spe_mssync_start(spe_context_ptr_t spe)
+{
+	if (spe == NULL ) {
+		errno = ESRCH;
+		return -1;
+	}
+	return _base_spe_mssync_start(spe);
+}
+
+int spe_mssync_status(spe_context_ptr_t spe)
+{
+	if (spe == NULL ) {
+		errno = ESRCH;
+		return -1;
+	}
+	return _base_spe_mssync_status(spe);
+}
+
+
+/*
  * SPU SIgnal Notification Facility
  */
 
Index: libspe2/spebase/dma.c
===================================================================
--- libspe2/spebase/dma.c	(revision 57)
+++ libspe2/spebase/dma.c	(working copy)
@@ -321,3 +321,50 @@ int _base_spe_mfcio_tag_status_read(spe_
 		return -1;
 	}
 }
+
+int _base_spe_mssync_start(spe_context_ptr_t spectx)
+{
+	int ret, fd;
+	unsigned int data = 1; /* Any value can be written here */
+
+	volatile struct spe_mssync_area *mss_area = 
+                spectx->base_private->mssync_mmap_base;
+
+	if (spectx->base_private->flags & SPE_MAP_PS) {
+		mss_area->MFC_MSSync = data; 
+		return 0;
+	} else {
+		fd = open_if_closed(spectx, FD_MSS, 0);
+		if (fd != -1) {
+			ret = write(fd, &data, sizeof (data));
+			if ((ret < 0) && (errno != EIO)) {
+				perror("spe_mssync_start: internal error");
+			}
+		return ret < 0 ? -1 : 0;
+		}
+	}
+}
+
+unsigned int _base_spe_mssync_status(spe_context_ptr_t spectx)
+{
+	int ret, fd;
+	unsigned int data;
+
+	volatile struct spe_mssync_area *mss_area = 
+                spectx->base_private->mssync_mmap_base;
+
+	if (spectx->base_private->flags & SPE_MAP_PS) {
+		return  mss_area->MFC_MSSync;
+	} else {
+		fd = open_if_closed(spectx, FD_MSS, 0);
+		if (fd != -1) {
+			ret = read(fd, &data, sizeof (data));
+			if ((ret < 0) && (errno != EIO)) {
+				perror("spe_mssync_start: internal error");
+			}
+		return data;
+		}
+	}
+}
+
+
Index: libspe2/spebase/spebase.h
===================================================================
--- libspe2/spebase/spebase.h	(revision 57)
+++ libspe2/spebase/spebase.h	(working copy)
@@ -663,6 +663,21 @@ int _base_spe_cpu_info_get(int info_requ
  */
 void  __spe_context_update_event(void);
 
+/**
+ * _base_spe_mssync_start starts Multisource Synchronisation
+ *
+ * @param spectx Specifies the SPE context
+ */
+int _base_spe_mssync_start(spe_context_ptr_t spectx);
+
+/**
+ * _base_spe_mssync_status retrieves status of Multisource Synchronisation
+ *
+ * @param spectx Specifies the SPE context
+ */
+unsigned int _base_spe_mssync_status(spe_context_ptr_t spectx);
+
+
 #ifdef __cplusplus
 }
 #endif
Index: libspe2/libspe2.h
===================================================================
--- libspe2/libspe2.h	(revision 57)
+++ libspe2/libspe2.h	(working copy)
@@ -165,6 +165,13 @@ int spe_out_intr_mbox_read (spe_context_
 int spe_out_intr_mbox_status (spe_context_ptr_t spe);
 
 /*
+ * Multisource Sync Facility
+ */
+int spe_mssync_start(spe_context_ptr_t spe);
+
+int spe_mssync_status(spe_context_ptr_t spe);
+
+/*
  * SPU SIgnal Notification Facility
  */
 int spe_signal_write (spe_context_ptr_t spe, unsigned int signal_reg, unsigned int data);

===================================================================

Best regards, 

Gerhard Stenzel, Linux on Cell Development, LTC
-------------------------------------------------------------------------------------
IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter | Geschaeftsfuehrung: Herbert Kircher
Sitz der Gesellschaft: Boeblingen | Registergericht: Amtsgericht Stuttgart, HRB 243294



More information about the cbe-oss-dev mailing list