Skip to content
Snippets Groups Projects
Select Git revision
  • 7b17a1a841fc2336eba53afade9cadb14bd3dd9a
  • master default
  • virtio-camera
  • venus
  • venus-rebased
  • virgl-blob-fixes
  • staging
  • stable-6.1
  • stable-6.0
  • stable-6.0-staging
  • stable-5.0
  • stable-4.2
  • stable-4.1
  • stable-4.0
  • stable-3.1
  • stable-3.0
  • stable-2.12
  • stable-2.11
  • stable-2.10
  • stable-2.9
  • stable-2.8
  • v7.1.0-rc2
  • v7.1.0-rc1
  • v7.1.0-rc0
  • v7.0.0
  • v7.0.0-rc4
  • v7.0.0-rc3
  • v7.0.0-rc2
  • v7.0.0-rc1
  • v7.0.0-rc0
  • v6.1.1
  • v6.2.0
  • v6.2.0-rc4
  • v6.2.0-rc3
  • v6.2.0-rc2
  • v6.2.0-rc1
  • v6.2.0-rc0
  • v6.0.1
  • v6.1.0
  • v6.1.0-rc4
  • v6.1.0-rc3
41 results

VERSION

Blame
  • mcryptd.c 17.47 KiB
    /*
     * Software multibuffer async crypto daemon.
     *
     * Copyright (c) 2014 Tim Chen <tim.c.chen@linux.intel.com>
     *
     * Adapted from crypto daemon.
     *
     * This program is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by the Free
     * Software Foundation; either version 2 of the License, or (at your option)
     * any later version.
     *
     */
    
    #include <crypto/algapi.h>
    #include <crypto/internal/hash.h>
    #include <crypto/internal/aead.h>
    #include <crypto/mcryptd.h>
    #include <crypto/crypto_wq.h>
    #include <linux/err.h>
    #include <linux/init.h>
    #include <linux/kernel.h>
    #include <linux/list.h>
    #include <linux/module.h>
    #include <linux/scatterlist.h>
    #include <linux/sched.h>
    #include <linux/slab.h>
    #include <linux/hardirq.h>
    
    #define MCRYPTD_MAX_CPU_QLEN 100
    #define MCRYPTD_BATCH 9
    
    static void *mcryptd_alloc_instance(struct crypto_alg *alg, unsigned int head,
    				   unsigned int tail);
    
    struct mcryptd_flush_list {
    	struct list_head list;
    	struct mutex lock;
    };
    
    static struct mcryptd_flush_list __percpu *mcryptd_flist;
    
    struct hashd_instance_ctx {
    	struct crypto_ahash_spawn spawn;
    	struct mcryptd_queue *queue;
    };
    
    static void mcryptd_queue_worker(struct work_struct *work);
    
    void mcryptd_arm_flusher(struct mcryptd_alg_cstate *cstate, unsigned long delay)
    {
    	struct mcryptd_flush_list *flist;
    
    	if (!cstate->flusher_engaged) {
    		/* put the flusher on the flush list */
    		flist = per_cpu_ptr(mcryptd_flist, smp_processor_id());
    		mutex_lock(&flist->lock);
    		list_add_tail(&cstate->flush_list, &flist->list);
    		cstate->flusher_engaged = true;
    		cstate->next_flush = jiffies + delay;
    		queue_delayed_work_on(smp_processor_id(), kcrypto_wq,
    			&cstate->flush, delay);
    		mutex_unlock(&flist->lock);
    	}
    }
    EXPORT_SYMBOL(mcryptd_arm_flusher);
    
    static int mcryptd_init_queue(struct mcryptd_queue *queue,
    			     unsigned int max_cpu_qlen)
    {