From: Arnd Bergmann <arnd@arndb.de>
To: Javier Martin <javier.martin@vista-silicon.com>
Cc: kernel@pengutronix.de, herbert@gondor.apana.org.au,
davem@davemloft.net, tony@atomide.com, swarren@nvidia.com,
shawn.guo@linaro.org, gcembed@gmail.com,
linux-arm-kernel@lists.infradead.org,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH 2/3] crypto: sahara: Add driver for SAHARA2 accelerator.
Date: Thu, 21 Feb 2013 13:13:45 +0000 [thread overview]
Message-ID: <201302211313.46078.arnd@arndb.de> (raw)
In-Reply-To: <1361449162-27302-3-git-send-email-javier.martin@vista-silicon.com>
On Thursday 21 February 2013, Javier Martin wrote:
> +
> +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;
> +
> + 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.
> +#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.
> +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,
> + 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.
> +
> +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.
> +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
next prev parent reply other threads:[~2013-02-21 13:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-21 12:19 [PATCH 0/3] crypto: sahara: Add support for SAHARA in i.MX27 Javier Martin
2013-02-21 12:19 ` [PATCH 1/3] i.MX27: Add platform support for SAHARA2 Javier Martin
2013-02-21 12:19 ` [PATCH 2/3] crypto: sahara: Add driver for SAHARA2 accelerator Javier Martin
2013-02-21 13:13 ` Arnd Bergmann [this message]
2013-02-21 14:35 ` javier Martin
2013-02-23 20:16 ` Arnaud Patard
2013-02-26 10:34 ` javier Martin
2013-02-21 12:19 ` [PATCH 3/3] Visstrim M10: Add support for SAHARA2 module Javier Martin
2013-02-21 12:59 ` [PATCH 0/3] crypto: sahara: Add support for SAHARA in i.MX27 Arnd Bergmann
2013-02-21 14:18 ` javier Martin
2013-02-21 14:40 ` Arnd Bergmann
2013-02-21 14:57 ` javier Martin
2013-02-21 15:23 ` Sascha Hauer
2013-02-21 15:40 ` Fabio Estevam
2013-02-21 16:40 ` Arnaud Patard
2013-02-21 16:47 ` Fabio Estevam
2013-02-21 20:59 ` Arnaud Patard
2013-02-21 15:18 ` Sascha Hauer
2013-02-21 15:23 ` javier Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201302211313.46078.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=gcembed@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=javier.martin@vista-silicon.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=shawn.guo@linaro.org \
--cc=swarren@nvidia.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox