lkml.org 
[lkml]   [2012]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH] crypto: serpent - add x86_64/avx assembler implementation
    Date
    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


    \
     
     \ /
      Last update: 2012-05-30 04:41    [W:0.026 / U:30.108 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site