2015-02-26 13:49:50

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 00/10] omap3 crypto fixes

This patch series fix crypto support for omap3 devices which use DT.

It enables AES and SHAM on N9/N950 and SHAM on N900. AES is still disabled for N900.

Pali Rohár (10):
ARM: OMAP2+: Return correct error values from device and hwmod
ARM: OMAP3: Fix crypto support for HS devices
crypto: omap-sham: Add support for omap3 devices
crypto: omap-sham: Check for return value from pm_runtime_get_sync
ARM: dts: omap3 hs: Remove timer12
ARM: dts: omap3: Add missing dmas for crypto
ARM: dts: n9/n950: Enable omap crypto support
ARM: dts: n900: Enable omap sham and include directly omap34xx.dtsi
ARM: dts: omap3-tao3530: Include directly omap34xx.dtsi
ARM: dts: Remove files omap34xx-hs.dtsi and omap36xx-hs.dtsi

arch/arm/boot/dts/omap3-n900.dts | 16 +++++-
arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
arch/arm/boot/dts/omap3-tao3530.dtsi | 11 +++-
arch/arm/boot/dts/omap3.dtsi | 4 ++
arch/arm/boot/dts/omap34xx-hs.dtsi | 16 ------
arch/arm/boot/dts/omap36xx-hs.dtsi | 16 ------
arch/arm/mach-omap2/omap_device.c | 30 ++++++-----
arch/arm/mach-omap2/omap_hwmod.c | 10 ++--
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 79 +++++++++++++++++++++++-----
drivers/crypto/omap-sham.c | 13 ++++-
10 files changed, 131 insertions(+), 66 deletions(-)
delete mode 100644 arch/arm/boot/dts/omap34xx-hs.dtsi
delete mode 100644 arch/arm/boot/dts/omap36xx-hs.dtsi

--
1.7.9.5


2015-02-26 13:49:51

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 01/10] ARM: OMAP2+: Return correct error values from device and hwmod

Without this patch function pm_runtime_get_sync() returns 0 even when some
omap subfunction fails. This patch properly propagate error codes from omap
functions back to caller.

This patch fix problem, when loading omap-aes driver in qemu cause kernel oops.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/mach-omap2/omap_device.c | 30 +++++++++++++++++-------------
arch/arm/mach-omap2/omap_hwmod.c | 10 ++++++----
2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index be9541e..9fd47a9 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -224,13 +224,13 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
*/
static int _omap_device_enable_hwmods(struct omap_device *od)
{
+ int ret = 0;
int i;

for (i = 0; i < od->hwmods_cnt; i++)
- omap_hwmod_enable(od->hwmods[i]);
+ ret |= omap_hwmod_enable(od->hwmods[i]);

- /* XXX pass along return value here? */
- return 0;
+ return ret;
}

/**
@@ -241,13 +241,13 @@ static int _omap_device_enable_hwmods(struct omap_device *od)
*/
static int _omap_device_idle_hwmods(struct omap_device *od)
{
+ int ret = 0;
int i;

for (i = 0; i < od->hwmods_cnt; i++)
- omap_hwmod_idle(od->hwmods[i]);
+ ret |= omap_hwmod_idle(od->hwmods[i]);

- /* XXX pass along return value here? */
- return 0;
+ return ret;
}

/* Public functions for use by core code */
@@ -595,18 +595,20 @@ static int _od_runtime_suspend(struct device *dev)
int ret;

ret = pm_generic_runtime_suspend(dev);
+ if (ret)
+ return ret;

- if (!ret)
- omap_device_idle(pdev);
-
- return ret;
+ return omap_device_idle(pdev);
}

static int _od_runtime_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
+ int ret;

- omap_device_enable(pdev);
+ ret = omap_device_enable(pdev);
+ if (ret)
+ return ret;

return pm_generic_runtime_resume(dev);
}
@@ -740,7 +742,8 @@ int omap_device_enable(struct platform_device *pdev)

ret = _omap_device_enable_hwmods(od);

- od->_state = OMAP_DEVICE_STATE_ENABLED;
+ if (ret == 0)
+ od->_state = OMAP_DEVICE_STATE_ENABLED;

return ret;
}
@@ -770,7 +773,8 @@ int omap_device_idle(struct platform_device *pdev)

ret = _omap_device_idle_hwmods(od);

- od->_state = OMAP_DEVICE_STATE_IDLE;
+ if (ret == 0)
+ od->_state = OMAP_DEVICE_STATE_IDLE;

return ret;
}
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 92afb72..870e984 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -3350,16 +3350,17 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
*/
int omap_hwmod_idle(struct omap_hwmod *oh)
{
+ int r;
unsigned long flags;

if (!oh)
return -EINVAL;

spin_lock_irqsave(&oh->_lock, flags);
- _idle(oh);
+ r = _idle(oh);
spin_unlock_irqrestore(&oh->_lock, flags);

- return 0;
+ return r;
}

/**
@@ -3372,16 +3373,17 @@ int omap_hwmod_idle(struct omap_hwmod *oh)
*/
int omap_hwmod_shutdown(struct omap_hwmod *oh)
{
+ int r;
unsigned long flags;

if (!oh)
return -EINVAL;

spin_lock_irqsave(&oh->_lock, flags);
- _shutdown(oh);
+ r = _shutdown(oh);
spin_unlock_irqrestore(&oh->_lock, flags);

- return 0;
+ return r;
}

/*
--
1.7.9.5

2015-02-26 13:49:56

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 06/10] ARM: dts: omap3: Add missing dmas for crypto

This patch adds missing dma DTS definitions for omap aes and sham drivers.
Without it kernel drivers do not work.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/boot/dts/omap3.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 60e6d6b..6e8b58f 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -92,6 +92,8 @@
ti,hwmods = "aes";
reg = <0x480c5000 0x50>;
interrupts = <0>;
+ dmas = <&sdma 65 &sdma 66>;
+ dma-names = "tx", "rx";
};

prm: prm@48306000 {
@@ -551,6 +553,8 @@
ti,hwmods = "sham";
reg = <0x480c3000 0x64>;
interrupts = <49>;
+ dmas = <&sdma 69>;
+ dma-names = "rx";
};

smartreflex_core: smartreflex@480cb000 {
--
1.7.9.5

2015-02-26 13:49:53

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 03/10] crypto: omap-sham: Add support for omap3 devices

omap3 support is same as omap2, just with different IO address (specified in DT)

Signed-off-by: Pali Rohár <[email protected]>
---
drivers/crypto/omap-sham.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 3c76696..b20e374 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -1792,6 +1792,10 @@ static const struct of_device_id omap_sham_of_match[] = {
.data = &omap_sham_pdata_omap2,
},
{
+ .compatible = "ti,omap3-sham",
+ .data = &omap_sham_pdata_omap2,
+ },
+ {
.compatible = "ti,omap4-sham",
.data = &omap_sham_pdata_omap4,
},
--
1.7.9.5

2015-02-26 13:49:54

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 04/10] crypto: omap-sham: Check for return value from pm_runtime_get_sync

Function pm_runtime_get_sync could fail and we need to check return
value to prevent kernel crash.

Signed-off-by: Pali Rohár <[email protected]>
---
drivers/crypto/omap-sham.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index b20e374..5573a1c 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -1949,7 +1949,13 @@ static int omap_sham_probe(struct platform_device *pdev)
dd->flags |= dd->pdata->flags;

pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
+
+ err = pm_runtime_get_sync(dev);
+ if (err < 0) {
+ dev_err(dev, "failed to get sync: %d\n", err);
+ goto err_pm;
+ }
+
rev = omap_sham_read(dd, SHA_REG_REV(dd));
pm_runtime_put_sync(&pdev->dev);

@@ -1979,6 +1985,7 @@ err_algs:
for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
crypto_unregister_ahash(
&dd->pdata->algs_info[i].algs_list[j]);
+err_pm:
pm_runtime_disable(dev);
if (dd->dma_lch)
dma_release_channel(dd->dma_lch);
--
1.7.9.5

2015-02-26 13:49:58

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 08/10] ARM: dts: n900: Enable omap sham and include directly omap34xx.dtsi

This patch moves content of file omap34xx-hs.dtsi into omap3-n900.dts and enable
omap sham support (omap HW support for SHA + MD5). After testing both omap hwmod
and omap-sham.ko drivers it looks like signed Nokia X-Loader enable L3 firewall
for omap sham. There is no kernel crash with both official bootloader and crypto
enable bootloader. So we can safely enable sham code.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/boot/dts/omap3-n900.dts | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index d16aa9c..10d5305 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -9,9 +9,23 @@

/dts-v1/;

-#include "omap34xx-hs.dtsi"
+#include "omap34xx.dtsi"
#include <dt-bindings/input/input.h>

+/*
+ * Default secure signed bootloader (Nokia X-Loader) does not enable L3 firewall
+ * for omap AES HW crypto support. When linux kernel try to access memory of AES
+ * blocks then kernel receive "Unhandled fault: external abort on non-linefetch"
+ * and crash. Until somebody fix omap-aes.c and omap_hwmod_3xxx_data.c code (no
+ * crash anymore) omap AES support will be disabled for all Nokia N900 devices.
+ * There is "unofficial" version of bootloader which enables AES in L3 firewall
+ * but it is not widely used and to prevent kernel crash rather AES is disabled.
+ * There is also no runtime detection code if AES is disabled in L3 firewall...
+ */
+&aes {
+ status = "disabled";
+};
+
/ {
model = "Nokia N900";
compatible = "nokia,omap3-n900", "ti,omap3430", "ti,omap3";
--
1.7.9.5

2015-02-26 13:50:00

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 10/10] ARM: dts: Remove files omap34xx-hs.dtsi and omap36xx-hs.dtsi

These files are not used by any DTS file anymore.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/boot/dts/omap34xx-hs.dtsi | 12 ------------
arch/arm/boot/dts/omap36xx-hs.dtsi | 12 ------------
2 files changed, 24 deletions(-)
delete mode 100644 arch/arm/boot/dts/omap34xx-hs.dtsi
delete mode 100644 arch/arm/boot/dts/omap36xx-hs.dtsi

diff --git a/arch/arm/boot/dts/omap34xx-hs.dtsi b/arch/arm/boot/dts/omap34xx-hs.dtsi
deleted file mode 100644
index d4be302..0000000
--- a/arch/arm/boot/dts/omap34xx-hs.dtsi
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Disabled modules for secure omaps */
-
-#include "omap34xx.dtsi"
-
-/* Secure omaps have some devices inaccessible depending on the firmware */
-&aes {
- status = "disabled";
-};
-
-&sham {
- status = "disabled";
-};
diff --git a/arch/arm/boot/dts/omap36xx-hs.dtsi b/arch/arm/boot/dts/omap36xx-hs.dtsi
deleted file mode 100644
index e93ff8d..0000000
--- a/arch/arm/boot/dts/omap36xx-hs.dtsi
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Disabled modules for secure omaps */
-
-#include "omap36xx.dtsi"
-
-/* Secure omaps have some devices inaccessible depending on the firmware */
-&aes {
- status = "disabled";
-};
-
-&sham {
- status = "disabled";
-};
--
1.7.9.5

2015-02-26 13:49:59

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 09/10] ARM: dts: omap3-tao3530: Include directly omap34xx.dtsi

This patch just move content of file omap34xx-hs.dtsi into omap3-tao3530.dts.
There is no code change, patch is just preparation for removing -hs file.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/boot/dts/omap3-tao3530.dtsi | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap3-tao3530.dtsi b/arch/arm/boot/dts/omap3-tao3530.dtsi
index e89820a..873aa10 100644
--- a/arch/arm/boot/dts/omap3-tao3530.dtsi
+++ b/arch/arm/boot/dts/omap3-tao3530.dtsi
@@ -8,7 +8,16 @@
*/
/dts-v1/;

-#include "omap34xx-hs.dtsi"
+#include "omap34xx.dtsi"
+
+/* Secure omaps have some devices inaccessible depending on the firmware */
+&aes {
+ status = "disabled";
+};
+
+&sham {
+ status = "disabled";
+};

/ {
cpus {
--
1.7.9.5

2015-02-26 13:49:57

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support

Harmattan system on Nokia N9 and N950 devices uses omap crypto support.
Bootloader on those devices is known that it enables HW crypto support.
This patch just include omap36xx.dtsi directly, so aes and sham is enabled.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index c41db94..800b379 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -8,7 +8,7 @@
* published by the Free Software Foundation.
*/

-#include "omap36xx-hs.dtsi"
+#include "omap36xx.dtsi"

/ {
cpus {
--
1.7.9.5

2015-02-26 13:49:55

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 05/10] ARM: dts: omap3 hs: Remove timer12

Device timer12 is automatically disabled on all HS devices via DTS property
"ti,timer-secure" in file omap3.dtsi so it can be safely removed. We do not
need to disable it on another place.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/boot/dts/omap34xx-hs.dtsi | 4 ----
arch/arm/boot/dts/omap36xx-hs.dtsi | 4 ----
2 files changed, 8 deletions(-)

diff --git a/arch/arm/boot/dts/omap34xx-hs.dtsi b/arch/arm/boot/dts/omap34xx-hs.dtsi
index 1ff6264..d4be302 100644
--- a/arch/arm/boot/dts/omap34xx-hs.dtsi
+++ b/arch/arm/boot/dts/omap34xx-hs.dtsi
@@ -10,7 +10,3 @@
&sham {
status = "disabled";
};
-
-&timer12 {
- status = "disabled";
-};
diff --git a/arch/arm/boot/dts/omap36xx-hs.dtsi b/arch/arm/boot/dts/omap36xx-hs.dtsi
index 2c7febb..e93ff8d 100644
--- a/arch/arm/boot/dts/omap36xx-hs.dtsi
+++ b/arch/arm/boot/dts/omap36xx-hs.dtsi
@@ -10,7 +10,3 @@
&sham {
status = "disabled";
};
-
-&timer12 {
- status = "disabled";
-};
--
1.7.9.5

2015-02-26 13:49:52

by Pali Rohár

[permalink] [raw]
Subject: [PATCH 02/10] ARM: OMAP3: Fix crypto support for HS devices

Register crypto hwmod links only if they are not disabled in DT.
If DT information is missing, enable them only for GP devices.

Before this patch crypto hwmod links were always disabled for all HS devices
and it was not possible to use omap-aes and omap-sham linux drivers.

Signed-off-by: Pali Rohár <[email protected]>
---
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 79 +++++++++++++++++++++++-----
1 file changed, 66 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 4e8e93c..de13a06 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3744,29 +3744,54 @@ static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
/* GP-only hwmod links */
static struct omap_hwmod_ocp_if *omap34xx_gp_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l4_sec__timer12,
- &omap3xxx_l4_core__sham,
- &omap3xxx_l4_core__aes,
NULL
};

static struct omap_hwmod_ocp_if *omap36xx_gp_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l4_sec__timer12,
- &omap3xxx_l4_core__sham,
- &omap3xxx_l4_core__aes,
NULL
};

static struct omap_hwmod_ocp_if *am35xx_gp_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l4_sec__timer12,
- /*
- * Apparently the SHA/MD5 and AES accelerator IP blocks are
- * only present on some AM35xx chips, and no one knows which
- * ones. See
- * http://www.spinics.net/lists/arm-kernel/msg215466.html So
- * if you need these IP blocks on an AM35xx, try uncommenting
- * the following lines.
- */
+ NULL
+};
+
+/* crypto hwmod links */
+static struct omap_hwmod_ocp_if *omap34xx_sham_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__sham,
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *omap34xx_aes_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__aes,
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *omap36xx_sham_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__sham,
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *omap36xx_aes_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__aes,
+ NULL
+};
+
+/*
+ * Apparently the SHA/MD5 and AES accelerator IP blocks are
+ * only present on some AM35xx chips, and no one knows which
+ * ones. See
+ * http://www.spinics.net/lists/arm-kernel/msg215466.html So
+ * if you need these IP blocks on an AM35xx, try uncommenting
+ * the following lines.
+ */
+static struct omap_hwmod_ocp_if *am35xx_sham_hwmod_ocp_ifs[] __initdata = {
/* &omap3xxx_l4_core__sham, */
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *am35xx_aes_hwmod_ocp_ifs[] __initdata = {
/* &omap3xxx_l4_core__aes, */
NULL
};
@@ -3871,7 +3896,8 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_hwmod_ocp_ifs[] __initdata = {
int __init omap3xxx_hwmod_init(void)
{
int r;
- struct omap_hwmod_ocp_if **h = NULL, **h_gp = NULL;
+ struct omap_hwmod_ocp_if **h = NULL, **h_gp = NULL, **h_sham = NULL, **h_aes = NULL;
+ struct device_node *bus = NULL;
unsigned int rev;

omap_hwmod_init();
@@ -3893,13 +3919,19 @@ int __init omap3xxx_hwmod_init(void)
rev == OMAP3430_REV_ES3_1 || rev == OMAP3430_REV_ES3_1_2) {
h = omap34xx_hwmod_ocp_ifs;
h_gp = omap34xx_gp_hwmod_ocp_ifs;
+ h_sham = omap34xx_sham_hwmod_ocp_ifs;
+ h_aes = omap34xx_aes_hwmod_ocp_ifs;
} else if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
h = am35xx_hwmod_ocp_ifs;
h_gp = am35xx_gp_hwmod_ocp_ifs;
+ h_sham = am35xx_sham_hwmod_ocp_ifs;
+ h_aes = am35xx_aes_hwmod_ocp_ifs;
} else if (rev == OMAP3630_REV_ES1_0 || rev == OMAP3630_REV_ES1_1 ||
rev == OMAP3630_REV_ES1_2) {
h = omap36xx_hwmod_ocp_ifs;
h_gp = omap36xx_gp_hwmod_ocp_ifs;
+ h_sham = omap36xx_sham_hwmod_ocp_ifs;
+ h_aes = omap36xx_aes_hwmod_ocp_ifs;
} else {
WARN(1, "OMAP3 hwmod family init: unknown chip type\n");
return -EINVAL;
@@ -3916,6 +3948,27 @@ int __init omap3xxx_hwmod_init(void)
return r;
}

+ /*
+ * Register crypto hwmod links only if they are not disabled in DT.
+ * If DT information is missing, enable them only for GP devices.
+ */
+
+ if (of_have_populated_dt())
+ bus = of_find_node_by_name(NULL, "ocp");
+
+ if (h_sham && ((!bus && omap_type() == OMAP2_DEVICE_TYPE_GP) ||
+ (bus && of_device_is_available(of_find_node_by_name(bus, "sham"))))) {
+ r = omap_hwmod_register_links(h_sham);
+ if (r < 0)
+ return r;
+ }
+
+ if (h_aes && ((!bus && omap_type() == OMAP2_DEVICE_TYPE_GP) ||
+ (bus && of_device_is_available(of_find_node_by_name(bus, "aes"))))) {
+ r = omap_hwmod_register_links(h_aes);
+ if (r < 0)
+ return r;
+ }

/*
* Register hwmod links specific to certain ES levels of a
--
1.7.9.5

2015-02-26 22:46:05

by Aaro Koskinen

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

Hi,

On Thu, Feb 26, 2015 at 02:49:50PM +0100, Pali Roh?r wrote:
> This patch series fix crypto support for omap3 devices which use DT.
>
> It enables AES and SHAM on N9/N950 and SHAM on N900. AES is still disabled for N900.

(Please format your lines somewhere near < 76 chars, especially in
commit logs, otherwise "git log" looks ugly on 80 char terminals.)

I tested these with stock bootloaders, and devices boot normally
and I can now modprobe omap-aes (on N9 and N950) and omap-sham
(on all three):

omap-aes 480c5000.aes: OMAP AES hw accel rev: 2.6
omap-sham 480c3000.sham: hw accel on OMAP rev 0.9

However I get these when CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set:

alg: hash: Chunking test 1 failed for omap-sha1
alg: hash: Chunking test 1 failed for omap-md5
alg: hash: Chunking test 1 failed for omap-hmac-sha1
alg: hash: Chunking test 1 failed for omap-hmac-md5

But that's probably unrelated to this series. For patches 1-8,
feel free to add:

Tested-by: Aaro Koskinen <[email protected]>

A.

2015-02-27 12:40:48

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Thursday 26 February 2015 23:46:05 Aaro Koskinen wrote:
> Hi,
>
> On Thu, Feb 26, 2015 at 02:49:50PM +0100, Pali Rohár wrote:
> > This patch series fix crypto support for omap3 devices which
> > use DT.
> >
> > It enables AES and SHAM on N9/N950 and SHAM on N900. AES is
> > still disabled for N900.
>
> (Please format your lines somewhere near < 76 chars,
> especially in commit logs, otherwise "git log" looks ugly on
> 80 char terminals.)
>
> I tested these with stock bootloaders, and devices boot
> normally and I can now modprobe omap-aes (on N9 and N950) and
> omap-sham (on all three):
>
> omap-aes 480c5000.aes: OMAP AES hw accel rev: 2.6
> omap-sham 480c3000.sham: hw accel on OMAP rev 0.9
>
> However I get these when CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
> is not set:
>
> alg: hash: Chunking test 1 failed for omap-sha1
> alg: hash: Chunking test 1 failed for omap-md5
> alg: hash: Chunking test 1 failed for omap-hmac-sha1
> alg: hash: Chunking test 1 failed for omap-hmac-md5
>
> But that's probably unrelated to this series. For patches 1-8,
> feel free to add:
>
> Tested-by: Aaro Koskinen <[email protected]>
>
> A.

Hi, thanks for testing!

Now I'm happy that I can load omap-aes and omap-sham drivers on
real n900 device, qemu n900 and after your tests also on real n9
and n950 without any kernel crash or oops. Of course omap-aes is
disabled on n900, but loading omap-aes.ko (accidentally) does not
hurt.

It looks like there are other parts in md5 and sha broken, but
first step is load & register all drivers without kernel crash.
And this is working now.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-02-27 16:01:55

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support

On Friday 27 February 2015 16:43:20 Tony Lindgren wrote:
> * Pali Rohár <[email protected]> [150226 05:54]:
> > Harmattan system on Nokia N9 and N950 devices uses omap
> > crypto support. Bootloader on those devices is known that
> > it enables HW crypto support. This patch just include
> > omap36xx.dtsi directly, so aes and sham is enabled.
>
> Let's also remove omap36xx-hs.dtsi with this patch if no other
> users.
>

Removing both -hs files is done by last patch in this series.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-02-27 15:43:20

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support

* Pali Rohár <[email protected]> [150226 05:54]:
> Harmattan system on Nokia N9 and N950 devices uses omap crypto support.
> Bootloader on those devices is known that it enables HW crypto support.
> This patch just include omap36xx.dtsi directly, so aes and sham is enabled.

Let's also remove omap36xx-hs.dtsi with this patch if no other users.

Regards,

Tony

> Signed-off-by: Pali Rohár <[email protected]>
> ---
> arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi b/arch/arm/boot/dts/omap3-n950-n9.dtsi
> index c41db94..800b379 100644
> --- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
> +++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
> @@ -8,7 +8,7 @@
> * published by the Free Software Foundation.
> */
>
> -#include "omap36xx-hs.dtsi"
> +#include "omap36xx.dtsi"
>
> / {
> cpus {
> --
> 1.7.9.5
>

2015-02-27 16:10:04

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support

* Pali Rohár <[email protected]> [150227 08:05]:
> On Friday 27 February 2015 16:43:20 Tony Lindgren wrote:
> > * Pali Rohár <[email protected]> [150226 05:54]:
> > > Harmattan system on Nokia N9 and N950 devices uses omap
> > > crypto support. Bootloader on those devices is known that
> > > it enables HW crypto support. This patch just include
> > > omap36xx.dtsi directly, so aes and sham is enabled.
> >
> > Let's also remove omap36xx-hs.dtsi with this patch if no other
> > users.
> >
>
> Removing both -hs files is done by last patch in this series.

Yes just noticed thanks, no need to change.

Regards,

Tony

2015-02-28 16:24:36

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 02/10] ARM: OMAP3: Fix crypto support for HS devices

On Thu 2015-02-26 14:49:52, Pali Roh?r wrote:
> Register crypto hwmod links only if they are not disabled in DT.
> If DT information is missing, enable them only for GP devices.
>
> Before this patch crypto hwmod links were always disabled for all HS devices
> and it was not possible to use omap-aes and omap-sham linux drivers.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:25:02

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 03/10] crypto: omap-sham: Add support for omap3 devices

On Thu 2015-02-26 14:49:53, Pali Roh?r wrote:
> omap3 support is same as omap2, just with different IO address (specified in DT)
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

> @@ -1792,6 +1792,10 @@ static const struct of_device_id omap_sham_of_match[] = {
> .data = &omap_sham_pdata_omap2,
> },
> {
> + .compatible = "ti,omap3-sham",
> + .data = &omap_sham_pdata_omap2,
> + },
> + {
> .compatible = "ti,omap4-sham",
> .data = &omap_sham_pdata_omap4,
> },

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:39:45

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 04/10] crypto: omap-sham: Check for return value from pm_runtime_get_sync

On Thu 2015-02-26 14:49:54, Pali Roh?r wrote:
> Function pm_runtime_get_sync could fail and we need to check return
> value to prevent kernel crash.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:41:53

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support

On Thu 2015-02-26 14:49:57, Pali Roh?r wrote:
> Harmattan system on Nokia N9 and N950 devices uses omap crypto support.
> Bootloader on those devices is known that it enables HW crypto support.
> This patch just include omap36xx.dtsi directly, so aes and sham is enabled.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

> --- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
> +++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
> @@ -8,7 +8,7 @@
> * published by the Free Software Foundation.
> */
>
> -#include "omap36xx-hs.dtsi"
> +#include "omap36xx.dtsi"
>
> / {
> cpus {

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:44:13

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 08/10] ARM: dts: n900: Enable omap sham and include directly omap34xx.dtsi

On Thu 2015-02-26 14:49:58, Pali Roh?r wrote:
> This patch moves content of file omap34xx-hs.dtsi into omap3-n900.dts and enable
> omap sham support (omap HW support for SHA + MD5). After testing both omap hwmod
> and omap-sham.ko drivers it looks like signed Nokia X-Loader enable L3 firewall
> for omap sham. There is no kernel crash with both official bootloader and crypto
> enable bootloader. So we can safely enable sham code.
>

> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>


> +/*
> + * Default secure signed bootloader (Nokia X-Loader) does not enable L3 firewall
> + * for omap AES HW crypto support. When linux kernel try to access memory of AES

When Linux Kernel tries...

> + * blocks then kernel receive "Unhandled fault: external abort on non-linefetch"
, the kernel receives

> + * and crash. Until somebody fix omap-aes.c and omap_hwmod_3xxx_data.c code (no

and crashes. Until somebody fixes

> + * crash anymore) omap AES support will be disabled for all Nokia N900 devices.
> + * There is "unofficial" version of bootloader which enables AES in L3 firewall
firewall,

> + * but it is not widely used and to prevent kernel crash rather AES is disabled.
> + * There is also no runtime detection code if AES is disabled in L3 firewall...
> + */
> +&aes {
> + status = "disabled";
> +};
> +
> / {
> model = "Nokia N900";
> compatible = "nokia,omap3-n900", "ti,omap3430", "ti,omap3";

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:44:58

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 09/10] ARM: dts: omap3-tao3530: Include directly omap34xx.dtsi

On Thu 2015-02-26 14:49:59, Pali Roh?r wrote:
> This patch just move content of file omap34xx-hs.dtsi into omap3-tao3530.dts.
> There is no code change, patch is just preparation for removing -hs file.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

> --- a/arch/arm/boot/dts/omap3-tao3530.dtsi
> +++ b/arch/arm/boot/dts/omap3-tao3530.dtsi
> @@ -8,7 +8,16 @@
> */
> /dts-v1/;
>
> -#include "omap34xx-hs.dtsi"
> +#include "omap34xx.dtsi"
> +
> +/* Secure omaps have some devices inaccessible depending on the firmware */
> +&aes {
> + status = "disabled";
> +};
> +
> +&sham {
> + status = "disabled";
> +};
>
> / {
> cpus {

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:45:08

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 10/10] ARM: dts: Remove files omap34xx-hs.dtsi and omap36xx-hs.dtsi

On Thu 2015-02-26 14:50:00, Pali Roh?r wrote:
> These files are not used by any DTS file anymore.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

> ---
> arch/arm/boot/dts/omap34xx-hs.dtsi | 12 ------------
> arch/arm/boot/dts/omap36xx-hs.dtsi | 12 ------------
> 2 files changed, 24 deletions(-)
> delete mode 100644 arch/arm/boot/dts/omap34xx-hs.dtsi
> delete mode 100644 arch/arm/boot/dts/omap36xx-hs.dtsi
>
> diff --git a/arch/arm/boot/dts/omap34xx-hs.dtsi b/arch/arm/boot/dts/omap34xx-hs.dtsi
> deleted file mode 100644
> index d4be302..0000000
> --- a/arch/arm/boot/dts/omap34xx-hs.dtsi
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -/* Disabled modules for secure omaps */
> -
> -#include "omap34xx.dtsi"
> -
> -/* Secure omaps have some devices inaccessible depending on the firmware */
> -&aes {
> - status = "disabled";
> -};
> -
> -&sham {
> - status = "disabled";
> -};
> diff --git a/arch/arm/boot/dts/omap36xx-hs.dtsi b/arch/arm/boot/dts/omap36xx-hs.dtsi
> deleted file mode 100644
> index e93ff8d..0000000
> --- a/arch/arm/boot/dts/omap36xx-hs.dtsi
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -/* Disabled modules for secure omaps */
> -
> -#include "omap36xx.dtsi"
> -
> -/* Secure omaps have some devices inaccessible depending on the firmware */
> -&aes {
> - status = "disabled";
> -};
> -
> -&sham {
> - status = "disabled";
> -};

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:46:04

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 06/10] ARM: dts: omap3: Add missing dmas for crypto

On Thu 2015-02-26 14:49:56, Pali Roh?r wrote:
> This patch adds missing dma DTS definitions for omap aes and sham drivers.
> Without it kernel drivers do not work.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-28 16:54:30

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 05/10] ARM: dts: omap3 hs: Remove timer12

On Thu 2015-02-26 14:49:55, Pali Roh?r wrote:
> Device timer12 is automatically disabled on all HS devices via DTS property
> "ti,timer-secure" in file omap3.dtsi so it can be safely removed. We do not
> need to disable it on another place.

Dunno. Theoretically, Linux is not the only user of dts... so even if
linux handles ti,timer-secure as "don't use it", that may not be right
for bootloaders etc.

> diff --git a/arch/arm/boot/dts/omap34xx-hs.dtsi b/arch/arm/boot/dts/omap34xx-hs.dtsi
> index 1ff6264..d4be302 100644
> --- a/arch/arm/boot/dts/omap34xx-hs.dtsi
> +++ b/arch/arm/boot/dts/omap34xx-hs.dtsi
> @@ -10,7 +10,3 @@
> &sham {
> status = "disabled";
> };
> -
> -&timer12 {
> - status = "disabled";
> -};
> diff --git a/arch/arm/boot/dts/omap36xx-hs.dtsi b/arch/arm/boot/dts/omap36xx-hs.dtsi
> index 2c7febb..e93ff8d 100644
> --- a/arch/arm/boot/dts/omap36xx-hs.dtsi
> +++ b/arch/arm/boot/dts/omap36xx-hs.dtsi
> @@ -10,7 +10,3 @@
> &sham {
> status = "disabled";
> };
> -
> -&timer12 {
> - status = "disabled";
> -};

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-03-06 18:36:32

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

* Pali Rohár <[email protected]> [150226 05:54]:
> This patch series fix crypto support for omap3 devices which use DT.
>
> It enables AES and SHAM on N9/N950 and SHAM on N900. AES is still disabled for N900.
>
> Pali Rohár (10):
> ARM: OMAP2+: Return correct error values from device and hwmod
> ARM: OMAP3: Fix crypto support for HS devices
> crypto: omap-sham: Add support for omap3 devices
> crypto: omap-sham: Check for return value from pm_runtime_get_sync
> ARM: dts: omap3 hs: Remove timer12
> ARM: dts: omap3: Add missing dmas for crypto
> ARM: dts: n9/n950: Enable omap crypto support
> ARM: dts: n900: Enable omap sham and include directly omap34xx.dtsi
> ARM: dts: omap3-tao3530: Include directly omap34xx.dtsi
> ARM: dts: Remove files omap34xx-hs.dtsi and omap36xx-hs.dtsi
>
> arch/arm/boot/dts/omap3-n900.dts | 16 +++++-
> arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
> arch/arm/boot/dts/omap3-tao3530.dtsi | 11 +++-
> arch/arm/boot/dts/omap3.dtsi | 4 ++
> arch/arm/boot/dts/omap34xx-hs.dtsi | 16 ------
> arch/arm/boot/dts/omap36xx-hs.dtsi | 16 ------
> arch/arm/mach-omap2/omap_device.c | 30 ++++++-----
> arch/arm/mach-omap2/omap_hwmod.c | 10 ++--
> arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 79 +++++++++++++++++++++++-----
> drivers/crypto/omap-sham.c | 13 ++++-
> 10 files changed, 131 insertions(+), 66 deletions(-)
> delete mode 100644 arch/arm/boot/dts/omap34xx-hs.dtsi
> delete mode 100644 arch/arm/boot/dts/omap36xx-hs.dtsi

Are there any fixes in this series that should go into
v4.0-rc series, or can it all wait for v4.1?

Regards,

Tony

2015-03-06 19:16:05

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Friday 06 March 2015 19:36:32 Tony Lindgren wrote:
> * Pali Rohár <[email protected]> [150226 05:54]:
> > This patch series fix crypto support for omap3 devices which
> > use DT.
> >
> > It enables AES and SHAM on N9/N950 and SHAM on N900. AES is
> > still disabled for N900.
> >
> > Pali Rohár (10):
> > ARM: OMAP2+: Return correct error values from device and
> > hwmod ARM: OMAP3: Fix crypto support for HS devices
> > crypto: omap-sham: Add support for omap3 devices
> > crypto: omap-sham: Check for return value from
> > pm_runtime_get_sync ARM: dts: omap3 hs: Remove timer12
> > ARM: dts: omap3: Add missing dmas for crypto
> > ARM: dts: n9/n950: Enable omap crypto support
> > ARM: dts: n900: Enable omap sham and include directly
> > omap34xx.dtsi ARM: dts: omap3-tao3530: Include directly
> > omap34xx.dtsi ARM: dts: Remove files omap34xx-hs.dtsi and
> > omap36xx-hs.dtsi
> >
> > arch/arm/boot/dts/omap3-n900.dts | 16 +++++-
> > arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
> > arch/arm/boot/dts/omap3-tao3530.dtsi | 11 +++-
> > arch/arm/boot/dts/omap3.dtsi | 4 ++
> > arch/arm/boot/dts/omap34xx-hs.dtsi | 16 ------
> > arch/arm/boot/dts/omap36xx-hs.dtsi | 16 ------
> > arch/arm/mach-omap2/omap_device.c | 30
> > ++++++----- arch/arm/mach-omap2/omap_hwmod.c |
> > 10 ++-- arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 79
> > +++++++++++++++++++++++----- drivers/crypto/omap-sham.c
> > | 13 ++++- 10 files changed, 131
> > insertions(+), 66 deletions(-) delete mode 100644
> > arch/arm/boot/dts/omap34xx-hs.dtsi delete mode 100644
> > arch/arm/boot/dts/omap36xx-hs.dtsi
>
> Are there any fixes in this series that should go into
> v4.0-rc series, or can it all wait for v4.1?
>
> Regards,
>
> Tony

I do not know which patches are you sending to 4.0-rc series, but
omap crypto is totally broken in linus tree for both GP & HS
omap3 devices when DT booting is used. This patch series fix that
problem.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-03-06 19:18:45

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

* Pali Rohár <[email protected]> [150306 11:16]:
> On Friday 06 March 2015 19:36:32 Tony Lindgren wrote:
> > * Pali Rohár <[email protected]> [150226 05:54]:
> > > This patch series fix crypto support for omap3 devices which
> > > use DT.
> > >
> > > It enables AES and SHAM on N9/N950 and SHAM on N900. AES is
> > > still disabled for N900.
> > >
> > > Pali Rohár (10):
> > > ARM: OMAP2+: Return correct error values from device and
> > > hwmod ARM: OMAP3: Fix crypto support for HS devices
> > > crypto: omap-sham: Add support for omap3 devices
> > > crypto: omap-sham: Check for return value from
> > > pm_runtime_get_sync ARM: dts: omap3 hs: Remove timer12
> > > ARM: dts: omap3: Add missing dmas for crypto
> > > ARM: dts: n9/n950: Enable omap crypto support
> > > ARM: dts: n900: Enable omap sham and include directly
> > > omap34xx.dtsi ARM: dts: omap3-tao3530: Include directly
> > > omap34xx.dtsi ARM: dts: Remove files omap34xx-hs.dtsi and
> > > omap36xx-hs.dtsi
> > >
> > > arch/arm/boot/dts/omap3-n900.dts | 16 +++++-
> > > arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +-
> > > arch/arm/boot/dts/omap3-tao3530.dtsi | 11 +++-
> > > arch/arm/boot/dts/omap3.dtsi | 4 ++
> > > arch/arm/boot/dts/omap34xx-hs.dtsi | 16 ------
> > > arch/arm/boot/dts/omap36xx-hs.dtsi | 16 ------
> > > arch/arm/mach-omap2/omap_device.c | 30
> > > ++++++----- arch/arm/mach-omap2/omap_hwmod.c |
> > > 10 ++-- arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 79
> > > +++++++++++++++++++++++----- drivers/crypto/omap-sham.c
> > > | 13 ++++- 10 files changed, 131
> > > insertions(+), 66 deletions(-) delete mode 100644
> > > arch/arm/boot/dts/omap34xx-hs.dtsi delete mode 100644
> > > arch/arm/boot/dts/omap36xx-hs.dtsi
> >
> > Are there any fixes in this series that should go into
> > v4.0-rc series, or can it all wait for v4.1?
> >
> > Regards,
> >
> > Tony
>
> I do not know which patches are you sending to 4.0-rc series, but
> omap crypto is totally broken in linus tree for both GP & HS
> omap3 devices when DT booting is used. This patch series fix that
> problem.

OK so the whole series is needed then. It seems too intrusive for
the v4.0-rc series unless this fixes a regression with some earlier
commit.

Regards,

Tony

2015-03-06 22:23:06

by Aaro Koskinen

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

Hi,

On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> Are there any fixes in this series that should go into
> v4.0-rc series, or can it all wait for v4.1?

I think these all should wait for v4.1.

A.

2015-03-07 23:19:25

by Aaro Koskinen

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

Hi,

On Fri, Feb 27, 2015 at 01:40:44PM +0100, Pali Roh?r wrote:
> > However I get these when CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
> > is not set:
> >
> > alg: hash: Chunking test 1 failed for omap-sha1
> > alg: hash: Chunking test 1 failed for omap-md5
> > alg: hash: Chunking test 1 failed for omap-hmac-sha1
> > alg: hash: Chunking test 1 failed for omap-hmac-md5

BTW, it seems these errors are reported to be introduced possibly
somewhere between 3.11 and 3.15:

https://lists.fedoraproject.org/pipermail/arm/2014-August/008240.html

A.

2015-03-08 10:01:16

by Pali Rohár

[permalink] [raw]
Subject: [PATCH v2] crypto: omap-sham: Check for return value from pm_runtime_get_sync

Function pm_runtime_get_sync could fail and we need to check return
value to prevent kernel crash.

Signed-off-by: Pali Rohár <[email protected]>
---
v2: Check return value for all pm_runtime_get_sync() calls
---
drivers/crypto/omap-sham.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index b20e374..c5df53d 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -362,7 +362,13 @@ static void omap_sham_copy_ready_hash(struct ahash_request *req)

static int omap_sham_hw_init(struct omap_sham_dev *dd)
{
- pm_runtime_get_sync(dd->dev);
+ int err;
+
+ err = pm_runtime_get_sync(dd->dev);
+ if (err < 0) {
+ dev_err(dd->dev, "failed to get sync: %d\n", err);
+ return err;
+ }

if (!test_bit(FLAGS_INIT, &dd->flags)) {
set_bit(FLAGS_INIT, &dd->flags);
@@ -1949,7 +1955,13 @@ static int omap_sham_probe(struct platform_device *pdev)
dd->flags |= dd->pdata->flags;

pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
+
+ err = pm_runtime_get_sync(dev);
+ if (err < 0) {
+ dev_err(dev, "failed to get sync: %d\n", err);
+ goto err_pm;
+ }
+
rev = omap_sham_read(dd, SHA_REG_REV(dd));
pm_runtime_put_sync(&pdev->dev);

@@ -1979,6 +1991,7 @@ err_algs:
for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
crypto_unregister_ahash(
&dd->pdata->algs_info[i].algs_list[j]);
+err_pm:
pm_runtime_disable(dev);
if (dd->dma_lch)
dma_release_channel(dd->dma_lch);
@@ -2021,7 +2034,11 @@ static int omap_sham_suspend(struct device *dev)

static int omap_sham_resume(struct device *dev)
{
- pm_runtime_get_sync(dev);
+ int err = pm_runtime_get_sync(dev);
+ if (err < 0) {
+ dev_err(dev, "failed to get sync: %d\n", err);
+ return err;
+ }
return 0;
}
#endif
--
1.7.9.5

2015-03-08 10:01:37

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> Hi,
>
> On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> > Are there any fixes in this series that should go into
> > v4.0-rc series, or can it all wait for v4.1?
>
> I think these all should wait for v4.1.
>
> A.

I would suggest to include at least patches 01, 04, 06. Probably
those could go to -stable tree... but this decision is up to you.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-03-08 16:35:13

by Paul Walmsley

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Sun, 8 Mar 2015, Pali Rohár wrote:

> On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> > On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> > > Are there any fixes in this series that should go into
> > > v4.0-rc series, or can it all wait for v4.1?
> >
> > I think these all should wait for v4.1.
> >
> > A.
>
> I would suggest to include at least patches 01, 04, 06. Probably
> those could go to -stable tree... but this decision is up to you.

I'm not sure patch 1 is a fix. As far as I know we haven't
run into any issues with it on real hardware - only on QEMU - unless you
know otherwise, Pali? Are we sure that the QEMU model behavior matches
the hardware?


- Paul

2015-03-09 20:53:19

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH v2] crypto: omap-sham: Check for return value from pm_runtime_get_sync

On Sun 2015-03-08 11:01:01, Pali Roh?r wrote:
> Function pm_runtime_get_sync could fail and we need to check return
> value to prevent kernel crash.
>
> Signed-off-by: Pali Roh?r <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-03-15 09:59:32

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Sunday 08 March 2015 17:35:13 Paul Walmsley wrote:
> On Sun, 8 Mar 2015, Pali Rohár wrote:
> > On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> > > On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren
wrote:
> > > > Are there any fixes in this series that should go into
> > > > v4.0-rc series, or can it all wait for v4.1?
> > >
> > > I think these all should wait for v4.1.
> > >
> > > A.
> >
> > I would suggest to include at least patches 01, 04, 06.
> > Probably those could go to -stable tree... but this
> > decision is up to you.
>
> I'm not sure patch 1 is a fix. As far as I know we haven't
> run into any issues with it on real hardware - only on QEMU -
> unless you know otherwise, Pali? Are we sure that the QEMU
> model behavior matches the hardware?
>
>
> - Paul

Patch 1 check for return value of more functions. If real HW or
software emulated HW (in qemu) does not support e.g. aes then
kernel show oops message, because kernel does not check return
values and try to touch non-existent HW. So I think patch 1 is
really fix. In my opinion if something can fail, then kernel
should check if it failed. And not expect that function call
always pass.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-03-16 21:49:33

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 06/10] ARM: dts: omap3: Add missing dmas for crypto

* Pavel Machek <[email protected]> [150228 08:49]:
> On Thu 2015-02-26 14:49:56, Pali Rohár wrote:
> > This patch adds missing dma DTS definitions for omap aes and sham drivers.
> > Without it kernel drivers do not work.
> >
> > Signed-off-by: Pali Rohár <[email protected]>
>
> Acked-by: Pavel Machek <[email protected]>

Applying this into omap-for-v4.0/fixes to remove the regression
for legacy vs DT based booting for GP omap3 boards.

Tony

2015-03-19 16:43:32

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 07/10] ARM: dts: n9/n950: Enable omap crypto support

* Pavel Machek <[email protected]> [150228 08:45]:
> On Thu 2015-02-26 14:49:57, Pali Rohár wrote:
> > Harmattan system on Nokia N9 and N950 devices uses omap crypto support.
> > Bootloader on those devices is known that it enables HW crypto support.
> > This patch just include omap36xx.dtsi directly, so aes and sham is enabled.
> >
> > Signed-off-by: Pali Rohár <[email protected]>
>
> Acked-by: Pavel Machek <[email protected]>

I'm picking patches 7 - 10 into omap-for-v4.1/dt branch thanks.

Tony

2015-05-14 21:17:41

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> Hi,
>
> On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> > Are there any fixes in this series that should go into
> > v4.0-rc series, or can it all wait for v4.1?
>
> I think these all should wait for v4.1.
>
> A.

4.1-rc3 was released and this patch series is still not included...

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-05-14 21:34:22

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

* Pali Rohár <[email protected]> [150514 14:19]:
> On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> > Hi,
> >
> > On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> > > Are there any fixes in this series that should go into
> > > v4.0-rc series, or can it all wait for v4.1?
> >
> > I think these all should wait for v4.1.
> >
> > A.
>
> 4.1-rc3 was released and this patch series is still not included...

The dts changes should be merged?

I suggest you repost the driver fixes so Herbert can queue them.

Regards,

Tony

2015-05-14 21:39:14

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

On Thursday 14 May 2015 23:34:19 Tony Lindgren wrote:
> * Pali Rohár <[email protected]> [150514 14:19]:
> > On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> > > Hi,
> > >
> > > On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> > > > Are there any fixes in this series that should go into
> > > > v4.0-rc series, or can it all wait for v4.1?
> > >
> > > I think these all should wait for v4.1.
> > >
> > > A.
> >
> > 4.1-rc3 was released and this patch series is still not included...
>
> The dts changes should be merged?
>

Looks like yes, but first two arch/arm/mach-omap2 patches not.

> I suggest you repost the driver fixes so Herbert can queue them.
>

Ok.

> Regards,
>
> Tony

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-05-14 21:40:37

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH v2] crypto: omap-sham: Check for return value from pm_runtime_get_sync

On Sunday 08 March 2015 11:01:01 Pali Rohár wrote:
> Function pm_runtime_get_sync could fail and we need to check return
> value to prevent kernel crash.
>
> Signed-off-by: Pali Rohár <[email protected]>
> ---
> v2: Check return value for all pm_runtime_get_sync() calls
> ---
> drivers/crypto/omap-sham.c | 23 ++++++++++++++++++++---
> 1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index b20e374..c5df53d 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -362,7 +362,13 @@ static void omap_sham_copy_ready_hash(struct
> ahash_request *req)
>
> static int omap_sham_hw_init(struct omap_sham_dev *dd)
> {
> - pm_runtime_get_sync(dd->dev);
> + int err;
> +
> + err = pm_runtime_get_sync(dd->dev);
> + if (err < 0) {
> + dev_err(dd->dev, "failed to get sync: %d\n", err);
> + return err;
> + }
>
> if (!test_bit(FLAGS_INIT, &dd->flags)) {
> set_bit(FLAGS_INIT, &dd->flags);
> @@ -1949,7 +1955,13 @@ static int omap_sham_probe(struct
> platform_device *pdev) dd->flags |= dd->pdata->flags;
>
> pm_runtime_enable(dev);
> - pm_runtime_get_sync(dev);
> +
> + err = pm_runtime_get_sync(dev);
> + if (err < 0) {
> + dev_err(dev, "failed to get sync: %d\n", err);
> + goto err_pm;
> + }
> +
> rev = omap_sham_read(dd, SHA_REG_REV(dd));
> pm_runtime_put_sync(&pdev->dev);
>
> @@ -1979,6 +1991,7 @@ err_algs:
> for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
> crypto_unregister_ahash(
> &dd->pdata->algs_info[i].algs_list[j]);
> +err_pm:
> pm_runtime_disable(dev);
> if (dd->dma_lch)
> dma_release_channel(dd->dma_lch);
> @@ -2021,7 +2034,11 @@ static int omap_sham_suspend(struct device
> *dev)
>
> static int omap_sham_resume(struct device *dev)
> {
> - pm_runtime_get_sync(dev);
> + int err = pm_runtime_get_sync(dev);
> + if (err < 0) {
> + dev_err(dev, "failed to get sync: %d\n", err);
> + return err;
> + }
> return 0;
> }
> #endif

Herbert, can you apply this patch?

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2015-05-14 22:03:26

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/10] omap3 crypto fixes

* Pali Rohár <[email protected]> [150514 14:40]:
> On Thursday 14 May 2015 23:34:19 Tony Lindgren wrote:
> > * Pali Rohár <[email protected]> [150514 14:19]:
> > > On Friday 06 March 2015 23:23:06 Aaro Koskinen wrote:
> > > > Hi,
> > > >
> > > > On Fri, Mar 06, 2015 at 10:36:32AM -0800, Tony Lindgren wrote:
> > > > > Are there any fixes in this series that should go into
> > > > > v4.0-rc series, or can it all wait for v4.1?
> > > >
> > > > I think these all should wait for v4.1.
> > > >
> > > > A.
> > >
> > > 4.1-rc3 was released and this patch series is still not included...
> >
> > The dts changes should be merged?
> >
>
> Looks like yes, but first two arch/arm/mach-omap2 patches not.

I suggest you repost those to separately so Paul can take
a look at them. It seems they can be merged separately from
the driver changes?

Regards,

Tony

2015-05-15 00:15:16

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH v2] crypto: omap-sham: Check for return value from pm_runtime_get_sync

On Thu, May 14, 2015 at 11:40:37PM +0200, Pali Roh?r wrote:
>
> Herbert, can you apply this patch?

OK I dug this out of patchwork for you. In future please post
patches that you want me to apply separately.

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2015-05-15 07:02:47

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH v2] crypto: omap-sham: Check for return value from pm_runtime_get_sync

On Thu, May 14, 2015 at 11:40:37PM +0200, Pali Roh?r wrote:
> On Sunday 08 March 2015 11:01:01 Pali Roh?r wrote:
> > Function pm_runtime_get_sync could fail and we need to check return
> > value to prevent kernel crash.
> >
> > Signed-off-by: Pali Roh?r <[email protected]>

Applied.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2015-05-15 09:19:33

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 03/10] crypto: omap-sham: Add support for omap3 devices

On Saturday 28 February 2015 17:25:02 Pavel Machek wrote:
> On Thu 2015-02-26 14:49:53, Pali Rohár wrote:
> > omap3 support is same as omap2, just with different IO address (specified in DT)
> >
> > Signed-off-by: Pali Rohár <[email protected]>
>
> Acked-by: Pavel Machek <[email protected]>
>
> > @@ -1792,6 +1792,10 @@ static const struct of_device_id omap_sham_of_match[] = {
> > .data = &omap_sham_pdata_omap2,
> > },
> > {
> > + .compatible = "ti,omap3-sham",
> > + .data = &omap_sham_pdata_omap2,
> > + },
> > + {
> > .compatible = "ti,omap4-sham",
> > .data = &omap_sham_pdata_omap4,
> > },
>

Herbert, this is second crypto patch in this series, can you apply it too?

--
Pali Rohár
[email protected]

2015-05-15 09:21:00

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH v2] crypto: omap-sham: Check for return value from pm_runtime_get_sync

On Friday 15 May 2015 15:02:29 Herbert Xu wrote:
> On Thu, May 14, 2015 at 11:40:37PM +0200, Pali Rohár wrote:
> > On Sunday 08 March 2015 11:01:01 Pali Rohár wrote:
> > > Function pm_runtime_get_sync could fail and we need to check return
> > > value to prevent kernel crash.
> > >
> > > Signed-off-by: Pali Rohár <[email protected]>
>
> Applied.

Thanks! In this patch series is also another one patch for crypto
subsystem. I replied to that patch email.

--
Pali Rohár
[email protected]

2015-05-18 04:30:08

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 03/10] crypto: omap-sham: Add support for omap3 devices

On Fri, May 15, 2015 at 11:19:33AM +0200, Pali Roh?r wrote:
> On Saturday 28 February 2015 17:25:02 Pavel Machek wrote:
> > On Thu 2015-02-26 14:49:53, Pali Roh?r wrote:
> > > omap3 support is same as omap2, just with different IO address (specified in DT)
> > >
> > > Signed-off-by: Pali Roh?r <[email protected]>
> >
> > Acked-by: Pavel Machek <[email protected]>
> >
> > > @@ -1792,6 +1792,10 @@ static const struct of_device_id omap_sham_of_match[] = {
> > > .data = &omap_sham_pdata_omap2,
> > > },
> > > {
> > > + .compatible = "ti,omap3-sham",
> > > + .data = &omap_sham_pdata_omap2,
> > > + },
> > > + {
> > > .compatible = "ti,omap4-sham",
> > > .data = &omap_sham_pdata_omap4,
> > > },
> >
>
> Herbert, this is second crypto patch in this series, can you apply it too?

Applied.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2015-05-21 11:44:52

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 01/10] ARM: OMAP2+: Return correct error values from device and hwmod

On Thursday 26 February 2015 14:49:51 Pali Rohár wrote:
> Without this patch function pm_runtime_get_sync() returns 0 even when some
> omap subfunction fails. This patch properly propagate error codes from omap
> functions back to caller.
>
> This patch fix problem, when loading omap-aes driver in qemu cause kernel oops.
>
> Signed-off-by: Pali Rohár <[email protected]>
> ---
> arch/arm/mach-omap2/omap_device.c | 30 +++++++++++++++++-------------
> arch/arm/mach-omap2/omap_hwmod.c | 10 ++++++----
> 2 files changed, 23 insertions(+), 17 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
> index be9541e..9fd47a9 100644
> --- a/arch/arm/mach-omap2/omap_device.c
> +++ b/arch/arm/mach-omap2/omap_device.c
> @@ -224,13 +224,13 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
> */
> static int _omap_device_enable_hwmods(struct omap_device *od)
> {
> + int ret = 0;
> int i;
>
> for (i = 0; i < od->hwmods_cnt; i++)
> - omap_hwmod_enable(od->hwmods[i]);
> + ret |= omap_hwmod_enable(od->hwmods[i]);
>
> - /* XXX pass along return value here? */
> - return 0;
> + return ret;
> }
>
> /**
> @@ -241,13 +241,13 @@ static int _omap_device_enable_hwmods(struct omap_device *od)
> */
> static int _omap_device_idle_hwmods(struct omap_device *od)
> {
> + int ret = 0;
> int i;
>
> for (i = 0; i < od->hwmods_cnt; i++)
> - omap_hwmod_idle(od->hwmods[i]);
> + ret |= omap_hwmod_idle(od->hwmods[i]);
>
> - /* XXX pass along return value here? */
> - return 0;
> + return ret;
> }
>
> /* Public functions for use by core code */
> @@ -595,18 +595,20 @@ static int _od_runtime_suspend(struct device *dev)
> int ret;
>
> ret = pm_generic_runtime_suspend(dev);
> + if (ret)
> + return ret;
>
> - if (!ret)
> - omap_device_idle(pdev);
> -
> - return ret;
> + return omap_device_idle(pdev);
> }
>
> static int _od_runtime_resume(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> + int ret;
>
> - omap_device_enable(pdev);
> + ret = omap_device_enable(pdev);
> + if (ret)
> + return ret;
>
> return pm_generic_runtime_resume(dev);
> }
> @@ -740,7 +742,8 @@ int omap_device_enable(struct platform_device *pdev)
>
> ret = _omap_device_enable_hwmods(od);
>
> - od->_state = OMAP_DEVICE_STATE_ENABLED;
> + if (ret == 0)
> + od->_state = OMAP_DEVICE_STATE_ENABLED;
>
> return ret;
> }
> @@ -770,7 +773,8 @@ int omap_device_idle(struct platform_device *pdev)
>
> ret = _omap_device_idle_hwmods(od);
>
> - od->_state = OMAP_DEVICE_STATE_IDLE;
> + if (ret == 0)
> + od->_state = OMAP_DEVICE_STATE_IDLE;
>
> return ret;
> }
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index 92afb72..870e984 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -3350,16 +3350,17 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
> */
> int omap_hwmod_idle(struct omap_hwmod *oh)
> {
> + int r;
> unsigned long flags;
>
> if (!oh)
> return -EINVAL;
>
> spin_lock_irqsave(&oh->_lock, flags);
> - _idle(oh);
> + r = _idle(oh);
> spin_unlock_irqrestore(&oh->_lock, flags);
>
> - return 0;
> + return r;
> }
>
> /**
> @@ -3372,16 +3373,17 @@ int omap_hwmod_idle(struct omap_hwmod *oh)
> */
> int omap_hwmod_shutdown(struct omap_hwmod *oh)
> {
> + int r;
> unsigned long flags;
>
> if (!oh)
> return -EINVAL;
>
> spin_lock_irqsave(&oh->_lock, flags);
> - _shutdown(oh);
> + r = _shutdown(oh);
> spin_unlock_irqrestore(&oh->_lock, flags);
>
> - return 0;
> + return r;
> }
>
> /*

Hello Paul, can you apply this patch?

--
Pali Rohár
[email protected]

2015-05-26 12:36:30

by Pali Rohár

[permalink] [raw]
Subject: Re: [PATCH 02/10] ARM: OMAP3: Fix crypto support for HS devices

Hi Paul,

this patch is also for omap2... Can you review it too?

On Saturday 28 February 2015 17:24:36 Pavel Machek wrote:
> On Thu 2015-02-26 14:49:52, Pali Rohár wrote:
> > Register crypto hwmod links only if they are not disabled in DT.
> > If DT information is missing, enable them only for GP devices.
> >
> > Before this patch crypto hwmod links were always disabled for all HS devices
> > and it was not possible to use omap-aes and omap-sham linux drivers.
> >
> > Signed-off-by: Pali Rohár <[email protected]>
>
> Acked-by: Pavel Machek <[email protected]>
>

--
Pali Rohár
[email protected]

2015-06-02 18:36:31

by Paul Walmsley

[permalink] [raw]
Subject: Re: [PATCH 02/10] ARM: OMAP3: Fix crypto support for HS devices

On Tue, 26 May 2015, Pali Rohár wrote:

> Hi Paul,
>
> this patch is also for omap2... Can you review it too?
>
> On Saturday 28 February 2015 17:24:36 Pavel Machek wrote:
> > On Thu 2015-02-26 14:49:52, Pali Rohár wrote:
> > > Register crypto hwmod links only if they are not disabled in DT.
> > > If DT information is missing, enable them only for GP devices.
> > >
> > > Before this patch crypto hwmod links were always disabled for all HS devices
> > > and it was not possible to use omap-aes and omap-sham linux drivers.
> > >
> > > Signed-off-by: Pali Rohár <[email protected]>
> >
> > Acked-by: Pavel Machek <[email protected]>
> >

Sent to Tony for v4.2, after tweaking it a bit (below)

- Paul

Subject: [PATCH] ARM: OMAP3: Fix crypto support for HS devices

Register crypto hwmod links only if they are not disabled in DT.
If DT information is missing, enable them only for GP devices.

Before this patch crypto hwmod links were always disabled for all HS
devices and it was not possible to use omap-aes and omap-sham linux
drivers.

Signed-off-by: Pali Rohár <[email protected]>
Acked-by: Pavel Machek <[email protected]>
[[email protected]: move the complex IP-block presence heuristics into their
own function to simplify the code; fix some checkpatch warnings]
Signed-off-by: Paul Walmsley <[email protected]>
---
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 107 +++++++++++++++++++++++++----
1 file changed, 94 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 0ca4d3fb7df6..dc55f8dedf2c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -3736,29 +3736,54 @@ static struct omap_hwmod_ocp_if *omap3xxx_hwmod_ocp_ifs[] __initdata = {
/* GP-only hwmod links */
static struct omap_hwmod_ocp_if *omap34xx_gp_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l4_sec__timer12,
- &omap3xxx_l4_core__sham,
- &omap3xxx_l4_core__aes,
NULL
};

static struct omap_hwmod_ocp_if *omap36xx_gp_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l4_sec__timer12,
- &omap3xxx_l4_core__sham,
- &omap3xxx_l4_core__aes,
NULL
};

static struct omap_hwmod_ocp_if *am35xx_gp_hwmod_ocp_ifs[] __initdata = {
&omap3xxx_l4_sec__timer12,
- /*
- * Apparently the SHA/MD5 and AES accelerator IP blocks are
- * only present on some AM35xx chips, and no one knows which
- * ones. See
- * http://www.spinics.net/lists/arm-kernel/msg215466.html So
- * if you need these IP blocks on an AM35xx, try uncommenting
- * the following lines.
- */
+ NULL
+};
+
+/* crypto hwmod links */
+static struct omap_hwmod_ocp_if *omap34xx_sham_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__sham,
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *omap34xx_aes_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__aes,
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *omap36xx_sham_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__sham,
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *omap36xx_aes_hwmod_ocp_ifs[] __initdata = {
+ &omap3xxx_l4_core__aes,
+ NULL
+};
+
+/*
+ * Apparently the SHA/MD5 and AES accelerator IP blocks are
+ * only present on some AM35xx chips, and no one knows which
+ * ones. See
+ * http://www.spinics.net/lists/arm-kernel/msg215466.html So
+ * if you need these IP blocks on an AM35xx, try uncommenting
+ * the following lines.
+ */
+static struct omap_hwmod_ocp_if *am35xx_sham_hwmod_ocp_ifs[] __initdata = {
/* &omap3xxx_l4_core__sham, */
+ NULL
+};
+
+static struct omap_hwmod_ocp_if *am35xx_aes_hwmod_ocp_ifs[] __initdata = {
/* &omap3xxx_l4_core__aes, */
NULL
};
@@ -3860,10 +3885,41 @@ static struct omap_hwmod_ocp_if *omap3xxx_dss_hwmod_ocp_ifs[] __initdata = {
NULL
};

+/**
+ * omap3xxx_hwmod_is_hs_ip_block_usable - is a security IP block accessible?
+ * @bus: struct device_node * for the top-level OMAP DT data
+ * @dev_name: device name used in the DT file
+ *
+ * Determine whether a "secure" IP block @dev_name is usable by Linux.
+ * There doesn't appear to be a 100% reliable way to determine this,
+ * so we rely on heuristics. If @bus is null, meaning there's no DT
+ * data, then we only assume the IP block is accessible if the OMAP is
+ * fused as a 'general-purpose' SoC. If however DT data is present,
+ * test to see if the IP block is described in the DT data and set to
+ * 'status = "okay"'. If so then we assume the ODM has configured the
+ * OMAP firewalls to allow access to the IP block.
+ *
+ * Return: 0 if device named @dev_name is not likely to be accessible,
+ * or 1 if it is likely to be accessible.
+ */
+static int __init omap3xxx_hwmod_is_hs_ip_block_usable(struct device_node *bus,
+ const char *dev_name)
+{
+ if (!bus)
+ return (omap_type() == OMAP2_DEVICE_TYPE_GP) ? 1 : 0;
+
+ if (of_device_is_available(of_find_node_by_name(bus, dev_name)))
+ return 1;
+
+ return 0;
+}
+
int __init omap3xxx_hwmod_init(void)
{
int r;
- struct omap_hwmod_ocp_if **h = NULL, **h_gp = NULL;
+ struct omap_hwmod_ocp_if **h = NULL, **h_gp = NULL, **h_sham = NULL;
+ struct omap_hwmod_ocp_if **h_aes = NULL;
+ struct device_node *bus = NULL;
unsigned int rev;

omap_hwmod_init();
@@ -3885,13 +3941,19 @@ int __init omap3xxx_hwmod_init(void)
rev == OMAP3430_REV_ES3_1 || rev == OMAP3430_REV_ES3_1_2) {
h = omap34xx_hwmod_ocp_ifs;
h_gp = omap34xx_gp_hwmod_ocp_ifs;
+ h_sham = omap34xx_sham_hwmod_ocp_ifs;
+ h_aes = omap34xx_aes_hwmod_ocp_ifs;
} else if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
h = am35xx_hwmod_ocp_ifs;
h_gp = am35xx_gp_hwmod_ocp_ifs;
+ h_sham = am35xx_sham_hwmod_ocp_ifs;
+ h_aes = am35xx_aes_hwmod_ocp_ifs;
} else if (rev == OMAP3630_REV_ES1_0 || rev == OMAP3630_REV_ES1_1 ||
rev == OMAP3630_REV_ES1_2) {
h = omap36xx_hwmod_ocp_ifs;
h_gp = omap36xx_gp_hwmod_ocp_ifs;
+ h_sham = omap36xx_sham_hwmod_ocp_ifs;
+ h_aes = omap36xx_aes_hwmod_ocp_ifs;
} else {
WARN(1, "OMAP3 hwmod family init: unknown chip type\n");
return -EINVAL;
@@ -3908,6 +3970,25 @@ int __init omap3xxx_hwmod_init(void)
return r;
}

+ /*
+ * Register crypto hwmod links only if they are not disabled in DT.
+ * If DT information is missing, enable them only for GP devices.
+ */
+
+ if (of_have_populated_dt())
+ bus = of_find_node_by_name(NULL, "ocp");
+
+ if (h_sham && omap3xxx_hwmod_is_hs_ip_block_usable(bus, "sham")) {
+ r = omap_hwmod_register_links(h_sham);
+ if (r < 0)
+ return r;
+ }
+
+ if (h_aes && omap3xxx_hwmod_is_hs_ip_block_usable(bus, "aes")) {
+ r = omap_hwmod_register_links(h_aes);
+ if (r < 0)
+ return r;
+ }

/*
* Register hwmod links specific to certain ES levels of a
--
2.1.4