* [PATCH 0/7] crypto: omap-sham updates
@ 2012-10-19 21:53 Mark A. Greer
2012-10-19 21:53 ` [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
` (7 more replies)
0 siblings, 8 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
This series updates the crypto omap-sham driver and supporting
infrastructure.
Notes:
a) Based on current k.o. c9623de (Merge branch 'v4l_for_linus'
of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media)
b) These have only been tested on an omap2420 h4 and an am37x evm. If you
have different hardware available and a few minutes, please test them.
A quick and easy test is to enable tcrypt as a module
(CONFIG_CRYPTO_TEST=m), boot, then run 'modprobe tcrypt sec=2 mode=403'.
'CONFIG_CRYPTO_SHA1' and 'CONFIG_CRYPTO_DEV_OMAP_SHAM' also have to be
enabled. A quick 'grep omap-sham /proc/interrupts' will tell you if
the omap-sham driver was really used.
c) To test these patches, you will likely need...
i) The patch included here:
http://marc.info/?l=kernel-janitors&m=134910841909057&w=2
ii) This patch from linux-omap/master:
27615a9 (ARM: OMAP: Trivial driver changes to remove include
plat/cpu.h)
iii) This patch from Paul Walmsley:
http://www.spinics.net/lists/linux-omap/msg79436.html
d) If you prefer, a version you can test is available at
git at github.com:mgreeraz/linux-mag.git mag/wip/crypto-test
e) There is a reduction in DMA performance after switching to dmaengine
(see http://www.spinics.net/lists/linux-omap/msg79855.html)
f) Many thanks to Jon Hunter for testing on his omap2420 h4.
Mark A. Greer (7):
ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod
ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module
ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod
ARM: OMAP2+: Remove unnecessary message when no SHA IP is present
crypto: omap-sham: Convert to use pm_runtime API
crypto: omap-sham: Add code to use dmaengine API
crypto: omap_sham: Remove usage of private DMA API
arch/arm/mach-omap2/clock2420_data.c | 1 +
arch/arm/mach-omap2/clock2430_data.c | 1 +
arch/arm/mach-omap2/clock3xxx_data.c | 1 +
arch/arm/mach-omap2/devices.c | 81 +++------
arch/arm/mach-omap2/omap_hwmod_2420_data.c | 1 +
arch/arm/mach-omap2/omap_hwmod_2430_data.c | 1 +
.../mach-omap2/omap_hwmod_2xxx_interconnect_data.c | 18 ++
arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c | 43 +++++
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 60 +++++++
arch/arm/mach-omap2/omap_hwmod_common_data.h | 2 +
drivers/crypto/omap-sham.c | 192 +++++++++++----------
11 files changed, 250 insertions(+), 151 deletions(-)
--
1.7.12
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
@ 2012-10-19 21:53 ` Mark A. Greer
2012-10-20 19:40 ` Paul Walmsley
2012-10-19 21:53 ` [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module Mark A. Greer
` (6 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Convert the device data for the OMAP2 SHAM crypto IP from
explicit platform_data to hwmod. When bit 1 (OMAP24XX_ST_SHA_MASK)
of the CM_IDLEST4_CORE register is set, the SHA IP is present.
CC: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
arch/arm/mach-omap2/clock2420_data.c | 1 +
arch/arm/mach-omap2/clock2430_data.c | 1 +
arch/arm/mach-omap2/devices.c | 38 +++++++++-------------
arch/arm/mach-omap2/omap_hwmod_2420_data.c | 1 +
arch/arm/mach-omap2/omap_hwmod_2430_data.c | 1 +
.../mach-omap2/omap_hwmod_2xxx_interconnect_data.c | 18 ++++++++++
arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c | 37 +++++++++++++++++++++
arch/arm/mach-omap2/omap_hwmod_common_data.h | 2 ++
8 files changed, 77 insertions(+), 22 deletions(-)
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index c3cde1a..a09603c 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -1905,6 +1905,7 @@ static struct omap_clk omap2420_clks[] = {
CLK(NULL, "vlynq_ick", &vlynq_ick, CK_242X),
CLK(NULL, "vlynq_fck", &vlynq_fck, CK_242X),
CLK(NULL, "des_ick", &des_ick, CK_242X),
+ CLK(NULL, "sha_ick", &sha_ick, CK_242X),
CLK("omap-sham", "ick", &sha_ick, CK_242X),
CLK(NULL, "sha_ick", &sha_ick, CK_242X),
CLK("omap_rng", "ick", &rng_ick, CK_242X),
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index 22404fe..654e314 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -1992,6 +1992,7 @@ static struct omap_clk omap2430_clks[] = {
CLK(NULL, "sdma_ick", &sdma_ick, CK_243X),
CLK(NULL, "sdrc_ick", &sdrc_ick, CK_243X),
CLK(NULL, "des_ick", &des_ick, CK_243X),
+ CLK(NULL, "sha_ick", &sha_ick, CK_242X),
CLK("omap-sham", "ick", &sha_ick, CK_243X),
CLK("omap_rng", "ick", &rng_ick, CK_243X),
CLK(NULL, "rng_ick", &rng_ick, CK_243X),
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index c8c2117..5b613fa 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -34,6 +34,8 @@
#include "mux.h"
#include "control.h"
#include "devices.h"
+#include "cm2xxx_3xxx.h"
+#include "cm-regbits-24xx.h"
#define L3_MODULES_MAX_LEN 12
#define L3_MODULES 3
@@ -453,24 +455,6 @@ static void omap_init_rng(void)
#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
-#ifdef CONFIG_ARCH_OMAP2
-static struct resource omap2_sham_resources[] = {
- {
- .start = OMAP24XX_SEC_SHA1MD5_BASE,
- .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
- .flags = IORESOURCE_MEM,
- },
- {
- .start = 51 + OMAP_INTC_START,
- .flags = IORESOURCE_IRQ,
- }
-};
-static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
-#else
-#define omap2_sham_resources NULL
-#define omap2_sham_resources_sz 0
-#endif
-
#ifdef CONFIG_ARCH_OMAP3
static struct resource omap3_sham_resources[] = {
{
@@ -500,17 +484,27 @@ static struct platform_device sham_device = {
static void omap_init_sham(void)
{
- if (cpu_is_omap24xx()) {
- sham_device.resource = omap2_sham_resources;
- sham_device.num_resources = omap2_sham_resources_sz;
+ if (cpu_is_omap24xx() &&
+ (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
+ OMAP24XX_ST_SHA_MASK)) {
+ struct omap_hwmod *oh;
+ struct platform_device *pdev;
+
+ oh = omap_hwmod_lookup("sham");
+ if (!oh)
+ return;
+
+ pdev = omap_device_build("omap-sham", -1, oh, NULL, 0, NULL,
+ 0, 0);
+ WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
} else if (cpu_is_omap34xx()) {
sham_device.resource = omap3_sham_resources;
sham_device.num_resources = omap3_sham_resources_sz;
+ platform_device_register(&sham_device);
} else {
pr_err("%s: platform not supported\n", __func__);
return;
}
- platform_device_register(&sham_device);
}
#else
static inline void omap_init_sham(void) { }
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index b5db600..b102a53 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -603,6 +603,7 @@ static struct omap_hwmod_ocp_if *omap2420_hwmod_ocp_ifs[] __initdata = {
&omap2420_l4_core__mcbsp2,
&omap2420_l4_core__msdi1,
&omap2xxx_l4_core__rng,
+ &omap2xxx_l4_core__sham,
&omap2420_l4_core__hdq1w,
&omap2420_l4_wkup__counter_32k,
&omap2420_l3__gpmc,
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index c455e41..b1ce7b0 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -963,6 +963,7 @@ static struct omap_hwmod_ocp_if *omap2430_hwmod_ocp_ifs[] __initdata = {
&omap2430_l4_core__mcbsp5,
&omap2430_l4_core__hdq1w,
&omap2xxx_l4_core__rng,
+ &omap2xxx_l4_core__sham,
&omap2430_l4_wkup__counter_32k,
&omap2430_l3__gpmc,
NULL,
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c
index 1a1287d..bb314c5 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c
@@ -138,6 +138,15 @@ static struct omap_hwmod_addr_space omap2_rng_addr_space[] = {
{ }
};
+struct omap_hwmod_addr_space omap2xxx_sham_addrs[] = {
+ {
+ .pa_start = 0x480a4000,
+ .pa_end = 0x480a4000 + 0x64 - 1,
+ .flags = ADDR_TYPE_RT
+ },
+ { }
+};
+
/*
* Common interconnect data
*/
@@ -389,3 +398,12 @@ struct omap_hwmod_ocp_if omap2xxx_l4_core__rng = {
.addr = omap2_rng_addr_space,
.user = OCP_USER_MPU | OCP_USER_SDMA,
};
+
+/* l4 core -> sham interface */
+struct omap_hwmod_ocp_if omap2xxx_l4_core__sham = {
+ .master = &omap2xxx_l4_core_hwmod,
+ .slave = &omap2xxx_sham_hwmod,
+ .clk = "sha_ick",
+ .addr = omap2xxx_sham_addrs,
+ .user = OCP_USER_MPU,
+};
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
index bd9220e..a041670 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
@@ -851,3 +851,40 @@ struct omap_hwmod omap2xxx_rng_hwmod = {
.flags = HWMOD_INIT_NO_RESET,
.class = &omap2_rng_hwmod_class,
};
+
+/* SHAM */
+
+static struct omap_hwmod_class_sysconfig omap2_sham_sysc = {
+ .rev_offs = 0x5c,
+ .sysc_offs = 0x60,
+ .syss_offs = 0x64,
+ .sysc_flags = (SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
+ SYSS_HAS_RESET_STATUS),
+ .sysc_fields = &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap2xxx_sham_class = {
+ .name = "sham",
+ .sysc = &omap2_sham_sysc,
+};
+
+struct omap_hwmod_irq_info omap2_sham_mpu_irqs[] = {
+ { .irq = 51 + OMAP_INTC_START, },
+ { .irq = -1 }
+};
+
+struct omap_hwmod omap2xxx_sham_hwmod = {
+ .name = "sham",
+ .mpu_irqs = omap2_sham_mpu_irqs,
+ .main_clk = "l4_ck",
+ .prcm = {
+ .omap2 = {
+ .module_offs = CORE_MOD,
+ .prcm_reg_id = 4,
+ .module_bit = OMAP24XX_EN_SHA_SHIFT,
+ .idlest_reg_id = 4,
+ .idlest_idle_bit = OMAP24XX_ST_SHA_SHIFT,
+ },
+ },
+ .class = &omap2xxx_sham_class,
+};
diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.h b/arch/arm/mach-omap2/omap_hwmod_common_data.h
index 2bc8f17..74a7b7a 100644
--- a/arch/arm/mach-omap2/omap_hwmod_common_data.h
+++ b/arch/arm/mach-omap2/omap_hwmod_common_data.h
@@ -78,6 +78,7 @@ extern struct omap_hwmod omap2xxx_mcspi2_hwmod;
extern struct omap_hwmod omap2xxx_counter_32k_hwmod;
extern struct omap_hwmod omap2xxx_gpmc_hwmod;
extern struct omap_hwmod omap2xxx_rng_hwmod;
+extern struct omap_hwmod omap2xxx_sham_hwmod;
/* Common interface data across OMAP2xxx */
extern struct omap_hwmod_ocp_if omap2xxx_l3_main__l4_core;
@@ -105,6 +106,7 @@ extern struct omap_hwmod_ocp_if omap2xxx_l4_core__dss_dispc;
extern struct omap_hwmod_ocp_if omap2xxx_l4_core__dss_rfbi;
extern struct omap_hwmod_ocp_if omap2xxx_l4_core__dss_venc;
extern struct omap_hwmod_ocp_if omap2xxx_l4_core__rng;
+extern struct omap_hwmod_ocp_if omap2xxx_l4_core__sham;
/* Common IP block data */
extern struct omap_hwmod_dma_info omap2_uart1_sdma_reqs[];
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
2012-10-19 21:53 ` [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
@ 2012-10-19 21:53 ` Mark A. Greer
2012-10-20 19:40 ` Paul Walmsley
2012-10-19 21:53 ` [PATCH 3/7] ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
` (5 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Add the DMA information for the OMAP2 SHA module.
CC: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c | 2 +-
arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c
index bb314c5..4b4fd5f 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_interconnect_data.c
@@ -405,5 +405,5 @@ struct omap_hwmod_ocp_if omap2xxx_l4_core__sham = {
.slave = &omap2xxx_sham_hwmod,
.clk = "sha_ick",
.addr = omap2xxx_sham_addrs,
- .user = OCP_USER_MPU,
+ .user = OCP_USER_MPU | OCP_USER_SDMA,
};
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
index a041670..703b269 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
@@ -873,9 +873,15 @@ struct omap_hwmod_irq_info omap2_sham_mpu_irqs[] = {
{ .irq = -1 }
};
+struct omap_hwmod_dma_info omap2_sham_sdma_chs[] = {
+ { .name = "rx", .dma_req = OMAP24XX_DMA_SHA1MD5_RX },
+ { .dma_req = -1 }
+};
+
struct omap_hwmod omap2xxx_sham_hwmod = {
.name = "sham",
.mpu_irqs = omap2_sham_mpu_irqs,
+ .sdma_reqs = omap2_sham_sdma_chs,
.main_clk = "l4_ck",
.prcm = {
.omap2 = {
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 3/7] ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
2012-10-19 21:53 ` [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
2012-10-19 21:53 ` [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module Mark A. Greer
@ 2012-10-19 21:53 ` Mark A. Greer
2012-10-20 19:41 ` Paul Walmsley
2012-10-19 21:53 ` [PATCH 4/7] ARM: OMAP2+: Remove unnecessary message when no SHA IP is present Mark A. Greer
` (4 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Convert the device data for the OMAP3 SHAM2 (SHA1/MD5) crypto IP
from explicit platform_data to hwmod. When bit 27 (OMAP3430_ST_SHA12_MASK)
of the CM_IDLEST1_CORE register is 0, the SHA2 IP is present.
CC: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
arch/arm/mach-omap2/clock3xxx_data.c | 1 +
arch/arm/mach-omap2/devices.c | 49 ++++--------------------
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 60 ++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 41 deletions(-)
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index 1f42c9d..63f9ec4 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3341,6 +3341,7 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL, "mmchs3_ick", &mmchs3_ick, CK_3430ES2PLUS | CK_AM35XX | CK_36XX),
CLK(NULL, "icr_ick", &icr_ick, CK_34XX | CK_36XX),
CLK("omap-aes", "ick", &aes2_ick, CK_34XX | CK_36XX),
+ CLK(NULL, "sha12_ick", &sha12_ick, CK_34XX | CK_36XX),
CLK("omap-sham", "ick", &sha12_ick, CK_34XX | CK_36XX),
CLK(NULL, "des2_ick", &des2_ick, CK_34XX | CK_36XX),
CLK("omap_hsmmc.1", "ick", &mmchs2_ick, CK_3XXX),
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 5b613fa..40211de 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -36,6 +36,7 @@
#include "devices.h"
#include "cm2xxx_3xxx.h"
#include "cm-regbits-24xx.h"
+#include "cm-regbits-34xx.h"
#define L3_MODULES_MAX_LEN 12
#define L3_MODULES 3
@@ -453,40 +454,14 @@ static void omap_init_rng(void)
WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
}
-#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
-
-#ifdef CONFIG_ARCH_OMAP3
-static struct resource omap3_sham_resources[] = {
- {
- .start = OMAP34XX_SEC_SHA1MD5_BASE,
- .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
- .flags = IORESOURCE_MEM,
- },
- {
- .start = 49 + OMAP_INTC_START,
- .flags = IORESOURCE_IRQ,
- },
- {
- .start = OMAP34XX_DMA_SHA1MD5_RX,
- .flags = IORESOURCE_DMA,
- }
-};
-static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
-#else
-#define omap3_sham_resources NULL
-#define omap3_sham_resources_sz 0
-#endif
-
-static struct platform_device sham_device = {
- .name = "omap-sham",
- .id = -1,
-};
-
-static void omap_init_sham(void)
+static void __init omap_init_sham(void)
{
- if (cpu_is_omap24xx() &&
- (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
- OMAP24XX_ST_SHA_MASK)) {
+ if ((cpu_is_omap24xx() &&
+ (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
+ OMAP24XX_ST_SHA_MASK)) ||
+ (cpu_is_omap34xx() &&
+ (!(omap2_cm_read_mod_reg(CORE_MOD, CM_IDLEST1) &
+ OMAP3430_ST_SHA12_MASK)))) {
struct omap_hwmod *oh;
struct platform_device *pdev;
@@ -497,18 +472,10 @@ static void omap_init_sham(void)
pdev = omap_device_build("omap-sham", -1, oh, NULL, 0, NULL,
0, 0);
WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
- } else if (cpu_is_omap34xx()) {
- sham_device.resource = omap3_sham_resources;
- sham_device.num_resources = omap3_sham_resources_sz;
- platform_device_register(&sham_device);
} else {
pr_err("%s: platform not supported\n", __func__);
- return;
}
}
-#else
-static inline void omap_init_sham(void) { }
-#endif
#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index f67b7ee..c09cc60 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3543,6 +3543,65 @@ static struct omap_hwmod_ocp_if omap3xxx_l3_main__gpmc = {
.user = OCP_USER_MPU | OCP_USER_SDMA,
};
+/* l4_core -> SHAM2 (SHA1/MD5) (similar to omap24xx) */
+static struct omap_hwmod_class_sysconfig omap3_sham_sysc = {
+ .rev_offs = 0x5c,
+ .sysc_offs = 0x60,
+ .syss_offs = 0x64,
+ .sysc_flags = (SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
+ SYSS_HAS_RESET_STATUS),
+ .sysc_fields = &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap3xxx_sham_class = {
+ .name = "sham",
+ .sysc = &omap3_sham_sysc,
+};
+
+struct omap_hwmod_irq_info omap3_sham_mpu_irqs[] = {
+ { .irq = 49 + OMAP_INTC_START, },
+ { .irq = -1 }
+};
+
+struct omap_hwmod_dma_info omap3_sham_sdma_reqs[] = {
+ { .name = "rx", .dma_req = OMAP34XX_DMA_SHA1MD5_RX, },
+ { .dma_req = -1 }
+};
+
+struct omap_hwmod omap3xxx_sham_hwmod = {
+ .name = "sham",
+ .mpu_irqs = omap3_sham_mpu_irqs,
+ .sdma_reqs = omap3_sham_sdma_reqs,
+ .main_clk = "sha12_ick",
+ .prcm = {
+ .omap2 = {
+ .module_offs = CORE_MOD,
+ .prcm_reg_id = 1,
+ .module_bit = OMAP3430_EN_SHA12_SHIFT,
+ .idlest_reg_id = 1,
+ .idlest_idle_bit = OMAP3430_ST_SHA12_SHIFT,
+ },
+ },
+ .class = &omap3xxx_sham_class,
+};
+
+static struct omap_hwmod_addr_space omap3xxx_sham_addrs[] = {
+ {
+ .pa_start = 0x480c3000,
+ .pa_end = 0x480c3000 + 0x64 - 1,
+ .flags = ADDR_TYPE_RT
+ },
+ { }
+};
+
+static struct omap_hwmod_ocp_if omap3xxx_l4_core__sham = {
+ .master = &omap3xxx_l4_core_hwmod,
+ .slave = &omap3xxx_sham_hwmod,
+ .clk = "sha12_ick",
+ .addr = omap3xxx_sham_addrs,
+ .user = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l3_main__l4_core,
&omap3xxx_l3_main__l4_per,
@@ -3590,6 +3649,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
&omap34xx_l4_core__mcspi4,
&omap3xxx_l4_wkup__counter_32k,
&omap3xxx_l3_main__gpmc,
+ &omap3xxx_l4_core__sham,
NULL,
};
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 4/7] ARM: OMAP2+: Remove unnecessary message when no SHA IP is present
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
` (2 preceding siblings ...)
2012-10-19 21:53 ` [PATCH 3/7] ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
@ 2012-10-19 21:53 ` Mark A. Greer
2012-10-19 21:53 ` [PATCH 5/7] crypto: omap-sham: Convert to use pm_runtime API Mark A. Greer
` (3 subsequent siblings)
7 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Remove the error message that prints when there is no SHA IP
present to make it consistent with all the other IPs.
CC: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
arch/arm/mach-omap2/devices.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 40211de..8784812 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -472,8 +472,6 @@ static void __init omap_init_sham(void)
pdev = omap_device_build("omap-sham", -1, oh, NULL, 0, NULL,
0, 0);
WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
- } else {
- pr_err("%s: platform not supported\n", __func__);
}
}
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/7] crypto: omap-sham: Convert to use pm_runtime API
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
` (3 preceding siblings ...)
2012-10-19 21:53 ` [PATCH 4/7] ARM: OMAP2+: Remove unnecessary message when no SHA IP is present Mark A. Greer
@ 2012-10-19 21:53 ` Mark A. Greer
2012-10-19 21:53 ` [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API Mark A. Greer
` (2 subsequent siblings)
7 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Convert the omap-sham crypto driver to use the
pm_runtime API instead of the clk API.
CC: Kevin Hilman <khilman@deeprootsystems.com>
CC: Paul Walmsley <paul@pwsan.com>
CC: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
drivers/crypto/omap-sham.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index a3fd6fc..acb85df 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -22,12 +22,12 @@
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
-#include <linux/clk.h>
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
+#include <linux/pm_runtime.h>
#include <linux/delay.h>
#include <linux/crypto.h>
#include <linux/cryptohash.h>
@@ -141,7 +141,6 @@ struct omap_sham_dev {
struct device *dev;
void __iomem *io_base;
int irq;
- struct clk *iclk;
spinlock_t lock;
int err;
int dma;
@@ -238,8 +237,6 @@ static void omap_sham_copy_ready_hash(struct ahash_request *req)
static int omap_sham_hw_init(struct omap_sham_dev *dd)
{
- clk_enable(dd->iclk);
-
if (!test_bit(FLAGS_INIT, &dd->flags)) {
omap_sham_write_mask(dd, SHA_REG_MASK,
SHA_REG_MASK_SOFTRESET, SHA_REG_MASK_SOFTRESET);
@@ -653,7 +650,6 @@ static void omap_sham_finish_req(struct ahash_request *req, int err)
/* atomic operation is not needed here */
dd->flags &= ~(BIT(FLAGS_BUSY) | BIT(FLAGS_FINAL) | BIT(FLAGS_CPU) |
BIT(FLAGS_DMA_READY) | BIT(FLAGS_OUTPUT_READY));
- clk_disable(dd->iclk);
if (req->base.complete)
req->base.complete(&req->base, err);
@@ -1198,14 +1194,6 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
if (err)
goto dma_err;
- /* Initializing the clock */
- dd->iclk = clk_get(dev, "ick");
- if (IS_ERR(dd->iclk)) {
- dev_err(dev, "clock intialization failed.\n");
- err = PTR_ERR(dd->iclk);
- goto clk_err;
- }
-
dd->io_base = ioremap(dd->phys_base, SZ_4K);
if (!dd->io_base) {
dev_err(dev, "can't ioremap\n");
@@ -1213,11 +1201,12 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
goto io_err;
}
- clk_enable(dd->iclk);
+ pm_runtime_enable(dev);
+ pm_runtime_get_sync(dev);
+
dev_info(dev, "hw accel on OMAP rev %u.%u\n",
(omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MAJOR) >> 4,
omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MINOR);
- clk_disable(dd->iclk);
spin_lock(&sham.lock);
list_add_tail(&dd->list, &sham.dev_list);
@@ -1235,9 +1224,8 @@ err_algs:
for (j = 0; j < i; j++)
crypto_unregister_ahash(&algs[j]);
iounmap(dd->io_base);
+ pm_runtime_disable(dev);
io_err:
- clk_put(dd->iclk);
-clk_err:
omap_sham_dma_cleanup(dd);
dma_err:
if (dd->irq >= 0)
@@ -1266,7 +1254,8 @@ static int __devexit omap_sham_remove(struct platform_device *pdev)
crypto_unregister_ahash(&algs[i]);
tasklet_kill(&dd->done_task);
iounmap(dd->io_base);
- clk_put(dd->iclk);
+ pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
omap_sham_dma_cleanup(dd);
if (dd->irq >= 0)
free_irq(dd->irq, dd);
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
` (4 preceding siblings ...)
2012-10-19 21:53 ` [PATCH 5/7] crypto: omap-sham: Convert to use pm_runtime API Mark A. Greer
@ 2012-10-19 21:53 ` Mark A. Greer
2012-10-21 11:52 ` Kasatkin, Dmitry
2012-10-19 21:54 ` [PATCH 7/7] crypto: omap_sham: Remove usage of private DMA API Mark A. Greer
2012-10-20 19:34 ` [PATCH 0/7] crypto: omap-sham updates Paul Walmsley
7 siblings, 1 reply; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:53 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Add code to use the new dmaengine API alongside
the existing DMA code that uses the private
OMAP DMA API. The API to use is chosen by
defining or undefining 'OMAP_SHAM_DMA_PRIVATE'.
CC: Russell King <rmk+kernel@arm.linux.org.uk>
CC: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
drivers/crypto/omap-sham.c | 150 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 145 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index acb85df..c782f60 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -13,6 +13,8 @@
* Some ideas are from old omap-sha1-md5.c driver.
*/
+#define OMAP_SHAM_DMA_PRIVATE
+
#define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/err.h>
@@ -27,6 +29,10 @@
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
+#ifndef OMAP_SHAM_DMA_PRIVATE
+#include <linux/dmaengine.h>
+#include <linux/omap-dma.h>
+#endif
#include <linux/pm_runtime.h>
#include <linux/delay.h>
#include <linux/crypto.h>
@@ -37,9 +43,11 @@
#include <crypto/hash.h>
#include <crypto/internal/hash.h>
+#ifdef OMAP_SHAM_DMA_PRIVATE
#include <plat/cpu.h>
#include <plat/dma.h>
#include <mach/irqs.h>
+#endif
#define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04))
#define SHA_REG_DIN(x) (0x1C + ((x) * 0x04))
@@ -47,6 +55,8 @@
#define SHA1_MD5_BLOCK_SIZE SHA1_BLOCK_SIZE
#define MD5_DIGEST_SIZE 16
+#define DST_MAXBURST 16 /* Really element number (en) */
+
#define SHA_REG_DIGCNT 0x14
#define SHA_REG_CTRL 0x18
@@ -110,6 +120,9 @@ struct omap_sham_reqctx {
/* walk state */
struct scatterlist *sg;
+#ifndef OMAP_SHAM_DMA_PRIVATE
+ struct scatterlist sgl;
+#endif
unsigned int offset; /* offset in current sg */
unsigned int total; /* total request */
@@ -143,8 +156,12 @@ struct omap_sham_dev {
int irq;
spinlock_t lock;
int err;
+#ifdef OMAP_SHAM_DMA_PRIVATE
int dma;
int dma_lch;
+#else
+ struct dma_chan *dma_lch;
+#endif
struct tasklet_struct done_task;
unsigned long flags;
@@ -312,15 +329,32 @@ static int omap_sham_xmit_cpu(struct omap_sham_dev *dd, const u8 *buf,
return -EINPROGRESS;
}
+#ifndef OMAP_SHAM_DMA_PRIVATE
+static void omap_sham_dma_callback(void *param)
+{
+ struct omap_sham_dev *dd = param;
+
+ set_bit(FLAGS_DMA_READY, &dd->flags);
+ tasklet_schedule(&dd->done_task);
+}
+#endif
+
static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
- size_t length, int final)
+ size_t length, int final, int is_sg)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
+#ifdef OMAP_SHAM_DMA_PRIVATE
int len32;
+#else
+ struct dma_async_tx_descriptor *tx;
+ struct dma_slave_config cfg;
+ int ret;
+#endif
dev_dbg(dd->dev, "xmit_dma: digcnt: %d, length: %d, final: %d\n",
ctx->digcnt, length, final);
+#ifdef OMAP_SHAM_DMA_PRIVATE
len32 = DIV_ROUND_UP(length, sizeof(u32));
omap_set_dma_transfer_params(dd->dma_lch, OMAP_DMA_DATA_TYPE_S32, len32,
@@ -330,6 +364,48 @@ static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
omap_set_dma_src_params(dd->dma_lch, 0, OMAP_DMA_AMODE_POST_INC,
dma_addr, 0, 0);
+#else
+ memset(&cfg, 0, sizeof(cfg));
+
+ cfg.dst_addr = dd->phys_base + SHA_REG_DIN(0);
+ cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+ cfg.dst_maxburst = DST_MAXBURST;
+
+ ret = dmaengine_slave_config(dd->dma_lch, &cfg);
+ if (ret) {
+ pr_err("omap-sham: can't configure dmaengine slave: %d\n", ret);
+ return ret;
+ }
+
+ if (is_sg) {
+ /*
+ * The SG entry passed in may not have the 'length' member
+ * set correctly so use a local SG entry (sgl) with the
+ * proper value for 'length' instead. If this is not done,
+ * the dmaengine may try to DMA the incorrect amount of data.
+ */
+ sg_init_table(&ctx->sgl, 1);
+ ctx->sgl.page_link = ctx->sg->page_link;
+ ctx->sgl.offset = ctx->sg->offset;
+ sg_dma_len(&ctx->sgl) = length;
+ sg_dma_address(&ctx->sgl) = sg_dma_address(ctx->sg);
+
+ tx = dmaengine_prep_slave_sg(dd->dma_lch, &ctx->sgl, 1,
+ DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+ } else {
+ tx = dmaengine_prep_slave_single(dd->dma_lch, dma_addr, length,
+ DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+ }
+
+ if (!tx) {
+ dev_err(dd->dev, "prep_slave_sg/single() failed\n");
+ return -EINVAL;
+ }
+
+ tx->callback = omap_sham_dma_callback;
+ tx->callback_param = dd;
+#endif
+
omap_sham_write_ctrl(dd, length, final, 1);
ctx->digcnt += length;
@@ -339,7 +415,12 @@ static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
set_bit(FLAGS_DMA_ACTIVE, &dd->flags);
+#ifdef OMAP_SHAM_DMA_PRIVATE
omap_start_dma(dd->dma_lch);
+#else
+ dmaengine_submit(tx);
+ dma_async_issue_pending(dd->dma_lch);
+#endif
return -EINPROGRESS;
}
@@ -386,6 +467,8 @@ static int omap_sham_xmit_dma_map(struct omap_sham_dev *dd,
struct omap_sham_reqctx *ctx,
size_t length, int final)
{
+ int ret;
+
ctx->dma_addr = dma_map_single(dd->dev, ctx->buffer, ctx->buflen,
DMA_TO_DEVICE);
if (dma_mapping_error(dd->dev, ctx->dma_addr)) {
@@ -395,8 +478,12 @@ static int omap_sham_xmit_dma_map(struct omap_sham_dev *dd,
ctx->flags &= ~BIT(FLAGS_SG);
- /* next call does not fail... so no unmap in the case of error */
- return omap_sham_xmit_dma(dd, ctx->dma_addr, length, final);
+ ret = omap_sham_xmit_dma(dd, ctx->dma_addr, length, final, 0);
+ if (ret)
+ dma_unmap_single(dd->dev, ctx->dma_addr, ctx->buflen,
+ DMA_TO_DEVICE);
+
+ return ret;
}
static int omap_sham_update_dma_slow(struct omap_sham_dev *dd)
@@ -431,6 +518,7 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
unsigned int length, final, tail;
struct scatterlist *sg;
+ int ret;
if (!ctx->total)
return 0;
@@ -438,6 +526,17 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
if (ctx->bufcnt || ctx->offset)
return omap_sham_update_dma_slow(dd);
+#ifndef OMAP_SHAM_DMA_PRIVATE
+ /*
+ * Don't use the sg interface when the transfer size is less
+ * than the number of elements in a DMA frame. Otherwise,
+ * the dmaengine infrastructure will calculate that it needs
+ * to transfer 0 frames which ultimately fails.
+ */
+ if (ctx->total < (DST_MAXBURST * sizeof(u32)))
+ return omap_sham_update_dma_slow(dd);
+#endif
+
dev_dbg(dd->dev, "fast: digcnt: %d, bufcnt: %u, total: %u\n",
ctx->digcnt, ctx->bufcnt, ctx->total);
@@ -475,8 +574,11 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
final = (ctx->flags & BIT(FLAGS_FINUP)) && !ctx->total;
- /* next call does not fail... so no unmap in the case of error */
- return omap_sham_xmit_dma(dd, sg_dma_address(ctx->sg), length, final);
+ ret = omap_sham_xmit_dma(dd, sg_dma_address(ctx->sg), length, final, 1);
+ if (ret)
+ dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE);
+
+ return ret;
}
static int omap_sham_update_cpu(struct omap_sham_dev *dd)
@@ -495,7 +597,12 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
+#ifdef OMAP_SHAM_DMA_PRIVATE
omap_stop_dma(dd->dma_lch);
+#else
+ dmaengine_terminate_all(dd->dma_lch);
+#endif
+
if (ctx->flags & BIT(FLAGS_SG)) {
dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE);
if (ctx->sg->length == ctx->offset) {
@@ -696,6 +803,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,
if (err)
goto err1;
+#ifdef OMAP_SHAM_DMA_PRIVATE
omap_set_dma_dest_params(dd->dma_lch, 0,
OMAP_DMA_AMODE_CONSTANT,
dd->phys_base + SHA_REG_DIN(0), 0, 16);
@@ -705,6 +813,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,
omap_set_dma_src_burst_mode(dd->dma_lch,
OMAP_DMA_DATA_BURST_4);
+#endif
if (ctx->digcnt)
/* request has changed - restore hash */
@@ -1096,6 +1205,7 @@ static irqreturn_t omap_sham_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
+#ifdef OMAP_SHAM_DMA_PRIVATE
static void omap_sham_dma_callback(int lch, u16 ch_status, void *data)
{
struct omap_sham_dev *dd = data;
@@ -1133,12 +1243,17 @@ static void omap_sham_dma_cleanup(struct omap_sham_dev *dd)
dd->dma_lch = -1;
}
}
+#endif
static int __devinit omap_sham_probe(struct platform_device *pdev)
{
struct omap_sham_dev *dd;
struct device *dev = &pdev->dev;
struct resource *res;
+#ifndef OMAP_SHAM_DMA_PRIVATE
+ dma_cap_mask_t mask;
+ unsigned dma_chan;
+#endif
int err, i, j;
dd = kzalloc(sizeof(struct omap_sham_dev), GFP_KERNEL);
@@ -1173,7 +1288,11 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
err = -ENODEV;
goto res_err;
}
+#ifdef OMAP_SHAM_DMA_PRIVATE
dd->dma = res->start;
+#else
+ dma_chan = res->start;
+#endif
/* Get the IRQ */
dd->irq = platform_get_irq(pdev, 0);
@@ -1190,9 +1309,22 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
goto res_err;
}
+#ifdef OMAP_SHAM_DMA_PRIVATE
err = omap_sham_dma_init(dd);
if (err)
goto dma_err;
+#else
+ dma_cap_zero(mask);
+ dma_cap_set(DMA_SLAVE, mask);
+
+ dd->dma_lch = dma_request_channel(mask, omap_dma_filter_fn, &dma_chan);
+ if (!dd->dma_lch) {
+ dev_err(dev, "unable to obtain RX DMA engine channel %u\n",
+ dma_chan);
+ err = -ENXIO;
+ goto dma_err;
+ }
+#endif
dd->io_base = ioremap(dd->phys_base, SZ_4K);
if (!dd->io_base) {
@@ -1226,7 +1358,11 @@ err_algs:
iounmap(dd->io_base);
pm_runtime_disable(dev);
io_err:
+#ifdef OMAP_SHAM_DMA_PRIVATE
omap_sham_dma_cleanup(dd);
+#else
+ dma_release_channel(dd->dma_lch);
+#endif
dma_err:
if (dd->irq >= 0)
free_irq(dd->irq, dd);
@@ -1256,7 +1392,11 @@ static int __devexit omap_sham_remove(struct platform_device *pdev)
iounmap(dd->io_base);
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
+#ifdef OMAP_SHAM_DMA_PRIVATE
omap_sham_dma_cleanup(dd);
+#else
+ dma_release_channel(dd->dma_lch);
+#endif
if (dd->irq >= 0)
free_irq(dd->irq, dd);
kfree(dd);
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 7/7] crypto: omap_sham: Remove usage of private DMA API
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
` (5 preceding siblings ...)
2012-10-19 21:53 ` [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API Mark A. Greer
@ 2012-10-19 21:54 ` Mark A. Greer
2012-10-20 19:34 ` [PATCH 0/7] crypto: omap-sham updates Paul Walmsley
7 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-19 21:54 UTC (permalink / raw)
To: linux-arm-kernel
From: "Mark A. Greer" <mgreer@animalcreek.com>
Remove usage of the private OMAP DMA API.
The dmaengine API will be used instead.
CC: Russell King <rmk+kernel@arm.linux.org.uk>
CC: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
---
drivers/crypto/omap-sham.c | 117 ---------------------------------------------
1 file changed, 117 deletions(-)
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index c782f60..627f75e 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -13,8 +13,6 @@
* Some ideas are from old omap-sha1-md5.c driver.
*/
-#define OMAP_SHAM_DMA_PRIVATE
-
#define pr_fmt(fmt) "%s: " fmt, __func__
#include <linux/err.h>
@@ -29,10 +27,8 @@
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#include <linux/dma-mapping.h>
-#ifndef OMAP_SHAM_DMA_PRIVATE
#include <linux/dmaengine.h>
#include <linux/omap-dma.h>
-#endif
#include <linux/pm_runtime.h>
#include <linux/delay.h>
#include <linux/crypto.h>
@@ -43,12 +39,6 @@
#include <crypto/hash.h>
#include <crypto/internal/hash.h>
-#ifdef OMAP_SHAM_DMA_PRIVATE
-#include <plat/cpu.h>
-#include <plat/dma.h>
-#include <mach/irqs.h>
-#endif
-
#define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04))
#define SHA_REG_DIN(x) (0x1C + ((x) * 0x04))
@@ -120,9 +110,7 @@ struct omap_sham_reqctx {
/* walk state */
struct scatterlist *sg;
-#ifndef OMAP_SHAM_DMA_PRIVATE
struct scatterlist sgl;
-#endif
unsigned int offset; /* offset in current sg */
unsigned int total; /* total request */
@@ -156,12 +144,7 @@ struct omap_sham_dev {
int irq;
spinlock_t lock;
int err;
-#ifdef OMAP_SHAM_DMA_PRIVATE
- int dma;
- int dma_lch;
-#else
struct dma_chan *dma_lch;
-#endif
struct tasklet_struct done_task;
unsigned long flags;
@@ -329,7 +312,6 @@ static int omap_sham_xmit_cpu(struct omap_sham_dev *dd, const u8 *buf,
return -EINPROGRESS;
}
-#ifndef OMAP_SHAM_DMA_PRIVATE
static void omap_sham_dma_callback(void *param)
{
struct omap_sham_dev *dd = param;
@@ -337,34 +319,18 @@ static void omap_sham_dma_callback(void *param)
set_bit(FLAGS_DMA_READY, &dd->flags);
tasklet_schedule(&dd->done_task);
}
-#endif
static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
size_t length, int final, int is_sg)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
-#ifdef OMAP_SHAM_DMA_PRIVATE
- int len32;
-#else
struct dma_async_tx_descriptor *tx;
struct dma_slave_config cfg;
int ret;
-#endif
dev_dbg(dd->dev, "xmit_dma: digcnt: %d, length: %d, final: %d\n",
ctx->digcnt, length, final);
-#ifdef OMAP_SHAM_DMA_PRIVATE
- len32 = DIV_ROUND_UP(length, sizeof(u32));
-
- omap_set_dma_transfer_params(dd->dma_lch, OMAP_DMA_DATA_TYPE_S32, len32,
- 1, OMAP_DMA_SYNC_PACKET, dd->dma,
- OMAP_DMA_DST_SYNC_PREFETCH);
-
- omap_set_dma_src_params(dd->dma_lch, 0, OMAP_DMA_AMODE_POST_INC,
- dma_addr, 0, 0);
-
-#else
memset(&cfg, 0, sizeof(cfg));
cfg.dst_addr = dd->phys_base + SHA_REG_DIN(0);
@@ -404,7 +370,6 @@ static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
tx->callback = omap_sham_dma_callback;
tx->callback_param = dd;
-#endif
omap_sham_write_ctrl(dd, length, final, 1);
@@ -415,12 +380,8 @@ static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
set_bit(FLAGS_DMA_ACTIVE, &dd->flags);
-#ifdef OMAP_SHAM_DMA_PRIVATE
- omap_start_dma(dd->dma_lch);
-#else
dmaengine_submit(tx);
dma_async_issue_pending(dd->dma_lch);
-#endif
return -EINPROGRESS;
}
@@ -526,7 +487,6 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
if (ctx->bufcnt || ctx->offset)
return omap_sham_update_dma_slow(dd);
-#ifndef OMAP_SHAM_DMA_PRIVATE
/*
* Don't use the sg interface when the transfer size is less
* than the number of elements in a DMA frame. Otherwise,
@@ -535,7 +495,6 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
*/
if (ctx->total < (DST_MAXBURST * sizeof(u32)))
return omap_sham_update_dma_slow(dd);
-#endif
dev_dbg(dd->dev, "fast: digcnt: %d, bufcnt: %u, total: %u\n",
ctx->digcnt, ctx->bufcnt, ctx->total);
@@ -597,11 +556,7 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)
{
struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
-#ifdef OMAP_SHAM_DMA_PRIVATE
- omap_stop_dma(dd->dma_lch);
-#else
dmaengine_terminate_all(dd->dma_lch);
-#endif
if (ctx->flags & BIT(FLAGS_SG)) {
dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE);
@@ -803,18 +758,6 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,
if (err)
goto err1;
-#ifdef OMAP_SHAM_DMA_PRIVATE
- omap_set_dma_dest_params(dd->dma_lch, 0,
- OMAP_DMA_AMODE_CONSTANT,
- dd->phys_base + SHA_REG_DIN(0), 0, 16);
-
- omap_set_dma_dest_burst_mode(dd->dma_lch,
- OMAP_DMA_DATA_BURST_16);
-
- omap_set_dma_src_burst_mode(dd->dma_lch,
- OMAP_DMA_DATA_BURST_4);
-#endif
-
if (ctx->digcnt)
/* request has changed - restore hash */
omap_sham_copy_hash(req, 0);
@@ -1205,55 +1148,13 @@ static irqreturn_t omap_sham_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
-#ifdef OMAP_SHAM_DMA_PRIVATE
-static void omap_sham_dma_callback(int lch, u16 ch_status, void *data)
-{
- struct omap_sham_dev *dd = data;
-
- if (ch_status != OMAP_DMA_BLOCK_IRQ) {
- pr_err("omap-sham DMA error status: 0x%hx\n", ch_status);
- dd->err = -EIO;
- clear_bit(FLAGS_INIT, &dd->flags);/* request to re-initialize */
- }
-
- set_bit(FLAGS_DMA_READY, &dd->flags);
- tasklet_schedule(&dd->done_task);
-}
-
-static int omap_sham_dma_init(struct omap_sham_dev *dd)
-{
- int err;
-
- dd->dma_lch = -1;
-
- err = omap_request_dma(dd->dma, dev_name(dd->dev),
- omap_sham_dma_callback, dd, &dd->dma_lch);
- if (err) {
- dev_err(dd->dev, "Unable to request DMA channel\n");
- return err;
- }
-
- return 0;
-}
-
-static void omap_sham_dma_cleanup(struct omap_sham_dev *dd)
-{
- if (dd->dma_lch >= 0) {
- omap_free_dma(dd->dma_lch);
- dd->dma_lch = -1;
- }
-}
-#endif
-
static int __devinit omap_sham_probe(struct platform_device *pdev)
{
struct omap_sham_dev *dd;
struct device *dev = &pdev->dev;
struct resource *res;
-#ifndef OMAP_SHAM_DMA_PRIVATE
dma_cap_mask_t mask;
unsigned dma_chan;
-#endif
int err, i, j;
dd = kzalloc(sizeof(struct omap_sham_dev), GFP_KERNEL);
@@ -1288,11 +1189,7 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
err = -ENODEV;
goto res_err;
}
-#ifdef OMAP_SHAM_DMA_PRIVATE
- dd->dma = res->start;
-#else
dma_chan = res->start;
-#endif
/* Get the IRQ */
dd->irq = platform_get_irq(pdev, 0);
@@ -1309,11 +1206,6 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
goto res_err;
}
-#ifdef OMAP_SHAM_DMA_PRIVATE
- err = omap_sham_dma_init(dd);
- if (err)
- goto dma_err;
-#else
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
@@ -1324,7 +1216,6 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
err = -ENXIO;
goto dma_err;
}
-#endif
dd->io_base = ioremap(dd->phys_base, SZ_4K);
if (!dd->io_base) {
@@ -1358,11 +1249,7 @@ err_algs:
iounmap(dd->io_base);
pm_runtime_disable(dev);
io_err:
-#ifdef OMAP_SHAM_DMA_PRIVATE
- omap_sham_dma_cleanup(dd);
-#else
dma_release_channel(dd->dma_lch);
-#endif
dma_err:
if (dd->irq >= 0)
free_irq(dd->irq, dd);
@@ -1392,11 +1279,7 @@ static int __devexit omap_sham_remove(struct platform_device *pdev)
iounmap(dd->io_base);
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-#ifdef OMAP_SHAM_DMA_PRIVATE
- omap_sham_dma_cleanup(dd);
-#else
dma_release_channel(dd->dma_lch);
-#endif
if (dd->irq >= 0)
free_irq(dd->irq, dd);
kfree(dd);
--
1.7.12
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 0/7] crypto: omap-sham updates
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
` (6 preceding siblings ...)
2012-10-19 21:54 ` [PATCH 7/7] crypto: omap_sham: Remove usage of private DMA API Mark A. Greer
@ 2012-10-20 19:34 ` Paul Walmsley
2012-10-22 19:38 ` Mark A. Greer
7 siblings, 1 reply; 21+ messages in thread
From: Paul Walmsley @ 2012-10-20 19:34 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, 19 Oct 2012, Mark A. Greer wrote:
> From: "Mark A. Greer" <mgreer@animalcreek.com>
>
> This series updates the crypto omap-sham driver and supporting
> infrastructure.
Looks pretty good; this will make it easier for us to migrate the
omap_hwmod code to a LDM bus. Will reply to the original patches with a
few comments and questions.
One general comment - for us to merge these through the OMAP tree, we'll
need acks from the hardware crypto folks. AFAIK they are:
CRYPTO API
M: Herbert Xu <herbert@gondor.apana.org.au>
M: "David S. Miller" <davem@davemloft.net>
L: linux-crypto at vger.kernel.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git
S: Maintained
F: Documentation/crypto/
F: arch/*/crypto/
F: crypto/
F: drivers/crypto/
F: include/crypto/
So it would be helpful if you could send those patches along to those
people and lists too, and ask them for acks.
- Paul
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-19 21:53 ` [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
@ 2012-10-20 19:40 ` Paul Walmsley
2012-10-22 19:33 ` Mark A. Greer
0 siblings, 1 reply; 21+ messages in thread
From: Paul Walmsley @ 2012-10-20 19:40 UTC (permalink / raw)
To: linux-arm-kernel
Hi
a few comments:
On Fri, 19 Oct 2012, Mark A. Greer wrote:
> From: "Mark A. Greer" <mgreer@animalcreek.com>
>
> Convert the device data for the OMAP2 SHAM crypto IP from
> explicit platform_data to hwmod. When bit 1 (OMAP24XX_ST_SHA_MASK)
> of the CM_IDLEST4_CORE register is set, the SHA IP is present.
>
> CC: Paul Walmsley <paul@pwsan.com>
> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
...
>
> diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
> index c3cde1a..a09603c 100644
> --- a/arch/arm/mach-omap2/clock2420_data.c
> +++ b/arch/arm/mach-omap2/clock2420_data.c
> @@ -1905,6 +1905,7 @@ static struct omap_clk omap2420_clks[] = {
> CLK(NULL, "vlynq_ick", &vlynq_ick, CK_242X),
> CLK(NULL, "vlynq_fck", &vlynq_fck, CK_242X),
> CLK(NULL, "des_ick", &des_ick, CK_242X),
> + CLK(NULL, "sha_ick", &sha_ick, CK_242X),
This isn't needed; this alias already exists two lines below.
> CLK("omap-sham", "ick", &sha_ick, CK_242X),
> CLK(NULL, "sha_ick", &sha_ick, CK_242X),
> CLK("omap_rng", "ick", &rng_ick, CK_242X),
> diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
> index 22404fe..654e314 100644
> --- a/arch/arm/mach-omap2/clock2430_data.c
> +++ b/arch/arm/mach-omap2/clock2430_data.c
> @@ -1992,6 +1992,7 @@ static struct omap_clk omap2430_clks[] = {
> CLK(NULL, "sdma_ick", &sdma_ick, CK_243X),
> CLK(NULL, "sdrc_ick", &sdrc_ick, CK_243X),
> CLK(NULL, "des_ick", &des_ick, CK_243X),
> + CLK(NULL, "sha_ick", &sha_ick, CK_242X),
> CLK("omap-sham", "ick", &sha_ick, CK_243X),
> CLK("omap_rng", "ick", &rng_ick, CK_243X),
> CLK(NULL, "rng_ick", &rng_ick, CK_243X),
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index c8c2117..5b613fa 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -34,6 +34,8 @@
> #include "mux.h"
> #include "control.h"
> #include "devices.h"
> +#include "cm2xxx_3xxx.h"
> +#include "cm-regbits-24xx.h"
>
> #define L3_MODULES_MAX_LEN 12
> #define L3_MODULES 3
> @@ -453,24 +455,6 @@ static void omap_init_rng(void)
>
> #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
>
> -#ifdef CONFIG_ARCH_OMAP2
> -static struct resource omap2_sham_resources[] = {
> - {
> - .start = OMAP24XX_SEC_SHA1MD5_BASE,
> - .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
> - .flags = IORESOURCE_MEM,
> - },
> - {
> - .start = 51 + OMAP_INTC_START,
> - .flags = IORESOURCE_IRQ,
> - }
> -};
> -static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
> -#else
> -#define omap2_sham_resources NULL
> -#define omap2_sham_resources_sz 0
> -#endif
> -
> #ifdef CONFIG_ARCH_OMAP3
> static struct resource omap3_sham_resources[] = {
> {
> @@ -500,17 +484,27 @@ static struct platform_device sham_device = {
>
> static void omap_init_sham(void)
> {
> - if (cpu_is_omap24xx()) {
> - sham_device.resource = omap2_sham_resources;
> - sham_device.num_resources = omap2_sham_resources_sz;
> + if (cpu_is_omap24xx() &&
> + (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
> + OMAP24XX_ST_SHA_MASK)) {
Hmm. Not sure I understand the purpose of this CM read. Don't we want to
initialize this device unconditionally?
Also we're trying to get rid of all of the direct CM/PRM accesses outside
of the prm*.c/cm*.c code. If we need something like this, we should add
some support for it in hwmod & CM code, since that's where the data lives.
- Paul
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module
2012-10-19 21:53 ` [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module Mark A. Greer
@ 2012-10-20 19:40 ` Paul Walmsley
2012-10-22 19:37 ` Mark A. Greer
0 siblings, 1 reply; 21+ messages in thread
From: Paul Walmsley @ 2012-10-20 19:40 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, 19 Oct 2012, Mark A. Greer wrote:
> From: "Mark A. Greer" <mgreer@animalcreek.com>
>
> Add the DMA information for the OMAP2 SHA module.
>
> CC: Paul Walmsley <paul@pwsan.com>
> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
This can probably be combined with the first patch.
- Paul
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/7] ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-19 21:53 ` [PATCH 3/7] ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
@ 2012-10-20 19:41 ` Paul Walmsley
0 siblings, 0 replies; 21+ messages in thread
From: Paul Walmsley @ 2012-10-20 19:41 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, 19 Oct 2012, Mark A. Greer wrote:
> From: "Mark A. Greer" <mgreer@animalcreek.com>
>
> Convert the device data for the OMAP3 SHAM2 (SHA1/MD5) crypto IP
> from explicit platform_data to hwmod. When bit 27 (OMAP3430_ST_SHA12_MASK)
> of the CM_IDLEST1_CORE register is 0, the SHA2 IP is present.
>
> CC: Paul Walmsley <paul@pwsan.com>
> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
...
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 5b613fa..40211de 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -36,6 +36,7 @@
> #include "devices.h"
> #include "cm2xxx_3xxx.h"
> #include "cm-regbits-24xx.h"
> +#include "cm-regbits-34xx.h"
>
> #define L3_MODULES_MAX_LEN 12
> #define L3_MODULES 3
> @@ -453,40 +454,14 @@ static void omap_init_rng(void)
> WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
> }
>
> -#if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
> -
> -#ifdef CONFIG_ARCH_OMAP3
> -static struct resource omap3_sham_resources[] = {
> - {
> - .start = OMAP34XX_SEC_SHA1MD5_BASE,
> - .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
> - .flags = IORESOURCE_MEM,
> - },
> - {
> - .start = 49 + OMAP_INTC_START,
> - .flags = IORESOURCE_IRQ,
> - },
> - {
> - .start = OMAP34XX_DMA_SHA1MD5_RX,
> - .flags = IORESOURCE_DMA,
> - }
> -};
> -static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
> -#else
> -#define omap3_sham_resources NULL
> -#define omap3_sham_resources_sz 0
> -#endif
> -
> -static struct platform_device sham_device = {
> - .name = "omap-sham",
> - .id = -1,
> -};
> -
> -static void omap_init_sham(void)
> +static void __init omap_init_sham(void)
> {
> - if (cpu_is_omap24xx() &&
> - (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
> - OMAP24XX_ST_SHA_MASK)) {
> + if ((cpu_is_omap24xx() &&
> + (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
> + OMAP24XX_ST_SHA_MASK)) ||
> + (cpu_is_omap34xx() &&
> + (!(omap2_cm_read_mod_reg(CORE_MOD, CM_IDLEST1) &
> + OMAP3430_ST_SHA12_MASK)))) {
Same comment here as on the CM read on the 2xxx patch.
- Paul
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API
2012-10-19 21:53 ` [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API Mark A. Greer
@ 2012-10-21 11:52 ` Kasatkin, Dmitry
2012-10-22 20:53 ` Mark A. Greer
0 siblings, 1 reply; 21+ messages in thread
From: Kasatkin, Dmitry @ 2012-10-21 11:52 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
I got only 3 patches out of 7.
Can you please re-submit them also to linux-crypto at vger.kernel.org
That is a list where crypto drivers are discussed.
Thanks.
- Dmitry
On Sat, Oct 20, 2012 at 12:53 AM, Mark A. Greer <mgreer@animalcreek.com> wrote:
> From: "Mark A. Greer" <mgreer@animalcreek.com>
>
> Add code to use the new dmaengine API alongside
> the existing DMA code that uses the private
> OMAP DMA API. The API to use is chosen by
> defining or undefining 'OMAP_SHAM_DMA_PRIVATE'.
>
> CC: Russell King <rmk+kernel@arm.linux.org.uk>
> CC: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
> ---
> drivers/crypto/omap-sham.c | 150 +++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 145 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index acb85df..c782f60 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -13,6 +13,8 @@
> * Some ideas are from old omap-sha1-md5.c driver.
> */
>
> +#define OMAP_SHAM_DMA_PRIVATE
> +
> #define pr_fmt(fmt) "%s: " fmt, __func__
>
> #include <linux/err.h>
> @@ -27,6 +29,10 @@
> #include <linux/platform_device.h>
> #include <linux/scatterlist.h>
> #include <linux/dma-mapping.h>
> +#ifndef OMAP_SHAM_DMA_PRIVATE
> +#include <linux/dmaengine.h>
> +#include <linux/omap-dma.h>
> +#endif
> #include <linux/pm_runtime.h>
> #include <linux/delay.h>
> #include <linux/crypto.h>
> @@ -37,9 +43,11 @@
> #include <crypto/hash.h>
> #include <crypto/internal/hash.h>
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> #include <plat/cpu.h>
> #include <plat/dma.h>
> #include <mach/irqs.h>
> +#endif
>
> #define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04))
> #define SHA_REG_DIN(x) (0x1C + ((x) * 0x04))
> @@ -47,6 +55,8 @@
> #define SHA1_MD5_BLOCK_SIZE SHA1_BLOCK_SIZE
> #define MD5_DIGEST_SIZE 16
>
> +#define DST_MAXBURST 16 /* Really element number (en) */
> +
> #define SHA_REG_DIGCNT 0x14
>
> #define SHA_REG_CTRL 0x18
> @@ -110,6 +120,9 @@ struct omap_sham_reqctx {
>
> /* walk state */
> struct scatterlist *sg;
> +#ifndef OMAP_SHAM_DMA_PRIVATE
> + struct scatterlist sgl;
> +#endif
> unsigned int offset; /* offset in current sg */
> unsigned int total; /* total request */
>
> @@ -143,8 +156,12 @@ struct omap_sham_dev {
> int irq;
> spinlock_t lock;
> int err;
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> int dma;
> int dma_lch;
> +#else
> + struct dma_chan *dma_lch;
> +#endif
> struct tasklet_struct done_task;
>
> unsigned long flags;
> @@ -312,15 +329,32 @@ static int omap_sham_xmit_cpu(struct omap_sham_dev *dd, const u8 *buf,
> return -EINPROGRESS;
> }
>
> +#ifndef OMAP_SHAM_DMA_PRIVATE
> +static void omap_sham_dma_callback(void *param)
> +{
> + struct omap_sham_dev *dd = param;
> +
> + set_bit(FLAGS_DMA_READY, &dd->flags);
> + tasklet_schedule(&dd->done_task);
> +}
> +#endif
> +
> static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
> - size_t length, int final)
> + size_t length, int final, int is_sg)
> {
> struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> int len32;
> +#else
> + struct dma_async_tx_descriptor *tx;
> + struct dma_slave_config cfg;
> + int ret;
> +#endif
>
> dev_dbg(dd->dev, "xmit_dma: digcnt: %d, length: %d, final: %d\n",
> ctx->digcnt, length, final);
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> len32 = DIV_ROUND_UP(length, sizeof(u32));
>
> omap_set_dma_transfer_params(dd->dma_lch, OMAP_DMA_DATA_TYPE_S32, len32,
> @@ -330,6 +364,48 @@ static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
> omap_set_dma_src_params(dd->dma_lch, 0, OMAP_DMA_AMODE_POST_INC,
> dma_addr, 0, 0);
>
> +#else
> + memset(&cfg, 0, sizeof(cfg));
> +
> + cfg.dst_addr = dd->phys_base + SHA_REG_DIN(0);
> + cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
> + cfg.dst_maxburst = DST_MAXBURST;
> +
> + ret = dmaengine_slave_config(dd->dma_lch, &cfg);
> + if (ret) {
> + pr_err("omap-sham: can't configure dmaengine slave: %d\n", ret);
> + return ret;
> + }
> +
> + if (is_sg) {
> + /*
> + * The SG entry passed in may not have the 'length' member
> + * set correctly so use a local SG entry (sgl) with the
> + * proper value for 'length' instead. If this is not done,
> + * the dmaengine may try to DMA the incorrect amount of data.
> + */
> + sg_init_table(&ctx->sgl, 1);
> + ctx->sgl.page_link = ctx->sg->page_link;
> + ctx->sgl.offset = ctx->sg->offset;
> + sg_dma_len(&ctx->sgl) = length;
> + sg_dma_address(&ctx->sgl) = sg_dma_address(ctx->sg);
> +
> + tx = dmaengine_prep_slave_sg(dd->dma_lch, &ctx->sgl, 1,
> + DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> + } else {
> + tx = dmaengine_prep_slave_single(dd->dma_lch, dma_addr, length,
> + DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> + }
> +
> + if (!tx) {
> + dev_err(dd->dev, "prep_slave_sg/single() failed\n");
> + return -EINVAL;
> + }
> +
> + tx->callback = omap_sham_dma_callback;
> + tx->callback_param = dd;
> +#endif
> +
> omap_sham_write_ctrl(dd, length, final, 1);
>
> ctx->digcnt += length;
> @@ -339,7 +415,12 @@ static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr,
>
> set_bit(FLAGS_DMA_ACTIVE, &dd->flags);
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> omap_start_dma(dd->dma_lch);
> +#else
> + dmaengine_submit(tx);
> + dma_async_issue_pending(dd->dma_lch);
> +#endif
>
> return -EINPROGRESS;
> }
> @@ -386,6 +467,8 @@ static int omap_sham_xmit_dma_map(struct omap_sham_dev *dd,
> struct omap_sham_reqctx *ctx,
> size_t length, int final)
> {
> + int ret;
> +
> ctx->dma_addr = dma_map_single(dd->dev, ctx->buffer, ctx->buflen,
> DMA_TO_DEVICE);
> if (dma_mapping_error(dd->dev, ctx->dma_addr)) {
> @@ -395,8 +478,12 @@ static int omap_sham_xmit_dma_map(struct omap_sham_dev *dd,
>
> ctx->flags &= ~BIT(FLAGS_SG);
>
> - /* next call does not fail... so no unmap in the case of error */
> - return omap_sham_xmit_dma(dd, ctx->dma_addr, length, final);
> + ret = omap_sham_xmit_dma(dd, ctx->dma_addr, length, final, 0);
> + if (ret)
> + dma_unmap_single(dd->dev, ctx->dma_addr, ctx->buflen,
> + DMA_TO_DEVICE);
> +
> + return ret;
> }
>
> static int omap_sham_update_dma_slow(struct omap_sham_dev *dd)
> @@ -431,6 +518,7 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
> struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
> unsigned int length, final, tail;
> struct scatterlist *sg;
> + int ret;
>
> if (!ctx->total)
> return 0;
> @@ -438,6 +526,17 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
> if (ctx->bufcnt || ctx->offset)
> return omap_sham_update_dma_slow(dd);
>
> +#ifndef OMAP_SHAM_DMA_PRIVATE
> + /*
> + * Don't use the sg interface when the transfer size is less
> + * than the number of elements in a DMA frame. Otherwise,
> + * the dmaengine infrastructure will calculate that it needs
> + * to transfer 0 frames which ultimately fails.
> + */
> + if (ctx->total < (DST_MAXBURST * sizeof(u32)))
> + return omap_sham_update_dma_slow(dd);
> +#endif
> +
> dev_dbg(dd->dev, "fast: digcnt: %d, bufcnt: %u, total: %u\n",
> ctx->digcnt, ctx->bufcnt, ctx->total);
>
> @@ -475,8 +574,11 @@ static int omap_sham_update_dma_start(struct omap_sham_dev *dd)
>
> final = (ctx->flags & BIT(FLAGS_FINUP)) && !ctx->total;
>
> - /* next call does not fail... so no unmap in the case of error */
> - return omap_sham_xmit_dma(dd, sg_dma_address(ctx->sg), length, final);
> + ret = omap_sham_xmit_dma(dd, sg_dma_address(ctx->sg), length, final, 1);
> + if (ret)
> + dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE);
> +
> + return ret;
> }
>
> static int omap_sham_update_cpu(struct omap_sham_dev *dd)
> @@ -495,7 +597,12 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)
> {
> struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req);
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> omap_stop_dma(dd->dma_lch);
> +#else
> + dmaengine_terminate_all(dd->dma_lch);
> +#endif
> +
> if (ctx->flags & BIT(FLAGS_SG)) {
> dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE);
> if (ctx->sg->length == ctx->offset) {
> @@ -696,6 +803,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,
> if (err)
> goto err1;
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> omap_set_dma_dest_params(dd->dma_lch, 0,
> OMAP_DMA_AMODE_CONSTANT,
> dd->phys_base + SHA_REG_DIN(0), 0, 16);
> @@ -705,6 +813,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,
>
> omap_set_dma_src_burst_mode(dd->dma_lch,
> OMAP_DMA_DATA_BURST_4);
> +#endif
>
> if (ctx->digcnt)
> /* request has changed - restore hash */
> @@ -1096,6 +1205,7 @@ static irqreturn_t omap_sham_irq(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> static void omap_sham_dma_callback(int lch, u16 ch_status, void *data)
> {
> struct omap_sham_dev *dd = data;
> @@ -1133,12 +1243,17 @@ static void omap_sham_dma_cleanup(struct omap_sham_dev *dd)
> dd->dma_lch = -1;
> }
> }
> +#endif
>
> static int __devinit omap_sham_probe(struct platform_device *pdev)
> {
> struct omap_sham_dev *dd;
> struct device *dev = &pdev->dev;
> struct resource *res;
> +#ifndef OMAP_SHAM_DMA_PRIVATE
> + dma_cap_mask_t mask;
> + unsigned dma_chan;
> +#endif
> int err, i, j;
>
> dd = kzalloc(sizeof(struct omap_sham_dev), GFP_KERNEL);
> @@ -1173,7 +1288,11 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
> err = -ENODEV;
> goto res_err;
> }
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> dd->dma = res->start;
> +#else
> + dma_chan = res->start;
> +#endif
>
> /* Get the IRQ */
> dd->irq = platform_get_irq(pdev, 0);
> @@ -1190,9 +1309,22 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
> goto res_err;
> }
>
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> err = omap_sham_dma_init(dd);
> if (err)
> goto dma_err;
> +#else
> + dma_cap_zero(mask);
> + dma_cap_set(DMA_SLAVE, mask);
> +
> + dd->dma_lch = dma_request_channel(mask, omap_dma_filter_fn, &dma_chan);
> + if (!dd->dma_lch) {
> + dev_err(dev, "unable to obtain RX DMA engine channel %u\n",
> + dma_chan);
> + err = -ENXIO;
> + goto dma_err;
> + }
> +#endif
>
> dd->io_base = ioremap(dd->phys_base, SZ_4K);
> if (!dd->io_base) {
> @@ -1226,7 +1358,11 @@ err_algs:
> iounmap(dd->io_base);
> pm_runtime_disable(dev);
> io_err:
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> omap_sham_dma_cleanup(dd);
> +#else
> + dma_release_channel(dd->dma_lch);
> +#endif
> dma_err:
> if (dd->irq >= 0)
> free_irq(dd->irq, dd);
> @@ -1256,7 +1392,11 @@ static int __devexit omap_sham_remove(struct platform_device *pdev)
> iounmap(dd->io_base);
> pm_runtime_put_sync(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> +#ifdef OMAP_SHAM_DMA_PRIVATE
> omap_sham_dma_cleanup(dd);
> +#else
> + dma_release_channel(dd->dma_lch);
> +#endif
> if (dd->irq >= 0)
> free_irq(dd->irq, dd);
> kfree(dd);
> --
> 1.7.12
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-20 19:40 ` Paul Walmsley
@ 2012-10-22 19:33 ` Mark A. Greer
2012-10-22 19:49 ` Paul Walmsley
0 siblings, 1 reply; 21+ messages in thread
From: Mark A. Greer @ 2012-10-22 19:33 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Oct 20, 2012 at 07:40:19PM +0000, Paul Walmsley wrote:
> Hi
Hi Paul.
> a few comments:
>
> On Fri, 19 Oct 2012, Mark A. Greer wrote:
>
> > From: "Mark A. Greer" <mgreer@animalcreek.com>
> >
> > Convert the device data for the OMAP2 SHAM crypto IP from
> > explicit platform_data to hwmod. When bit 1 (OMAP24XX_ST_SHA_MASK)
> > of the CM_IDLEST4_CORE register is set, the SHA IP is present.
> >
> > CC: Paul Walmsley <paul@pwsan.com>
> > Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
>
> ...
>
> >
> > diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
> > index c3cde1a..a09603c 100644
> > --- a/arch/arm/mach-omap2/clock2420_data.c
> > +++ b/arch/arm/mach-omap2/clock2420_data.c
> > @@ -1905,6 +1905,7 @@ static struct omap_clk omap2420_clks[] = {
> > CLK(NULL, "vlynq_ick", &vlynq_ick, CK_242X),
> > CLK(NULL, "vlynq_fck", &vlynq_fck, CK_242X),
> > CLK(NULL, "des_ick", &des_ick, CK_242X),
> > + CLK(NULL, "sha_ick", &sha_ick, CK_242X),
>
> This isn't needed; this alias already exists two lines below.
Umm, yeah. Oops. :)
> > CLK("omap-sham", "ick", &sha_ick, CK_242X),
> > CLK(NULL, "sha_ick", &sha_ick, CK_242X),
> > CLK("omap_rng", "ick", &rng_ick, CK_242X),
> > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > index c8c2117..5b613fa 100644
> > --- a/arch/arm/mach-omap2/devices.c
> > +++ b/arch/arm/mach-omap2/devices.c
> > @@ -500,17 +484,27 @@ static struct platform_device sham_device = {
> >
> > static void omap_init_sham(void)
> > {
> > - if (cpu_is_omap24xx()) {
> > - sham_device.resource = omap2_sham_resources;
> > - sham_device.num_resources = omap2_sham_resources_sz;
> > + if (cpu_is_omap24xx() &&
> > + (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
> > + OMAP24XX_ST_SHA_MASK)) {
>
> Hmm. Not sure I understand the purpose of this CM read. Don't we want to
> initialize this device unconditionally?
No, the device doesn't exist on all parts. This is the only way
to tell if its there (AFAIK).
> Also we're trying to get rid of all of the direct CM/PRM accesses outside
> of the prm*.c/cm*.c code. If we need something like this, we should add
> some support for it in hwmod & CM code, since that's where the data lives.
Okay.
Mark
--
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module
2012-10-20 19:40 ` Paul Walmsley
@ 2012-10-22 19:37 ` Mark A. Greer
2012-10-22 19:53 ` Paul Walmsley
0 siblings, 1 reply; 21+ messages in thread
From: Mark A. Greer @ 2012-10-22 19:37 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Oct 20, 2012 at 07:40:44PM +0000, Paul Walmsley wrote:
> On Fri, 19 Oct 2012, Mark A. Greer wrote:
>
> > From: "Mark A. Greer" <mgreer@animalcreek.com>
> >
> > Add the DMA information for the OMAP2 SHA module.
> >
> > CC: Paul Walmsley <paul@pwsan.com>
> > Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
>
> This can probably be combined with the first patch.
I made it a separate patch because the original omap2xxx code didn't
support DMA and I wanted to keep the first patch an apples-apples
conversion and _add_ functionality in this, separate, patch.
I prefer 2 patches but if you still want me to combine them, let me know.
Mark
--
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 0/7] crypto: omap-sham updates
2012-10-20 19:34 ` [PATCH 0/7] crypto: omap-sham updates Paul Walmsley
@ 2012-10-22 19:38 ` Mark A. Greer
0 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-22 19:38 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Oct 20, 2012 at 07:34:51PM +0000, Paul Walmsley wrote:
> On Fri, 19 Oct 2012, Mark A. Greer wrote:
>
> > From: "Mark A. Greer" <mgreer@animalcreek.com>
> >
> > This series updates the crypto omap-sham driver and supporting
> > infrastructure.
>
> Looks pretty good; this will make it easier for us to migrate the
> omap_hwmod code to a LDM bus. Will reply to the original patches with a
> few comments and questions.
>
> One general comment - for us to merge these through the OMAP tree, we'll
> need acks from the hardware crypto folks. AFAIK they are:
>
> CRYPTO API
> M: Herbert Xu <herbert@gondor.apana.org.au>
> M: "David S. Miller" <davem@davemloft.net>
> L: linux-crypto at vger.kernel.org
> T: git git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git
> S: Maintained
> F: Documentation/crypto/
> F: arch/*/crypto/
> F: crypto/
> F: drivers/crypto/
> F: include/crypto/
>
> So it would be helpful if you could send those patches along to those
> people and lists too, and ask them for acks.
I will do that. Thanks for your feedback.
Mark
--
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-22 19:33 ` Mark A. Greer
@ 2012-10-22 19:49 ` Paul Walmsley
2012-10-23 22:02 ` Mark A. Greer
0 siblings, 1 reply; 21+ messages in thread
From: Paul Walmsley @ 2012-10-22 19:49 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 22 Oct 2012, Mark A. Greer wrote:
> On Sat, Oct 20, 2012 at 07:40:19PM +0000, Paul Walmsley wrote:
>
> > > static void omap_init_sham(void)
> > > {
> > > - if (cpu_is_omap24xx()) {
> > > - sham_device.resource = omap2_sham_resources;
> > > - sham_device.num_resources = omap2_sham_resources_sz;
> > > + if (cpu_is_omap24xx() &&
> > > + (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
> > > + OMAP24XX_ST_SHA_MASK)) {
> >
> > Hmm. Not sure I understand the purpose of this CM read. Don't we want to
> > initialize this device unconditionally?
>
> No, the device doesn't exist on all parts.
It should exist on all OMAP2xxx, AFAIK. (Whether some bootloader
firewalled it off is another matter, of course.)
> This is the only way to tell if its there (AFAIK).
Hmm. I don't think the CM_IDLEST bits work that way, in the general case.
They just indicate whether the PRCM considers that IP block to be
currently accessible. So for example if the clocks are disabled to an IP
block, the CM_IDLEST bit would indicate that it's not accessible. The
software could then enable the clocks, and the CM_IDLEST bit would
indicate that it is accessible. We use this in the clock framework and
hwmod code after enabling clocks to wait until the system considers the IP
block accessible. See for example
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/arm/mach-omap2/clock.c;h=961ac8f7e13d8c84a1cbb4587255ea685520bd18;hb=HEAD#l80
...
Now it's possible that on some TI chips, the CM_IDLEST bit is tied to the
SIdleAck signal originating from the IP block. (I've been told that on
other OMAPs, CM_IDLEST is actually tied to the SIdleReq signal originating
from the PRCM, which is not terribly useful...) So if it's tied to the
SIdleAck signal, and the PRCM clocks are enabled, then it might provide an
indication of whether the IP block exists on that chip. But ultimately
the IP block might still be firewalled off even if it appears to exist to
the PRCM. So for 3xxx, I'd suggest just adding it to the appropriate
GP-specific hwmod init lists, such as omap3xxx_gp_hwmod_ocp_ifs.
- Paul
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module
2012-10-22 19:37 ` Mark A. Greer
@ 2012-10-22 19:53 ` Paul Walmsley
2012-10-22 20:01 ` Mark A. Greer
0 siblings, 1 reply; 21+ messages in thread
From: Paul Walmsley @ 2012-10-22 19:53 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 22 Oct 2012, Mark A. Greer wrote:
> On Sat, Oct 20, 2012 at 07:40:44PM +0000, Paul Walmsley wrote:
> > On Fri, 19 Oct 2012, Mark A. Greer wrote:
> >
> > > From: "Mark A. Greer" <mgreer@animalcreek.com>
> > >
> > > Add the DMA information for the OMAP2 SHA module.
> > >
> > > CC: Paul Walmsley <paul@pwsan.com>
> > > Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
> >
> > This can probably be combined with the first patch.
>
> I made it a separate patch because the original omap2xxx code didn't
> support DMA and I wanted to keep the first patch an apples-apples
> conversion and _add_ functionality in this, separate, patch.
>
> I prefer 2 patches but if you still want me to combine them, let me know.
OK, I see. That's fine, then. Maybe add a sentence about that into the
patch description of #2, that this effectively enables a code path in
the driver that wasn't being used before, and therefore should be in a
separate patch for ease of bisecting?
- Paul
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module
2012-10-22 19:53 ` Paul Walmsley
@ 2012-10-22 20:01 ` Mark A. Greer
0 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-22 20:01 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Oct 22, 2012 at 07:53:06PM +0000, Paul Walmsley wrote:
> On Mon, 22 Oct 2012, Mark A. Greer wrote:
>
> > On Sat, Oct 20, 2012 at 07:40:44PM +0000, Paul Walmsley wrote:
> > > On Fri, 19 Oct 2012, Mark A. Greer wrote:
> > >
> > > > From: "Mark A. Greer" <mgreer@animalcreek.com>
> > > >
> > > > Add the DMA information for the OMAP2 SHA module.
> > > >
> > > > CC: Paul Walmsley <paul@pwsan.com>
> > > > Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
> > >
> > > This can probably be combined with the first patch.
> >
> > I made it a separate patch because the original omap2xxx code didn't
> > support DMA and I wanted to keep the first patch an apples-apples
> > conversion and _add_ functionality in this, separate, patch.
> >
> > I prefer 2 patches but if you still want me to combine them, let me know.
>
> OK, I see. That's fine, then. Maybe add a sentence about that into the
> patch description of #2, that this effectively enables a code path in
> the driver that wasn't being used before, and therefore should be in a
> separate patch for ease of bisecting?
Sure. After your comment I realized my description was insufficient.
Mark
--
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API
2012-10-21 11:52 ` Kasatkin, Dmitry
@ 2012-10-22 20:53 ` Mark A. Greer
0 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-22 20:53 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Oct 21, 2012 at 02:52:13PM +0300, Kasatkin, Dmitry wrote:
> Hello,
>
> I got only 3 patches out of 7.
> Can you please re-submit them also to linux-crypto at vger.kernel.org
> That is a list where crypto drivers are discussed.
Okay, I will CC you and the linux-crypto on the entire series when
I submit v2.
Sorry about that.
Mark
--
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod
2012-10-22 19:49 ` Paul Walmsley
@ 2012-10-23 22:02 ` Mark A. Greer
0 siblings, 0 replies; 21+ messages in thread
From: Mark A. Greer @ 2012-10-23 22:02 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Oct 22, 2012 at 07:49:47PM +0000, Paul Walmsley wrote:
> On Mon, 22 Oct 2012, Mark A. Greer wrote:
>
> > On Sat, Oct 20, 2012 at 07:40:19PM +0000, Paul Walmsley wrote:
> >
> > > > static void omap_init_sham(void)
> > > > {
> > > > - if (cpu_is_omap24xx()) {
> > > > - sham_device.resource = omap2_sham_resources;
> > > > - sham_device.num_resources = omap2_sham_resources_sz;
> > > > + if (cpu_is_omap24xx() &&
> > > > + (omap2_cm_read_mod_reg(CORE_MOD, OMAP24XX_CM_IDLEST4) &
> > > > + OMAP24XX_ST_SHA_MASK)) {
> > >
> > > Hmm. Not sure I understand the purpose of this CM read. Don't we want to
> > > initialize this device unconditionally?
> >
> > No, the device doesn't exist on all parts.
>
> It should exist on all OMAP2xxx, AFAIK. (Whether some bootloader
> firewalled it off is another matter, of course.)
>
> > This is the only way to tell if its there (AFAIK).
>
> Hmm. I don't think the CM_IDLEST bits work that way, in the general case.
> They just indicate whether the PRCM considers that IP block to be
> currently accessible. So for example if the clocks are disabled to an IP
> block, the CM_IDLEST bit would indicate that it's not accessible. The
> software could then enable the clocks, and the CM_IDLEST bit would
> indicate that it is accessible. We use this in the clock framework and
> hwmod code after enabling clocks to wait until the system considers the IP
> block accessible. See for example
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/arm/mach-omap2/clock.c;h=961ac8f7e13d8c84a1cbb4587255ea685520bd18;hb=HEAD#l80
>
> ...
>
> Now it's possible that on some TI chips, the CM_IDLEST bit is tied to the
> SIdleAck signal originating from the IP block. (I've been told that on
> other OMAPs, CM_IDLEST is actually tied to the SIdleReq signal originating
> from the PRCM, which is not terribly useful...) So if it's tied to the
> SIdleAck signal, and the PRCM clocks are enabled, then it might provide an
> indication of whether the IP block exists on that chip. But ultimately
> the IP block might still be firewalled off even if it appears to exist to
> the PRCM. So for 3xxx, I'd suggest just adding it to the appropriate
> GP-specific hwmod init lists, such as omap3xxx_gp_hwmod_ocp_ifs.
Paul, thank you for the clear explanation.
I've talked to some hardware guys and I have come to the following
conclusions:
a) What you say above about CM_IDLEST is correct.
b) There seems to be no good way, in general, to tell if the SHA
(or AES or RNG or ...) module exists.
c) The best thing to do is what you suggest and add the SHA hwmod
data for all omap2's and omap3 GP's.
I will respin my patches with everyone's comments addressed later today.
Thanks everyone.
Mark
--
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2012-10-23 22:02 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-19 21:53 [PATCH 0/7] crypto: omap-sham updates Mark A. Greer
2012-10-19 21:53 ` [PATCH 1/7] ARM: OMAP2xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
2012-10-20 19:40 ` Paul Walmsley
2012-10-22 19:33 ` Mark A. Greer
2012-10-22 19:49 ` Paul Walmsley
2012-10-23 22:02 ` Mark A. Greer
2012-10-19 21:53 ` [PATCH 2/7] ARM: OMAP2xxx: hwmod: Add DMA information for SHAM module Mark A. Greer
2012-10-20 19:40 ` Paul Walmsley
2012-10-22 19:37 ` Mark A. Greer
2012-10-22 19:53 ` Paul Walmsley
2012-10-22 20:01 ` Mark A. Greer
2012-10-19 21:53 ` [PATCH 3/7] ARM: OMAP3xxx: hwmod: Convert SHAM crypto device data to hwmod Mark A. Greer
2012-10-20 19:41 ` Paul Walmsley
2012-10-19 21:53 ` [PATCH 4/7] ARM: OMAP2+: Remove unnecessary message when no SHA IP is present Mark A. Greer
2012-10-19 21:53 ` [PATCH 5/7] crypto: omap-sham: Convert to use pm_runtime API Mark A. Greer
2012-10-19 21:53 ` [PATCH 6/7] crypto: omap-sham: Add code to use dmaengine API Mark A. Greer
2012-10-21 11:52 ` Kasatkin, Dmitry
2012-10-22 20:53 ` Mark A. Greer
2012-10-19 21:54 ` [PATCH 7/7] crypto: omap_sham: Remove usage of private DMA API Mark A. Greer
2012-10-20 19:34 ` [PATCH 0/7] crypto: omap-sham updates Paul Walmsley
2012-10-22 19:38 ` Mark A. Greer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).