From patchwork Wed Dec 10 19:02:32 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Detsch X-Patchwork-Id: 13281 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 50406474C1 for ; Thu, 11 Dec 2008 06:05:13 +1100 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from igw2.br.ibm.com (igw2.br.ibm.com [32.104.18.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "igw2.br.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id CB5D34750D for ; Thu, 11 Dec 2008 06:02:38 +1100 (EST) Received: from d24relay01.br.ibm.com (unknown [9.8.31.16]) by igw2.br.ibm.com (Postfix) with ESMTP id 98DF717F694 for ; Wed, 10 Dec 2008 15:45:43 -0200 (BRDT) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mBAK27Ws3739902 for ; Wed, 10 Dec 2008 17:02:07 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mBAJ2WwT011095 for ; Wed, 10 Dec 2008 17:02:32 -0200 Received: from [9.8.13.23] ([9.8.13.23]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id mBAJ2WVH011025 for ; Wed, 10 Dec 2008 17:02:32 -0200 Date: Wed, 10 Dec 2008 17:02:32 -0200 From: adetsch@br.ibm.com Message-Id: <200812101902.mBAJ2WVH011025@d24av01.br.ibm.com> To: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] (no subject) X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org From b28ee65c357ef4d0fbd2f571fba53f01b90ac937 Mon Sep 17 00:00:00 2001 In-Reply-To: <200812101654.05091.adetsch@br.ibm.com> References: <200812101654.05091.adetsch@br.ibm.com> From: Andre Detsch Date: Wed, 10 Dec 2008 16:02:32 -0300 Subject: [PATCH 02/18] powerpc/spufs: Add gang structure for standalone ctxts MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812101702.32314.adetsch@br.ibm.com> All contexts should have a gang structure to provide a common data abstraction for scheduling. Standalone gangs are just gangs of one. Signed-off-by: Luke Browning Signed-off-by: Andre Detsch --- arch/powerpc/platforms/cell/spufs/context.c | 30 +++++++++++++++++++++----- arch/powerpc/platforms/cell/spufs/inode.c | 16 ++++++++++++- 2 files changed, 38 insertions(+), 8 deletions(-) goto out_iput; diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c index d6c184d..85b5c1f 100644 --- a/arch/powerpc/platforms/cell/spufs/context.c +++ b/arch/powerpc/platforms/cell/spufs/context.c @@ -35,14 +35,28 @@ atomic_t nr_spu_contexts = ATOMIC_INIT(0); struct spu_context *alloc_spu_context(struct spu_gang *gang) { struct spu_context *ctx; + ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) goto out; + + /* Allocate an anonymous gang if the caller did not explicitly + * create one so that a common data abstraction exists for + * the scheduler. Gangs are queued to the runqueue. In this case, + * the gang is a gang of one. + */ + if (!gang) { + gang = alloc_spu_gang(); + if (!gang) + goto out_free; + } + /* Binding to physical processor deferred * until spu_activate(). */ if (spu_init_csa(&ctx->csa)) - goto out_free; + goto out_free_gang; + spin_lock_init(&ctx->mmio_lock); mutex_init(&ctx->mapping_lock); kref_init(&ctx->kref); @@ -58,15 +72,16 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang) ctx->owner = get_task_mm(current); INIT_LIST_HEAD(&ctx->rq); INIT_LIST_HEAD(&ctx->aff_list); - if (gang) - spu_gang_add_ctx(gang, ctx); - + spu_gang_add_ctx(gang, ctx); spu_update_sched_info(ctx); spu_set_timeslice(ctx); ctx->stats.util_state = SPU_UTIL_IDLE_LOADED; atomic_inc(&nr_spu_contexts); goto out; + +out_free_gang: + kfree(gang); out_free: kfree(ctx); ctx = NULL; @@ -76,15 +91,18 @@ out: void destroy_spu_context(struct kref *kref) { + struct spu_gang *gang; struct spu_context *ctx; + ctx = container_of(kref, struct spu_context, kref); + gang = ctx->gang; + spu_context_nospu_trace(destroy_spu_context__enter, ctx); mutex_lock(&ctx->state_mutex); spu_deactivate(ctx); mutex_unlock(&ctx->state_mutex); spu_fini_csa(&ctx->csa); - if (ctx->gang) - spu_gang_remove_ctx(ctx->gang, ctx); + spu_gang_remove_ctx(ctx->gang, ctx); if (ctx->prof_priv_kref) kref_put(ctx->prof_priv_kref, ctx->prof_priv_release); BUG_ON(!list_empty(&ctx->rq)); diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index 61dfc67..ad00772 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -261,18 +261,30 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags, { int ret; struct inode *inode; - struct spu_context *ctx; + struct spu_context *ctx, *gang_ctx; + struct spu_gang *gang; ret = -ENOSPC; inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR); if (!inode) goto out; + /* Can't mix sched and no-sched within the same gang. */ + gang = SPUFS_I(dir)->i_gang; + if (gang) { + gang_ctx = list_first_entry(&gang->list, struct spu_context, gang_list); + if ((flags & SPU_CREATE_NOSCHED) ^ + (gang_ctx->flags & SPU_CREATE_NOSCHED)) { + ret = -EPERM; + goto out_iput; + } + } + if (dir->i_mode & S_ISGID) { inode->i_gid = dir->i_gid; inode->i_mode &= S_ISGID; } - ctx = alloc_spu_context(SPUFS_I(dir)->i_gang); /* XXX gang */ + ctx = alloc_spu_context(gang); SPUFS_I(inode)->i_ctx = ctx; if (!ctx)