From: Andi Kleen <andi@firstfloor.org>
To: Johannes Goetzfried
<Johannes.Goetzfried@informatik.stud.uni-erlangen.de>
Cc: "Herbert Xu" <herbert@gondor.hengli.com.au>,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
"Tilo Müller" <tilo.mueller@informatik.uni-erlangen.de>
Subject: Re: [PATCH] crypto: serpent - add x86_64/avx assembler implementation
Date: Tue, 29 May 2012 19:27:43 -0700 [thread overview]
Message-ID: <m2396il7xc.fsf@firstfloor.org> (raw)
In-Reply-To: <20120527145112.GF17705@kronos.redsun> (Johannes Goetzfried's message of "Sun, 27 May 2012 16:51:12 +0200")
Johannes Goetzfried
<Johannes.Goetzfried@informatik.stud.uni-erlangen.de> writes:
> +
> +static int __init serpent_init(void)
> +{
> + u64 xcr0;
> +
> + if (!cpu_has_avx || !cpu_has_osxsave) {
> + printk(KERN_INFO "AVX instructions are not detected.\n");
> + return -ENODEV;
> + }
> +
> + xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
> + if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) {
> + printk(KERN_INFO "AVX detected but unusable.\n");
> + return -ENODEV;
> + }
> +
> + return crypto_register_algs(serpent_algs, ARRAY_SIZE(serpent_algs));
> +}
> +
> +static void __exit serpent_exit(void)
> +{
> + crypto_unregister_algs(serpent_algs, ARRAY_SIZE(serpent_algs));
> +}
> +
> +module_init(serpent_init);
> +module_exit(serpent_exit);
> +
> +MODULE_DESCRIPTION("Serpent Cipher Algorithm, AVX optimized");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("serpent");
The driver needs CPUID annotations now (since 3.3), so that it can be
autoloaded. Something like:
#include <asm/cpu_device_id.h>
static const struct x86_cpu_id avx_cpu_id[] = {
X86_FEATURE_MATCH(X86_FEATURE_AVX),
{}
};
MODULE_DEVICE_TABLE(x86cpu, avx_cpu_id);
Replace the manual check in init with
if (!x86_match_cpu(avx_cpu_id))
return -ENODEV;
Also drivers should never print anything when they cannot find hardware.
Remove that printk.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
next prev parent reply other threads:[~2012-05-30 2:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-27 14:51 Johannes Goetzfried
2012-05-28 6:37 ` Jussi Kivilinna
2012-05-28 14:10 ` Johannes Goetzfried
2012-05-28 21:33 ` Jussi Kivilinna
2012-05-30 2:27 ` Andi Kleen [this message]
2012-05-30 7:30 ` Jussi Kivilinna
2012-05-30 11:32 ` Johannes Goetzfried
2012-05-30 15:39 ` Andi Kleen
2012-05-30 17:36 ` Johannes Goetzfried
2012-05-30 18:53 ` Jussi Kivilinna
2012-06-09 14:50 ` [PATCH] crypto: aes - make assembler implementation default for i386 and x86-64 Jussi Kivilinna
2012-06-12 8:26 ` Herbert Xu
2012-06-12 18:25 ` Jussi Kivilinna
2012-06-18 9:02 ` Herbert Xu
2012-06-20 11:49 ` Jussi Kivilinna
2012-05-30 21:29 ` [PATCH] crypto: serpent - add x86_64/avx assembler implementation Herbert Xu
2012-05-30 21:40 ` Andi Kleen
2012-05-30 21:44 ` Herbert Xu
2012-05-30 21:55 ` Andi Kleen
2012-05-30 22:34 ` Herbert Xu
2012-05-30 11:36 ` Johannes Goetzfried
2012-05-30 16:26 ` Andi Kleen
2012-05-30 17:49 ` Johannes Goetzfried
2012-05-28 14:12 Johannes Goetzfried
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=m2396il7xc.fsf@firstfloor.org \
--to=andi@firstfloor.org \
--cc=Johannes.Goetzfried@informatik.stud.uni-erlangen.de \
--cc=herbert@gondor.hengli.com.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tilo.mueller@informatik.uni-erlangen.de \
/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
Powered by JetHome