All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Siewior <cbe-oss-dev@ml.breakpoint.cc>
To: cbe-oss-dev@ozlabs.org
Cc: <herbert@gondor.apana.org.au>, <arnd@arndb.de>, <jk@ozlabs.org>,
	linux-crypto@vger.kernel.org,
	Sebastian Siewior <sebastian@breakpoint.cc>
Subject: [patch 06/10] spufs: add kspu_alloc_context()
Date: Thu, 16 Aug 2007 22:01:11 +0200	[thread overview]
Message-ID: <20070816200136.639095000@ml.breakpoint.cc> (raw)
In-Reply-To: 20070816200105.735608000@ml.breakpoint.cc

[-- Attachment #1: spufs-add_kspu_alloc_context.diff --]
[-- Type: text/plain, Size: 2132 bytes --]

Function behaves like alloc_spu_context() but instead of current-> init
task's informations are used and the problem state bit is removed.

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -32,7 +32,8 @@
 
 atomic_t nr_spu_contexts = ATOMIC_INIT(0);
 
-struct spu_context *alloc_spu_context(struct spu_gang *gang)
+static struct spu_context *__alloc_spu_context(struct spu_gang *gang,
+		struct mm_struct *mm)
 {
 	struct spu_context *ctx;
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
@@ -54,7 +55,7 @@ struct spu_context *alloc_spu_context(st
 	init_waitqueue_head(&ctx->mfc_wq);
 	ctx->state = SPU_STATE_SAVED;
 	ctx->ops = &spu_backing_ops;
-	ctx->owner = get_task_mm(current);
+	ctx->owner = mm;
 	INIT_LIST_HEAD(&ctx->rq);
 	INIT_LIST_HEAD(&ctx->aff_list);
 	if (gang)
@@ -73,6 +74,37 @@ out:
 	return ctx;
 }
 
+struct spu_context *alloc_spu_context(struct spu_gang *gang)
+{
+	struct mm_struct *mm;
+	struct spu_context *ctx;
+
+	mm = get_task_mm(current);
+	ctx = __alloc_spu_context(gang, mm);
+	if (!ctx)
+		mmput(mm);
+	return ctx;
+}
+
+struct spu_context *kspu_alloc_context(void)
+{
+	struct spu_context *ctx;
+
+	/* for priviliged spu context, we borrow all the task specific
+	 * informations from init_task.
+	 */
+	atomic_inc(&init_mm.mm_users);
+	ctx = __alloc_spu_context(NULL, &init_mm);
+	if (!ctx) {
+		mmput(&init_mm);
+		return ctx;
+	}
+
+	/* remove problem state bit in order to access kernel memory */
+	ctx->csa.priv1.mfc_sr1_RW &= ~MFC_STATE1_PROBLEM_STATE_MASK;
+	return ctx;
+}
+
 void destroy_spu_context(struct kref *kref)
 {
 	struct spu_context *ctx;
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -232,6 +232,7 @@ static inline void spu_release(struct sp
 }
 
 struct spu_context * alloc_spu_context(struct spu_gang *gang);
+struct spu_context *kspu_alloc_context(void);
 void destroy_spu_context(struct kref *kref);
 struct spu_context * get_spu_context(struct spu_context *ctx);
 int put_spu_context(struct spu_context *ctx);

-- 

  parent reply	other threads:[~2007-08-16 20:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-16 20:01 [patch 00/10] KSPU API + AES offloaded to SPU + testing module Sebastian Siewior
2007-08-16 20:01 ` [patch 01/10] t add cast to regain ablkcipher_request from private ctx Sebastian Siewior
2007-08-17  8:55   ` Herbert Xu
2007-08-16 20:01 ` [patch 02/10] crypto: retrieve private ctx aligned Sebastian Siewior
2007-08-16 20:01 ` [patch 03/10] spufs: kspu documentation Sebastian Siewior
2007-08-16 20:01 ` [patch 04/10] spufs: kspu doc skeleton Sebastian Siewior
2007-08-16 20:01 ` [patch 05/10] spufs: kspu add required declarations Sebastian Siewior
2007-08-16 20:01 ` Sebastian Siewior [this message]
2007-08-16 20:01 ` [patch 07/10] spufs: add kernel support for spu task Sebastian Siewior
2007-08-18 16:48   ` Arnd Bergmann
2007-08-16 20:01 ` [patch 08/10] spufs: SPE side implementation of kspu Sebastian Siewior
2007-08-16 20:01 ` [patch 09/10] spufs: SPU-AES support (kernel side) Sebastian Siewior
     [not found]   ` <20070828154637.GA21007@Chamillionaire.breakpoint.cc>
2007-08-29  7:15     ` [patch 1/1] spufs: SPU-AES support (kspu+ablkcipher user) Herbert Xu
2007-08-29  9:28       ` Sebastian Siewior
     [not found]     ` <18132.43463.753224.982580@cargo.ozlabs.ibm.com>
2007-08-29  9:09       ` [Cbe-oss-dev] " Sebastian Siewior
2007-08-16 20:01 ` [patch 10/10] cryptoapi: async speed test Sebastian Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070816200136.639095000@ml.breakpoint.cc \
    --to=cbe-oss-dev@ml.breakpoint.cc \
    --cc=arnd@arndb.de \
    --cc=cbe-oss-dev@ozlabs.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jk@ozlabs.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=sebastian@breakpoint.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.