Re: [PATCH v2 1/4] Crypto: Crypto driver support aes/des/des3 for rk3288

2015-11-06 Thread Sandy Harris
On Thu, Nov 5, 2015 at 8:17 PM, Zain Wang  wrote:
> The names registered are:
> ecb(aes) cbc(aes) ecb(des) cbc(des) ecb(des3_ede) cbc(des3_ede)
> You can alloc tags above in your case.

Why on Earth are you allowing DES? Here's a reference from around the
turn of the century on why the FreeS/WAN project refused to implement
it then:
http://www.freeswan.org/freeswan_trees/freeswan-1.97/doc/politics.html#desnotsecure

In 1998 a $200,000-odd purpose-built machine using FPGAs could break
DES in a few days. Morre's Law applies; my guess would be that today
you could break it in hours for well under $10,000 using either GPUs
or Intel's Xeon Phi.

Even if you have to implement DES because you need it as a component
for 3DES and some standards still require 3DES, single DES should not
be exposed in the user interface.
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/4] ARM: dts: rockchip: Add Crypto drivers for rk3288

2015-11-06 Thread Heiko Stuebner
Am Freitag, 6. November 2015, 09:17:23 schrieb Zain Wang:
> Add Crypto drivers for rk3288 including crypto controller and dma clk.
> 
> Signed-off-by: Zain Wang 
> ---
> 
> Changed in v2:
> - None
> 
> Changed in v1:
> - remove the _crypto suffix
> - use "rockchip,rk3288-crypto" instead of "rockchip,rk3288"
> 
>  arch/arm/boot/dts/rk3288.dtsi | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
> index 6a79c9c..7b7914e 100644
> --- a/arch/arm/boot/dts/rk3288.dtsi
> +++ b/arch/arm/boot/dts/rk3288.dtsi
> @@ -170,6 +170,21 @@
>   };
>   };
>  
> + crypto: cypto-controller@ff8a {
> + compatible = "rockchip,rk3288-crypto";
> + reg = <0xff8a 0x4000>;
> + interrupts = ;
> + clocks = < ACLK_CRYPTO>,
> +  < HCLK_CRYPTO>,
> +  < SCLK_CRYPTO>,
> +  < ACLK_DMAC1>;
> + clock-names = "aclk",
> +   "hclk",
> +   "sclk",
> +   "apb_pclk";
> + status = "okay";
> + };
> +

please move that whole node to the right location. Entries are sorted by 
register address (the ff8a should then of course be below  i2s@ff89 
and above vop@ff93)


>   reserved-memory {
>   #address-cells = <1>;
>   #size-cells = <1>;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/4] ARM: dts: rockchip: Add Crypto drivers for rk3288

2015-11-06 Thread Zain


On 2015年11月06日 18:12, Heiko Stuebner wrote:
> Am Freitag, 6. November 2015, 09:17:23 schrieb Zain Wang:
>> Add Crypto drivers for rk3288 including crypto controller and dma clk.
>>
>> Signed-off-by: Zain Wang 
>> ---
>>
>> Changed in v2:
>> - None
>>
>> Changed in v1:
>> - remove the _crypto suffix
>> - use "rockchip,rk3288-crypto" instead of "rockchip,rk3288"
>>
>>  arch/arm/boot/dts/rk3288.dtsi | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
>> index 6a79c9c..7b7914e 100644
>> --- a/arch/arm/boot/dts/rk3288.dtsi
>> +++ b/arch/arm/boot/dts/rk3288.dtsi
>> @@ -170,6 +170,21 @@
>>  };
>>  };
>>  
>> +crypto: cypto-controller@ff8a {
>> +compatible = "rockchip,rk3288-crypto";
>> +reg = <0xff8a 0x4000>;
>> +interrupts = ;
>> +clocks = < ACLK_CRYPTO>,
>> + < HCLK_CRYPTO>,
>> + < SCLK_CRYPTO>,
>> + < ACLK_DMAC1>;
>> +clock-names = "aclk",
>> +  "hclk",
>> +  "sclk",
>> +  "apb_pclk";
>> +status = "okay";
>> +};
>> +
> please move that whole node to the right location. Entries are sorted by 
> register address (the ff8a should then of course be below  i2s@ff89 
> and above vop@ff93)
ok! done!
>
>
>>  reserved-memory {
>>  #address-cells = <1>;
>>  #size-cells = <1>;
>>
>
>
>


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/4] ARM: dts: rockchip: Add Crypto drivers for rk3288

2015-11-06 Thread Zain
Hi:

On 2015年11月06日 10:00, Caesar Wang wrote:
> the subject should be add the node/info for crypto...
ok! done!
>
> 在 2015年11月06日 09:17, Zain Wang 写道:
>> Add Crypto drivers for rk3288 including crypto controller and dma clk.
>>
>> Signed-off-by: Zain Wang 
>> ---
>>
>> Changed in v2:
>> - None
>>
>> Changed in v1:
>> - remove the _crypto suffix
>> - use "rockchip,rk3288-crypto" instead of "rockchip,rk3288"
>>
>>   arch/arm/boot/dts/rk3288.dtsi | 15 +++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/rk3288.dtsi
>> b/arch/arm/boot/dts/rk3288.dtsi
>> index 6a79c9c..7b7914e 100644
>> --- a/arch/arm/boot/dts/rk3288.dtsi
>> +++ b/arch/arm/boot/dts/rk3288.dtsi
>> @@ -170,6 +170,21 @@
>>   };
>>   };
>>   +crypto: cypto-controller@ff8a {
>> +compatible = "rockchip,rk3288-crypto";
>> +reg = <0xff8a 0x4000>;
>> +interrupts = ;
>> +clocks = < ACLK_CRYPTO>,
>> + < HCLK_CRYPTO>,
>> + < SCLK_CRYPTO>,
>> + < ACLK_DMAC1>;
>> +clock-names = "aclk",
>> +  "hclk",
>> +  "sclk",
>> +  "apb_pclk";
>
> I guess  you can do this:
>
> clocks = < ACLK_CRYPTO>, < HCLK_CRYPTO>,  < SCLK_CRYPTO>, 
> < ACLK_DMAC1>;
>
> clock-names = "aclk", "hclk",  "sclk", "apb_pclk";
ok! done!
>
>
>> +status = "okay";
>> +};
>> +
>>   reserved-memory {
>>   #address-cells = <1>;
>>   #size-cells = <1>;
>
>


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/4] Crypto: Crypto driver support aes/des/des3 for rk3288

2015-11-06 Thread Zain
Hi

On 2015年11月06日 09:54, Caesar Wang wrote:
> I guess the subject:
> "crypto: rockchip: "
>
> Maybe better.
ok! done!
>
> 在 2015年11月06日 09:17, Zain Wang 写道:
>> The names registered are:
>>  ecb(aes) cbc(aes) ecb(des) cbc(des) ecb(des3_ede) cbc(des3_ede)
>> You can alloc tags above in your case.
>>
>> And other algorithms and platforms will be added later on.
>>
>> Signed-off-by: Zain Wang 
>> ---
>>
>> Changed in v2:
>> - remove some part about hash
>> - add weak key detection
>> - changed some variate's type
>>
>> Changde in v1:
>> - modify some variate's name
>> - modify some variate's type
>> - modify some return value
>> - remove or modify some print info
>> - use more dev_xxx in probe
>> - modify the prio of cipher
>
> [...]
>
>> +static int rk_crypto_remove(struct platform_device *pdev)
>> +{
>> +struct crypto_info_t *crypto_tmp = platform_get_drvdata(pdev);
>> +
>> +rk_crypto_unregister();
>> +tasklet_kill(_tmp->crypto_tasklet);
>> +free_irq(crypto_tmp->irq, crypto_tmp);
>> +crypto_p = NULL;
>> +
>> +return 0;
>> +}
>> +
>> +#ifdef CONFIG_OF
>> +static const struct of_device_id crypto_of_id_table[] = {
>> +{ .compatible = "rockchip,rk3288-crypto" },
>> +{}
>> +};
>> +#endif /* CONFIG_OF */
>
> I see the rk3368/ rk32xx SoCs the crypto seem the same IP.
> So,
> I guess we should put the "of_device_id"  before the device probe
> since we should can compatible for more SoCs.
>
> Others, for example the commit need a bit change.
ok! done!
>
>> +
>> +static struct platform_driver crypto_driver = {
>> +.probe= rk_crypto_probe,
>> +.remove= rk_crypto_remove,
>> +.driver= {
>> +.name= "rockchip,rk3288-crypto",
>> +.of_match_table= of_match_ptr(crypto_of_id_table),
>> +},
>> +};
>> +
>> +module_platform_driver(crypto_driver);
>> +
>> +MODULE_LICENSE("GPL");
>> +MODULE_AUTHOR("Zain Wang");
>> diff --git a/drivers/crypto/rockchip/rk3288_crypto.h
>> b/drivers/crypto/rockchip/rk3288_crypto.h
>> new file mode 100644
>> index 000..cf4cd18
>> --- /dev/null
>> +++ b/drivers/crypto/rockchip/rk3288_crypto.h
>> @@ -0,0 +1,222 @@
>> +#ifndef __RK3288_CRYPTO_H__
>> +#define __RK3288_CRYPTO_H__
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define _SBF(v, f)((v) << (f))
>> +
>> +/* Crypto control registers*/
>> +#define RK_CRYPTO_INTSTS0x
>> +#define RK_CRYPTO_PKA_DONE_INTBIT(5)
>> +#define RK_CRYPTO_HASH_DONE_INTBIT(4)
>> +#define RK_CRYPTO_HRDMA_ERR_INTBIT(3)
>> +#define RK_CRYPTO_HRDMA_DONE_INTBIT(2)
>> +#define RK_CRYPTO_BCDMA_ERR_INTBIT(1)
>> +#define RK_CRYPTO_BCDMA_DONE_INTBIT(0)
>> +
>> +#define RK_CRYPTO_INTENA0x0004
>> +#define RK_CRYPTO_PKA_DONE_ENABIT(5)
>> +#define RK_CRYPTO_HASH_DONE_ENABIT(4)
>> +#define RK_CRYPTO_HRDMA_ERR_ENABIT(3)
>> +#define RK_CRYPTO_HRDMA_DONE_ENABIT(2)
>> +#define RK_CRYPTO_BCDMA_ERR_ENABIT(1)
>> +#define RK_CRYPTO_BCDMA_DONE_ENABIT(0)
>> +
>> +#define RK_CRYPTO_CTRL0x0008
>> +#define RK_CRYPTO_WRITE_MASK(0x << 16)
>> +#define RK_CRYPTO_TRNG_FLUSHBIT(9)
>> +#define RK_CRYPTO_TRNG_STARTBIT(8)
>> +#define RK_CRYPTO_PKA_FLUSHBIT(7)
>> +#define RK_CRYPTO_HASH_FLUSHBIT(6)
>> +#define RK_CRYPTO_BLOCK_FLUSHBIT(5)
>> +#define RK_CRYPTO_PKA_STARTBIT(4)
>> +#define RK_CRYPTO_HASH_STARTBIT(3)
>> +#define RK_CRYPTO_BLOCK_STARTBIT(2)
>> +#define RK_CRYPTO_TDES_STARTBIT(1)
>> +#define RK_CRYPTO_AES_STARTBIT(0)
>> +
>> +#define RK_CRYPTO_CONF0x000c
>> +/* HASH Receive DMA Address Mode:   fix | increment */
>> +#define RK_CRYPTO_HR_ADDR_MODEBIT(8)
>> +/* Block Transmit DMA Address Mode: fix | increment */
>> +#define RK_CRYPTO_BT_ADDR_MODEBIT(7)
>> +/* Block Receive DMA Address Mode:  fix | increment */
>> +#define RK_CRYPTO_BR_ADDR_MODEBIT(6)
>> +#define RK_CRYPTO_BYTESWAP_HRFIFOBIT(5)
>> +#define RK_CRYPTO_BYTESWAP_BTFIFOBIT(4)
>> +#define RK_CRYPTO_BYTESWAP_BRFIFOBIT(3)
>> +/* AES = 0 OR DES = 1 */
>> +#define RK_CRYPTO_DESSELBIT(2)
>> +#define RK_CYYPTO_HASHINSEL_INDEPENDENT_SOURCE_SBF(0x00, 0)
>> +#define RK_CYYPTO_HASHINSEL_BLOCK_CIPHER_INPUT_SBF(0x01, 0)
>> +#define RK_CYYPTO_HASHINSEL_BLOCK_CIPHER_OUTPUT_SBF(0x02, 0)
>> +
>> +/* Block Receiving DMA Start Address Register */
>> +#define RK_CRYPTO_BRDMAS0x0010
>> +/* Block Transmitting DMA Start Address Register */
>> +#define RK_CRYPTO_BTDMAS0x0014
>> +/* Block Receiving DMA Length Register */
>> +#define RK_CRYPTO_BRDMAL0x0018
>> +/* Hash Receiving DMA Start Address Register */
>> +#define RK_CRYPTO_HRDMAS0x001c
>> +/* Hash Receiving DMA Length Register */
>> +#define RK_CRYPTO_HRDMAL0x0020
>> +
>> +/* AES 

Re: [PATCH v2 0/4] Crypto: add crypto accelerator support for rk3288

2015-11-06 Thread Zain


On 2015年11月06日 09:36, Caesar Wang wrote:
> Hi
>
> 在 2015年11月06日 09:17, Zain Wang 写道:
>> This commit support three cipher(AES/DES/DES3) and two
>> chainmode(ecb/cbc),
>> and the more algorithms and new hash drivers will be added later on.
>>
>> Changed in v2:
>> - remove some part about hash
>> - add weak key detection
>> - changed some variate's type
>>
>> Changed in v1:
>> - modify some variate's name
>> - modify some variate's type
>> - modify some return value
>> - remove or modify some print info
>> - use more dev_xxx in probe
>> - modify the prio of cipher
>> - add Kconfig
>>
>> Zain Wang (4):
>>Crypto: Crypto driver support aes/des/des3 for rk3288
>>clk: rockchip: set an id for crypto clk
>>ARM: dts: rockchip: Add Crypto drivers for rk3288
>>crypto: rockchip/crypto - add DT bindings documentation
> I guess the series patchs order should be:
>
> pacth 1/4 dt-binds/
> patch 2/4 clk id
> patch 3/4 crypto driver
> patch 4/4 dts
>
ok! done!
>
>
>>
>>   .../devicetree/bindings/crypto/rockchip-crypto.txt |  29 ++
>>   arch/arm/boot/dts/rk3288.dtsi  |  15 +
>>   drivers/clk/rockchip/clk-rk3288.c  |   2 +-
>>   drivers/crypto/Kconfig |  11 +
>>   drivers/crypto/Makefile|   1 +
>>   drivers/crypto/rockchip/Makefile   |   3 +
>>   drivers/crypto/rockchip/rk3288_crypto.c| 380
>> +++
>>   drivers/crypto/rockchip/rk3288_crypto.h| 222 +
>>   drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c | 511
>> +
>>   include/dt-bindings/clock/rk3288-cru.h |   1 +
>>   10 files changed, 1174 insertions(+), 1 deletion(-)
>>   create mode 100644
>> Documentation/devicetree/bindings/crypto/rockchip-crypto.txt
>>   create mode 100644 drivers/crypto/rockchip/Makefile
>>   create mode 100644 drivers/crypto/rockchip/rk3288_crypto.c
>>   create mode 100644 drivers/crypto/rockchip/rk3288_crypto.h
>>   create mode 100644 drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
>>
>
>


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 4/4] crypto: rockchip/crypto - add DT bindings documentation

2015-11-06 Thread Heiko Stuebner
Am Freitag, 6. November 2015, 09:17:24 schrieb Zain Wang:
> Add DT bindings documentation for the rk3288 crypto drivers.
> 
> Signed-off-by: Zain Wang 
> ---
> 
> Changde in v2:
> - None
> 
> Changed in v1:
> - remove the _crypto suffix
> - use "rockchip,rk3288-crypto" instead of "rockchip,rk3288"
> - remove the description of status
> 
>  .../devicetree/bindings/crypto/rockchip-crypto.txt | 29 
++
>  1 file changed, 29 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/crypto/rockchip-
crypto.txt
> 
> diff --git a/Documentation/devicetree/bindings/crypto/rockchip-crypto.txt 
b/Documentation/devicetree/bindings/crypto/rockchip-crypto.txt
> new file mode 100644
> index 000..d27e203
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/crypto/rockchip-crypto.txt
> @@ -0,0 +1,29 @@
> +Rockchip Electronics And Security Accelerator
> +
> +Required properties:
> +- compatible: Should be "rockchip,rk3288-crypto"
> +- reg: base physical address of the engine and length of memory mapped
> +   region
> +- interrupts: interrupt number
> +- clocks: reference to the clocks about crypto
> +- clock-names: "aclk" used to clock data
> +"hclk" used to clock data
> +"srst" used to clock crypto accelerator

mistmatch between description and example. I think you mean "sclk" instead of 
"srst", like we talked about in the first version.

> +"apb_pclk" used to clock dma
> +
> +Examples:
> +
> + crypto: cypto-controller@ff8a {
> + compatible = "rockchip,rk3288-crypto";
> + reg = <0xff8a 0x4000>;
> + interrupts = ;
> + clocks = < ACLK_CRYPTO>,
> +  < HCLK_CRYPTO>,
> +  < SCLK_CRYPTO>,
> +  < ACLK_DMAC1>;
> + clock-names = "aclk",
> +   "hclk",
> +   "sclk",
> +   "apb_pclk";
> + status = "okay";
> + };
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 4/4] crypto: rockchip/crypto - add DT bindings documentation

2015-11-06 Thread Zain
Hi

On 2015年11月06日 17:00, Heiko Stuebner wrote:
> Am Freitag, 6. November 2015, 09:17:24 schrieb Zain Wang:
>> Add DT bindings documentation for the rk3288 crypto drivers.
>>
>> Signed-off-by: Zain Wang 
>> ---
>>
>> Changde in v2:
>> - None
>>
>> Changed in v1:
>> - remove the _crypto suffix
>> - use "rockchip,rk3288-crypto" instead of "rockchip,rk3288"
>> - remove the description of status
>>
>>  .../devicetree/bindings/crypto/rockchip-crypto.txt | 29 
> ++
>>  1 file changed, 29 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/crypto/rockchip-
> crypto.txt
>> diff --git a/Documentation/devicetree/bindings/crypto/rockchip-crypto.txt 
> b/Documentation/devicetree/bindings/crypto/rockchip-crypto.txt
>> new file mode 100644
>> index 000..d27e203
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/crypto/rockchip-crypto.txt
>> @@ -0,0 +1,29 @@
>> +Rockchip Electronics And Security Accelerator
>> +
>> +Required properties:
>> +- compatible: Should be "rockchip,rk3288-crypto"
>> +- reg: base physical address of the engine and length of memory mapped
>> +   region
>> +- interrupts: interrupt number
>> +- clocks: reference to the clocks about crypto
>> +- clock-names: "aclk" used to clock data
>> +   "hclk" used to clock data
>> +   "srst" used to clock crypto accelerator
> mistmatch between description and example. I think you mean "sclk" instead of 
> "srst", like we talked about in the first version.
I am sorry that forgetting to change it here.
You can see I have changed it in other part like example below.
>
>> +   "apb_pclk" used to clock dma
>> +
>> +Examples:
>> +
>> +crypto: cypto-controller@ff8a {
>> +compatible = "rockchip,rk3288-crypto";
>> +reg = <0xff8a 0x4000>;
>> +interrupts = ;
>> +clocks = < ACLK_CRYPTO>,
>> + < HCLK_CRYPTO>,
>> + < SCLK_CRYPTO>,
>> + < ACLK_DMAC1>;
>> +clock-names = "aclk",
>> +  "hclk",
>> +  "sclk",
>> +  "apb_pclk";
>> +status = "okay";
>> +};
>>
>
>
>
Thanks
Zain

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 1/4] Crypto: Crypto driver support aes/des/des3 for rk3288

2015-11-06 Thread Heiko Stuebner
Hi Zain,

Am Dienstag, 3. November 2015, 13:52:05 schrieb Zain Wang:
> Crypto driver support cbc/ecb two chainmode, and aes/des/des3 three cipher
> mode.
> The names registered are:
> ecb(aes) cbc(aes) ecb(des) cbc(des) ecb(des3_ede) cbc(des3_ede)
> You can alloc tags above in your case.
> 
> And other algorithms and platforms will be added later on.
> 
> Signed-off-by: Zain Wang 
> ---
>  drivers/crypto/Kconfig |  11 +
>  drivers/crypto/Makefile|   1 +
>  drivers/crypto/rockchip/Makefile   |   3 +
>  drivers/crypto/rockchip/rk3288_crypto.c| 383 
>  drivers/crypto/rockchip/rk3288_crypto.h| 290 
>  drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c | 501 
> +
>  6 files changed, 1189 insertions(+)
>  create mode 100644 drivers/crypto/rockchip/Makefile
>  create mode 100644 drivers/crypto/rockchip/rk3288_crypto.c
>  create mode 100644 drivers/crypto/rockchip/rk3288_crypto.h
>  create mode 100644 drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
> 
> diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
> index 2569e04..d1e42cf 100644
> --- a/drivers/crypto/Kconfig
> +++ b/drivers/crypto/Kconfig
> @@ -498,4 +498,15 @@ config CRYPTO_DEV_SUN4I_SS
> To compile this driver as a module, choose M here: the module
> will be called sun4i-ss.
>  
> +config CRYPTO_DEV_ROCKCHIP
> + tristate "Rockchip's Cryptographic Engine driver"
> +
> + select CRYPTO_AES
> + select CRYPTO_DES
> + select CRYPTO_BLKCIPHER
> +
> + help
> +   This driver interfaces with the hardware crypto accelerator.
> +   Supporting cbc/ecb chainmode, and aes/des/des3_ede cipher mode.
> +
>  endif # CRYPTO_HW
> diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
> index c3ced6f..713de9d 100644
> --- a/drivers/crypto/Makefile
> +++ b/drivers/crypto/Makefile
> @@ -29,3 +29,4 @@ obj-$(CONFIG_CRYPTO_DEV_QAT) += qat/
>  obj-$(CONFIG_CRYPTO_DEV_QCE) += qce/
>  obj-$(CONFIG_CRYPTO_DEV_VMX) += vmx/
>  obj-$(CONFIG_CRYPTO_DEV_SUN4I_SS) += sunxi-ss/
> +obj-$(CONFIG_CRYPTO_DEV_ROCKCHIP) += rockchip/
> diff --git a/drivers/crypto/rockchip/Makefile 
> b/drivers/crypto/rockchip/Makefile
> new file mode 100644
> index 000..7051c6c
> --- /dev/null
> +++ b/drivers/crypto/rockchip/Makefile
> @@ -0,0 +1,3 @@
> +obj-$(CONFIG_CRYPTO_DEV_ROCKCHIP) += rk_crypto.o
> +rk_crypto-objs := rk3288_crypto.o \
> +   rk3288_crypto_ablkcipher.o \
> diff --git a/drivers/crypto/rockchip/rk3288_crypto.c 
> b/drivers/crypto/rockchip/rk3288_crypto.c
> new file mode 100644
> index 000..02830f2
> --- /dev/null
> +++ b/drivers/crypto/rockchip/rk3288_crypto.c
> @@ -0,0 +1,383 @@

[...]


> +static int rk_crypto_probe(struct platform_device *pdev)
> +{
> + int err = 0;
> + struct resource *res;
> + struct device *dev = >dev;
> + struct crypto_info_t *crypto_info;
> +

rk3288 chromebooks use the crypto-engine to validate the boot images and
seem to leave it in a half-on state. This results in an irq pending
during probe and thus a null-pointer dereference in the irq-handler, as
it runs before the crypto-device is fully initialized.

resetting the crypto block, successfull fixed that issue, so I did the
following change:

---
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 121b6d5..e978fb2 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -182,6 +182,8 @@
  "hclk",
  "sclk",
  "apb_pclk";
+   resets = < SRST_CRYPTO>;
+   reset-names = "crypto";
status = "okay";
};
 
diff --git a/drivers/crypto/rockchip/rk3288_crypto.c 
b/drivers/crypto/rockchip/rk3288_crypto.c
index 02830f2..2245d3d 100644
--- a/drivers/crypto/rockchip/rk3288_crypto.c
+++ b/drivers/crypto/rockchip/rk3288_crypto.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct crypto_info_t *crypto_p;
 
@@ -266,6 +267,15 @@ static int rk_crypto_probe(struct platform_device *pdev)
struct resource *res;
struct device *dev = >dev;
struct crypto_info_t *crypto_info;
+   struct reset_control *rst;
+
+   /* reset the block to remove any pending actions */
+   rst = devm_reset_control_get(dev, "crypto");
+   if (!IS_ERR(rst)) {
+   reset_control_assert(rst);
+   usleep_range(10, 20);
+   reset_control_deassert(rst);
+   }
 
crypto_info = devm_kzalloc(>dev,
sizeof(*crypto_info), GFP_KERNEL);
---


> + crypto_info = devm_kzalloc(>dev,
> + sizeof(*crypto_info), GFP_KERNEL);
> + if (!crypto_info)
> + return -ENOMEM;
> +
> + spin_lock_init(_info->lock);
> +
> + res = 

A Call For Charity

2015-11-06 Thread Jessica
My Name is Mrs Jessica Peterside from United Kingdom who is suffering from 
cancer of the lungs 
and I wish to use my fund to serve the poor in your country since I have 
limited time on earth  
Regards Mrs Jessica Peterside
reply for more details on this Email:mrsjessicapetersid...@gmail.com
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] hw_random: omap3-rom-rng: convert timer to delayed work

2015-11-06 Thread Grygorii Strashko

On 11/06/2015 12:15 AM, Aaro Koskinen wrote:

We cannot put the HW RNG to idle using a timer because we cannot disable
clocks from atomic context. Use a delayed work instead.

Fixes a warning with CONFIG_DEBUG_MUTEXES on Nokia N900 during boot.

Reported-by: Sebastian Reichel 
Signed-off-by: Aaro Koskinen 
---
  drivers/char/hw_random/omap3-rom-rng.c | 11 ++-
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/char/hw_random/omap3-rom-rng.c 
b/drivers/char/hw_random/omap3-rom-rng.c
index a405cdc..58191c6 100644
--- a/drivers/char/hw_random/omap3-rom-rng.c
+++ b/drivers/char/hw_random/omap3-rom-rng.c
@@ -29,11 +29,11 @@
  /* param1: ptr, param2: count, param3: flag */
  static u32 (*omap3_rom_rng_call)(u32, u32, u32);

-static struct timer_list idle_timer;
+static struct delayed_work idle_work;
  static int rng_idle;
  static struct clk *rng_clk;

-static void omap3_rom_rng_idle(unsigned long data)
+static void omap3_rom_rng_idle(struct work_struct *work)
  {
int r;

@@ -51,7 +51,7 @@ static int omap3_rom_rng_get_random(void *buf, unsigned int 
count)
u32 r;
u32 ptr;

-   del_timer_sync(_timer);
+   cancel_delayed_work_sync(_work);
if (rng_idle) {
clk_prepare_enable(rng_clk);
r = omap3_rom_rng_call(0, 0, RNG_GEN_PRNG_HW_INIT);
@@ -65,7 +65,7 @@ static int omap3_rom_rng_get_random(void *buf, unsigned int 
count)

ptr = virt_to_phys(buf);
r = omap3_rom_rng_call(ptr, count, RNG_GEN_HW);
-   mod_timer(_timer, jiffies + msecs_to_jiffies(500));
+   schedule_delayed_work(_work, msecs_to_jiffies(500));
if (r != 0)
return -EINVAL;
return 0;
@@ -102,7 +102,7 @@ static int omap3_rom_rng_probe(struct platform_device *pdev)
return -EINVAL;
}

-   setup_timer(_timer, omap3_rom_rng_idle, 0);
+   INIT_DELAYED_WORK(_work, omap3_rom_rng_idle);
rng_clk = devm_clk_get(>dev, "ick");
if (IS_ERR(rng_clk)) {
pr_err("unable to get RNG clock\n");
@@ -118,6 +118,7 @@ static int omap3_rom_rng_probe(struct platform_device *pdev)

  static int omap3_rom_rng_remove(struct platform_device *pdev)
  {
+   cancel_delayed_work_sync(_work);
hwrng_unregister(_rom_rng_ops);
clk_disable_unprepare(rng_clk);
return 0;



Sry, It looks like PM runtime autosuspend might work well here.
What do you think?

--
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/7] crypto: picoxcell: check return value of sg_nents_for_len

2015-11-06 Thread Jamie Iles
On Wed, Nov 04, 2015 at 09:13:37PM +0100, LABBE Corentin wrote:
> The sg_nents_for_len() function could fail, this patch add a check for
> its return value.
> In the same time, we remove sg_count() as it is used as an alias of
> sg_nents_for_len.
> 
> Signed-off-by: LABBE Corentin 

Acked-by: Jamie Iles 

thanks for doing this!

Jamie
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html