public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* Mutex fast-path implementation sh4a
@ 2008-11-19 13:23 michael
  2008-11-20  4:43 ` Paul Mundt
  2008-11-20 17:18 ` Michael Trimarchi
  0 siblings, 2 replies; 3+ messages in thread
From: michael @ 2008-11-19 13:23 UTC (permalink / raw)
  To: linux-sh

Hi,

I'm not an expert of sh4 assembler instruction on gcc, but I figure out 
how to implement
the fastpath_lock and trylock, and I obtain this code:

static inline void
__mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *))
{
        int __res;

        __asm__ __volatile__ (

                "movli.l        @%1, %0 \n\t"
                "dt             %0      \n\t"
                "movco.l        %0, @%1 \n\t"
                : "=&z" (__res)
                : "r" (&(count)->counter)
                : "t" );

        if (unlikely(__res != count->counter))
                fail_fn(count);
}

The retval function is very quite similar to this one. I don't find 
documentation about sh assembler,
can someone point me out to documentation?
The start point was the arm implementation and the 
arch/sh/include/asm/atomic-llsc.h file.

Can be a correct implementation?

Regards Michael



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Mutex fast-path implementation sh4a
  2008-11-19 13:23 Mutex fast-path implementation sh4a michael
@ 2008-11-20  4:43 ` Paul Mundt
  2008-11-20 17:18 ` Michael Trimarchi
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2008-11-20  4:43 UTC (permalink / raw)
  To: linux-sh

On Wed, Nov 19, 2008 at 02:23:04PM +0100, michael wrote:
> Hi,
> 
> I'm not an expert of sh4 assembler instruction on gcc, but I figure out 
> how to implement
> the fastpath_lock and trylock, and I obtain this code:
> 
> static inline void
> __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *))
> {
>        int __res;
> 
>        __asm__ __volatile__ (
> 
>                "movli.l        @%1, %0 \n\t"
>                "dt             %0      \n\t"
>                "movco.l        %0, @%1 \n\t"
>                : "=&z" (__res)
>                : "r" (&(count)->counter)
>                : "t" );
> 
>        if (unlikely(__res != count->counter))
>                fail_fn(count);
> }
> 
The assembly looks fine, but you probably want to change the __res test
to something like:

	if (unlikely(__res != 0))
		fail_fn(count);

Given that you already have the counter value implemented there. This
will save you an additional memory access due to the fact the atomic
counter is volatile.

When you are implementing this, you should also include the comment from
ARM, as the single-pass atomic sequence without looping semantics aren't
entirely obvious without it.

> The retval function is very quite similar to this one. I don't find 
> documentation about sh assembler,
> can someone point me out to documentation?

What sort of documentation are you looking for? A good start is the SH-4A
software manual, which you can find the pdf for from any SH-4A part
specification download. If you are particularly concerned about inline
assembly, then you need to look at the GCC manual for SH-specific
information. Anything else you can feel free to ask on the list.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Mutex fast-path implementation sh4a
  2008-11-19 13:23 Mutex fast-path implementation sh4a michael
  2008-11-20  4:43 ` Paul Mundt
@ 2008-11-20 17:18 ` Michael Trimarchi
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Trimarchi @ 2008-11-20 17:18 UTC (permalink / raw)
  To: linux-sh



Hi,
...

> When you are implementing this, you should also include the comment from
> ARM, as the single-pass atomic sequence without looping semantics aren't
> entirely obvious without it.
> 

I change the comment in the pathes that I already send.

> > The retval function is very quite similar to this one. I don't find 
> > documentation about sh assembler,
> > can someone point me out to documentation?
> 
> What sort of documentation are you looking for? A good start is the SH-4A

I have downloaded that one, thanks.

> software manual, which you can find the pdf for from any SH-4A part
> specification download. If you are particularly concerned about inline
> assembly, then you need to look at the GCC manual for SH-specific
> information. Anything else you can feel free to ask on the list.

I don't find it, but I will take a look at google.

Regards Michael


      Unisciti alla community di Io fotografo e video, il nuovo corso di fotografia di Gazzetta dello sport:
http://www.flickr.com/groups/iofotografoevideo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-20 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-19 13:23 Mutex fast-path implementation sh4a michael
2008-11-20  4:43 ` Paul Mundt
2008-11-20 17:18 ` Michael Trimarchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox