From: Paul Mackerras <paulus@samba.org>
To: matt@genesi-usa.com
Cc: linuxppc-dev@ozlabs.org
Subject: Re: AltiVec in the kernel
Date: Wed, 19 Jul 2006 03:43:06 +1000 [thread overview]
Message-ID: <17597.7594.554879.945280@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <004c01c6aa68$6f580d00$99dfdfdf@bakuhatsu.net>
Matt Sealey writes:
> Once upon a time we were all told this wouldn't work for some reason,
> but a lot of documentation now hints that it does actually work and
> for instance there is a RAID5/6 driver (for G5) which uses AltiVec
> in a kernel context.
It's possible, with some restrictions, basically the same restrictions
on using floating point in the kernel.
Kernel use of altivec interacts with the lazy altivec context switch
that we do on UP kernels, and the fact that the kernel context switch
doesn't save/restore the altivec state. That means that before using
altivec in the kernel you may have to save away the altivec state, and
you have to make sure you don't sleep or get preempted while using
altivec.
> But I didn't find any definitive documentation on how one goes about
> it. The largest clue I found was in Documentation/cpu_features.txt:
>
> #ifdef CONFIG_ALTIVEC
> BEGIN_FTR_SECTION
> mfspr r22,SPRN_VRSAVE /* if G4, save vrsave register value */
> stw r22,THREAD_VRSAVE(r23)
> END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
> #endif /* CONFIG_ALTIVEC */
>
> So we can use AltiVec by implementing this kind of wrapper around
> kernel functions which may use AltiVec?
No, that's irrelevant; that just has to do with the VRSAVE register,
not the altivec state. In fact VRSAVE isn't actually even part of the
altivec state.
> In the code above is there ANY significance of r22 and r23 other
> than that they are fairly high up and probably marked as "will
> be trashed" by all the relevant ABIs and so?
I hope we do a bit better than "probably" ... :) No, there is no
particular significance to the choice of r22 and r23. If you read the
code you will see that those registers are saved at the beginning of
the context switch routine and restored (from the new process's stack)
at the end.
Paul.
next prev parent reply other threads:[~2006-07-18 17:43 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 12:48 AltiVec in the kernel Matt Sealey
2006-07-18 13:53 ` Kumar Gala
2006-07-18 15:10 ` Matt Sealey
2006-07-18 17:56 ` Paul Mackerras
2006-07-19 18:10 ` Linas Vepstas
2006-07-19 18:19 ` Paul Mackerras
2006-07-19 18:38 ` Johannes Berg
2006-07-19 18:57 ` Linas Vepstas
2006-07-20 12:31 ` Matt Sealey
2006-07-20 13:23 ` Kumar Gala
2006-07-20 13:33 ` Matt Sealey
2006-07-20 17:42 ` Linas Vepstas
2006-07-20 18:47 ` Brian D. Carlstrom
2006-07-20 19:05 ` Olof Johansson
2006-07-20 21:56 ` Brian D. Carlstrom
2006-07-20 22:39 ` Daniel Ostrow
2006-07-21 6:35 ` Olof Johansson
2006-07-21 14:42 ` Matt Sealey
2006-07-21 16:51 ` Linas Vepstas
2006-07-21 18:08 ` Matt Sealey
2006-07-22 3:09 ` Segher Boessenkool
2006-07-23 13:28 ` Matt Sealey
2006-07-23 21:37 ` Benjamin Herrenschmidt
2006-07-21 18:46 ` Brian D. Carlstrom
2006-07-21 21:30 ` Hollis Blanchard
2006-07-21 22:21 ` Peter Bergner
2006-07-18 18:39 ` Benjamin Herrenschmidt
2006-07-18 17:43 ` Paul Mackerras [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-12-11 11:45 Simon Richter
2009-12-11 15:49 ` Arnd Bergmann
2009-12-16 22:11 ` Sebastian Andrzej 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=17597.7594.554879.945280@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=matt@genesi-usa.com \
/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).