Commit 9a07a796 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto update from Herbert Xu:
 "API:

   - Crypto self tests can now be disabled at boot/run time.
   - Add async support to algif_aead.

  Algorithms:

   - A large number of fixes to MPI from Nicolai Stange.
   - Performance improvement for HMAC DRBG.

  Drivers:

   - Use generic crypto engine in omap-des.
   - Merge ppc4xx-rng and crypto4xx drivers.
   - Fix lockups in sun4i-ss driver by disabling IRQs.
   - Add DMA engine support to ccp.
   - Reenable talitos hash algorithms.
   - Add support for Hisilicon SoC RNG.
   - Add basic crypto driver for the MXC SCC.

  Others:

   - Do not allocate crypto hash tfm in NORECLAIM context in ecryptfs"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (77 commits)
  crypto: qat - change the adf_ctl_stop_devices to void
  crypto: caam - fix caam_jr_alloc() ret code
  crypto: vmx - comply with ABIs that specify vrsave as reserved.
  crypto: testmgr - Add a flag allowing the self-tests to be disabled at runtime.
  crypto: ccp - constify ccp_actions structure
  crypto: marvell/cesa - Use dma_pool_zalloc
  crypto: qat - make adf_vf_isr.c dependant on IOV config
  crypto: qat - Fix typo in comments
  lib: asn1_decoder - add MODULE_LICENSE("GPL")
  crypto: omap-sham - Use dma_request_chan() for requesting DMA channel
  crypto: omap-des - Use dma_request_chan() for requesting DMA channel
  crypto: omap-aes - Use dma_request_chan() for requesting DMA channel
  crypto: omap-des - Integrate with the crypto engine framework
  crypto: s5p-sss - fix incorrect usage of scatterlists api
  crypto: s5p-sss - Fix missed interrupts when working with 8 kB blocks
  crypto: s5p-sss - Use common BIT macro
  crypto: mxc-scc - fix unwinding in mxc_scc_crypto_register()
  crypto: mxc-scc - signedness bugs in mxc_scc_ablkcipher_req_init()
  crypto: talitos - fix ahash algorithms registration
  crypto: ccp - Ensure all dependencies are specified
  ...
parents 16490980 256b1cfb
...@@ -1936,9 +1936,9 @@ static int test_skcipher(void) ...@@ -1936,9 +1936,9 @@ static int test_skcipher(void)
} }
req = skcipher_request_alloc(skcipher, GFP_KERNEL); req = skcipher_request_alloc(skcipher, GFP_KERNEL);
if (IS_ERR(req)) { if (!req) {
pr_info("could not allocate request queue\n"); pr_info("could not allocate skcipher request\n");
ret = PTR_ERR(req); ret = -ENOMEM;
goto out; goto out;
} }
......
Freescale Security Controller (SCC)
Required properties:
- compatible : Should be "fsl,imx25-scc".
- reg : Should contain register location and length.
- interrupts : Should contain interrupt numbers for SCM IRQ and SMN IRQ.
- interrupt-names : Should specify the names "scm" and "smn" for the
SCM IRQ and SMN IRQ.
- clocks: Should contain the clock driving the SCC core.
- clock-names: Should be set to "ipg".
Example:
scc: crypto@53fac000 {
compatible = "fsl,imx25-scc";
reg = <0x53fac000 0x4000>;
clocks = <&clks 111>;
clock-names = "ipg";
interrupts = <49>, <50>;
interrupt-names = "scm", "smn";
};
...@@ -23,10 +23,8 @@ Required properties: ...@@ -23,10 +23,8 @@ Required properties:
- "samsung,exynos4210-secss" for Exynos4210, Exynos4212, Exynos4412, Exynos5250, - "samsung,exynos4210-secss" for Exynos4210, Exynos4212, Exynos4412, Exynos5250,
Exynos5260 and Exynos5420 SoCs. Exynos5260 and Exynos5420 SoCs.
- reg : Offset and length of the register set for the module - reg : Offset and length of the register set for the module
- interrupts : interrupt specifiers of SSS module interrupts, should contain - interrupts : interrupt specifiers of SSS module interrupts (one feed
following entries: control interrupt).
- first : feed control interrupt (required for all variants),
- second : hash interrupt (required only for samsung,s5pv210-secss).
- clocks : list of clock phandle and specifier pairs for all clocks listed in - clocks : list of clock phandle and specifier pairs for all clocks listed in
clock-names property. clock-names property.
......
Hisilicon Random Number Generator
Required properties:
- compatible : Should be "hisilicon,hip04-rng" or "hisilicon,hip05-rng"
- reg : Offset and length of the register set of this block
Example:
rng@d1010000 {
compatible = "hisilicon,hip05-rng";
reg = <0xd1010000 0x100>;
};
...@@ -838,6 +838,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -838,6 +838,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
It will be ignored when crashkernel=X,high is not used It will be ignored when crashkernel=X,high is not used
or memory reserved is below 4G. or memory reserved is below 4G.
cryptomgr.notests
[KNL] Disable crypto self-tests
cs89x0_dma= [HW,NET] cs89x0_dma= [HW,NET]
Format: <dma> Format: <dma>
......
...@@ -627,6 +627,7 @@ F: include/linux/altera_jtaguart.h ...@@ -627,6 +627,7 @@ F: include/linux/altera_jtaguart.h
AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER
M: Tom Lendacky <thomas.lendacky@amd.com> M: Tom Lendacky <thomas.lendacky@amd.com>
M: Gary Hook <gary.hook@amd.com>
L: linux-crypto@vger.kernel.org L: linux-crypto@vger.kernel.org
S: Supported S: Supported
F: drivers/crypto/ccp/ F: drivers/crypto/ccp/
......
...@@ -420,6 +420,15 @@ pwm3: pwm@53fa8000 { ...@@ -420,6 +420,15 @@ pwm3: pwm@53fa8000 {
interrupts = <41>; interrupts = <41>;
}; };
scc: crypto@53fac000 {
compatible = "fsl,imx25-scc";
reg = <0x53fac000 0x4000>;
clocks = <&clks 111>;
clock-names = "ipg";
interrupts = <49>, <50>;
interrupt-names = "scm", "smn";
};
esdhc1: esdhc@53fb4000 { esdhc1: esdhc@53fb4000 {
compatible = "fsl,imx25-esdhc"; compatible = "fsl,imx25-esdhc";
reg = <0x53fb4000 0x4000>; reg = <0x53fb4000 0x4000>;
......
This diff is collapsed.
...@@ -237,6 +237,7 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen, ...@@ -237,6 +237,7 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
break; break;
case OID_sha224: case OID_sha224:
ctx->sinfo->sig.hash_algo = "sha224"; ctx->sinfo->sig.hash_algo = "sha224";
break;
default: default:
printk("Unsupported digest algo: %u\n", ctx->last_oid); printk("Unsupported digest algo: %u\n", ctx->last_oid);
return -ENOPKG; return -ENOPKG;
......
...@@ -592,8 +592,10 @@ static const struct drbg_state_ops drbg_ctr_ops = { ...@@ -592,8 +592,10 @@ static const struct drbg_state_ops drbg_ctr_ops = {
******************************************************************/ ******************************************************************/
#if defined(CONFIG_CRYPTO_DRBG_HASH) || defined(CONFIG_CRYPTO_DRBG_HMAC) #if defined(CONFIG_CRYPTO_DRBG_HASH) || defined(CONFIG_CRYPTO_DRBG_HMAC)
static int drbg_kcapi_hash(struct drbg_state *drbg, const unsigned char *key, static int drbg_kcapi_hash(struct drbg_state *drbg, unsigned char *outval,
unsigned char *outval, const struct list_head *in); const struct list_head *in);
static void drbg_kcapi_hmacsetkey(struct drbg_state *drbg,
const unsigned char *key);
static int drbg_init_hash_kernel(struct drbg_state *drbg); static int drbg_init_hash_kernel(struct drbg_state *drbg);
static int drbg_fini_hash_kernel(struct drbg_state *drbg); static int drbg_fini_hash_kernel(struct drbg_state *drbg);
#endif /* (CONFIG_CRYPTO_DRBG_HASH || CONFIG_CRYPTO_DRBG_HMAC) */ #endif /* (CONFIG_CRYPTO_DRBG_HASH || CONFIG_CRYPTO_DRBG_HMAC) */
...@@ -619,9 +621,11 @@ static int drbg_hmac_update(struct drbg_state *drbg, struct list_head *seed, ...@@ -619,9 +621,11 @@ static int drbg_hmac_update(struct drbg_state *drbg, struct list_head *seed,
LIST_HEAD(seedlist); LIST_HEAD(seedlist);
LIST_HEAD(vdatalist); LIST_HEAD(vdatalist);
if (!reseed) if (!reseed) {
/* 10.1.2.3 step 2 -- memset(0) of C is implicit with kzalloc */ /* 10.1.2.3 step 2 -- memset(0) of C is implicit with kzalloc */
memset(drbg->V, 1, drbg_statelen(drbg)); memset(drbg->V, 1, drbg_statelen(drbg));
drbg_kcapi_hmacsetkey(drbg, drbg->C);
}
drbg_string_fill(&seed1, drbg->V, drbg_statelen(drbg)); drbg_string_fill(&seed1, drbg->V, drbg_statelen(drbg));
list_add_tail(&seed1.list, &seedlist); list_add_tail(&seed1.list, &seedlist);
...@@ -641,12 +645,13 @@ static int drbg_hmac_update(struct drbg_state *drbg, struct list_head *seed, ...@@ -641,12 +645,13 @@ static int drbg_hmac_update(struct drbg_state *drbg, struct list_head *seed,
prefix = DRBG_PREFIX1; prefix = DRBG_PREFIX1;
/* 10.1.2.2 step 1 and 4 -- concatenation and HMAC for key */ /* 10.1.2.2 step 1 and 4 -- concatenation and HMAC for key */
seed2.buf = &prefix; seed2.buf = &prefix;
ret = drbg_kcapi_hash(drbg, drbg->C, drbg->C, &seedlist); ret = drbg_kcapi_hash(drbg, drbg->C, &seedlist);
if (ret) if (ret)
return ret; return ret;
drbg_kcapi_hmacsetkey(drbg, drbg->C);
/* 10.1.2.2 step 2 and 5 -- HMAC for V */ /* 10.1.2.2 step 2 and 5 -- HMAC for V */
ret = drbg_kcapi_hash(drbg, drbg->C, drbg->V, &vdatalist); ret = drbg_kcapi_hash(drbg, drbg->V, &vdatalist);
if (ret) if (ret)
return ret; return ret;
...@@ -681,7 +686,7 @@ static int drbg_hmac_generate(struct drbg_state *drbg, ...@@ -681,7 +686,7 @@ static int drbg_hmac_generate(struct drbg_state *drbg,
while (len < buflen) { while (len < buflen) {
unsigned int outlen = 0; unsigned int outlen = 0;
/* 10.1.2.5 step 4.1 */ /* 10.1.2.5 step 4.1 */
ret = drbg_kcapi_hash(drbg, drbg->C, drbg->V, &datalist); ret = drbg_kcapi_hash(drbg, drbg->V, &datalist);
if (ret) if (ret)
return ret; return ret;
outlen = (drbg_blocklen(drbg) < (buflen - len)) ? outlen = (drbg_blocklen(drbg) < (buflen - len)) ?
...@@ -796,7 +801,7 @@ static int drbg_hash_df(struct drbg_state *drbg, ...@@ -796,7 +801,7 @@ static int drbg_hash_df(struct drbg_state *drbg,
while (len < outlen) { while (len < outlen) {
short blocklen = 0; short blocklen = 0;
/* 10.4.1 step 4.1 */ /* 10.4.1 step 4.1 */
ret = drbg_kcapi_hash(drbg, NULL, tmp, entropylist); ret = drbg_kcapi_hash(drbg, tmp, entropylist);
if (ret) if (ret)
goto out; goto out;
/* 10.4.1 step 4.2 */ /* 10.4.1 step 4.2 */
...@@ -874,7 +879,7 @@ static int drbg_hash_process_addtl(struct drbg_state *drbg, ...@@ -874,7 +879,7 @@ static int drbg_hash_process_addtl(struct drbg_state *drbg,
list_add_tail(&data1.list, &datalist); list_add_tail(&data1.list, &datalist);
list_add_tail(&data2.list, &datalist); list_add_tail(&data2.list, &datalist);
list_splice_tail(addtl, &datalist); list_splice_tail(addtl, &datalist);
ret = drbg_kcapi_hash(drbg, NULL, drbg->scratchpad, &datalist); ret = drbg_kcapi_hash(drbg, drbg->scratchpad, &datalist);
if (ret) if (ret)
goto out; goto out;
...@@ -907,7 +912,7 @@ static int drbg_hash_hashgen(struct drbg_state *drbg, ...@@ -907,7 +912,7 @@ static int drbg_hash_hashgen(struct drbg_state *drbg,
while (len < buflen) { while (len < buflen) {
unsigned int outlen = 0; unsigned int outlen = 0;
/* 10.1.1.4 step hashgen 4.1 */ /* 10.1.1.4 step hashgen 4.1 */
ret = drbg_kcapi_hash(drbg, NULL, dst, &datalist); ret = drbg_kcapi_hash(drbg, dst, &datalist);
if (ret) { if (ret) {
len = ret; len = ret;
goto out; goto out;
...@@ -956,7 +961,7 @@ static int drbg_hash_generate(struct drbg_state *drbg, ...@@ -956,7 +961,7 @@ static int drbg_hash_generate(struct drbg_state *drbg,
list_add_tail(&data1.list, &datalist); list_add_tail(&data1.list, &datalist);
drbg_string_fill(&data2, drbg->V, drbg_statelen(drbg)); drbg_string_fill(&data2, drbg->V, drbg_statelen(drbg));
list_add_tail(&data2.list, &datalist); list_add_tail(&data2.list, &datalist);
ret = drbg_kcapi_hash(drbg, NULL, drbg->scratchpad, &datalist); ret = drbg_kcapi_hash(drbg, drbg->scratchpad, &datalist);
if (ret) { if (ret) {
len = ret; len = ret;
goto out; goto out;
...@@ -1600,14 +1605,20 @@ static int drbg_fini_hash_kernel(struct drbg_state *drbg) ...@@ -1600,14 +1605,20 @@ static int drbg_fini_hash_kernel(struct drbg_state *drbg)
return 0; return 0;
} }
static int drbg_kcapi_hash(struct drbg_state *drbg, const unsigned char *key, static void drbg_kcapi_hmacsetkey(struct drbg_state *drbg,
unsigned char *outval, const struct list_head *in) const unsigned char *key)
{ {
struct sdesc *sdesc = (struct sdesc *)drbg->priv_data; struct sdesc *sdesc = (struct sdesc *)drbg->priv_data;
struct drbg_string *input = NULL;
if (key)
crypto_shash_setkey(sdesc->shash.tfm, key, drbg_statelen(drbg)); crypto_shash_setkey(sdesc->shash.tfm, key, drbg_statelen(drbg));
}
static int drbg_kcapi_hash(struct drbg_state *drbg, unsigned char *outval,
const struct list_head *in)
{
struct sdesc *sdesc = (struct sdesc *)drbg->priv_data;
struct drbg_string *input = NULL;
crypto_shash_init(&sdesc->shash); crypto_shash_init(&sdesc->shash);
list_for_each_entry(input, in, list) list_for_each_entry(input, in, list)
crypto_shash_update(&sdesc->shash, input->buf, input->len); crypto_shash_update(&sdesc->shash, input->buf, input->len);
......
...@@ -32,7 +32,7 @@ static int lzo_init(struct crypto_tfm *tfm) ...@@ -32,7 +32,7 @@ static int lzo_init(struct crypto_tfm *tfm)
struct lzo_ctx *ctx = crypto_tfm_ctx(tfm); struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
ctx->lzo_comp_mem = kmalloc(LZO1X_MEM_COMPRESS, ctx->lzo_comp_mem = kmalloc(LZO1X_MEM_COMPRESS,
GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT); GFP_KERNEL | __GFP_NOWARN);
if (!ctx->lzo_comp_mem) if (!ctx->lzo_comp_mem)
ctx->lzo_comp_mem = vmalloc(LZO1X_MEM_COMPRESS); ctx->lzo_comp_mem = vmalloc(LZO1X_MEM_COMPRESS);
if (!ctx->lzo_comp_mem) if (!ctx->lzo_comp_mem)
......
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
#include "internal.h" #include "internal.h"
static bool notests;
module_param(notests, bool, 0644);
MODULE_PARM_DESC(notests, "disable crypto self-tests");
#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
/* a perfect nop */ /* a perfect nop */
...@@ -3885,6 +3889,11 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) ...@@ -3885,6 +3889,11 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
int j; int j;
int rc; int rc;
if (!fips_enabled && notests) {
printk_once(KERN_INFO "alg: self-tests disabled\n");
return 0;
}
alg_test_descs_check_order(); alg_test_descs_check_order();
if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
......
...@@ -268,19 +268,6 @@ config HW_RANDOM_NOMADIK ...@@ -268,19 +268,6 @@ config HW_RANDOM_NOMADIK
If unsure, say Y. If unsure, say Y.
config HW_RANDOM_PPC4XX
tristate "PowerPC 4xx generic true random number generator support"
depends on PPC && 4xx
default HW_RANDOM
---help---
This driver provides the kernel-side support for the TRNG hardware
found in the security function of some PowerPC 4xx SoCs.
To compile this driver as a module, choose M here: the
module will be called ppc4xx-rng.
If unsure, say N.
config HW_RANDOM_PSERIES config HW_RANDOM_PSERIES
tristate "pSeries HW Random Number Generator support" tristate "pSeries HW Random Number Generator support"
depends on PPC64 && IBMVIO depends on PPC64 && IBMVIO
...@@ -309,7 +296,8 @@ config HW_RANDOM_POWERNV ...@@ -309,7 +296,8 @@ config HW_RANDOM_POWERNV
config HW_RANDOM_EXYNOS config HW_RANDOM_EXYNOS
tristate "EXYNOS HW random number generator support" tristate "EXYNOS HW random number generator support"
depends on ARCH_EXYNOS depends on ARCH_EXYNOS || COMPILE_TEST
depends on HAS_IOMEM
default HW_RANDOM default HW_RANDOM
---help--- ---help---
This driver provides kernel-side support for the Random Number This driver provides kernel-side support for the Random Number
...@@ -333,6 +321,19 @@ config HW_RANDOM_TPM ...@@ -333,6 +321,19 @@ config HW_RANDOM_TPM
If unsure, say Y. If unsure, say Y.
config HW_RANDOM_HISI
tristate "Hisilicon Random Number Generator support"
depends on HW_RANDOM && ARCH_HISI
default HW_RANDOM
---help---
This driver provides kernel-side support for the Random Number
Generator hardware found on Hisilicon Hip04 and Hip05 SoC.
To compile this driver as a module, choose M here: the
module will be called hisi-rng.
If unsure, say Y.
config HW_RANDOM_MSM config HW_RANDOM_MSM
tristate "Qualcomm SoCs Random Number Generator support" tristate "Qualcomm SoCs Random Number Generator support"
depends on HW_RANDOM && ARCH_QCOM depends on HW_RANDOM && ARCH_QCOM
......
...@@ -22,10 +22,10 @@ obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o ...@@ -22,10 +22,10 @@ obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o
obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o
obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o
obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o
obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o
obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o
obj-$(CONFIG_HW_RANDOM_HISI) += hisi-rng.o
obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o
obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o
obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* exynos-rng.c - Random Number Generator driver for the exynos * exynos-rng.c - Random Number Generator driver for the exynos
* *
* Copyright (C) 2012 Samsung Electronics * Copyright (C) 2012 Samsung Electronics
* Jonghwa Lee <jonghwa3.lee@smasung.com> * Jonghwa Lee <jonghwa3.lee@samsung.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -77,7 +77,8 @@ static int exynos_init(struct hwrng *rng) ...@@ -77,7 +77,8 @@ static int exynos_init(struct hwrng *rng)
pm_runtime_get_sync(exynos_rng->dev); pm_runtime_get_sync(exynos_rng->dev);
ret = exynos_rng_configure(exynos_rng); ret = exynos_rng_configure(exynos_rng);
pm_runtime_put_noidle(exynos_rng->dev); pm_runtime_mark_last_busy(exynos_rng->dev);
pm_runtime_put_autosuspend(exynos_rng->dev);
return ret; return ret;
} }
...@@ -89,6 +90,7 @@ static int exynos_read(struct hwrng *rng, void *buf, ...@@ -89,6 +90,7 @@ static int exynos_read(struct hwrng *rng, void *buf,
struct exynos_rng, rng); struct exynos_rng, rng);
u32 *data = buf; u32 *data = buf;
int retry = 100; int retry = 100;
int ret = 4;
pm_runtime_get_sync(exynos_rng->dev); pm_runtime_get_sync(exynos_rng->dev);
...@@ -97,23 +99,27 @@ static int exynos_read(struct hwrng *rng, void *buf, ...@@ -97,23 +99,27 @@ static int exynos_read(struct hwrng *rng, void *buf,
while (!(exynos_rng_readl(exynos_rng, while (!(exynos_rng_readl(exynos_rng,
EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry) EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry)
cpu_relax(); cpu_relax();
if (!retry) if (!retry) {
return -ETIMEDOUT; ret = -ETIMEDOUT;
goto out;
}
exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET); exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET);
*data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET); *data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET);
out:
pm_runtime_mark_last_busy(exynos_rng->dev); pm_runtime_mark_last_busy(exynos_rng->dev);
pm_runtime_put_sync_autosuspend(exynos_rng->dev); pm_runtime_put_sync_autosuspend(exynos_rng->dev);
return 4; return ret;
} }
static int exynos_rng_probe(struct platform_device *pdev) static int exynos_rng_probe(struct platform_device *pdev)
{ {
struct exynos_rng *exynos_rng; struct exynos_rng *exynos_rng;
struct resource *res; struct resource *res;
int ret;
exynos_rng = devm_kzalloc(&pdev->dev, sizeof(struct exynos_rng), exynos_rng = devm_kzalloc(&pdev->dev, sizeof(struct exynos_rng),
GFP_KERNEL); GFP_KERNEL);
...@@ -141,7 +147,21 @@ static int exynos_rng_probe(struct platform_device *pdev) ...@@ -141,7 +147,21 @@ static int exynos_rng_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
return devm_hwrng_register(&pdev->dev, &exynos_rng->rng); ret = devm_hwrng_register(&pdev->dev, &exynos_rng->rng);
if (ret) {
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
return ret;
}
static int exynos_rng_remove(struct platform_device *pdev)
{
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
return 0;
} }
static int __maybe_unused exynos_rng_runtime_suspend(struct device *dev) static int __maybe_unused exynos_rng_runtime_suspend(struct device *dev)
...@@ -201,6 +221,7 @@ static struct platform_driver exynos_rng_driver = { ...@@ -201,6 +221,7 @@ static struct platform_driver exynos_rng_driver = {
.of_match_table = exynos_rng_dt_match, .of_match_table = exynos_rng_dt_match,
}, },
.probe = exynos_rng_probe, .probe = exynos_rng_probe,
.remove = exynos_rng_remove,
}; };
module_platform_driver(exynos_rng_driver); module_platform_driver(exynos_rng_driver);
......
/*
* Copyright (C) 2016 HiSilicon Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/hw_random.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/random.h>
#define RNG_SEED 0x0
#define RNG_CTRL 0x4
#define RNG_SEED_SEL BIT(2)
#define RNG_RING_EN BIT(1)
#define RNG_EN BIT(0)
#define RNG_RAN_NUM 0x10
#define RNG_PHY_SEED 0x14
#define to_hisi_rng(p) container_of(p, struct hisi_rng, rng)
static int seed_sel;
module_param(seed_sel, int, S_IRUGO);
MODULE_PARM_DESC(seed_sel, "Auto reload seed. 0, use LFSR(default); 1, use ring oscillator.");
struct hisi_rng {
void __iomem *base;
struct hwrng rng;
};
static int hisi_rng_init(struct hwrng *rng)
{
struct hisi_rng *hrng = to_hisi_rng(rng);
int val = RNG_EN;
u32 seed;
/* get a random number as initial seed */
get_random_bytes(&seed, sizeof(seed));
writel_relaxed(seed, hrng->base + RNG_SEED);
/**
* The seed is reload periodically, there are two choice
* of seeds, default seed using the value from LFSR, or
* will use seed generated by ring oscillator.
*/
if (seed_sel == 1)
val |= RNG_RING_EN | RNG_SEED_SEL;
writel_relaxed(val, hrng->base + RNG_CTRL);
return 0;
}
static void hisi_rng_cleanup(struct hwrng *rng)
{
struct hisi_rng *hrng = to_hisi_rng(rng);
writel_relaxed(0, hrng->base + RNG_CTRL);
}
static int hisi_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
{
struct hisi_rng *hrng = to_hisi_rng(rng);
u32 *data = buf;
*data = readl_relaxed(hrng->base + RNG_RAN_NUM);
return 4;
}
static int hisi_rng_probe(struct platform_device *pdev)
{
struct hisi_rng *rng;
struct resource *res;
int ret;
rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL);
if (!rng)
return -ENOMEM;
platform_set_drvdata(pdev, rng);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
rng->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(rng->base))
return PTR_ERR(rng->base);
rng->rng.name = pdev->name;
rng->rng.init = hisi_rng_init;
rng->rng.cleanup = hisi_rng_cleanup;
rng->rng.read = hisi_rng_read;
ret = devm_hwrng_register(&pdev->dev, &rng->rng);
if (ret) {
dev_err(&pdev->dev, "failed to register hwrng\n");
return ret;
}
return 0;
}
static const struct of_device_id hisi_rng_dt_ids[] = {
{ .compatible = "hisilicon,hip04-rng" },
{ .compatible = "hisilicon,hip05-rng" },
{ }
};
MODULE_DEVICE_TABLE(of, hisi_rng_dt_ids);
static struct platform_driver hisi_rng_driver = {
.probe = hisi_rng_probe,
.driver = {
.name = "hisi-rng",
.of_match_table = of_match_ptr(hisi_rng_dt_ids),
},
};
module_platform_driver(hisi_rng_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Kefeng Wang <wangkefeng.wang@huawei>");
MODULE_DESCRIPTION("Hisilicon random number generator driver");
/*
* Generic PowerPC 44x RNG driver
*
* Copyright 2011 IBM Corporation
*
* 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; version 2 of the License.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/hw_random.h>
#include <linux/delay.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <asm/io.h>
#define PPC4XX_TRNG_DEV_CTRL 0x60080
#define PPC4XX_TRNGE 0x00020000
#define PPC4XX_TRNG_CTRL 0x0008
#define PPC4XX_TRNG_CTRL_DALM 0x20
#define PPC4XX_TRNG_STAT 0x0004
#define PPC4XX_TRNG_STAT_B 0x1
#define PPC4XX_TRNG_DATA 0x0000
#define MODULE_NAME "ppc4xx_rng"
static int ppc4xx_rng_data_present(struct hwrng *rng, int wait)
{
void __iomem *rng_regs = (void __iomem *) rng->priv;
int busy, i, present = 0;
for (i = 0; i < 20; i++) {
busy = (in_le32(rng_regs + PPC4XX_TRNG_STAT) & PPC4XX_TRNG_STAT_B);
if (!busy || !wait) {
present = 1;
break;
}
udelay(10);
}
return present;
}
static int ppc4xx_rng_data_read(struct hwrng *rng, u32 *data)
{
void __iomem *rng_regs = (void __iomem *) rng->priv;
*data = in_le32(rng_regs + PPC4XX_TRNG_DATA);
return 4;
}
static int ppc4xx_rng_enable(int enable)
{
struct device_node *ctrl;
void __iomem *ctrl_reg;
int err = 0;
u32 val;
/* Find the main crypto device node and map it to turn the TRNG on */
ctrl = of_find_compatible_node(NULL, NULL, "amcc,ppc4xx-crypto");
if (!ctrl)
return -ENODEV;
ctrl_reg = of_iomap(ctrl, 0);
if (!ctrl_reg) {
err = -ENODEV;
goto out;
}
val = in_le32(ctrl_reg + PPC4XX_TRNG_DEV_CTRL);
if (enable)
val |= PPC4XX_TRNGE;
else
val = val & ~PPC4XX_TRNGE;
out_le32(ctrl_reg + PPC4XX_TRNG_DEV_CTRL, val);
iounmap(ctrl_reg);
out:
of_node_put(ctrl);
return err;
}
static struct hwrng ppc4xx_rng = {
.name = MODULE_NAME,
.data_present = ppc4xx_rng_data_present,
.data_read = ppc4xx_rng_data_read,
};
static int ppc4xx_rng_probe(struct platform_device *dev)
{
void __iomem *rng_regs;
int err = 0;
rng_regs = of_iomap(dev->dev.of_node, 0);
if (!rng_regs)
return -ENODEV;
err = ppc4xx_rng_enable(1);
if (err)
return err;
out_le32(rng_regs + PPC4XX_TRNG_CTRL, PPC4XX_TRNG_CTRL_DALM);
ppc4xx_rng.priv = (unsigned long) rng_regs;
err = hwrng_register(&ppc4xx_rng);
return err;
}
static int ppc4xx_rng_remove(struct platform_device *dev)
{
void __iomem *rng_regs = (void __iomem *) ppc4xx_rng.priv;
hwrng_unregister(&ppc4xx_rng);
ppc4xx_rng_enable(0);
iounmap(rng_regs);
return 0;
}
static const struct of_device_id ppc4xx_rng_match[] = {
{ .compatible = "ppc4xx-rng", },
{ .compatible = "amcc,ppc460ex-rng", },
{ .compatible = "amcc,ppc440epx-rng", },
{},
};
MODULE_DEVICE_TABLE(of, ppc4xx_rng_match);
static struct platform_driver ppc4xx_rng_driver = {
.driver = {
.name = MODULE_NAME,
.of_match_table = ppc4xx_rng_match,
},
.probe = ppc4xx_rng_probe,
.remove = ppc4xx_rng_remove,
};
module_platform_driver(ppc4xx_rng_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Josh Boyer <jwboyer@linux.vnet.ibm.com>");
MODULE_DESCRIPTION("HW RNG driver for PPC 4xx processors");
...@@ -279,6 +279,14 @@ config CRYPTO_DEV_PPC4XX ...@@ -279,6 +279,14 @@ config CRYPTO_DEV_PPC4XX
help help
This option allows you to have support for AMCC crypto acceleration. This option allows you to have support for AMCC crypto acceleration.
config HW_RANDOM_PPC4XX
bool "PowerPC 4xx generic true random number generator support"
depends on CRYPTO_DEV_PPC4XX && HW_RANDOM
default y
---help---
This option provides the kernel-side support for the TRNG hardware
found in the security function of some PowerPC 4xx SoCs.
config CRYPTO_DEV_OMAP_SHAM config CRYPTO_DEV_OMAP_SHAM
tristate "Support for OMAP MD5/SHA1/SHA2 hw accelerator" tristate "Support for OMAP MD5/SHA1/SHA2 hw accelerator"
depends on ARCH_OMAP2PLUS depends on ARCH_OMAP2PLUS
...@@ -302,15 +310,16 @@ config CRYPTO_DEV_OMAP_AES ...@@ -302,15 +310,16 @@ config CRYPTO_DEV_OMAP_AES
want to use the OMAP module for AES algorithms. want to use the OMAP module for AES algorithms.
config CRYPTO_DEV_OMAP_DES config CRYPTO_DEV_OMAP_DES
tristate "Support for OMAP DES3DES hw engine" tristate "Support for OMAP DES/3DES hw engine"
depends on ARCH_OMAP2PLUS depends on ARCH_OMAP2PLUS
select CRYPTO_DES select CRYPTO_DES
select CRYPTO_BLKCIPHER select CRYPTO_BLKCIPHER
select CRYPTO_ENGINE
help help
OMAP processors have DES/3DES module accelerator. Select this if you OMAP processors have DES/3DES module accelerator. Select this if you
want to use the OMAP module for DES and 3DES algorithms. Currently want to use the OMAP module for DES and 3DES algorithms. Currently
the ECB and CBC modes of operation supported by the driver. Also the ECB and CBC modes of operation are supported by the driver. Also
accesses made on unaligned boundaries are also supported. accesses made on unaligned boundaries are supported.
config CRYPTO_DEV_PICOXCELL config CRYPTO_DEV_PICOXCELL
tristate "Support for picoXcell IPSEC and Layer2 crypto engines" tristate "Support for picoXcell IPSEC and Layer2 crypto engines"
...@@ -340,9 +349,19 @@ config CRYPTO_DEV_SAHARA ...@@ -340,9 +349,19 @@ config CRYPTO_DEV_SAHARA
This option enables support for the SAHARA HW crypto accelerator This option enables support for the SAHARA HW crypto accelerator
found in some Freescale i.MX chips. found in some Freescale i.MX chips.
config CRYPTO_DEV_MXC_SCC
tristate "Support for Freescale Security Controller (SCC)"
depends on ARCH_MXC && OF
select CRYPTO_BLKCIPHER
select CRYPTO_DES
help
This option enables support for the Security Controller (SCC)
found in Freescale i.MX25 chips.
config CRYPTO_DEV_S5P config CRYPTO_DEV_S5P
tristate "Support for Samsung S5PV210/Exynos crypto accelerator" tristate "Support for Samsung S5PV210/Exynos crypto accelerator"
depends on ARCH_S5PV210 || ARCH_EXYNOS depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
depends on HAS_IOMEM && HAS_DMA
select CRYPTO_AES select CRYPTO_AES
select CRYPTO_BLKCIPHER select CRYPTO_BLKCIPHER
help help
......
...@@ -23,6 +23,7 @@ obj-$(CONFIG_CRYPTO_DEV_PICOXCELL) += picoxcell_crypto.o ...@@ -23,6 +23,7 @@ obj-$(CONFIG_CRYPTO_DEV_PICOXCELL) += picoxcell_crypto.o
obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/ obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o
obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o
obj-$(CONFIG_CRYPTO_DEV_MXC_SCC) += mxc-scc.o
obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
obj-$(CONFIG_CRYPTO_DEV_UX500) += ux500/ obj-$(CONFIG_CRYPTO_DEV_UX500) += ux500/
obj-$(CONFIG_CRYPTO_DEV_QAT) += qat/ obj-$(CONFIG_CRYPTO_DEV_QAT) += qat/
......
obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += crypto4xx.o obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += crypto4xx.o
crypto4xx-y := crypto4xx_core.o crypto4xx_alg.o crypto4xx_sa.o crypto4xx-y := crypto4xx_core.o crypto4xx_alg.o crypto4xx_sa.o
crypto4xx-$(CONFIG_HW_RANDOM_PPC4XX) += crypto4xx_trng.o
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "crypto4xx_reg_def.h" #include "crypto4xx_reg_def.h"
#include "crypto4xx_core.h" #include "crypto4xx_core.h"
#include "crypto4xx_sa.h" #include "crypto4xx_sa.h"
#include "crypto4xx_trng.h"
#define PPC4XX_SEC_VERSION_STR "0.5" #define PPC4XX_SEC_VERSION_STR "0.5"
...@@ -1225,6 +1226,7 @@ static int crypto4xx_probe(struct platform_device *ofdev) ...@@ -1225,6 +1226,7 @@ static int crypto4xx_probe(struct platform_device *ofdev)
if (rc) if (rc)
goto err_start_dev; goto err_start_dev;
ppc4xx_trng_probe(core_dev);
return 0; return 0;
err_start_dev: err_start_dev:
...@@ -1252,6 +1254,8 @@ static int crypto4xx_remove(struct platform_device *ofdev) ...@@ -1252,6 +1254,8 @@ static int crypto4xx_remove(struct platform_device *ofdev)
struct device *dev = &ofdev->dev; struct device *dev = &ofdev->dev;
struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev); struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev);
ppc4xx_trng_remove(core_dev);
free_irq(core_dev->irq, dev); free_irq(core_dev->irq, dev);
irq_dispose_mapping(core_dev->irq); irq_dispose_mapping(core_dev->irq);
...@@ -1272,7 +1276,7 @@ MODULE_DEVICE_TABLE(of, crypto4xx_match); ...@@ -1272,7 +1276,7 @@ MODULE_DEVICE_TABLE(of, crypto4xx_match);
static struct platform_driver crypto4xx_driver = { static struct platform_driver crypto4xx_driver = {
.driver = { .driver = {
.name = "crypto4xx", .name = MODULE_NAME,
.of_match_table = crypto4xx_match, .of_match_table = crypto4xx_match,
}, },
.probe = crypto4xx_probe, .probe = crypto4xx_probe,
...@@ -1284,4 +1288,3 @@ module_platform_driver(crypto4xx_driver); ...@@ -1284,4 +1288,3 @@ module_platform_driver(crypto4xx_driver);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("James Hsiao <jhsiao@amcc.com>"); MODULE_AUTHOR("James Hsiao <jhsiao@amcc.com>");
MODULE_DESCRIPTION("Driver for AMCC PPC4xx crypto accelerator"); MODULE_DESCRIPTION("Driver for AMCC PPC4xx crypto accelerator");
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <crypto/internal/hash.h> #include <crypto/internal/hash.h>
#define MODULE_NAME "crypto4xx"
#define PPC460SX_SDR0_SRST 0x201 #define PPC460SX_SDR0_SRST 0x201
#define PPC405EX_SDR0_SRST 0x200 #define PPC405EX_SDR0_SRST 0x200
#define PPC460EX_SDR0_SRST 0x201 #define PPC460EX_SDR0_SRST 0x201
...@@ -72,6 +74,7 @@ struct crypto4xx_device { ...@@ -72,6 +74,7 @@ struct crypto4xx_device {
char *name; char *name;
u64 ce_phy_address; u64 ce_phy_address;
void __iomem *ce_base; void __iomem *ce_base;
void __iomem *trng_base;
void *pdr; /* base address of packet void *pdr; /* base address of packet
descriptor ring */ descriptor ring */
...@@ -106,6 +109,7 @@ struct crypto4xx_core_device { ...@@ -106,6 +109,7 @@ struct crypto4xx_core_device {
struct device *device; struct device *device;
struct platform_device *ofdev; struct platform_device *ofdev;
struct crypto4xx_device *dev; struct crypto4xx_device *dev;
struct hwrng *trng;
u32 int_status; u32 int_status;
u32 irq; u32 irq;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
......
...@@ -125,6 +125,7 @@ ...@@ -125,6 +125,7 @@
#define PPC4XX_INTERRUPT_CLR 0x3ffff #define PPC4XX_INTERRUPT_CLR 0x3ffff
#define PPC4XX_PRNG_CTRL_AUTO_EN 0x3 #define PPC4XX_PRNG_CTRL_AUTO_EN 0x3
#define PPC4XX_DC_3DES_EN 1 #define PPC4XX_DC_3DES_EN 1
#define PPC4XX_TRNG_EN 0x00020000
#define PPC4XX_INT_DESCR_CNT 4 #define PPC4XX_INT_DESCR_CNT 4
#define PPC4XX_INT_TIMEOUT_CNT 0 #define PPC4XX_INT_TIMEOUT_CNT 0
#define PPC4XX_INT_CFG 1 #define PPC4XX_INT_CFG 1
......
/*
* Generic PowerPC 44x RNG driver
*
* Copyright 2011 IBM Corporation
*
* 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; version 2 of the License.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/hw_random.h>
#include <linux/delay.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/io.h>
#include "crypto4xx_core.h"
#include "crypto4xx_trng.h"
#include "crypto4xx_reg_def.h"
#define PPC4XX_TRNG_CTRL 0x0008
#define PPC4XX_TRNG_CTRL_DALM 0x20
#define PPC4XX_TRNG_STAT 0x0004
#define PPC4XX_TRNG_STAT_B 0x1
#define PPC4XX_TRNG_DATA 0x0000
static int ppc4xx_trng_data_present(struct hwrng *rng, int wait)
{
struct crypto4xx_device *dev = (void *)rng->priv;
int busy, i, present = 0;
for (i = 0; i < 20; i++) {
busy = (in_le32(dev->trng_base + PPC4XX_TRNG_STAT) &
PPC4XX_TRNG_STAT_B);
if (!busy || !wait) {
present = 1;
break;
}
udelay(10);
}
return present;
}
static int ppc4xx_trng_data_read(struct hwrng *rng, u32 *data)
{
struct crypto4xx_device *dev = (void *)rng->priv;
*data = in_le32(dev->trng_base + PPC4XX_TRNG_DATA);
return 4;
}
static void ppc4xx_trng_enable(struct crypto4xx_device *dev, bool enable)
{
u32 device_ctrl;
device_ctrl = readl(dev->ce_base + CRYPTO4XX_DEVICE_CTRL);
if (enable)
device_ctrl |= PPC4XX_TRNG_EN;
else
device_ctrl &= ~PPC4XX_TRNG_EN;
writel(device_ctrl, dev->ce_base + CRYPTO4XX_DEVICE_CTRL);
}
static const struct of_device_id ppc4xx_trng_match[] = {
{ .compatible = "ppc4xx-rng", },
{ .compatible = "amcc,ppc460ex-rng", },
{ .compatible = "amcc,ppc440epx-rng", },
{},
};
void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
{
struct crypto4xx_device *dev = core_dev->dev;
struct device_node *trng = NULL;
struct hwrng *rng = NULL;
int err;
/* Find the TRNG device node and map it */
trng = of_find_matching_node(NULL, ppc4xx_trng_match);
if (!trng || !of_device_is_available(trng))
return;
dev->trng_base = of_iomap(trng, 0);
of_node_put(trng);
if (!dev->trng_base)
goto err_out;
rng = kzalloc(sizeof(*rng), GFP_KERNEL);
if (!rng)
goto err_out;
rng->name = MODULE_NAME;
rng->data_present = ppc4xx_trng_data_present;
rng->data_read = ppc4xx_trng_data_read;
rng->priv = (unsigned long) dev;
core_dev->trng = rng;
ppc4xx_trng_enable(dev, true);
out_le32(dev->trng_base + PPC4XX_TRNG_CTRL, PPC4XX_TRNG_CTRL_DALM);
err = devm_hwrng_register(core_dev->device, core_dev->trng);
if (err) {
ppc4xx_trng_enable(dev, false);
dev_err(core_dev->device, "failed to register hwrng (%d).\n",
err);
goto err_out;
}
return;
err_out:
of_node_put(trng);
iounmap(dev->trng_base);
kfree(rng);
dev->trng_base = NULL;
core_dev->trng = NULL;
}
void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev)
{
if (core_dev && core_dev->trng) {
struct crypto4xx_device *dev = core_dev->dev;
devm_hwrng_unregister(core_dev->device, core_dev->trng);
ppc4xx_trng_enable(dev, false);
iounmap(dev->trng_base);
kfree(core_dev->trng);
}
}
MODULE_ALIAS("ppc4xx_rng");
/**
* AMCC SoC PPC4xx Crypto Driver
*
* Copyright (c) 2008 Applied Micro Circuits Corporation.
* All rights reserved. James Hsiao <jhsiao@amcc.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This file defines the security context
* associate format.
*/
#ifndef __CRYPTO4XX_TRNG_H__
#define __CRYPTO4XX_TRNG_H__
#ifdef CONFIG_HW_RANDOM_PPC4XX
void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev);
void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev);
#else
static inline void ppc4xx_trng_probe(
struct crypto4xx_device *dev __maybe_unused) { }
static inline void ppc4xx_trng_remove(
struct crypto4xx_device *dev __maybe_unused) { }
#endif
#endif
...@@ -248,7 +248,7 @@ static void caam_jr_dequeue(unsigned long devarg) ...@@ -248,7 +248,7 @@ static void caam_jr_dequeue(unsigned long devarg)
struct device *caam_jr_alloc(void) struct device *caam_jr_alloc(void)
{ {
struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL; struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL;
struct device *dev = NULL; struct device *dev = ERR_PTR(-ENODEV);
int min_tfm_cnt = INT_MAX; int min_tfm_cnt = INT_MAX;
int tfm_cnt; int tfm_cnt;
......
...@@ -3,6 +3,8 @@ config CRYPTO_DEV_CCP_DD ...@@ -3,6 +3,8 @@ config CRYPTO_DEV_CCP_DD
depends on CRYPTO_DEV_CCP depends on CRYPTO_DEV_CCP
default m default m
select HW_RANDOM select HW_RANDOM
select DMA_ENGINE
select DMADEVICES
select CRYPTO_SHA1 select CRYPTO_SHA1
select CRYPTO_SHA256 select CRYPTO_SHA256
help help
......
obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o
ccp-objs := ccp-dev.o ccp-ops.o ccp-dev-v3.o ccp-platform.o ccp-objs := ccp-dev.o \
ccp-ops.o \
ccp-dev-v3.o \
ccp-platform.o \
ccp-dmaengine.o
ccp-$(CONFIG_PCI) += ccp-pci.o ccp-$(CONFIG_PCI) += ccp-pci.o
obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
......
...@@ -406,6 +406,11 @@ static int ccp_init(struct ccp_device *ccp) ...@@ -406,6 +406,11 @@ static int ccp_init(struct ccp_device *ccp)
goto e_kthread; goto e_kthread;
} }
/* Register the DMA engine support */
ret = ccp_dmaengine_register(ccp);
if (ret)
goto e_hwrng;
ccp_add_device(ccp); ccp_add_device(ccp);
/* Enable interrupts */ /* Enable interrupts */
...@@ -413,6 +418,9 @@ static int ccp_init(struct ccp_device *ccp) ...@@ -413,6 +418,9 @@ static int ccp_init(struct ccp_device *ccp)
return 0; return 0;
e_hwrng:
hwrng_unregister(&ccp->hwrng);
e_kthread: e_kthread:
for (i = 0; i < ccp->cmd_q_count; i++) for (i = 0; i < ccp->cmd_q_count; i++)
if (ccp->cmd_q[i].kthread) if (ccp->cmd_q[i].kthread)
...@@ -436,6 +444,9 @@ static void ccp_destroy(struct ccp_device *ccp) ...@@ -436,6 +444,9 @@ static void ccp_destroy(struct ccp_device *ccp)
/* Remove this device from the list of available units first */ /* Remove this device from the list of available units first */
ccp_del_device(ccp); ccp_del_device(ccp);
/* Unregister the DMA engine */
ccp_dmaengine_unregister(ccp);
/* Unregister the RNG */ /* Unregister the RNG */
hwrng_unregister(&ccp->hwrng); hwrng_unregister(&ccp->hwrng);
...@@ -515,7 +526,7 @@ static irqreturn_t ccp_irq_handler(int irq, void *data) ...@@ -515,7 +526,7 @@ static irqreturn_t ccp_irq_handler(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static struct ccp_actions ccp3_actions = { static const struct ccp_actions ccp3_actions = {
.perform_aes = ccp_perform_aes, .perform_aes = ccp_perform_aes,
.perform_xts_aes = ccp_perform_xts_aes, .perform_xts_aes = ccp_perform_xts_aes,
.perform_sha = ccp_perform_sha, .perform_sha = ccp_perform_sha,
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/rwlock_types.h> #include <linux/spinlock_types.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/delay.h> #include <linux/delay.h>
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/hw_random.h> #include <linux/hw_random.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/interrupt.h>
#include <linux/irqreturn.h>
#include <linux/dmaengine.h>
#define MAX_CCP_NAME_LEN 16 #define MAX_CCP_NAME_LEN 16
#define MAX_DMAPOOL_NAME_LEN 32 #define MAX_DMAPOOL_NAME_LEN 32
...@@ -159,7 +162,7 @@ struct ccp_actions { ...@@ -159,7 +162,7 @@ struct ccp_actions {
/* Structure to hold CCP version-specific values */ /* Structure to hold CCP version-specific values */
struct ccp_vdata { struct ccp_vdata {
unsigned int version; unsigned int version;
struct ccp_actions *perform; const struct ccp_actions *perform;
}; };
extern struct ccp_vdata ccpv3; extern struct ccp_vdata ccpv3;
...@@ -167,6 +170,39 @@ extern struct ccp_vdata ccpv3; ...@@ -167,6 +170,39 @@ extern struct ccp_vdata ccpv3;
struct ccp_device; struct ccp_device;
struct ccp_cmd; struct ccp_cmd;
struct ccp_dma_cmd {
struct list_head entry;
struct ccp_cmd ccp_cmd;
};
struct ccp_dma_desc {
struct list_head entry;
struct ccp_device *ccp;
struct list_head pending;
struct list_head active;
enum dma_status status;
struct dma_async_tx_descriptor tx_desc;
size_t len;
};
struct ccp_dma_chan {
struct ccp_device *ccp;
spinlock_t lock;
struct list_head pending;
struct list_head active;
struct list_head complete;
struct tasklet_struct cleanup_tasklet;
enum dma_status status;
struct dma_chan dma_chan;
};
struct ccp_cmd_queue { struct ccp_cmd_queue {
struct ccp_device *ccp; struct ccp_device *ccp;
...@@ -260,6 +296,14 @@ struct ccp_device { ...@@ -260,6 +296,14 @@ struct ccp_device {
struct hwrng hwrng; struct hwrng hwrng;
unsigned int hwrng_retries; unsigned int hwrng_retries;
/*
* Support for the CCP DMA capabilities
*/
struct dma_device dma_dev;
struct ccp_dma_chan *ccp_dma_chan;
struct kmem_cache *dma_cmd_cache;
struct kmem_cache *dma_desc_cache;
/* /*
* A counter used to generate job-ids for cmds submitted to the CCP * A counter used to generate job-ids for cmds submitted to the CCP
*/ */
...@@ -418,4 +462,7 @@ int ccp_cmd_queue_thread(void *data); ...@@ -418,4 +462,7 @@ int ccp_cmd_queue_thread(void *data);
int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd); int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd);
int ccp_dmaengine_register(struct ccp_device *ccp);
void ccp_dmaengine_unregister(struct ccp_device *ccp);
#endif #endif
This diff is collapsed.
...@@ -1427,6 +1427,70 @@ static int ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, ...@@ -1427,6 +1427,70 @@ static int ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q,
return ret; return ret;
} }
static int ccp_run_passthru_nomap_cmd(struct ccp_cmd_queue *cmd_q,
struct ccp_cmd *cmd)
{
struct ccp_passthru_nomap_engine *pt = &cmd->u.passthru_nomap;
struct ccp_dm_workarea mask;
struct ccp_op op;
int ret;
if (!pt->final && (pt->src_len & (CCP_PASSTHRU_BLOCKSIZE - 1)))
return -EINVAL;
if (!pt->src_dma || !pt->dst_dma)
return -EINVAL;
if (pt->bit_mod != CCP_PASSTHRU_BITWISE_NOOP) {
if (pt->mask_len != CCP_PASSTHRU_MASKSIZE)
return -EINVAL;
if (!pt->mask)
return -EINVAL;
}
BUILD_BUG_ON(CCP_PASSTHRU_KSB_COUNT != 1);
memset(&op, 0, sizeof(op));
op.cmd_q = cmd_q;
op.jobid = ccp_gen_jobid(cmd_q->ccp);
if (pt->bit_mod != CCP_PASSTHRU_BITWISE_NOOP) {
/* Load the mask */
op.ksb_key = cmd_q->ksb_key;
mask.length = pt->mask_len;
mask.dma.address = pt->mask;
mask.dma.length = pt->mask_len;
ret = ccp_copy_to_ksb(cmd_q, &mask, op.jobid, op.ksb_key,
CCP_PASSTHRU_BYTESWAP_NOOP);
if (ret) {
cmd->engine_error = cmd_q->cmd_error;
return ret;
}
}
/* Send data to the CCP Passthru engine */
op.eom = 1;
op.soc = 1;
op.src.type = CCP_MEMTYPE_SYSTEM;
op.src.u.dma.address = pt->src_dma;
op.src.u.dma.offset = 0;
op.src.u.dma.length = pt->src_len;
op.dst.type = CCP_MEMTYPE_SYSTEM;
op.dst.u.dma.address = pt->dst_dma;
op.dst.u.dma.offset = 0;
op.dst.u.dma.length = pt->src_len;
ret = cmd_q->ccp->vdata->perform->perform_passthru(&op);
if (ret)
cmd->engine_error = cmd_q->cmd_error;
return ret;
}
static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
{ {
struct ccp_ecc_engine *ecc = &cmd->u.ecc; struct ccp_ecc_engine *ecc = &cmd->u.ecc;
...@@ -1762,6 +1826,9 @@ int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ...@@ -1762,6 +1826,9 @@ int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
ret = ccp_run_rsa_cmd(cmd_q, cmd); ret = ccp_run_rsa_cmd(cmd_q, cmd);
break; break;
case CCP_ENGINE_PASSTHRU: case CCP_ENGINE_PASSTHRU:
if (cmd->flags & CCP_CMD_PASSTHRU_NO_DMA_MAP)
ret = ccp_run_passthru_nomap_cmd(cmd_q, cmd);
else
ret = ccp_run_passthru_cmd(cmd_q, cmd); ret = ccp_run_passthru_cmd(cmd_q, cmd);
break; break;
case CCP_ENGINE_ECC: case CCP_ENGINE_ECC:
......
...@@ -475,18 +475,18 @@ static int mv_cesa_probe(struct platform_device *pdev) ...@@ -475,18 +475,18 @@ static int mv_cesa_probe(struct platform_device *pdev)
engine->regs = cesa->regs + CESA_ENGINE_OFF(i); engine->regs = cesa->regs + CESA_ENGINE_OFF(i);
if (dram && cesa->caps->has_tdma) if (dram && cesa->caps->has_tdma)
mv_cesa_conf_mbus_windows(&cesa->engines[i], dram); mv_cesa_conf_mbus_windows(engine, dram);
writel(0, cesa->engines[i].regs + CESA_SA_INT_STATUS); writel(0, engine->regs + CESA_SA_INT_STATUS);
writel(CESA_SA_CFG_STOP_DIG_ERR, writel(CESA_SA_CFG_STOP_DIG_ERR,
cesa->engines[i].regs + CESA_SA_CFG); engine->regs + CESA_SA_CFG);
writel(engine->sram_dma & CESA_SA_SRAM_MSK, writel(engine->sram_dma & CESA_SA_SRAM_MSK,
cesa->engines[i].regs + CESA_SA_DESC_P0); engine->regs + CESA_SA_DESC_P0);
ret = devm_request_threaded_irq(dev, irq, NULL, mv_cesa_int, ret = devm_request_threaded_irq(dev, irq, NULL, mv_cesa_int,
IRQF_ONESHOT, IRQF_ONESHOT,
dev_name(&pdev->dev), dev_name(&pdev->dev),
&cesa->engines[i]); engine);
if (ret) if (ret)
goto err_cleanup; goto err_cleanup;
} }
......
...@@ -768,7 +768,6 @@ static int mv_cesa_ahash_export(struct ahash_request *req, void *hash, ...@@ -768,7 +768,6 @@ static int mv_cesa_ahash_export(struct ahash_request *req, void *hash,
*len = creq->len; *len = creq->len;
memcpy(hash, creq->state, digsize); memcpy(hash, creq->state, digsize);
memset(cache, 0, blocksize); memset(cache, 0, blocksize);
if (creq->cache)
memcpy(cache, creq->cache, creq->cache_ptr); memcpy(cache, creq->cache, creq->cache_ptr);
return 0; return 0;
......
...@@ -99,12 +99,11 @@ mv_cesa_dma_add_desc(struct mv_cesa_tdma_chain *chain, gfp_t flags) ...@@ -99,12 +99,11 @@ mv_cesa_dma_add_desc(struct mv_cesa_tdma_chain *chain, gfp_t flags)
struct mv_cesa_tdma_desc *new_tdma = NULL; struct mv_cesa_tdma_desc *new_tdma = NULL;
dma_addr_t dma_handle; dma_addr_t dma_handle;
new_tdma = dma_pool_alloc(cesa_dev->dma->tdma_desc_pool, flags, new_tdma = dma_pool_zalloc(cesa_dev->dma->tdma_desc_pool, flags,
&dma_handle); &dma_handle);
if (!new_tdma) if (!new_tdma)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
memset(new_tdma, 0, sizeof(*new_tdma));
new_tdma->cur_dma = dma_handle; new_tdma->cur_dma = dma_handle;
if (chain->last) { if (chain->last) {
chain->last->next_dma = cpu_to_le32(dma_handle); chain->last->next_dma = cpu_to_le32(dma_handle);
......
This diff is collapsed.
...@@ -1598,7 +1598,7 @@ static void *new_queue(unsigned long q_type) ...@@ -1598,7 +1598,7 @@ static void *new_queue(unsigned long q_type)
static void free_queue(void *p, unsigned long q_type) static void free_queue(void *p, unsigned long q_type)
{ {
return kmem_cache_free(queue_cache[q_type - 1], p); kmem_cache_free(queue_cache[q_type - 1], p);
} }
static int queue_cache_init(void) static int queue_cache_init(void)
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/omap-dma.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -176,9 +175,7 @@ struct omap_aes_dev { ...@@ -176,9 +175,7 @@ struct omap_aes_dev {
struct scatter_walk in_walk; struct scatter_walk in_walk;
struct scatter_walk out_walk; struct scatter_walk out_walk;
int dma_in;
struct dma_chan *dma_lch_in; struct dma_chan *dma_lch_in;
int dma_out;
struct dma_chan *dma_lch_out; struct dma_chan *dma_lch_out;
int in_sg_len; int in_sg_len;
int out_sg_len; int out_sg_len;
...@@ -351,30 +348,21 @@ static void omap_aes_dma_out_callback(void *data) ...@@ -351,30 +348,21 @@ static void omap_aes_dma_out_callback(void *data)
static int omap_aes_dma_init(struct omap_aes_dev *dd) static int omap_aes_dma_init(struct omap_aes_dev *dd)
{ {
int err = -ENOMEM; int err;
dma_cap_mask_t mask;
dd->dma_lch_out = NULL; dd->dma_lch_out = NULL;
dd->dma_lch_in = NULL; dd->dma_lch_in = NULL;
dma_cap_zero(mask); dd->dma_lch_in = dma_request_chan(dd->dev, "rx");
dma_cap_set(DMA_SLAVE, mask); if (IS_ERR(dd->dma_lch_in)) {
dd->dma_lch_in = dma_request_slave_channel_compat(mask,
omap_dma_filter_fn,
&dd->dma_in,
dd->dev, "rx");
if (!dd->dma_lch_in) {
dev_err(dd->dev, "Unable to request in DMA channel\n"); dev_err(dd->dev, "Unable to request in DMA channel\n");
goto err_dma_in; return PTR_ERR(dd->dma_lch_in);
} }
dd->dma_lch_out = dma_request_slave_channel_compat(mask, dd->dma_lch_out = dma_request_chan(dd->dev, "tx");
omap_dma_filter_fn, if (IS_ERR(dd->dma_lch_out)) {
&dd->dma_out,
dd->dev, "tx");
if (!dd->dma_lch_out) {
dev_err(dd->dev, "Unable to request out DMA channel\n"); dev_err(dd->dev, "Unable to request out DMA channel\n");
err = PTR_ERR(dd->dma_lch_out);
goto err_dma_out; goto err_dma_out;
} }
...@@ -382,14 +370,15 @@ static int omap_aes_dma_init(struct omap_aes_dev *dd) ...@@ -382,14 +370,15 @@ static int omap_aes_dma_init(struct omap_aes_dev *dd)
err_dma_out: err_dma_out:
dma_release_channel(dd->dma_lch_in); dma_release_channel(dd->dma_lch_in);
err_dma_in:
if (err)
pr_err("error: %d\n", err);
return err; return err;
} }
static void omap_aes_dma_cleanup(struct omap_aes_dev *dd) static void omap_aes_dma_cleanup(struct omap_aes_dev *dd)
{ {
if (dd->pio_only)
return;
dma_release_channel(dd->dma_lch_out); dma_release_channel(dd->dma_lch_out);
dma_release_channel(dd->dma_lch_in); dma_release_channel(dd->dma_lch_in);
} }
...@@ -1080,9 +1069,6 @@ static int omap_aes_get_res_of(struct omap_aes_dev *dd, ...@@ -1080,9 +1069,6 @@ static int omap_aes_get_res_of(struct omap_aes_dev *dd,
goto err; goto err;
} }
dd->dma_out = -1; /* Dummy value that's unused */
dd->dma_in = -1; /* Dummy value that's unused */
dd->pdata = match->data; dd->pdata = match->data;
err: err:
...@@ -1116,24 +1102,6 @@ static int omap_aes_get_res_pdev(struct omap_aes_dev *dd, ...@@ -1116,24 +1102,6 @@ static int omap_aes_get_res_pdev(struct omap_aes_dev *dd,
} }
memcpy(res, r, sizeof(*res)); memcpy(res, r, sizeof(*res));
/* Get the DMA out channel */
r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
if (!r) {
dev_err(dev, "no DMA out resource info\n");
err = -ENODEV;
goto err;
}
dd->dma_out = r->start;
/* Get the DMA in channel */
r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
if (!r) {
dev_err(dev, "no DMA in resource info\n");
err = -ENODEV;
goto err;
}
dd->dma_in = r->start;
/* Only OMAP2/3 can be non-DT */ /* Only OMAP2/3 can be non-DT */
dd->pdata = &omap_aes_pdata_omap2; dd->pdata = &omap_aes_pdata_omap2;
...@@ -1191,7 +1159,9 @@ static int omap_aes_probe(struct platform_device *pdev) ...@@ -1191,7 +1159,9 @@ static int omap_aes_probe(struct platform_device *pdev)
tasklet_init(&dd->done_task, omap_aes_done_task, (unsigned long)dd); tasklet_init(&dd->done_task, omap_aes_done_task, (unsigned long)dd);
err = omap_aes_dma_init(dd); err = omap_aes_dma_init(dd);
if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) { if (err == -EPROBE_DEFER) {
goto err_irq;
} else if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) {
dd->pio_only = 1; dd->pio_only = 1;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
...@@ -1248,7 +1218,7 @@ static int omap_aes_probe(struct platform_device *pdev) ...@@ -1248,7 +1218,7 @@ static int omap_aes_probe(struct platform_device *pdev)
for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
crypto_unregister_alg( crypto_unregister_alg(
&dd->pdata->algs_info[i].algs_list[j]); &dd->pdata->algs_info[i].algs_list[j]);
if (!dd->pio_only)
omap_aes_dma_cleanup(dd); omap_aes_dma_cleanup(dd);
err_irq: err_irq:
tasklet_kill(&dd->done_task); tasklet_kill(&dd->done_task);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/omap-dma.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -39,6 +38,7 @@ ...@@ -39,6 +38,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <crypto/des.h> #include <crypto/des.h>
#include <crypto/algapi.h>
#define DST_MAXBURST 2 #define DST_MAXBURST 2
...@@ -132,14 +132,10 @@ struct omap_des_dev { ...@@ -132,14 +132,10 @@ struct omap_des_dev {
unsigned long flags; unsigned long flags;
int err; int err;
/* spinlock used for queues */
spinlock_t lock;
struct crypto_queue queue;
struct tasklet_struct done_task; struct tasklet_struct done_task;
struct tasklet_struct queue_task;
struct ablkcipher_request *req; struct ablkcipher_request *req;
struct crypto_engine *engine;
/* /*
* total is used by PIO mode for book keeping so introduce * total is used by PIO mode for book keeping so introduce
* variable total_save as need it to calc page_order * variable total_save as need it to calc page_order
...@@ -158,9 +154,7 @@ struct omap_des_dev { ...@@ -158,9 +154,7 @@ struct omap_des_dev {
struct scatter_walk in_walk; struct scatter_walk in_walk;
struct scatter_walk out_walk; struct scatter_walk out_walk;
int dma_in;
struct dma_chan *dma_lch_in; struct dma_chan *dma_lch_in;
int dma_out;
struct dma_chan *dma_lch_out; struct dma_chan *dma_lch_out;
int in_sg_len; int in_sg_len;
int out_sg_len; int out_sg_len;
...@@ -340,30 +334,21 @@ static void omap_des_dma_out_callback(void *data) ...@@ -340,30 +334,21 @@ static void omap_des_dma_out_callback(void *data)
static int omap_des_dma_init(struct omap_des_dev *dd) static int omap_des_dma_init(struct omap_des_dev *dd)
{ {
int err = -ENOMEM; int err;
dma_cap_mask_t mask;
dd->dma_lch_out = NULL; dd->dma_lch_out = NULL;
dd->dma_lch_in = NULL; dd->dma_lch_in = NULL;
dma_cap_zero(mask); dd->dma_lch_in = dma_request_chan(dd->dev, "rx");
dma_cap_set(DMA_SLAVE, mask); if (IS_ERR(dd->dma_lch_in)) {
dd->dma_lch_in = dma_request_slave_channel_compat(mask,
omap_dma_filter_fn,
&dd->dma_in,
dd->dev, "rx");
if (!dd->dma_lch_in) {
dev_err(dd->dev, "Unable to request in DMA channel\n"); dev_err(dd->dev, "Unable to request in DMA channel\n");
goto err_dma_in; return PTR_ERR(dd->dma_lch_in);
} }
dd->dma_lch_out = dma_request_slave_channel_compat(mask, dd->dma_lch_out = dma_request_chan(dd->dev, "tx");
omap_dma_filter_fn, if (IS_ERR(dd->dma_lch_out)) {
&dd->dma_out,
dd->dev, "tx");
if (!dd->dma_lch_out) {
dev_err(dd->dev, "Unable to request out DMA channel\n"); dev_err(dd->dev, "Unable to request out DMA channel\n");
err = PTR_ERR(dd->dma_lch_out);
goto err_dma_out; goto err_dma_out;
} }
...@@ -371,14 +356,15 @@ static int omap_des_dma_init(struct omap_des_dev *dd) ...@@ -371,14 +356,15 @@ static int omap_des_dma_init(struct omap_des_dev *dd)
err_dma_out: err_dma_out:
dma_release_channel(dd->dma_lch_in); dma_release_channel(dd->dma_lch_in);
err_dma_in:
if (err)
pr_err("error: %d\n", err);
return err; return err;
} }
static void omap_des_dma_cleanup(struct omap_des_dev *dd) static void omap_des_dma_cleanup(struct omap_des_dev *dd)
{ {
if (dd->pio_only)
return;
dma_release_channel(dd->dma_lch_out); dma_release_channel(dd->dma_lch_out);
dma_release_channel(dd->dma_lch_in); dma_release_channel(dd->dma_lch_in);
} }
...@@ -520,9 +506,7 @@ static void omap_des_finish_req(struct omap_des_dev *dd, int err) ...@@ -520,9 +506,7 @@ static void omap_des_finish_req(struct omap_des_dev *dd, int err)
pr_debug("err: %d\n", err); pr_debug("err: %d\n", err);
pm_runtime_put(dd->dev); pm_runtime_put(dd->dev);
dd->flags &= ~FLAGS_BUSY; crypto_finalize_request(dd->engine, req, err);
req->base.complete(&req->base, err);
} }
static int omap_des_crypt_dma_stop(struct omap_des_dev *dd) static int omap_des_crypt_dma_stop(struct omap_des_dev *dd)
...@@ -587,32 +571,22 @@ static int omap_des_copy_sgs(struct omap_des_dev *dd) ...@@ -587,32 +571,22 @@ static int omap_des_copy_sgs(struct omap_des_dev *dd)
static int omap_des_handle_queue(struct omap_des_dev *dd, static int omap_des_handle_queue(struct omap_des_dev *dd,
struct ablkcipher_request *req) struct ablkcipher_request *req)
{ {
struct crypto_async_request *async_req, *backlog;
struct omap_des_ctx *ctx;
struct omap_des_reqctx *rctx;
unsigned long flags;
int err, ret = 0;
spin_lock_irqsave(&dd->lock, flags);
if (req) if (req)
ret = ablkcipher_enqueue_request(&dd->queue, req); return crypto_transfer_request_to_engine(dd->engine, req);
if (dd->flags & FLAGS_BUSY) {
spin_unlock_irqrestore(&dd->lock, flags);
return ret;
}
backlog = crypto_get_backlog(&dd->queue);
async_req = crypto_dequeue_request(&dd->queue);
if (async_req)
dd->flags |= FLAGS_BUSY;
spin_unlock_irqrestore(&dd->lock, flags);
if (!async_req) return 0;
return ret; }
if (backlog) static int omap_des_prepare_req(struct crypto_engine *engine,
backlog->complete(backlog, -EINPROGRESS); struct ablkcipher_request *req)
{
struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(
crypto_ablkcipher_reqtfm(req));
struct omap_des_dev *dd = omap_des_find_dev(ctx);
struct omap_des_reqctx *rctx;
req = ablkcipher_request_cast(async_req); if (!dd)
return -ENODEV;
/* assign new request to device */ /* assign new request to device */
dd->req = req; dd->req = req;
...@@ -642,16 +616,20 @@ static int omap_des_handle_queue(struct omap_des_dev *dd, ...@@ -642,16 +616,20 @@ static int omap_des_handle_queue(struct omap_des_dev *dd,
dd->ctx = ctx; dd->ctx = ctx;
ctx->dd = dd; ctx->dd = dd;
err = omap_des_write_ctrl(dd); return omap_des_write_ctrl(dd);
if (!err) }
err = omap_des_crypt_dma_start(dd);
if (err) {
/* des_task will not finish it, so do it here */
omap_des_finish_req(dd, err);
tasklet_schedule(&dd->queue_task);
}
return ret; /* return ret, which is enqueue return value */ static int omap_des_crypt_req(struct crypto_engine *engine,
struct ablkcipher_request *req)
{
struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(
crypto_ablkcipher_reqtfm(req));
struct omap_des_dev *dd = omap_des_find_dev(ctx);
if (!dd)
return -ENODEV;
return omap_des_crypt_dma_start(dd);
} }
static void omap_des_done_task(unsigned long data) static void omap_des_done_task(unsigned long data)
...@@ -683,18 +661,10 @@ static void omap_des_done_task(unsigned long data) ...@@ -683,18 +661,10 @@ static void omap_des_done_task(unsigned long data)
} }
omap_des_finish_req(dd, 0); omap_des_finish_req(dd, 0);
omap_des_handle_queue(dd, NULL);
pr_debug("exit\n"); pr_debug("exit\n");
} }
static void omap_des_queue_task(unsigned long data)
{
struct omap_des_dev *dd = (struct omap_des_dev *)data;
omap_des_handle_queue(dd, NULL);
}
static int omap_des_crypt(struct ablkcipher_request *req, unsigned long mode) static int omap_des_crypt(struct ablkcipher_request *req, unsigned long mode)
{ {
struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(
...@@ -999,8 +969,6 @@ static int omap_des_get_of(struct omap_des_dev *dd, ...@@ -999,8 +969,6 @@ static int omap_des_get_of(struct omap_des_dev *dd,
return -EINVAL; return -EINVAL;
} }
dd->dma_out = -1; /* Dummy value that's unused */
dd->dma_in = -1; /* Dummy value that's unused */
dd->pdata = match->data; dd->pdata = match->data;
return 0; return 0;
...@@ -1016,33 +984,10 @@ static int omap_des_get_of(struct omap_des_dev *dd, ...@@ -1016,33 +984,10 @@ static int omap_des_get_of(struct omap_des_dev *dd,
static int omap_des_get_pdev(struct omap_des_dev *dd, static int omap_des_get_pdev(struct omap_des_dev *dd,
struct platform_device *pdev) struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct resource *r;
int err = 0;
/* Get the DMA out channel */
r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
if (!r) {
dev_err(dev, "no DMA out resource info\n");
err = -ENODEV;
goto err;
}
dd->dma_out = r->start;
/* Get the DMA in channel */
r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
if (!r) {
dev_err(dev, "no DMA in resource info\n");
err = -ENODEV;
goto err;
}
dd->dma_in = r->start;
/* non-DT devices get pdata from pdev */ /* non-DT devices get pdata from pdev */
dd->pdata = pdev->dev.platform_data; dd->pdata = pdev->dev.platform_data;
err: return 0;
return err;
} }
static int omap_des_probe(struct platform_device *pdev) static int omap_des_probe(struct platform_device *pdev)
...@@ -1062,9 +1007,6 @@ static int omap_des_probe(struct platform_device *pdev) ...@@ -1062,9 +1007,6 @@ static int omap_des_probe(struct platform_device *pdev)
dd->dev = dev; dd->dev = dev;
platform_set_drvdata(pdev, dd); platform_set_drvdata(pdev, dd);
spin_lock_init(&dd->lock);
crypto_init_queue(&dd->queue, OMAP_DES_QUEUE_LENGTH);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(dev, "no MEM resource info\n"); dev_err(dev, "no MEM resource info\n");
...@@ -1103,10 +1045,11 @@ static int omap_des_probe(struct platform_device *pdev) ...@@ -1103,10 +1045,11 @@ static int omap_des_probe(struct platform_device *pdev)
(reg & dd->pdata->minor_mask) >> dd->pdata->minor_shift); (reg & dd->pdata->minor_mask) >> dd->pdata->minor_shift);
tasklet_init(&dd->done_task, omap_des_done_task, (unsigned long)dd); tasklet_init(&dd->done_task, omap_des_done_task, (unsigned long)dd);
tasklet_init(&dd->queue_task, omap_des_queue_task, (unsigned long)dd);
err = omap_des_dma_init(dd); err = omap_des_dma_init(dd);
if (err && DES_REG_IRQ_STATUS(dd) && DES_REG_IRQ_ENABLE(dd)) { if (err == -EPROBE_DEFER) {
goto err_irq;
} else if (err && DES_REG_IRQ_STATUS(dd) && DES_REG_IRQ_ENABLE(dd)) {
dd->pio_only = 1; dd->pio_only = 1;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
...@@ -1144,17 +1087,30 @@ static int omap_des_probe(struct platform_device *pdev) ...@@ -1144,17 +1087,30 @@ static int omap_des_probe(struct platform_device *pdev)
} }
} }
/* Initialize des crypto engine */
dd->engine = crypto_engine_alloc_init(dev, 1);
if (!dd->engine)
goto err_algs;
dd->engine->prepare_request = omap_des_prepare_req;
dd->engine->crypt_one_request = omap_des_crypt_req;
err = crypto_engine_start(dd->engine);
if (err)
goto err_engine;
return 0; return 0;
err_engine:
crypto_engine_exit(dd->engine);
err_algs: err_algs:
for (i = dd->pdata->algs_info_size - 1; i >= 0; i--) for (i = dd->pdata->algs_info_size - 1; i >= 0; i--)
for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
crypto_unregister_alg( crypto_unregister_alg(
&dd->pdata->algs_info[i].algs_list[j]); &dd->pdata->algs_info[i].algs_list[j]);
if (!dd->pio_only)
omap_des_dma_cleanup(dd); omap_des_dma_cleanup(dd);
err_irq: err_irq:
tasklet_kill(&dd->done_task); tasklet_kill(&dd->done_task);
tasklet_kill(&dd->queue_task);
err_get: err_get:
pm_runtime_disable(dev); pm_runtime_disable(dev);
err_res: err_res:
...@@ -1182,7 +1138,6 @@ static int omap_des_remove(struct platform_device *pdev) ...@@ -1182,7 +1138,6 @@ static int omap_des_remove(struct platform_device *pdev)
&dd->pdata->algs_info[i].algs_list[j]); &dd->pdata->algs_info[i].algs_list[j]);
tasklet_kill(&dd->done_task); tasklet_kill(&dd->done_task);
tasklet_kill(&dd->queue_task);
omap_des_dma_cleanup(dd); omap_des_dma_cleanup(dd);
pm_runtime_disable(dd->dev); pm_runtime_disable(dd->dev);
dd = NULL; dd = NULL;
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/omap-dma.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -219,7 +218,6 @@ struct omap_sham_dev { ...@@ -219,7 +218,6 @@ struct omap_sham_dev {
int irq; int irq;
spinlock_t lock; spinlock_t lock;
int err; int err;
unsigned int dma;
struct dma_chan *dma_lch; struct dma_chan *dma_lch;
struct tasklet_struct done_task; struct tasklet_struct done_task;
u8 polling_mode; u8 polling_mode;
...@@ -1842,7 +1840,6 @@ static int omap_sham_get_res_of(struct omap_sham_dev *dd, ...@@ -1842,7 +1840,6 @@ static int omap_sham_get_res_of(struct omap_sham_dev *dd,
goto err; goto err;
} }
dd->dma = -1; /* Dummy value that's unused */
dd->pdata = match->data; dd->pdata = match->data;
err: err:
...@@ -1884,15 +1881,6 @@ static int omap_sham_get_res_pdev(struct omap_sham_dev *dd, ...@@ -1884,15 +1881,6 @@ static int omap_sham_get_res_pdev(struct omap_sham_dev *dd,
goto err; goto err;
} }
/* Get the DMA */
r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
if (!r) {
dev_err(dev, "no DMA resource info\n");
err = -ENODEV;
goto err;
}
dd->dma = r->start;
/* Only OMAP2/3 can be non-DT */ /* Only OMAP2/3 can be non-DT */
dd->pdata = &omap_sham_pdata_omap2; dd->pdata = &omap_sham_pdata_omap2;
...@@ -1946,9 +1934,12 @@ static int omap_sham_probe(struct platform_device *pdev) ...@@ -1946,9 +1934,12 @@ static int omap_sham_probe(struct platform_device *pdev)
dma_cap_zero(mask); dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask); dma_cap_set(DMA_SLAVE, mask);
dd->dma_lch = dma_request_slave_channel_compat(mask, omap_dma_filter_fn, dd->dma_lch = dma_request_chan(dev, "rx");
&dd->dma, dev, "rx"); if (IS_ERR(dd->dma_lch)) {
if (!dd->dma_lch) { err = PTR_ERR(dd->dma_lch);
if (err == -EPROBE_DEFER)
goto data_err;
dd->polling_mode = 1; dd->polling_mode = 1;
dev_dbg(dev, "using polling mode instead of dma\n"); dev_dbg(dev, "using polling mode instead of dma\n");
} }
...@@ -1995,7 +1986,7 @@ static int omap_sham_probe(struct platform_device *pdev) ...@@ -1995,7 +1986,7 @@ static int omap_sham_probe(struct platform_device *pdev)
&dd->pdata->algs_info[i].algs_list[j]); &dd->pdata->algs_info[i].algs_list[j]);
err_pm: err_pm:
pm_runtime_disable(dev); pm_runtime_disable(dev);
if (dd->dma_lch) if (dd->polling_mode)
dma_release_channel(dd->dma_lch); dma_release_channel(dd->dma_lch);
data_err: data_err:
dev_err(dev, "initialization failed.\n"); dev_err(dev, "initialization failed.\n");
...@@ -2021,7 +2012,7 @@ static int omap_sham_remove(struct platform_device *pdev) ...@@ -2021,7 +2012,7 @@ static int omap_sham_remove(struct platform_device *pdev)
tasklet_kill(&dd->done_task); tasklet_kill(&dd->done_task);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (dd->dma_lch) if (!dd->polling_mode)
dma_release_channel(dd->dma_lch); dma_release_channel(dd->dma_lch);
return 0; return 0;
......
...@@ -300,9 +300,7 @@ static void adf_remove(struct pci_dev *pdev) ...@@ -300,9 +300,7 @@ static void adf_remove(struct pci_dev *pdev)
pr_err("QAT: Driver removal failed\n"); pr_err("QAT: Driver removal failed\n");
return; return;
} }
if (adf_dev_stop(accel_dev)) adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n");
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
adf_disable_aer(accel_dev); adf_disable_aer(accel_dev);
adf_cleanup_accel(accel_dev); adf_cleanup_accel(accel_dev);
......
...@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev) ...@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
{ {
} }
static int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0)) {
dev_err(&GET_DEV(accel_dev),
"Failed to send Init event to PF\n");
return -EFAULT;
}
return 0;
}
static void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0))
dev_err(&GET_DEV(accel_dev),
"Failed to send Shutdown event to PF\n");
}
void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data) void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
{ {
hw_data->dev_class = &c3xxxiov_class; hw_data->dev_class = &c3xxxiov_class;
......
...@@ -238,6 +238,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -238,6 +238,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto out_err_free_reg; goto out_err_free_reg;
set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
ret = adf_dev_init(accel_dev); ret = adf_dev_init(accel_dev);
if (ret) if (ret)
goto out_err_dev_shutdown; goto out_err_dev_shutdown;
...@@ -270,9 +272,7 @@ static void adf_remove(struct pci_dev *pdev) ...@@ -270,9 +272,7 @@ static void adf_remove(struct pci_dev *pdev)
pr_err("QAT: Driver removal failed\n"); pr_err("QAT: Driver removal failed\n");
return; return;
} }
if (adf_dev_stop(accel_dev)) adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n");
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
adf_cleanup_accel(accel_dev); adf_cleanup_accel(accel_dev);
adf_cleanup_pci_dev(accel_dev); adf_cleanup_pci_dev(accel_dev);
......
...@@ -300,9 +300,7 @@ static void adf_remove(struct pci_dev *pdev) ...@@ -300,9 +300,7 @@ static void adf_remove(struct pci_dev *pdev)
pr_err("QAT: Driver removal failed\n"); pr_err("QAT: Driver removal failed\n");
return; return;
} }
if (adf_dev_stop(accel_dev)) adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n");
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
adf_disable_aer(accel_dev); adf_disable_aer(accel_dev);
adf_cleanup_accel(accel_dev); adf_cleanup_accel(accel_dev);
......
...@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev) ...@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
{ {
} }
static int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0)) {
dev_err(&GET_DEV(accel_dev),
"Failed to send Init event to PF\n");
return -EFAULT;
}
return 0;
}
static void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0))
dev_err(&GET_DEV(accel_dev),
"Failed to send Shutdown event to PF\n");
}
void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data) void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)
{ {
hw_data->dev_class = &c62xiov_class; hw_data->dev_class = &c62xiov_class;
......
...@@ -238,6 +238,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -238,6 +238,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto out_err_free_reg; goto out_err_free_reg;
set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
ret = adf_dev_init(accel_dev); ret = adf_dev_init(accel_dev);
if (ret) if (ret)
goto out_err_dev_shutdown; goto out_err_dev_shutdown;
...@@ -270,9 +272,7 @@ static void adf_remove(struct pci_dev *pdev) ...@@ -270,9 +272,7 @@ static void adf_remove(struct pci_dev *pdev)
pr_err("QAT: Driver removal failed\n"); pr_err("QAT: Driver removal failed\n");
return; return;
} }
if (adf_dev_stop(accel_dev)) adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n");
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
adf_cleanup_accel(accel_dev); adf_cleanup_accel(accel_dev);
adf_cleanup_pci_dev(accel_dev); adf_cleanup_pci_dev(accel_dev);
......
...@@ -9,7 +9,6 @@ clean-files += qat_rsaprivkey-asn1.c qat_rsaprivkey-asn1.h ...@@ -9,7 +9,6 @@ clean-files += qat_rsaprivkey-asn1.c qat_rsaprivkey-asn1.h
obj-$(CONFIG_CRYPTO_DEV_QAT) += intel_qat.o obj-$(CONFIG_CRYPTO_DEV_QAT) += intel_qat.o
intel_qat-objs := adf_cfg.o \ intel_qat-objs := adf_cfg.o \
adf_isr.o \ adf_isr.o \
adf_vf_isr.o \
adf_ctl_drv.o \ adf_ctl_drv.o \
adf_dev_mgr.o \ adf_dev_mgr.o \
adf_init.o \ adf_init.o \
...@@ -27,4 +26,5 @@ intel_qat-objs := adf_cfg.o \ ...@@ -27,4 +26,5 @@ intel_qat-objs := adf_cfg.o \
qat_hal.o qat_hal.o
intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o intel_qat-$(CONFIG_DEBUG_FS) += adf_transport_debug.o
intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o intel_qat-$(CONFIG_PCI_IOV) += adf_sriov.o adf_pf2vf_msg.o \
adf_vf2pf_msg.o adf_vf_isr.o
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#define ADF_DH895XCC_MAILBOX_STRIDE 0x1000 #define ADF_DH895XCC_MAILBOX_STRIDE 0x1000
#define ADF_ADMINMSG_LEN 32 #define ADF_ADMINMSG_LEN 32
static const u8 const_tab[1024] = { static const u8 const_tab[1024] __aligned(1024) = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
......
...@@ -57,10 +57,8 @@ ...@@ -57,10 +57,8 @@
#define ADF_RING_DC_SIZE "NumConcurrentRequests" #define ADF_RING_DC_SIZE "NumConcurrentRequests"
#define ADF_RING_ASYM_TX "RingAsymTx" #define ADF_RING_ASYM_TX "RingAsymTx"
#define ADF_RING_SYM_TX "RingSymTx" #define ADF_RING_SYM_TX "RingSymTx"
#define ADF_RING_RND_TX "RingNrbgTx"
#define ADF_RING_ASYM_RX "RingAsymRx" #define ADF_RING_ASYM_RX "RingAsymRx"
#define ADF_RING_SYM_RX "RingSymRx" #define ADF_RING_SYM_RX "RingSymRx"
#define ADF_RING_RND_RX "RingNrbgRx"
#define ADF_RING_DC_TX "RingTx" #define ADF_RING_DC_TX "RingTx"
#define ADF_RING_DC_RX "RingRx" #define ADF_RING_DC_RX "RingRx"
#define ADF_ETRMGR_BANK "Bank" #define ADF_ETRMGR_BANK "Bank"
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
#define ADF_STATUS_AE_INITIALISED 4 #define ADF_STATUS_AE_INITIALISED 4
#define ADF_STATUS_AE_UCODE_LOADED 5 #define ADF_STATUS_AE_UCODE_LOADED 5
#define ADF_STATUS_AE_STARTED 6 #define ADF_STATUS_AE_STARTED 6
#define ADF_STATUS_ORPHAN_TH_RUNNING 7 #define ADF_STATUS_PF_RUNNING 7
#define ADF_STATUS_IRQ_ALLOCATED 8 #define ADF_STATUS_IRQ_ALLOCATED 8
enum adf_dev_reset_mode { enum adf_dev_reset_mode {
...@@ -103,7 +103,7 @@ int adf_service_unregister(struct service_hndl *service); ...@@ -103,7 +103,7 @@ int adf_service_unregister(struct service_hndl *service);
int adf_dev_init(struct adf_accel_dev *accel_dev); int adf_dev_init(struct adf_accel_dev *accel_dev);
int adf_dev_start(struct adf_accel_dev *accel_dev); int adf_dev_start(struct adf_accel_dev *accel_dev);
int adf_dev_stop(struct adf_accel_dev *accel_dev); void adf_dev_stop(struct adf_accel_dev *accel_dev);
void adf_dev_shutdown(struct adf_accel_dev *accel_dev); void adf_dev_shutdown(struct adf_accel_dev *accel_dev);
int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr); int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr);
...@@ -236,8 +236,13 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, ...@@ -236,8 +236,13 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
uint32_t vf_mask); uint32_t vf_mask);
void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev); void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
int adf_vf2pf_init(struct adf_accel_dev *accel_dev);
void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev);
int adf_init_pf_wq(void); int adf_init_pf_wq(void);
void adf_exit_pf_wq(void); void adf_exit_pf_wq(void);
int adf_init_vf_wq(void);
void adf_exit_vf_wq(void);
#else #else
static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs) static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
{ {
...@@ -256,6 +261,15 @@ static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev) ...@@ -256,6 +261,15 @@ static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
{ {
} }
static inline int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
{
return 0;
}
static inline void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
{
}
static inline int adf_init_pf_wq(void) static inline int adf_init_pf_wq(void)
{ {
return 0; return 0;
...@@ -264,5 +278,15 @@ static inline int adf_init_pf_wq(void) ...@@ -264,5 +278,15 @@ static inline int adf_init_pf_wq(void)
static inline void adf_exit_pf_wq(void) static inline void adf_exit_pf_wq(void)
{ {
} }
static inline int adf_init_vf_wq(void)
{
return 0;
}
static inline void adf_exit_vf_wq(void)
{
}
#endif #endif
#endif #endif
...@@ -270,26 +270,33 @@ static int adf_ctl_is_device_in_use(int id) ...@@ -270,26 +270,33 @@ static int adf_ctl_is_device_in_use(int id)
return 0; return 0;
} }
static int adf_ctl_stop_devices(uint32_t id) static void adf_ctl_stop_devices(uint32_t id)
{ {
struct adf_accel_dev *accel_dev; struct adf_accel_dev *accel_dev;
int ret = 0;
list_for_each_entry_reverse(accel_dev, adf_devmgr_get_head(), list) { list_for_each_entry(accel_dev, adf_devmgr_get_head(), list) {
if (id == accel_dev->accel_id || id == ADF_CFG_ALL_DEVICES) { if (id == accel_dev->accel_id || id == ADF_CFG_ALL_DEVICES) {
if (!adf_dev_started(accel_dev)) if (!adf_dev_started(accel_dev))
continue; continue;
if (adf_dev_stop(accel_dev)) { /* First stop all VFs */
dev_err(&GET_DEV(accel_dev), if (!accel_dev->is_vf)
"Failed to stop qat_dev%d\n", id); continue;
ret = -EFAULT;
} else { adf_dev_stop(accel_dev);
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
} }
} }
list_for_each_entry(accel_dev, adf_devmgr_get_head(), list) {
if (id == accel_dev->accel_id || id == ADF_CFG_ALL_DEVICES) {
if (!adf_dev_started(accel_dev))
continue;
adf_dev_stop(accel_dev);
adf_dev_shutdown(accel_dev);
}
} }
return ret;
} }
static int adf_ctl_ioctl_dev_stop(struct file *fp, unsigned int cmd, static int adf_ctl_ioctl_dev_stop(struct file *fp, unsigned int cmd,
...@@ -318,9 +325,8 @@ static int adf_ctl_ioctl_dev_stop(struct file *fp, unsigned int cmd, ...@@ -318,9 +325,8 @@ static int adf_ctl_ioctl_dev_stop(struct file *fp, unsigned int cmd,
pr_info("QAT: Stopping acceleration device qat_dev%d.\n", pr_info("QAT: Stopping acceleration device qat_dev%d.\n",
ctl_data->device_id); ctl_data->device_id);
ret = adf_ctl_stop_devices(ctl_data->device_id); adf_ctl_stop_devices(ctl_data->device_id);
if (ret)
pr_err("QAT: failed to stop device.\n");
out: out:
kfree(ctl_data); kfree(ctl_data);
return ret; return ret;
...@@ -465,12 +471,17 @@ static int __init adf_register_ctl_device_driver(void) ...@@ -465,12 +471,17 @@ static int __init adf_register_ctl_device_driver(void)
if (adf_init_pf_wq()) if (adf_init_pf_wq())
goto err_pf_wq; goto err_pf_wq;
if (adf_init_vf_wq())
goto err_vf_wq;
if (qat_crypto_register()) if (qat_crypto_register())
goto err_crypto_register; goto err_crypto_register;
return 0; return 0;
err_crypto_register: err_crypto_register:
adf_exit_vf_wq();
err_vf_wq:
adf_exit_pf_wq(); adf_exit_pf_wq();
err_pf_wq: err_pf_wq:
adf_exit_aer(); adf_exit_aer();
...@@ -485,6 +496,7 @@ static void __exit adf_unregister_ctl_device_driver(void) ...@@ -485,6 +496,7 @@ static void __exit adf_unregister_ctl_device_driver(void)
{ {
adf_chr_drv_destroy(); adf_chr_drv_destroy();
adf_exit_aer(); adf_exit_aer();
adf_exit_vf_wq();
adf_exit_pf_wq(); adf_exit_pf_wq();
qat_crypto_unregister(); qat_crypto_unregister();
adf_clean_vf_map(false); adf_clean_vf_map(false);
......
...@@ -236,9 +236,9 @@ EXPORT_SYMBOL_GPL(adf_dev_start); ...@@ -236,9 +236,9 @@ EXPORT_SYMBOL_GPL(adf_dev_start);
* is shuting down. * is shuting down.
* To be used by QAT device specific drivers. * To be used by QAT device specific drivers.
* *
* Return: 0 on success, error code otherwise. * Return: void
*/ */
int adf_dev_stop(struct adf_accel_dev *accel_dev) void adf_dev_stop(struct adf_accel_dev *accel_dev)
{ {
struct service_hndl *service; struct service_hndl *service;
struct list_head *list_itr; struct list_head *list_itr;
...@@ -246,9 +246,9 @@ int adf_dev_stop(struct adf_accel_dev *accel_dev) ...@@ -246,9 +246,9 @@ int adf_dev_stop(struct adf_accel_dev *accel_dev)
int ret; int ret;
if (!adf_dev_started(accel_dev) && if (!adf_dev_started(accel_dev) &&
!test_bit(ADF_STATUS_STARTING, &accel_dev->status)) { !test_bit(ADF_STATUS_STARTING, &accel_dev->status))
return 0; return;
}
clear_bit(ADF_STATUS_STARTING, &accel_dev->status); clear_bit(ADF_STATUS_STARTING, &accel_dev->status);
clear_bit(ADF_STATUS_STARTED, &accel_dev->status); clear_bit(ADF_STATUS_STARTED, &accel_dev->status);
...@@ -279,8 +279,6 @@ int adf_dev_stop(struct adf_accel_dev *accel_dev) ...@@ -279,8 +279,6 @@ int adf_dev_stop(struct adf_accel_dev *accel_dev)
else else
clear_bit(ADF_STATUS_AE_STARTED, &accel_dev->status); clear_bit(ADF_STATUS_AE_STARTED, &accel_dev->status);
} }
return 0;
} }
EXPORT_SYMBOL_GPL(adf_dev_stop); EXPORT_SYMBOL_GPL(adf_dev_stop);
...@@ -329,6 +327,8 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev) ...@@ -329,6 +327,8 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev)
clear_bit(accel_dev->accel_id, &service->init_status); clear_bit(accel_dev->accel_id, &service->init_status);
} }
hw_data->disable_iov(accel_dev);
if (test_bit(ADF_STATUS_IRQ_ALLOCATED, &accel_dev->status)) { if (test_bit(ADF_STATUS_IRQ_ALLOCATED, &accel_dev->status)) {
hw_data->free_irq(accel_dev); hw_data->free_irq(accel_dev);
clear_bit(ADF_STATUS_IRQ_ALLOCATED, &accel_dev->status); clear_bit(ADF_STATUS_IRQ_ALLOCATED, &accel_dev->status);
...@@ -344,7 +344,6 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev) ...@@ -344,7 +344,6 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev)
if (hw_data->exit_admin_comms) if (hw_data->exit_admin_comms)
hw_data->exit_admin_comms(accel_dev); hw_data->exit_admin_comms(accel_dev);
hw_data->disable_iov(accel_dev);
adf_cleanup_etr_data(accel_dev); adf_cleanup_etr_data(accel_dev);
adf_dev_restore(accel_dev); adf_dev_restore(accel_dev);
} }
......
...@@ -302,7 +302,7 @@ static void adf_cleanup_bh(struct adf_accel_dev *accel_dev) ...@@ -302,7 +302,7 @@ static void adf_cleanup_bh(struct adf_accel_dev *accel_dev)
} }
/** /**
* adf_vf_isr_resource_free() - Free IRQ for acceleration device * adf_isr_resource_free() - Free IRQ for acceleration device
* @accel_dev: Pointer to acceleration device. * @accel_dev: Pointer to acceleration device.
* *
* Function frees interrupts for acceleration device. * Function frees interrupts for acceleration device.
...@@ -317,7 +317,7 @@ void adf_isr_resource_free(struct adf_accel_dev *accel_dev) ...@@ -317,7 +317,7 @@ void adf_isr_resource_free(struct adf_accel_dev *accel_dev)
EXPORT_SYMBOL_GPL(adf_isr_resource_free); EXPORT_SYMBOL_GPL(adf_isr_resource_free);
/** /**
* adf_vf_isr_resource_alloc() - Allocate IRQ for acceleration device * adf_isr_resource_alloc() - Allocate IRQ for acceleration device
* @accel_dev: Pointer to acceleration device. * @accel_dev: Pointer to acceleration device.
* *
* Function allocates interrupts for acceleration device. * Function allocates interrupts for acceleration device.
......
...@@ -249,13 +249,7 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs) ...@@ -249,13 +249,7 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
return -EBUSY; return -EBUSY;
} }
if (adf_dev_stop(accel_dev)) { adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev),
"Failed to stop qat_dev%d\n",
accel_dev->accel_id);
return -EFAULT;
}
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
} }
......
/*
This file is provided under a dual BSD/GPLv2 license. When using or
redistributing this file, you may do so under either license.
GPL LICENSE SUMMARY
Copyright(c) 2015 Intel Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
Contact Information:
qat-linux@intel.com
BSD LICENSE
Copyright(c) 2015 Intel Corporation.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "adf_accel_devices.h"
#include "adf_common_drv.h"
#include "adf_pf2vf_msg.h"
/**
* adf_vf2pf_init() - send init msg to PF
* @accel_dev: Pointer to acceleration VF device.
*
* Function sends an init messge from the VF to a PF
*
* Return: 0 on success, error code otherwise.
*/
int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0)) {
dev_err(&GET_DEV(accel_dev),
"Failed to send Init event to PF\n");
return -EFAULT;
}
set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
return 0;
}
EXPORT_SYMBOL_GPL(adf_vf2pf_init);
/**
* adf_vf2pf_shutdown() - send shutdown msg to PF
* @accel_dev: Pointer to acceleration VF device.
*
* Function sends a shutdown messge from the VF to a PF
*
* Return: void
*/
void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
if (test_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status))
if (adf_iov_putmsg(accel_dev, msg, 0))
dev_err(&GET_DEV(accel_dev),
"Failed to send Shutdown event to PF\n");
}
EXPORT_SYMBOL_GPL(adf_vf2pf_shutdown);
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/workqueue.h>
#include "adf_accel_devices.h" #include "adf_accel_devices.h"
#include "adf_common_drv.h" #include "adf_common_drv.h"
#include "adf_cfg.h" #include "adf_cfg.h"
...@@ -64,6 +65,13 @@ ...@@ -64,6 +65,13 @@
#define ADF_VINTSOU_BUN BIT(0) #define ADF_VINTSOU_BUN BIT(0)
#define ADF_VINTSOU_PF2VF BIT(1) #define ADF_VINTSOU_PF2VF BIT(1)
static struct workqueue_struct *adf_vf_stop_wq;
struct adf_vf_stop_data {
struct adf_accel_dev *accel_dev;
struct work_struct work;
};
static int adf_enable_msi(struct adf_accel_dev *accel_dev) static int adf_enable_msi(struct adf_accel_dev *accel_dev)
{ {
struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev; struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev;
...@@ -90,6 +98,20 @@ static void adf_disable_msi(struct adf_accel_dev *accel_dev) ...@@ -90,6 +98,20 @@ static void adf_disable_msi(struct adf_accel_dev *accel_dev)
pci_disable_msi(pdev); pci_disable_msi(pdev);
} }
static void adf_dev_stop_async(struct work_struct *work)
{
struct adf_vf_stop_data *stop_data =
container_of(work, struct adf_vf_stop_data, work);
struct adf_accel_dev *accel_dev = stop_data->accel_dev;
adf_dev_stop(accel_dev);
adf_dev_shutdown(accel_dev);
/* Re-enable PF2VF interrupts */
adf_enable_pf2vf_interrupts(accel_dev);
kfree(stop_data);
}
static void adf_pf2vf_bh_handler(void *data) static void adf_pf2vf_bh_handler(void *data)
{ {
struct adf_accel_dev *accel_dev = data; struct adf_accel_dev *accel_dev = data;
...@@ -107,11 +129,29 @@ static void adf_pf2vf_bh_handler(void *data) ...@@ -107,11 +129,29 @@ static void adf_pf2vf_bh_handler(void *data)
goto err; goto err;
switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) { switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) {
case ADF_PF2VF_MSGTYPE_RESTARTING: case ADF_PF2VF_MSGTYPE_RESTARTING: {
struct adf_vf_stop_data *stop_data;
dev_dbg(&GET_DEV(accel_dev), dev_dbg(&GET_DEV(accel_dev),
"Restarting msg received from PF 0x%x\n", msg); "Restarting msg received from PF 0x%x\n", msg);
adf_dev_stop(accel_dev);
break; clear_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
stop_data = kzalloc(sizeof(*stop_data), GFP_ATOMIC);
if (!stop_data) {
dev_err(&GET_DEV(accel_dev),
"Couldn't schedule stop for vf_%d\n",
accel_dev->accel_id);
return;
}
stop_data->accel_dev = accel_dev;
INIT_WORK(&stop_data->work, adf_dev_stop_async);
queue_work(adf_vf_stop_wq, &stop_data->work);
/* To ack, clear the PF2VFINT bit */
msg &= ~BIT(0);
ADF_CSR_WR(pmisc_bar_addr, hw_data->get_pf2vf_offset(0), msg);
return;
}
case ADF_PF2VF_MSGTYPE_VERSION_RESP: case ADF_PF2VF_MSGTYPE_VERSION_RESP:
dev_dbg(&GET_DEV(accel_dev), dev_dbg(&GET_DEV(accel_dev),
"Version resp received from PF 0x%x\n", msg); "Version resp received from PF 0x%x\n", msg);
...@@ -278,3 +318,18 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev) ...@@ -278,3 +318,18 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev)
return -EFAULT; return -EFAULT;
} }
EXPORT_SYMBOL_GPL(adf_vf_isr_resource_alloc); EXPORT_SYMBOL_GPL(adf_vf_isr_resource_alloc);
int __init adf_init_vf_wq(void)
{
adf_vf_stop_wq = create_workqueue("adf_vf_stop_wq");
return !adf_vf_stop_wq ? -EFAULT : 0;
}
void adf_exit_vf_wq(void)
{
if (adf_vf_stop_wq)
destroy_workqueue(adf_vf_stop_wq);
adf_vf_stop_wq = NULL;
}
...@@ -593,7 +593,7 @@ int qat_rsa_get_d(void *context, size_t hdrlen, unsigned char tag, ...@@ -593,7 +593,7 @@ int qat_rsa_get_d(void *context, size_t hdrlen, unsigned char tag,
ret = -ENOMEM; ret = -ENOMEM;
ctx->d = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_d, GFP_KERNEL); ctx->d = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_d, GFP_KERNEL);
if (!ctx->n) if (!ctx->d)
goto err; goto err;
memcpy(ctx->d + (ctx->key_sz - vlen), ptr, vlen); memcpy(ctx->d + (ctx->key_sz - vlen), ptr, vlen);
...@@ -711,7 +711,7 @@ static void qat_rsa_exit_tfm(struct crypto_akcipher *tfm) ...@@ -711,7 +711,7 @@ static void qat_rsa_exit_tfm(struct crypto_akcipher *tfm)
} }
qat_crypto_put_instance(ctx->inst); qat_crypto_put_instance(ctx->inst);
ctx->n = NULL; ctx->n = NULL;
ctx->d = NULL; ctx->e = NULL;
ctx->d = NULL; ctx->d = NULL;
} }
......
...@@ -302,9 +302,7 @@ static void adf_remove(struct pci_dev *pdev) ...@@ -302,9 +302,7 @@ static void adf_remove(struct pci_dev *pdev)
pr_err("QAT: Driver removal failed\n"); pr_err("QAT: Driver removal failed\n");
return; return;
} }
if (adf_dev_stop(accel_dev)) adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n");
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
adf_disable_aer(accel_dev); adf_disable_aer(accel_dev);
adf_cleanup_accel(accel_dev); adf_cleanup_accel(accel_dev);
......
...@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev) ...@@ -109,29 +109,6 @@ static void adf_vf_void_noop(struct adf_accel_dev *accel_dev)
{ {
} }
static int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0)) {
dev_err(&GET_DEV(accel_dev),
"Failed to send Init event to PF\n");
return -EFAULT;
}
return 0;
}
static void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
{
u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
(ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
if (adf_iov_putmsg(accel_dev, msg, 0))
dev_err(&GET_DEV(accel_dev),
"Failed to send Shutdown event to PF\n");
}
void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data) void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
{ {
hw_data->dev_class = &dh895xcciov_class; hw_data->dev_class = &dh895xcciov_class;
......
...@@ -238,6 +238,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -238,6 +238,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto out_err_free_reg; goto out_err_free_reg;
set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
ret = adf_dev_init(accel_dev); ret = adf_dev_init(accel_dev);
if (ret) if (ret)
goto out_err_dev_shutdown; goto out_err_dev_shutdown;
...@@ -270,9 +272,7 @@ static void adf_remove(struct pci_dev *pdev) ...@@ -270,9 +272,7 @@ static void adf_remove(struct pci_dev *pdev)
pr_err("QAT: Driver removal failed\n"); pr_err("QAT: Driver removal failed\n");
return; return;
} }
if (adf_dev_stop(accel_dev)) adf_dev_stop(accel_dev);
dev_err(&GET_DEV(accel_dev), "Failed to stop QAT accel dev\n");
adf_dev_shutdown(accel_dev); adf_dev_shutdown(accel_dev);
adf_cleanup_accel(accel_dev); adf_cleanup_accel(accel_dev);
adf_cleanup_pci_dev(accel_dev); adf_cleanup_pci_dev(accel_dev);
......
This diff is collapsed.
...@@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) ...@@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
unsigned int todo; unsigned int todo;
struct sg_mapping_iter mi, mo; struct sg_mapping_iter mi, mo;
unsigned int oi, oo; /* offset for in and out */ unsigned int oi, oo; /* offset for in and out */
unsigned long flags;
if (areq->nbytes == 0) if (areq->nbytes == 0)
return 0; return 0;
...@@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) ...@@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
return -EINVAL; return -EINVAL;
} }
spin_lock_bh(&ss->slock); spin_lock_irqsave(&ss->slock, flags);
for (i = 0; i < op->keylen; i += 4) for (i = 0; i < op->keylen; i += 4)
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
...@@ -117,7 +118,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) ...@@ -117,7 +118,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
sg_miter_stop(&mi); sg_miter_stop(&mi);
sg_miter_stop(&mo); sg_miter_stop(&mo);
writel(0, ss->base + SS_CTL); writel(0, ss->base + SS_CTL);
spin_unlock_bh(&ss->slock); spin_unlock_irqrestore(&ss->slock, flags);
return err; return err;
} }
...@@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) ...@@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
unsigned int ob = 0; /* offset in buf */ unsigned int ob = 0; /* offset in buf */
unsigned int obo = 0; /* offset in bufo*/ unsigned int obo = 0; /* offset in bufo*/
unsigned int obl = 0; /* length of data in bufo */ unsigned int obl = 0; /* length of data in bufo */
unsigned long flags;
if (areq->nbytes == 0) if (areq->nbytes == 0)
return 0; return 0;
...@@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) ...@@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
if (no_chunk == 1) if (no_chunk == 1)
return sun4i_ss_opti_poll(areq); return sun4i_ss_opti_poll(areq);
spin_lock_bh(&ss->slock); spin_lock_irqsave(&ss->slock, flags);
for (i = 0; i < op->keylen; i += 4) for (i = 0; i < op->keylen; i += 4)
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
...@@ -307,7 +309,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) ...@@ -307,7 +309,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
sg_miter_stop(&mi); sg_miter_stop(&mi);
sg_miter_stop(&mo); sg_miter_stop(&mo);
writel(0, ss->base + SS_CTL); writel(0, ss->base + SS_CTL);
spin_unlock_bh(&ss->slock); spin_unlock_irqrestore(&ss->slock, flags);
return err; return err;
} }
......
...@@ -835,6 +835,16 @@ struct talitos_ahash_req_ctx { ...@@ -835,6 +835,16 @@ struct talitos_ahash_req_ctx {
struct scatterlist *psrc; struct scatterlist *psrc;
}; };
struct talitos_export_state {
u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
u8 buf[HASH_MAX_BLOCK_SIZE];
unsigned int swinit;
unsigned int first;
unsigned int last;
unsigned int to_hash_later;
unsigned int nbuf;
};
static int aead_setkey(struct crypto_aead *authenc, static int aead_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen) const u8 *key, unsigned int keylen)
{ {
...@@ -1981,6 +1991,46 @@ static int ahash_digest(struct ahash_request *areq) ...@@ -1981,6 +1991,46 @@ static int ahash_digest(struct ahash_request *areq)
return ahash_process_req(areq, areq->nbytes); return ahash_process_req(areq, areq->nbytes);
} }
static int ahash_export(struct ahash_request *areq, void *out)
{
struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
struct talitos_export_state *export = out;
memcpy(export->hw_context, req_ctx->hw_context,
req_ctx->hw_context_size);
memcpy(export->buf, req_ctx->buf, req_ctx->nbuf);
export->swinit = req_ctx->swinit;
export->first = req_ctx->first;
export->last = req_ctx->last;
export->to_hash_later = req_ctx->to_hash_later;
export->nbuf = req_ctx->nbuf;
return 0;
}
static int ahash_import(struct ahash_request *areq, const void *in)
{
struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
const struct talitos_export_state *export = in;
memset(req_ctx, 0, sizeof(*req_ctx));
req_ctx->hw_context_size =
(crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE)
? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256
: TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512;
memcpy(req_ctx->hw_context, export->hw_context,
req_ctx->hw_context_size);
memcpy(req_ctx->buf, export->buf, export->nbuf);
req_ctx->swinit = export->swinit;
req_ctx->first = export->first;
req_ctx->last = export->last;
req_ctx->to_hash_later = export->to_hash_later;
req_ctx->nbuf = export->nbuf;
return 0;
}
struct keyhash_result { struct keyhash_result {
struct completion completion; struct completion completion;
int err; int err;
...@@ -2458,6 +2508,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2458,6 +2508,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = MD5_DIGEST_SIZE, .halg.digestsize = MD5_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "md5", .cra_name = "md5",
.cra_driver_name = "md5-talitos", .cra_driver_name = "md5-talitos",
...@@ -2473,6 +2524,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2473,6 +2524,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA1_DIGEST_SIZE, .halg.digestsize = SHA1_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "sha1", .cra_name = "sha1",
.cra_driver_name = "sha1-talitos", .cra_driver_name = "sha1-talitos",
...@@ -2488,6 +2540,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2488,6 +2540,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA224_DIGEST_SIZE, .halg.digestsize = SHA224_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "sha224", .cra_name = "sha224",
.cra_driver_name = "sha224-talitos", .cra_driver_name = "sha224-talitos",
...@@ -2503,6 +2556,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2503,6 +2556,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA256_DIGEST_SIZE, .halg.digestsize = SHA256_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "sha256", .cra_name = "sha256",
.cra_driver_name = "sha256-talitos", .cra_driver_name = "sha256-talitos",
...@@ -2518,6 +2572,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2518,6 +2572,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA384_DIGEST_SIZE, .halg.digestsize = SHA384_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "sha384", .cra_name = "sha384",
.cra_driver_name = "sha384-talitos", .cra_driver_name = "sha384-talitos",
...@@ -2533,6 +2588,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2533,6 +2588,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA512_DIGEST_SIZE, .halg.digestsize = SHA512_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "sha512", .cra_name = "sha512",
.cra_driver_name = "sha512-talitos", .cra_driver_name = "sha512-talitos",
...@@ -2548,6 +2604,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2548,6 +2604,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = MD5_DIGEST_SIZE, .halg.digestsize = MD5_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "hmac(md5)", .cra_name = "hmac(md5)",
.cra_driver_name = "hmac-md5-talitos", .cra_driver_name = "hmac-md5-talitos",
...@@ -2563,6 +2620,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2563,6 +2620,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA1_DIGEST_SIZE, .halg.digestsize = SHA1_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "hmac(sha1)", .cra_name = "hmac(sha1)",
.cra_driver_name = "hmac-sha1-talitos", .cra_driver_name = "hmac-sha1-talitos",
...@@ -2578,6 +2636,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2578,6 +2636,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA224_DIGEST_SIZE, .halg.digestsize = SHA224_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "hmac(sha224)", .cra_name = "hmac(sha224)",
.cra_driver_name = "hmac-sha224-talitos", .cra_driver_name = "hmac-sha224-talitos",
...@@ -2593,6 +2652,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2593,6 +2652,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA256_DIGEST_SIZE, .halg.digestsize = SHA256_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "hmac(sha256)", .cra_name = "hmac(sha256)",
.cra_driver_name = "hmac-sha256-talitos", .cra_driver_name = "hmac-sha256-talitos",
...@@ -2608,6 +2668,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2608,6 +2668,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA384_DIGEST_SIZE, .halg.digestsize = SHA384_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "hmac(sha384)", .cra_name = "hmac(sha384)",
.cra_driver_name = "hmac-sha384-talitos", .cra_driver_name = "hmac-sha384-talitos",
...@@ -2623,6 +2684,7 @@ static struct talitos_alg_template driver_algs[] = { ...@@ -2623,6 +2684,7 @@ static struct talitos_alg_template driver_algs[] = {
{ .type = CRYPTO_ALG_TYPE_AHASH, { .type = CRYPTO_ALG_TYPE_AHASH,
.alg.hash = { .alg.hash = {
.halg.digestsize = SHA512_DIGEST_SIZE, .halg.digestsize = SHA512_DIGEST_SIZE,
.halg.statesize = sizeof(struct talitos_export_state),
.halg.base = { .halg.base = {
.cra_name = "hmac(sha512)", .cra_name = "hmac(sha512)",
.cra_driver_name = "hmac-sha512-talitos", .cra_driver_name = "hmac-sha512-talitos",
...@@ -2814,6 +2876,8 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, ...@@ -2814,6 +2876,8 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
t_alg->algt.alg.hash.finup = ahash_finup; t_alg->algt.alg.hash.finup = ahash_finup;
t_alg->algt.alg.hash.digest = ahash_digest; t_alg->algt.alg.hash.digest = ahash_digest;
t_alg->algt.alg.hash.setkey = ahash_setkey; t_alg->algt.alg.hash.setkey = ahash_setkey;
t_alg->algt.alg.hash.import = ahash_import;
t_alg->algt.alg.hash.export = ahash_export;
if (!(priv->features & TALITOS_FTR_HMAC_OK) && if (!(priv->features & TALITOS_FTR_HMAC_OK) &&
!strncmp(alg->cra_name, "hmac", 4)) { !strncmp(alg->cra_name, "hmac", 4)) {
......
...@@ -139,6 +139,26 @@ my $vmr = sub { ...@@ -139,6 +139,26 @@ my $vmr = sub {
" vor $vx,$vy,$vy"; " vor $vx,$vy,$vy";
}; };
# Some ABIs specify vrsave, special-purpose register #256, as reserved
# for system use.
my $no_vrsave = ($flavour =~ /aix|linux64le/);
my $mtspr = sub {
my ($f,$idx,$ra) = @_;
if ($idx == 256 && $no_vrsave) {
" or $ra,$ra,$ra";
} else {
" mtspr $idx,$ra";
}
};
my $mfspr = sub {
my ($f,$rd,$idx) = @_;
if ($idx == 256 && $no_vrsave) {
" li $rd,-1";
} else {
" mfspr $rd,$idx";
}
};
# PowerISA 2.06 stuff # PowerISA 2.06 stuff
sub vsxmem_op { sub vsxmem_op {
my ($f, $vrt, $ra, $rb, $op) = @_; my ($f, $vrt, $ra, $rb, $op) = @_;
......
This diff is collapsed.
...@@ -242,7 +242,6 @@ struct ecryptfs_crypt_stat { ...@@ -242,7 +242,6 @@ struct ecryptfs_crypt_stat {
struct list_head keysig_list; struct list_head keysig_list;
struct mutex keysig_list_mutex; struct mutex keysig_list_mutex;
struct mutex cs_tfm_mutex; struct mutex cs_tfm_mutex;
struct mutex cs_hash_tfm_mutex;
struct mutex cs_mutex; struct mutex cs_mutex;
}; };
...@@ -577,7 +576,7 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, ...@@ -577,7 +576,7 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
int sg_size); int sg_size);
int ecryptfs_compute_root_iv(struct ecryptfs_crypt_stat *crypt_stat); int ecryptfs_compute_root_iv(struct ecryptfs_crypt_stat *crypt_stat);
void ecryptfs_rotate_iv(unsigned char *iv); void ecryptfs_rotate_iv(unsigned char *iv);
void ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat); int ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
void ecryptfs_destroy_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat); void ecryptfs_destroy_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
void ecryptfs_destroy_mount_crypt_stat( void ecryptfs_destroy_mount_crypt_stat(
struct ecryptfs_mount_crypt_stat *mount_crypt_stat); struct ecryptfs_mount_crypt_stat *mount_crypt_stat);
......
This diff is collapsed.
This diff is collapsed.
...@@ -405,8 +405,7 @@ static inline void aead_request_set_tfm(struct aead_request *req, ...@@ -405,8 +405,7 @@ static inline void aead_request_set_tfm(struct aead_request *req,
* encrypt and decrypt API calls. During the allocation, the provided aead * encrypt and decrypt API calls. During the allocation, the provided aead
* handle is registered in the request data structure. * handle is registered in the request data structure.
* *
* Return: allocated request handle in case of success; IS_ERR() is true in case * Return: allocated request handle in case of success, or NULL if out of memory
* of an error, PTR_ERR() returns the error code.
*/ */
static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
gfp_t gfp) gfp_t gfp)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment