linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Akinobu Mita <mita@fixstars.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>,
	cbe-oss-dev@ozlabs.org
Subject: Re: [patch 3/3] cell: prevent alignment interrupt on local store
Date: Wed, 11 Apr 2007 12:06:56 +0900	[thread overview]
Message-ID: <20070411030656.GA2469@localhost.localdomain> (raw)
In-Reply-To: <ca57c91a479a78be2f0004a40695f1ba@kernel.crashing.org>

On Tue, Apr 10, 2007 at 02:52:33PM +0200, Segher Boessenkool wrote:
> >An Alignment interrupt occurs when the instruction is lmw, stmw, lswi, 
> >lswx,
> >stswi, or stswx, and the operand is in local store.
> >
> >GCC generated such instructions to handle memcpy() instead of kernel
> >defined memcpy() without -mno-string option.
> 
> >+# An Alignment interrupt occurs when the instruction is lmw, stmw, 
> >lswi, lswx,
> >+# stswi, or stswx, and the operand is in local store.
> >+CFLAGS_run.o := -mno-string
> >+CFLAGS_file.o := -mno-string
> 
> NAK.  Please use memcpy_fromio() and friends instead,
> that's what they're there for.  I believe Arnd was working
> on this?
> 
> Your patch is only a partial solution, you'd need -mno-multiple
> -mno-algebraic -mno-dcbz too (and two of those don't even
> exist).

This is the patch which fix the problem with using memcpy_fromio/toio()
on LS. It seems better than adding many -mno-* options to specific
files.

From: Akinobu Mita <mita@fixstars.com>
Subject: spufs: use memcpy_fromio() to copy from local store

GCC may generates inline copy loop to handle memcpy() function
instead of kernel defined memcpy(). But this inlined version of memcpy()
causes an alignment interrupt when copying from local store.

This patch uses memcpy_fromio() and memcpy_toio to copy local store
to prevent memcpy() being inlined.

Signed-off-by: Akinobu Mita <mita@fixstars.com>

---
 arch/powerpc/platforms/cell/spufs/run.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: 2.6-git-ps3/arch/powerpc/platforms/cell/spufs/run.c
===================================================================
--- 2.6-git-ps3.orig/arch/powerpc/platforms/cell/spufs/run.c
+++ 2.6-git-ps3/arch/powerpc/platforms/cell/spufs/run.c
@@ -260,10 +260,10 @@ int spu_process_callback(struct spu_cont
 	/* get syscall block from local store */
 	npc = ctx->ops->npc_read(ctx);
 	ls = ctx->ops->get_ls(ctx);
-	ls_pointer = *(u32*)(ls + npc);
+	ls_pointer = *(u32 *)(ls + npc);
 	if (ls_pointer > (LS_SIZE - sizeof(s)))
 		return -EFAULT;
-	memcpy(&s, ls + ls_pointer, sizeof (s));
+	memcpy_fromio(&s, ls + ls_pointer, sizeof(s));
 
 	/* do actual syscall without pinning the spu */
 	ret = 0;
@@ -283,7 +283,7 @@ int spu_process_callback(struct spu_cont
 	}
 
 	/* write result, jump over indirect pointer */
-	memcpy(ls + ls_pointer, &spu_ret, sizeof (spu_ret));
+	memcpy_toio(ls + ls_pointer, &spu_ret, sizeof(spu_ret));
 	ctx->ops->npc_write(ctx, npc);
 	ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
 	return ret;

  reply	other threads:[~2007-04-11  3:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10 11:15 [patch 3/3] cell: prevent alignment interrupt on local store Akinobu Mita
2007-04-10 12:52 ` Segher Boessenkool
2007-04-11  3:06   ` Akinobu Mita [this message]
2007-04-10 21:22 ` Benjamin Herrenschmidt
2007-04-11  2:56   ` Akinobu Mita
2007-04-11  3:30     ` Benjamin Herrenschmidt
2007-04-11 21:03       ` Segher Boessenkool
2007-04-12  4:23         ` Olaf Hering
2007-04-12  5:26           ` Benjamin Herrenschmidt
2007-04-12  6:33             ` Olaf Hering
2007-04-12  6:38               ` Benjamin Herrenschmidt
2007-04-12  8:31                 ` Gabriel Paubert
2007-04-12  8:48                   ` Benjamin Herrenschmidt
2007-04-12  6:50           ` Segher Boessenkool
2007-04-12  6:57             ` [Cbe-oss-dev] " Michael Ellerman
2007-04-12  7:07               ` Segher Boessenkool
2007-04-12 18:43           ` Arnd Bergmann
2007-04-12 18:55             ` Arnd Bergmann
2007-04-12 19:57               ` Segher Boessenkool
2007-04-12 19:52             ` Segher Boessenkool
2007-04-12 13:01   ` [RFC, PATCH] selection of CPU optimization Arnd Bergmann
2007-04-12 16:45     ` Kumar Gala
2007-04-12 17:26       ` [Cbe-oss-dev] " Arnd Bergmann
2007-04-12 18:17         ` Kumar Gala
2007-04-12 19:25           ` Arnd Bergmann
2007-04-12 20:04           ` Olof Johansson
2007-04-12 20:01             ` Segher Boessenkool
2007-04-12 20:22               ` Olof Johansson
2007-04-12 20:22                 ` Segher Boessenkool
2007-04-12 19:50         ` Segher Boessenkool
2007-04-13  0:10           ` Arnd Bergmann
2007-04-13  2:03             ` Olof Johansson
2007-04-13 18:43             ` Segher Boessenkool

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=20070411030656.GA2469@localhost.localdomain \
    --to=mita@fixstars.com \
    --cc=arnd@arndb.de \
    --cc=cbe-oss-dev@ozlabs.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    --cc=segher@kernel.crashing.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).