From patchwork Thu Sep 11 23:38:16 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: powerpc/spufs: Allow gang to grow in size after it has been started Date: Thu, 11 Sep 2008 13:38:16 -0000 From: Andre Detsch X-Patchwork-Id: 254 Message-Id: <200809112038.17055.adetsch@br.ibm.com> To: cbe-oss-dev@ozlabs.org Cc: LukeBrowning@us.ibm.com, Jeremy Kerr Just deactivate it, add the new context, and let the calling thread drives its reactivation. It needs to be unscheduled, since it may no longer fit or it may need to be migrated to a different node. Signed-off-by: Luke Browning Signed-off-by: Andre Detsch diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c index 21ba409..c472519 100644 --- a/arch/powerpc/platforms/cell/spufs/context.c +++ b/arch/powerpc/platforms/cell/spufs/context.c @@ -57,6 +57,17 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang) if (spu_init_csa(&ctx->csa)) goto out_free_gang; + /* If the gang is running, it needs to be stopped, since we have a + * new context that needs to be gang scheduled. Gangs are allowed + * to grow and shrink over time, but they are unscheduled when it + * happens as the gang may need to migrated to a different node. + */ + if (atomic_read(&gang->nstarted)) { + mutex_lock(&gang->mutex); + spu_deactivate(gang); + mutex_unlock(&gang->mutex); + } + spin_lock_init(&ctx->mmio_lock); mutex_init(&ctx->mapping_lock);