[Cbe-oss-dev] [RFC/PATCH 2/2] spufs: Add a "capabilities" file to spu contexts

Benjamin Herrenschmidt benh at kernel.crashing.org
Fri May 25 14:54:05 EST 2007


This adds a "capabilities" file to spu contexts consisting of a
list of space separated capability names. The current exposed
capabilities are "sched" (the context is scheduleable) and
"step" (the context supports single stepping).

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---

---

 arch/powerpc/platforms/cell/spufs/file.c |   32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Index: linux-cell/arch/powerpc/platforms/cell/spufs/file.c
===================================================================
--- linux-cell.orig/arch/powerpc/platforms/cell/spufs/file.c	2007-05-25 13:57:11.000000000 +1000
+++ linux-cell/arch/powerpc/platforms/cell/spufs/file.c	2007-05-25 14:24:10.000000000 +1000
@@ -39,6 +39,7 @@
 
 #define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
 
+
 static int
 spufs_mem_open(struct inode *inode, struct file *file)
 {
@@ -1796,6 +1797,35 @@ static int spufs_info_open(struct inode 
 	return 0;
 }
 
+#define CAPS_BUF_LEN		64
+#define ADD_ONE_CAP(name)	\
+  do { p += snprintf(p, CAPS_BUF_LEN - 3 - (p - buffer), "%s ", #name); \
+     } while(0)
+
+static ssize_t spufs_caps_read(struct file *file, char __user *buf,
+			       size_t len, loff_t *pos)
+{
+	struct spu_context *ctx = file->private_data;
+	char buffer[CAPS_BUF_LEN];
+	char *p = buffer;
+
+	if (!(ctx->flags & SPU_CREATE_NOSCHED))
+		ADD_ONE_CAP(sched);
+	if (!(ctx->flags & SPU_CREATE_ISOLATE))
+		ADD_ONE_CAP(step);
+
+	/* remove last space and add newline */
+	if (p != buffer)
+		p--;
+	*(p++) = '\n';
+	return simple_read_from_buffer(buf, len, pos, buffer, p - buffer);
+}
+
+static const struct file_operations spufs_caps_fops = {
+	.open = spufs_info_open,
+	.read = spufs_caps_read,
+};
+
 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
 			char __user *buf, size_t len, loff_t *pos)
 {
@@ -2014,6 +2044,7 @@ static const struct file_operations spuf
 };
 
 struct tree_descr spufs_dir_contents[] = {
+	{ "capabilities", &spufs_caps_fops, 0444, },
 	{ "mem",  &spufs_mem_fops,  0666, },
 	{ "regs", &spufs_regs_fops,  0666, },
 	{ "mbox", &spufs_mbox_fops, 0444, },
@@ -2049,6 +2080,7 @@ struct tree_descr spufs_dir_contents[] =
 };
 
 struct tree_descr spufs_dir_nosched_contents[] = {
+	{ "capabilities", &spufs_caps_fops, 0444, },
 	{ "mem",  &spufs_mem_fops,  0666, },
 	{ "mbox", &spufs_mbox_fops, 0444, },
 	{ "ibox", &spufs_ibox_fops, 0444, },



More information about the cbe-oss-dev mailing list