Skip to contentSkip to conversation

crypto: sahara: Add support for SAHARA in i.MX27.

PATCH New Javier Martin 5 participants 19 messages Feb 21, 2013 – Feb 26, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

This series of patches provide AES-ECB and AES-CBC support for the SAHARA2 cryptographic accelerator which is inside the i.MX27 SoC. It is expected that more algorithms will be supported in the future.

For testing, a Visstrim M10 board has been used and the code related to this platform has been included too.

[PATCH 1/3] i.MX27: Add platform support for SAHARA2. [PATCH 2/3] crypto: sahara: Add driver for SAHARA2 accelerator. [PATCH 3/3] Visstrim M10: Add support for SAHARA2 module.

#1 lore raw

PATCH 1/3 i.MX27: Add platform support for SAHARA2.

i.MX27 devices include this HW cryptographic
accelerator.

---
 arch/arm/mach-imx/clk-imx27.c                     |    2 ++
 arch/arm/mach-imx/devices-imx27.h                 |    4 +++
 arch/arm/mach-imx/devices/Kconfig                 |    4 +++
 arch/arm/mach-imx/devices/Makefile                |    1 +
 arch/arm/mach-imx/devices/devices-common.h        |    8 +++++
 arch/arm/mach-imx/devices/platform-imx27-sahara.c |   37 +++++++++++++++++++++
 6 files changed, 56 insertions(+)
 create mode 100644 arch/arm/mach-imx/devices/platform-imx27-sahara.c
arch/arm/mach-imx/clk-imx27.c +2 -0
index 4c1d1e4..0b9664a 100644
@@ -253,6 +253,8 @@ int __init mx27_clocks_init(unsigned long fref)
 	clk_register_clkdev(clk[nfc_baud_gate], NULL, "imx27-nand.0");
 	clk_register_clkdev(clk[vpu_baud_gate], "per", "coda-imx27.0");
 	clk_register_clkdev(clk[vpu_ahb_gate], "ahb", "coda-imx27.0");
+	clk_register_clkdev(clk[sahara_ahb_gate], "ahb", "sahara-imx27.0");
+	clk_register_clkdev(clk[sahara_ipg_gate], "ipg", "sahara-imx27.0");
 	clk_register_clkdev(clk[dma_ahb_gate], "ahb", "imx27-dma");
 	clk_register_clkdev(clk[dma_ipg_gate], "ipg", "imx27-dma");
 	clk_register_clkdev(clk[fec_ipg_gate], "ipg", "imx27-fec.0");
arch/arm/mach-imx/devices-imx27.h +4 -0
index 1309625..3bc95d8 100644
@@ -20,6 +20,10 @@ extern const struct imx_imx27_coda_data imx27_coda_data;
 #define imx27_add_coda()	\
 	imx_add_imx27_coda(&imx27_coda_data)
 
+extern const struct imx_imx27_sahara_data imx27_sahara_data;
+#define imx27_add_sahara()	\
+	imx_add_imx27_sahara(&imx27_sahara_data)
+
 extern const struct imx_imx2_wdt_data imx27_imx2_wdt_data;
 #define imx27_add_imx2_wdt()	\
 	imx_add_imx2_wdt(&imx27_imx2_wdt_data)
arch/arm/mach-imx/devices/Kconfig +4 -0
index 9a8f1ca..3edaa8d 100644
@@ -20,6 +20,10 @@ config IMX_HAVE_PLATFORM_IMX27_CODA
 	bool
 	default y if SOC_IMX27
 
+config IMX_HAVE_PLATFORM_IMX27_SAHARA
+	bool
+	default y if SOC_IMX27
+
 config IMX_HAVE_PLATFORM_IMX2_WDT
 	bool
 
arch/arm/mach-imx/devices/Makefile +1 -0
index 6acf37e..f5534a2 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
 obj-y += platform-gpio-mxc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX21_HCD) += platform-imx21-hcd.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX27_CODA) += platform-imx27-coda.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX27_SAHARA) += platform-imx27-sahara.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX2_WDT) += platform-imx2-wdt.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMXDI_RTC) += platform-imxdi_rtc.o
 obj-y += platform-imx-dma.o
arch/arm/mach-imx/devices/devices-common.h +8 -0
index 6277baf..48065b2 100644
@@ -91,6 +91,14 @@ struct imx_imx27_coda_data {
 struct platform_device *__init imx_add_imx27_coda(
 		const struct imx_imx27_coda_data *data);
 
+struct imx_imx27_sahara_data {
+	resource_size_t iobase;
+	resource_size_t iosize;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_imx27_sahara(
+		const struct imx_imx27_sahara_data *data);
+
 struct imx_imx2_wdt_data {
 	int id;
 	resource_size_t iobase;
arch/arm/mach-imx/devices/platform-imx27-sahara.c new file +37 -0
new file mode 100644
index 0000000..94288f4
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Vista Silicon
+ * Javier Martin <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+
+#include "../hardware.h"
+#include "devices-common.h"
+
+#ifdef CONFIG_SOC_IMX27
+const struct imx_imx27_sahara_data imx27_sahara_data __initconst = {
+	.iobase = MX27_SAHARA_BASE_ADDR,
+	.iosize = SZ_2K,
+	.irq = MX27_INT_SAHARA,
+};
+#endif
+
+struct platform_device *__init imx_add_imx27_sahara(
+		const struct imx_imx27_sahara_data *data)
+{
+	struct resource res[] = {
+		{
+			.start = data->iobase,
+			.end = data->iobase + data->iosize - 1,
+			.flags = IORESOURCE_MEM,
+		}, {
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+	return imx_add_platform_device_dmamask("sahara-imx27", 0, res, 2, NULL,
+					0, DMA_BIT_MASK(32));
+}
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/3 crypto: sahara: Add driver for SAHARA2 accelerator.

In reply to Javier Martin

SAHARA2 HW module is included in the i.MX27 SoC from Freescale. It is capable of performing cipher algorithms such as AES, 3DES..., hashing and RNG too.

This driver provides support for AES-CBC and AES-ECB by now.

---
 drivers/crypto/Kconfig  |   10 +
 drivers/crypto/Makefile |    1 +
 drivers/crypto/sahara.c | 1050 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1061 insertions(+)
 create mode 100644 drivers/crypto/sahara.c
drivers/crypto/Kconfig +10 -0
index 87ec4d0..3a5c597 100644
@@ -276,6 +276,16 @@ config CRYPTO_DEV_PICOXCELL
 
 	  Saying m here will build a module named pipcoxcell_crypto.
 
+config CRYPTO_DEV_SAHARA
+	tristate "Support for SAHARA crypto accelerator"
+	depends on MACH_MX27 && EXPERIMENTAL
+	select CRYPTO_BLKCIPHER
+	select CRYPTO_AES
+	select CRYPTO_ECB
+	help
+	  This option enables support for the SAHARA HW crypto accelerator
+	  found in some Freescale i.MX chips.
+
 config CRYPTO_DEV_S5P
 	tristate "Support for Samsung S5PV210 crypto accelerator"
 	depends on ARCH_S5PV210
drivers/crypto/Makefile +1 -0
index 880a47b..38ce13d 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
 obj-$(CONFIG_CRYPTO_DEV_OMAP_SHAM) += omap-sham.o
 obj-$(CONFIG_CRYPTO_DEV_OMAP_AES) += omap-aes.o
 obj-$(CONFIG_CRYPTO_DEV_PICOXCELL) += picoxcell_crypto.o
+obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o
 obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o
 obj-$(CONFIG_CRYPTO_DEV_TEGRA_AES) += tegra-aes.o
 obj-$(CONFIG_CRYPTO_DEV_UX500) += ux500/
drivers/crypto/sahara.c new file +1050 -0

1,050 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/3 crypto: sahara: Add driver for SAHARA2 accelerator.

Quoted 29 lines · Javier Martin
drivers/crypto/sahara.c new file +29 -0
+
+struct sahara_dev {
+	struct device		*device;
+	void __iomem		*regs_base;
+	struct clk		*clk_ipg;
+	struct clk		*clk_ahb;
+
+	struct sahara_ctx	*ctx;
+	spinlock_t		lock;
+	struct crypto_queue	queue;
+	unsigned long		flags;
+
+	struct tasklet_struct	done_task;
+	struct tasklet_struct	queue_task;
+
+	struct sahara_hw_desc	*hw_desc[SAHARA_MAX_HW_DESC];
+	dma_addr_t		hw_phys_desc[SAHARA_MAX_HW_DESC];
+
+	u8			*key_base;
+	dma_addr_t		key_phys_base;
+
+	u8			*iv_base;
+	dma_addr_t		iv_phys_base;
+
+	struct sahara_hw_link	*hw_link[SAHARA_MAX_HW_LINK];
+	dma_addr_t		hw_phys_link[SAHARA_MAX_HW_LINK];
+
+	struct ablkcipher_request *req;
+	size_t			total;

drivers/crypto/sahara.c line 167

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+	struct scatterlist	*in_sg;
+	unsigned int		nb_in_sg;
+	struct scatterlist	*out_sg;
+	unsigned int		nb_out_sg;
+
+	u32			error;
+	struct timer_list	watchdog;
+};
+
+static struct sahara_dev *dev_ptr;

Please remove this global device pointer, it should not be needed, since you can store the pointer in the context object.

drivers/crypto/sahara.c line 316

Quoted 7 lines
drivers/crypto/sahara.c new file +7 -0
+#ifdef DEBUG
+
+static char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
+
+static void sahara_decode_status(struct sahara_dev *dev, unsigned int status)
+{
+	u8 state = SAHARA_STATUS_GET_STATE(status);

You can simplify the code a lot if you replace the #ifdef around the function with an

	if (!IS_ENBLED(DEBUG))
		return;

at the start of the function. That will lead to gcc completely removing the code an everything referenced by it.

Quoted 6 lines
drivers/crypto/sahara.c new file +6 -0
+static void sahara_aes_done_task(unsigned long data)
+{
+	struct sahara_dev *dev = (struct sahara_dev *)data;
+	unsigned long flags;
+
+	dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,

drivers/crypto/sahara.c line 411

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+		DMA_TO_DEVICE);
+	dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
+		DMA_FROM_DEVICE);
+
+	spin_lock_irqsave(&dev->lock, flags);
+	clear_bit(FLAGS_BUSY, &dev->flags);
+	spin_unlock_irqrestore(&dev->lock, flags);
+
+	dev->req->base.complete(&dev->req->base, dev->error);
+}

Does dev->lock have to be irq-disabled? You don't seem to take it from an interrupt handler.

Also, when you know that code is called without irqs enabled and you just want to disable them, you can use the cheaper spin_lock_irq() rather than spin_lock_irqsave().

In short, use either spin_lock_irq or spin_lock here. When protecting against a tasklet, you will need spin_lock_bh.

drivers/crypto/sahara.c line 420

Quoted 9 lines
drivers/crypto/sahara.c new file +9 -0
+
+void sahara_watchdog(unsigned long data)
+{
+	struct sahara_dev *dev = (struct sahara_dev *)data;
+	unsigned int err = sahara_read(dev, SAHARA_REG_ERRSTATUS);
+#ifdef DEBUG
+	unsigned int stat = sahara_read(dev, SAHARA_REG_STATUS);
+	sahara_decode_status(dev, stat);
+#endif

When you kill off the #ifdef, you should move this sahara_read() call into the sahara_decode_status() function so it gets compiled conditionally.

drivers/crypto/sahara.c line 861

Quoted 5 lines
drivers/crypto/sahara.c new file +5 -0
+static struct platform_device_id sahara_platform_ids[] = {
+	{ .name = "sahara-imx27" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, sahara_platform_ids);

You are missing the of_device_ids here. We probably don't even need the platform_device_id list and can instead mandate that this is only used by platforms that are already converted to DT booting.

Please also add a DT binding document for this driver that mentions the name and the resources that need to be provided.

Arnd

#4 lore raw

PATCH 2/3 crypto: sahara: Add driver for SAHARA2 accelerator.

Hi Arnd,
thanks for your review.

Quoted 35 lines · Arnd Bergmann
Quoted 34 lines · Javier Martin
drivers/crypto/sahara.c new file +34 -0
+
+struct sahara_dev {
+     struct device           *device;
+     void __iomem            *regs_base;
+     struct clk              *clk_ipg;
+     struct clk              *clk_ahb;
+
+     struct sahara_ctx       *ctx;
+     spinlock_t              lock;
+     struct crypto_queue     queue;
+     unsigned long           flags;
+
+     struct tasklet_struct   done_task;
+     struct tasklet_struct   queue_task;
+
+     struct sahara_hw_desc   *hw_desc[SAHARA_MAX_HW_DESC];
+     dma_addr_t              hw_phys_desc[SAHARA_MAX_HW_DESC];
+
+     u8                      *key_base;
+     dma_addr_t              key_phys_base;
+
+     u8                      *iv_base;
+     dma_addr_t              iv_phys_base;
+
+     struct sahara_hw_link   *hw_link[SAHARA_MAX_HW_LINK];
+     dma_addr_t              hw_phys_link[SAHARA_MAX_HW_LINK];
+
+     struct ablkcipher_request *req;
+     size_t                  total;
+     struct scatterlist      *in_sg;
+     unsigned int            nb_in_sg;
+     struct scatterlist      *out_sg;
+     unsigned int            nb_out_sg;
+
Quoted 8 lines

drivers/crypto/sahara.c line 167

Quoted 5 lines
drivers/crypto/sahara.c new file +5 -0
+     u32                     error;
+     struct timer_list       watchdog;
+};
+
+static struct sahara_dev *dev_ptr;

Please remove this global device pointer, it should not be needed, since you can store the pointer in the context object.

Ok. Looks cleaner this way.

Quoted 12 lines

drivers/crypto/sahara.c line 316

Quoted 8 lines
drivers/crypto/sahara.c new file +7 -0
+#ifdef DEBUG
+
+static char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
+
+static void sahara_decode_status(struct sahara_dev *dev, unsigned int status)
+{
+     u8 state = SAHARA_STATUS_GET_STATE(status);

You can simplify the code a lot if you replace the #ifdef around the function with an

Quoted 6 lines
        if (!IS_ENBLED(DEBUG))
                return;

at the start of the function. That will lead to gcc completely removing the code an everything referenced by it.

Great. Thank you for the tip.

Quoted 20 lines
Quoted 6 lines
drivers/crypto/sahara.c new file +6 -0
+static void sahara_aes_done_task(unsigned long data)
+{
+     struct sahara_dev *dev = (struct sahara_dev *)data;
+     unsigned long flags;
+
+     dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,

drivers/crypto/sahara.c line 411

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+             DMA_TO_DEVICE);
+     dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
+             DMA_FROM_DEVICE);
+
+     spin_lock_irqsave(&dev->lock, flags);
+     clear_bit(FLAGS_BUSY, &dev->flags);
+     spin_unlock_irqrestore(&dev->lock, flags);
+
+     dev->req->base.complete(&dev->req->base, dev->error);
+}

Does dev->lock have to be irq-disabled? You don't seem to take it from an interrupt handler.

Quoted 6 lines

Also, when you know that code is called without irqs enabled and you just want to disable them, you can use the cheaper spin_lock_irq() rather than spin_lock_irqsave().

In short, use either spin_lock_irq or spin_lock here. When protecting against a tasklet, you will need spin_lock_bh.

You are right, dev->lock is only held by encrypt()/decrypt() callbacks and some tasklets so spin_lock() and spin_lock_bh() seem suitable here.

Quoted 5 lines
Quoted 5 lines
drivers/crypto/sahara.c new file +5 -0
+
+void sahara_watchdog(unsigned long data)
+{
+     struct sahara_dev *dev = (struct sahara_dev *)data;
+     unsigned int err = sahara_read(dev, SAHARA_REG_ERRSTATUS);
Quoted 9 lines

drivers/crypto/sahara.c line 420

Quoted 4 lines
drivers/crypto/sahara.c new file +4 -0
+#ifdef DEBUG
+     unsigned int stat = sahara_read(dev, SAHARA_REG_STATUS);
+     sahara_decode_status(dev, stat);
+#endif

When you kill off the #ifdef, you should move this sahara_read() call into the sahara_decode_status() function so it gets compiled conditionally.

All right.

Quoted 11 lines

drivers/crypto/sahara.c line 861

Quoted 5 lines
drivers/crypto/sahara.c new file +5 -0
+static struct platform_device_id sahara_platform_ids[] = {
+     { .name = "sahara-imx27" },
+     { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, sahara_platform_ids);

You are missing the of_device_ids here. We probably don't even need the platform_device_id list and can instead mandate that this is only used by platforms that are already converted to DT booting.

Quoted 2 lines

Please also add a DT binding document for this driver that mentions the name and the resources that need to be provided.

Please, take a look at 0/3 to discuss about this matter.

Regards.

Signature · 7 lines
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
#5 lore raw

PATCH 2/3 crypto: sahara: Add driver for SAHARA2 accelerator.

In reply to Javier Martin

Javier Martin <[email protected]> writes:

Hi,

Quoted 7 lines

SAHARA2 HW module is included in the i.MX27 SoC from Freescale. It is capable of performing cipher algorithms such as AES, 3DES..., hashing and RNG too.

This driver provides support for AES-CBC and AES-ECB by now.

[...]

Quoted 104 lines
drivers/crypto/sahara.c new file +104 -0
+	int irq;
+	int err;
+	int i;
+
+	dev = devm_kzalloc(&pdev->dev, sizeof(struct sahara_dev), GFP_KERNEL);
+	if (dev == NULL) {
+		dev_err(&pdev->dev, "unable to alloc data struct.\n");
+		return -ENOMEM;
+	}
+
+	dev->device = &pdev->dev;
+	platform_set_drvdata(pdev, dev);
+
+	/* Get the base address */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "failed to get memory region resource\n");
+		return -ENODEV;
+	}
+
+	if (devm_request_mem_region(&pdev->dev, res->start,
+			resource_size(res), SAHARA_NAME) == NULL) {
+		dev_err(&pdev->dev, "failed to request memory region\n");
+		return -ENOENT;
+	}
+	dev->regs_base = devm_ioremap(&pdev->dev, res->start,
+				      resource_size(res));
+	if (!dev->regs_base) {
+		dev_err(&pdev->dev, "failed to ioremap address region\n");
+		return -ENOENT;
+	}
+
+	/* Get the IRQ */
+	irq = platform_get_irq(pdev,  0);
+	if (irq < 0) {
+		dev_err(&pdev->dev, "failed to get irq resource\n");
+		return irq;
+	}
+
+	if (devm_request_irq(&pdev->dev, irq, sahara_irq_handler,
+		0, SAHARA_NAME, dev) < 0) {
+		dev_err(&pdev->dev, "failed to request irq\n");
+		return -ENOENT;
+	}
+
+	/* clocks */
+	dev->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+	if (IS_ERR(dev->clk_ipg)) {
+		dev_err(&pdev->dev, "Could not get ipg clock\n");
+		return PTR_ERR(dev->clk_ipg);
+	}
+
+	dev->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+	if (IS_ERR(dev->clk_ahb)) {
+		dev_err(&pdev->dev, "Could not get ahb clock\n");
+		return PTR_ERR(dev->clk_ahb);
+	}
+
+	/* Allocate HW descriptors */
+	dev->hw_desc[0] = dma_alloc_coherent(&pdev->dev,
+			SAHARA_MAX_HW_DESC * sizeof(struct sahara_hw_desc),
+			&dev->hw_phys_desc[0], GFP_KERNEL);
+	if (!dev->hw_desc[0]) {
+		dev_err(&pdev->dev, "Could not allocate hw descriptors\n");
+		return -ENOMEM;
+	}
+	dev->hw_desc[1] = dev->hw_desc[0] + 1;
+	dev->hw_phys_desc[1] = dev->hw_phys_desc[0] +
+				sizeof(struct sahara_hw_desc);
+
+	/* Allocate space for iv and key */
+	dev->key_base = dma_alloc_coherent(&pdev->dev, 2 * AES_KEYSIZE_128,
+				&dev->key_phys_base, GFP_KERNEL);
+	if (!dev->key_base) {
+		dev_err(&pdev->dev, "Could not allocate memory for key\n");
+		err = -ENOMEM;
+		goto err_key;
+	}
+	dev->iv_base = dev->key_base + AES_KEYSIZE_128;
+	dev->iv_phys_base = dev->key_phys_base + AES_KEYSIZE_128;
+
+	/* Allocate space for HW links */
+	dev->hw_link[0] = dma_alloc_coherent(&pdev->dev,
+			SAHARA_MAX_HW_LINK * sizeof(struct sahara_hw_link),
+			&dev->hw_phys_link[0], GFP_KERNEL);
+	if (!dev->hw_link) {
+		dev_err(&pdev->dev, "Could not allocate hw links\n");
+		err = -ENOMEM;
+		goto err_link;
+	}
+	for (i = 1; i < SAHARA_MAX_HW_LINK; i++) {
+		dev->hw_phys_link[i] = dev->hw_phys_link[i - 1] +
+					sizeof(struct sahara_hw_link);
+		dev->hw_link[i] = dev->hw_link[i - 1] + 1;
+	}
+
+	crypto_init_queue(&dev->queue, SAHARA_QUEUE_LENGTH);
+
+	dev_ptr = dev;
+
+	tasklet_init(&dev->queue_task, sahara_aes_queue_task,
+		     (unsigned long)dev);
+	tasklet_init(&dev->done_task, sahara_aes_done_task,
+		     (unsigned long)dev);

drivers/crypto/sahara.c line 981

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+
+	init_timer(&dev->watchdog);
+	dev->watchdog.function = &sahara_watchdog;
+	dev->watchdog.data = (unsigned long)dev;
+
+	clk_prepare_enable(dev->clk_ipg);
+	clk_prepare_enable(dev->clk_ahb);
+
+	version = sahara_read(dev, SAHARA_REG_VERSION);
+	if (version != SAHARA_VERSION_3) {

According to fsl kernel tree on linaro.org, on imx5 (sahara 4), the register layout is different so a new check should be added:
(version >> 8) & 0xff == 4

Quoted 19 lines
drivers/crypto/sahara.c new file +19 -0
+		dev_err(&pdev->dev, "SAHARA version %d not supported\n",
+			version);
+		err = -ENODEV;
+		goto err_algs;
+	}
+
+	sahara_write(dev, SAHARA_CMD_RESET | SAHARA_CMD_MODE_BATCH,
+		     SAHARA_REG_CMD);
+	sahara_write(dev, SAHARA_CONTROL_SET_THROTTLE(0) |
+			SAHARA_CONTROL_SET_MAXBURST(8) |
+			SAHARA_CONTROL_RNG_AUTORSD |
+			SAHARA_CONTROL_ENABLE_INT,
+			SAHARA_REG_CONTROL);
+
+	err = sahara_register_algs(dev);
+	if (err)
+		goto err_algs;
+
+	dev_info(&pdev->dev, "SAHARA version %d initialized\n", version);

drivers/crypto/sahara.c line 1010

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+
+	return 0;
+
+err_algs:
+	dev_ptr = NULL;
+	kfree(dev->key_base);
+	clk_disable_unprepare(dev->clk_ipg);
+	clk_disable_unprepare(dev->clk_ahb);
+err_link:
+	kfree(dev->key_base);

you're freeing 2 time key_base but not hw_link

Review

Quoted 2 lines
(quoted diff) +2 -0
+err_key:
+	kfree(dev->hw_desc[0]);

This one makes my kernel oops. Can be also reproduced by unloading the module.

drivers/crypto/sahara.c line 1016

Quoted 4 lines
drivers/crypto/sahara.c new file +4 -0
+	return err;
+}
+
+static int __devexit sahara_remove(struct platform_device *pdev)

__devinit & __devexit are gone.

drivers/crypto/sahara.c line 1021

Quoted 5 lines
drivers/crypto/sahara.c new file +5 -0
+{
+	struct sahara_dev *dev = platform_get_drvdata(pdev);
+
+	kfree(dev->key_base);
+	kfree(dev->hw_desc[0]);

missing kfree for hw_link too ?

Other than the remarks above, I'm hitting this while loading the kernel:

kernel: [ 49.305657] sahara 83ff8000.sahara: nbytes: 16, enc: 1, cbc: 0
kernel: [ 53.625599] BUG: spinlock lockup suspected on CPU#0, cryptomgr_test/2040
kernel: [ 53.625772] lock: 0xc27a1824, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
kernel: [ 53.625943] Backtrace:
kernel: [ 53.626061] [<c0010e34>] (dump_backtrace+0x0/0x10c) from [<c05173d0>] (dump_stack+0x18/0x1c)
kernel: [ 53.626251] r6:0fd84000 r5:c27a1824 r4:00000000 r3:c24f26c0
kernel: [ 53.626444] [<c05173b8>] (dump_stack+0x0/0x1c) from [<c051ab18>] (spin_dump+0x80/0x94)
kernel: [ 53.626621] [<c051aa98>] (spin_dump+0x0/0x94) from [<c01f680c>] (do_raw_spin_lock+0xe8/0x12c)
kernel: [ 53.626792] r5:00000000 r4:0fd84000
kernel: [ 53.626913] [<c01f6724>] (do_raw_spin_lock+0x0/0x12c) from [<c051ed14>] (_raw_spin_lock_irqsave+0x64/0x70)
kernel: [ 53.627133] [<c051ecb0>] (_raw_spin_lock_irqsave+0x0/0x70) from [<bf00d388>] (sahara_aes_crypt+0x7c/0x100 [sahara])
kernel: [ 53.627363] r6:00000001 r5:c20b8580 r4:c27a1810
kernel: [ 53.627525] [<bf00d30c>] (sahara_aes_crypt+0x0/0x100 [sahara]) from [<bf00d538>] (sahara_aes_ecb_encrypt+0x48/0x4c [sahara])
kernel: [ 53.627744] r8:c2755d28 r7:df9f3000 r6:00000001 r5:c20b8b00 r4:c20b8580
kernel: [ 53.627970] [<bf00d4f0>] (sahara_aes_ecb_encrypt+0x0/0x4c [sahara]) from [<c01cce08>] (__test_skcipher+0x22c/0x874)
kernel: [ 53.628176] r5:c0772794 r4:c0772794
kernel: [ 53.628293] [<c01ccbdc>] (__test_skcipher+0x0/0x874) from [<c01ceb68>] (test_skcipher+0x2c/0x58)
kernel: [ 53.628483] [<c01ceb3c>] (test_skcipher+0x0/0x58) from [<c01cec08>] (alg_test_skcipher+0x74/0xac)
kernel: [ 53.628660] r7:dfbfe9c0 r6:c0539aac r5:c20b8b00 r4:00000000
kernel: [ 53.628840] [<c01ceb94>] (alg_test_skcipher+0x0/0xac) from [<c01ce54c>] (alg_test+0x154/0x1c8)
kernel: [ 53.629014] r7:ffffffff r6:00000185 r5:dfbfe9c0 r4:00000000
kernel: [ 53.632986] [<c01ce3f8>] (alg_test+0x0/0x1c8) from [<c01cc280>] (cryptomgr_test+0x2c/0x50)

Despite this, the test seems to succeed and the sahara interrupt is increasing so it may be working.

Arnaud

#6 lore raw

PATCH 2/3 crypto: sahara: Add driver for SAHARA2 accelerator.

Hi Arnaud,
thank you for your feedback. Sorry, I always forget to test my drivers as modules.

I'll address the issues you pointed out, as well as the improvements suggested by Arnd, for v2.

Regards.

Quoted 216 lines · Arnaud Patard

Javier Martin <[email protected]> writes:

Hi,

Quoted 7 lines

SAHARA2 HW module is included in the i.MX27 SoC from Freescale. It is capable of performing cipher algorithms such as AES, 3DES..., hashing and RNG too.

This driver provides support for AES-CBC and AES-ECB by now.

[...]

Quoted 104 lines
drivers/crypto/sahara.c new file +104 -0
+     int irq;
+     int err;
+     int i;
+
+     dev = devm_kzalloc(&pdev->dev, sizeof(struct sahara_dev), GFP_KERNEL);
+     if (dev == NULL) {
+             dev_err(&pdev->dev, "unable to alloc data struct.\n");
+             return -ENOMEM;
+     }
+
+     dev->device = &pdev->dev;
+     platform_set_drvdata(pdev, dev);
+
+     /* Get the base address */
+     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+     if (!res) {
+             dev_err(&pdev->dev, "failed to get memory region resource\n");
+             return -ENODEV;
+     }
+
+     if (devm_request_mem_region(&pdev->dev, res->start,
+                     resource_size(res), SAHARA_NAME) == NULL) {
+             dev_err(&pdev->dev, "failed to request memory region\n");
+             return -ENOENT;
+     }
+     dev->regs_base = devm_ioremap(&pdev->dev, res->start,
+                                   resource_size(res));
+     if (!dev->regs_base) {
+             dev_err(&pdev->dev, "failed to ioremap address region\n");
+             return -ENOENT;
+     }
+
+     /* Get the IRQ */
+     irq = platform_get_irq(pdev,  0);
+     if (irq < 0) {
+             dev_err(&pdev->dev, "failed to get irq resource\n");
+             return irq;
+     }
+
+     if (devm_request_irq(&pdev->dev, irq, sahara_irq_handler,
+             0, SAHARA_NAME, dev) < 0) {
+             dev_err(&pdev->dev, "failed to request irq\n");
+             return -ENOENT;
+     }
+
+     /* clocks */
+     dev->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+     if (IS_ERR(dev->clk_ipg)) {
+             dev_err(&pdev->dev, "Could not get ipg clock\n");
+             return PTR_ERR(dev->clk_ipg);
+     }
+
+     dev->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+     if (IS_ERR(dev->clk_ahb)) {
+             dev_err(&pdev->dev, "Could not get ahb clock\n");
+             return PTR_ERR(dev->clk_ahb);
+     }
+
+     /* Allocate HW descriptors */
+     dev->hw_desc[0] = dma_alloc_coherent(&pdev->dev,
+                     SAHARA_MAX_HW_DESC * sizeof(struct sahara_hw_desc),
+                     &dev->hw_phys_desc[0], GFP_KERNEL);
+     if (!dev->hw_desc[0]) {
+             dev_err(&pdev->dev, "Could not allocate hw descriptors\n");
+             return -ENOMEM;
+     }
+     dev->hw_desc[1] = dev->hw_desc[0] + 1;
+     dev->hw_phys_desc[1] = dev->hw_phys_desc[0] +
+                             sizeof(struct sahara_hw_desc);
+
+     /* Allocate space for iv and key */
+     dev->key_base = dma_alloc_coherent(&pdev->dev, 2 * AES_KEYSIZE_128,
+                             &dev->key_phys_base, GFP_KERNEL);
+     if (!dev->key_base) {
+             dev_err(&pdev->dev, "Could not allocate memory for key\n");
+             err = -ENOMEM;
+             goto err_key;
+     }
+     dev->iv_base = dev->key_base + AES_KEYSIZE_128;
+     dev->iv_phys_base = dev->key_phys_base + AES_KEYSIZE_128;
+
+     /* Allocate space for HW links */
+     dev->hw_link[0] = dma_alloc_coherent(&pdev->dev,
+                     SAHARA_MAX_HW_LINK * sizeof(struct sahara_hw_link),
+                     &dev->hw_phys_link[0], GFP_KERNEL);
+     if (!dev->hw_link) {
+             dev_err(&pdev->dev, "Could not allocate hw links\n");
+             err = -ENOMEM;
+             goto err_link;
+     }
+     for (i = 1; i < SAHARA_MAX_HW_LINK; i++) {
+             dev->hw_phys_link[i] = dev->hw_phys_link[i - 1] +
+                                     sizeof(struct sahara_hw_link);
+             dev->hw_link[i] = dev->hw_link[i - 1] + 1;
+     }
+
+     crypto_init_queue(&dev->queue, SAHARA_QUEUE_LENGTH);
+
+     dev_ptr = dev;
+
+     tasklet_init(&dev->queue_task, sahara_aes_queue_task,
+                  (unsigned long)dev);
+     tasklet_init(&dev->done_task, sahara_aes_done_task,
+                  (unsigned long)dev);

drivers/crypto/sahara.c line 981

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+
+     init_timer(&dev->watchdog);
+     dev->watchdog.function = &sahara_watchdog;
+     dev->watchdog.data = (unsigned long)dev;
+
+     clk_prepare_enable(dev->clk_ipg);
+     clk_prepare_enable(dev->clk_ahb);
+
+     version = sahara_read(dev, SAHARA_REG_VERSION);
+     if (version != SAHARA_VERSION_3) {

According to fsl kernel tree on linaro.org, on imx5 (sahara 4), the register layout is different so a new check should be added:
(version >> 8) & 0xff == 4

Quoted 19 lines
drivers/crypto/sahara.c new file +19 -0
+             dev_err(&pdev->dev, "SAHARA version %d not supported\n",
+                     version);
+             err = -ENODEV;
+             goto err_algs;
+     }
+
+     sahara_write(dev, SAHARA_CMD_RESET | SAHARA_CMD_MODE_BATCH,
+                  SAHARA_REG_CMD);
+     sahara_write(dev, SAHARA_CONTROL_SET_THROTTLE(0) |
+                     SAHARA_CONTROL_SET_MAXBURST(8) |
+                     SAHARA_CONTROL_RNG_AUTORSD |
+                     SAHARA_CONTROL_ENABLE_INT,
+                     SAHARA_REG_CONTROL);
+
+     err = sahara_register_algs(dev);
+     if (err)
+             goto err_algs;
+
+     dev_info(&pdev->dev, "SAHARA version %d initialized\n", version);

drivers/crypto/sahara.c line 1010

Quoted 10 lines
drivers/crypto/sahara.c new file +10 -0
+
+     return 0;
+
+err_algs:
+     dev_ptr = NULL;
+     kfree(dev->key_base);
+     clk_disable_unprepare(dev->clk_ipg);
+     clk_disable_unprepare(dev->clk_ahb);
+err_link:
+     kfree(dev->key_base);

you're freeing 2 time key_base but not hw_link

Review

Quoted 2 lines
(quoted diff) +2 -0
+err_key:
+     kfree(dev->hw_desc[0]);

This one makes my kernel oops. Can be also reproduced by unloading the module.

drivers/crypto/sahara.c line 1016

Quoted 4 lines
drivers/crypto/sahara.c new file +4 -0
+     return err;
+}
+
+static int __devexit sahara_remove(struct platform_device *pdev)

__devinit & __devexit are gone.

drivers/crypto/sahara.c line 1021

Quoted 5 lines
drivers/crypto/sahara.c new file +5 -0
+{
+     struct sahara_dev *dev = platform_get_drvdata(pdev);
+
+     kfree(dev->key_base);
+     kfree(dev->hw_desc[0]);

missing kfree for hw_link too ?

Other than the remarks above, I'm hitting this while loading the kernel:

kernel: [ 49.305657] sahara 83ff8000.sahara: nbytes: 16, enc: 1, cbc: 0
kernel: [ 53.625599] BUG: spinlock lockup suspected on CPU#0, cryptomgr_test/2040
kernel: [ 53.625772] lock: 0xc27a1824, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
kernel: [ 53.625943] Backtrace:
kernel: [ 53.626061] [<c0010e34>] (dump_backtrace+0x0/0x10c) from [<c05173d0>] (dump_stack+0x18/0x1c)
kernel: [ 53.626251] r6:0fd84000 r5:c27a1824 r4:00000000 r3:c24f26c0
kernel: [ 53.626444] [<c05173b8>] (dump_stack+0x0/0x1c) from [<c051ab18>] (spin_dump+0x80/0x94)
kernel: [ 53.626621] [<c051aa98>] (spin_dump+0x0/0x94) from [<c01f680c>] (do_raw_spin_lock+0xe8/0x12c)
kernel: [ 53.626792] r5:00000000 r4:0fd84000
kernel: [ 53.626913] [<c01f6724>] (do_raw_spin_lock+0x0/0x12c) from [<c051ed14>] (_raw_spin_lock_irqsave+0x64/0x70)
kernel: [ 53.627133] [<c051ecb0>] (_raw_spin_lock_irqsave+0x0/0x70) from [<bf00d388>] (sahara_aes_crypt+0x7c/0x100 [sahara])
kernel: [ 53.627363] r6:00000001 r5:c20b8580 r4:c27a1810
kernel: [ 53.627525] [<bf00d30c>] (sahara_aes_crypt+0x0/0x100 [sahara]) from [<bf00d538>] (sahara_aes_ecb_encrypt+0x48/0x4c [sahara])
kernel: [ 53.627744] r8:c2755d28 r7:df9f3000 r6:00000001 r5:c20b8b00 r4:c20b8580
kernel: [ 53.627970] [<bf00d4f0>] (sahara_aes_ecb_encrypt+0x0/0x4c [sahara]) from [<c01cce08>] (__test_skcipher+0x22c/0x874)
kernel: [ 53.628176] r5:c0772794 r4:c0772794
kernel: [ 53.628293] [<c01ccbdc>] (__test_skcipher+0x0/0x874) from [<c01ceb68>] (test_skcipher+0x2c/0x58)
kernel: [ 53.628483] [<c01ceb3c>] (test_skcipher+0x0/0x58) from [<c01cec08>] (alg_test_skcipher+0x74/0xac)
kernel: [ 53.628660] r7:dfbfe9c0 r6:c0539aac r5:c20b8b00 r4:00000000
kernel: [ 53.628840] [<c01ceb94>] (alg_test_skcipher+0x0/0xac) from [<c01ce54c>] (alg_test+0x154/0x1c8)
kernel: [ 53.629014] r7:ffffffff r6:00000185 r5:dfbfe9c0 r4:00000000
kernel: [ 53.632986] [<c01ce3f8>] (alg_test+0x0/0x1c8) from [<c01cc280>] (cryptomgr_test+0x2c/0x50)

Despite this, the test seems to succeed and the sahara interrupt is increasing so it may be working.

Arnaud

Signature · 7 lines
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
#7 lore raw

PATCH 3/3 Visstrim M10: Add support for SAHARA2 module.

In reply to Javier Martin
---
 arch/arm/mach-imx/Kconfig                   |    1 +
 arch/arm/mach-imx/mach-imx27_visstrim_m10.c |    1 +
 2 files changed, 2 insertions(+)
arch/arm/mach-imx/Kconfig +1 -0
index 1ad0d76..d232a56 100644
@@ -402,6 +402,7 @@ config MACH_IMX27_VISSTRIM_M10
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MX2_CAMERA
 	select IMX_HAVE_PLATFORM_MX2_EMMA
+	select IMX_HAVE_PLATFORM_IMX27_SAHARA
 	select IMX_HAVE_PLATFORM_MXC_EHCI
 	select IMX_HAVE_PLATFORM_MXC_MMC
 	select LEDS_GPIO_REGISTER
arch/arm/mach-imx/mach-imx27_visstrim_m10.c +1 -0
index 318bd8d..b051592 100644
@@ -565,6 +565,7 @@ static void __init visstrim_m10_board_init(void)
 	imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
 	imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
 	imx27_add_fec(NULL);
+	imx27_add_sahara();
 	imx_add_gpio_keys(&visstrim_gpio_keys_platform_data);
 	platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
 	imx_add_platform_device("mx27vis", 0, NULL, 0, &snd_mx27vis_pdata,
Signature · 1 line
1.7.9.5
#8 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

In reply to Javier Martin
Quoted 6 lines · Javier Martin

This series of patches provide AES-ECB and AES-CBC support for the SAHARA2 cryptographic accelerator which is inside the i.MX27 SoC. It is expected that more algorithms will be supported in the future.

For testing, a Visstrim M10 board has been used and the code related to this platform has been included too.

As a new device driver, this needs to be supported on the DT based imx27 machines, while support for the individual board files seems unnecessary.

How about converting the Visstrim M10 board file over to DT so you don't have to add any more infrastructure for imx that we will just have to remove again one day?

Arnd

#9 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Hi Arnd,

Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · Javier Martin

This series of patches provide AES-ECB and AES-CBC support for the SAHARA2 cryptographic accelerator which is inside the i.MX27 SoC. It is expected that more algorithms will be supported in the future.

For testing, a Visstrim M10 board has been used and the code related to this platform has been included too.

Quoted 6 lines

As a new device driver, this needs to be supported on the DT based imx27 machines, while support for the individual board files seems unnecessary.

How about converting the Visstrim M10 board file over to DT so you don't have to add any more infrastructure for imx that we will just have to remove again one day?

We know about the existence of DT and the constant migration process that is taking place towards it.

Moreover we are strongly interested in converting the Visstrim SM10 platform to DT. Unfortunately, there are several issues that need to be solved so that Visstrim M10 can be fully converted to DT:
- full SoC camera DT support
- DT support for ov7670
- pinctrl support for i.MX27

Furthermore, we have limited resources at the moment and we have to decide priorities. But having an hybrid platform-DT support is our next task for Visstrim M10.

However, I understand your concern about new drivers having DT support. Maybe a good approach could be that I added compile-tested only DT support for this driver and remove platform support for mainline submission (although we maintain it internally in our repositories).

What do you think?

Regards.

Signature · 7 lines
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
#10 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Quoted 9 lines · javier Martin

We know about the existence of DT and the constant migration process that is taking place towards it.

Moreover we are strongly interested in converting the Visstrim SM10 platform to DT. Unfortunately, there are several issues that need to be solved so that Visstrim M10 can be fully converted to DT:
- full SoC camera DT support
- DT support for ov7670
- pinctrl support for i.MX27

Ok, I see. Full device tree support is certainly asking too much then.

Quoted 3 lines

Furthermore, we have limited resources at the moment and we have to decide priorities. But having an hybrid platform-DT support is our next task for Visstrim M10.

Ok, cool.

Quoted 7 lines

However, I understand your concern about new drivers having DT support. Maybe a good approach could be that I added compile-tested only DT support for this driver and remove platform support for mainline submission (although we maintain it internally in our repositories).

What do you think?

Sounds good. Since it sounds like the hardware is available in all imx27 device, maybe someone else can test your driver on an imx27 board that already has partial DT support when you add it to arch/arm/boot/dts/imx27.dtsi?

Is there any reason why an imx27 based board would not support this driver? Are there any other chips that could use it, e.g. imx25 or imx6?

Arnd

#11 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Quoted 25 lines · Arnd Bergmann
Quoted 9 lines · javier Martin

We know about the existence of DT and the constant migration process that is taking place towards it.

Moreover we are strongly interested in converting the Visstrim SM10 platform to DT. Unfortunately, there are several issues that need to be solved so that Visstrim M10 can be fully converted to DT:
- full SoC camera DT support
- DT support for ov7670
- pinctrl support for i.MX27

Ok, I see. Full device tree support is certainly asking too much then.

Quoted 3 lines

Furthermore, we have limited resources at the moment and we have to decide priorities. But having an hybrid platform-DT support is our next task for Visstrim M10.

Ok, cool.

Quoted 6 lines

However, I understand your concern about new drivers having DT support. Maybe a good approach could be that I added compile-tested only DT support for this driver and remove platform support for mainline submission (although we maintain it internally in our repositories).

Quoted 6 lines
Quoted 1 line

What do you think?

Sounds good. Since it sounds like the hardware is available in all imx27 device, maybe someone else can test your driver on an imx27 board that already has partial DT support when you add it to arch/arm/boot/dts/imx27.dtsi?

Yes, since the module is integrated in i.MX27 that seems the way to go.

Quoted 3 lines

Is there any reason why an imx27 based board would not support this driver? Are there any other chips that could use it, e.g. imx25 or imx6?

No, there's no reason for an i.mx27 board not to support this driver since the module doesn't have any external interfaces.

I think other i.MX chips have similar devices but I am not sure to what extent they are compatible or not. Probably Sascha Hauer or Shawn Guo (already in CC) could tell better than me since they have a wider view on the i.MX range.

Regards.

Signature · 7 lines
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
maintainer
#12 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

In reply to Arnd Bergmann
Quoted 27 lines · Arnd Bergmann
Quoted 9 lines · javier Martin

We know about the existence of DT and the constant migration process that is taking place towards it.

Moreover we are strongly interested in converting the Visstrim SM10 platform to DT. Unfortunately, there are several issues that need to be solved so that Visstrim M10 can be fully converted to DT:
- full SoC camera DT support
- DT support for ov7670
- pinctrl support for i.MX27

Ok, I see. Full device tree support is certainly asking too much then.

Quoted 3 lines

Furthermore, we have limited resources at the moment and we have to decide priorities. But having an hybrid platform-DT support is our next task for Visstrim M10.

Ok, cool.

Quoted 7 lines

However, I understand your concern about new drivers having DT support. Maybe a good approach could be that I added compile-tested only DT support for this driver and remove platform support for mainline submission (although we maintain it internally in our repositories).

What do you think?

Quoted 8 lines

Sounds good. Since it sounds like the hardware is available in all imx27 device, maybe someone else can test your driver on an imx27 board that already has partial DT support when you add it to arch/arm/boot/dts/imx27.dtsi?

Is there any reason why an imx27 based board would not support this driver? Are there any other chips that could use it, e.g. imx25 or imx6?

Neither i.MX25, i.MX31 nor i.MX21 have this unit. I haven't checked the others, but I assume this is i.MX27 only.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
reviewer
#13 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Quoted 2 lines · Sascha Hauer

Neither i.MX25, i.MX31 nor i.MX21 have this unit. I haven't checked the others, but I assume this is i.MX27 only.

There is Sahara variants on mx51/mx53.

#14 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Fabio Estevam <[email protected]> writes:
Hi,

Quoted 6 lines · Sascha Hauer
Quoted 3 lines

Neither i.MX25, i.MX31 nor i.MX21 have this unit. I haven't checked the others, but I assume this is i.MX27 only.

There is Sahara variants on mx51/mx53.

How different are the variants ? I've a imx51 device with DT support so if someone running sahara on a system with DT is needed, I can be this person (as long as a way to test it is provided too).

Arnaud

reviewer
#15 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Quoted 3 lines · Arnaud Patard

How different are the variants ? I've a imx51 device with DT support so if someone running sahara on a system with DT is needed, I can be this person (as long as a way to test it is provided too).

mx27 has Saharav2, mx51 has Saharav4. I didn't check the differences in detail though.

For mx51 the Sahara block is described in the document "MCIMX51 Applications Processor Security Reference Manual, Rev. 1"

I can also test the sahara dt support on a mx27pdk.

#16 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Fabio Estevam <[email protected]> writes:

Hi,

Quoted 7 lines
Quoted 3 lines · Arnaud Patard

How different are the variants ? I've a imx51 device with DT support so if someone running sahara on a system with DT is needed, I can be this person (as long as a way to test it is provided too).

Quoted 5 lines

mx27 has Saharav2, mx51 has Saharav4. I didn't check the differences in detail though.

For mx51 the Sahara block is described in the document "MCIMX51 Applications Processor Security Reference Manual, Rev. 1"

Sorry but this document is not freely available so I can't look at it.

Arnaud

maintainer
#17 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

In reply to javier Martin
Quoted 21 lines · javier Martin

Hi Arnd,

Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · Javier Martin

This series of patches provide AES-ECB and AES-CBC support for the SAHARA2 cryptographic accelerator which is inside the i.MX27 SoC. It is expected that more algorithms will be supported in the future.

For testing, a Visstrim M10 board has been used and the code related to this platform has been included too.

Quoted 6 lines

As a new device driver, this needs to be supported on the DT based imx27 machines, while support for the individual board files seems unnecessary.

How about converting the Visstrim M10 board file over to DT so you don't have to add any more infrastructure for imx that we will just have to remove again one day?

We know about the existence of DT and the constant migration process that is taking place towards it.

Quoted 6 lines

Moreover we are strongly interested in converting the Visstrim SM10 platform to DT. Unfortunately, there are several issues that need to be solved so that Visstrim M10 can be fully converted to DT:
- full SoC camera DT support
- DT support for ov7670
- pinctrl support for i.MX27

For the pinctrl stuff I suggest doing what we have done for the newer i.MX SoCs before we had pinctrl: Match by board compatible string and call into the board code for using the static pinctrl tables which are already there. I would like to have propert pinctrl support for the older i.MX, but probably the motivation for writing it is quite low for the older SoCs.

We have a patch in the queue converting the clock lookups for i.MX27 to dt which should be ready for posting soon.

Then the main road blockers should be out of the way to get rid of the bulk of the board code.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#18 lore raw

cover crypto: sahara: Add support for SAHARA in i.MX27.

Quoted 29 lines · Sascha Hauer
Quoted 21 lines · javier Martin

Hi Arnd,

Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · Javier Martin

This series of patches provide AES-ECB and AES-CBC support for the SAHARA2 cryptographic accelerator which is inside the i.MX27 SoC. It is expected that more algorithms will be supported in the future.

For testing, a Visstrim M10 board has been used and the code related to this platform has been included too.

Quoted 6 lines

As a new device driver, this needs to be supported on the DT based imx27 machines, while support for the individual board files seems unnecessary.

How about converting the Visstrim M10 board file over to DT so you don't have to add any more infrastructure for imx that we will just have to remove again one day?

We know about the existence of DT and the constant migration process that is taking place towards it.

Quoted 6 lines

Moreover we are strongly interested in converting the Visstrim SM10 platform to DT. Unfortunately, there are several issues that need to be solved so that Visstrim M10 can be fully converted to DT:
- full SoC camera DT support
- DT support for ov7670
- pinctrl support for i.MX27

Quoted 6 lines

For the pinctrl stuff I suggest doing what we have done for the newer i.MX SoCs before we had pinctrl: Match by board compatible string and call into the board code for using the static pinctrl tables which are already there. I would like to have propert pinctrl support for the older i.MX, but probably the motivation for writing it is quite low for the older SoCs.

OK, I take a look at it.

Quoted 2 lines

We have a patch in the queue converting the clock lookups for i.MX27 to dt which should be ready for posting soon.

Great.

Quoted 2 lines

Then the main road blockers should be out of the way to get rid of the bulk of the board code.

Signature · 7 lines
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com