1 From 4baa099377d73ea99c7802a9685815b32e8bf119 Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Thu, 21 Dec 2017 15:08:18 +0100
4 Subject: [PATCH 1/6] crypto: crypto4xx - shuffle iomap in front of request_irq
6 It is possible to avoid the ce_base null pointer check in the
7 drivers' interrupt handler routine "crypto4xx_ce_interrupt_handler()"
8 by simply doing the iomap in front of the IRQ registration.
10 This way, the ce_base will always be valid in the handler and
11 a branch in an critical path can be avoided.
13 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
15 drivers/crypto/amcc/crypto4xx_core.c | 21 +++++++++------------
16 1 file changed, 9 insertions(+), 12 deletions(-)
18 --- a/drivers/crypto/amcc/crypto4xx_core.c
19 +++ b/drivers/crypto/amcc/crypto4xx_core.c
20 @@ -1075,9 +1075,6 @@ static irqreturn_t crypto4xx_ce_interrup
21 struct device *dev = (struct device *)data;
22 struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev);
24 - if (!core_dev->dev->ce_base)
27 writel(PPC4XX_INTERRUPT_CLR,
28 core_dev->dev->ce_base + CRYPTO4XX_INT_CLR);
29 tasklet_schedule(&core_dev->tasklet);
30 @@ -1325,13 +1322,6 @@ static int crypto4xx_probe(struct platfo
31 tasklet_init(&core_dev->tasklet, crypto4xx_bh_tasklet_cb,
34 - /* Register for Crypto isr, Crypto Engine IRQ */
35 - core_dev->irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
36 - rc = request_irq(core_dev->irq, crypto4xx_ce_interrupt_handler, 0,
37 - core_dev->dev->name, dev);
39 - goto err_request_irq;
41 core_dev->dev->ce_base = of_iomap(ofdev->dev.of_node, 0);
42 if (!core_dev->dev->ce_base) {
43 dev_err(dev, "failed to of_iomap\n");
44 @@ -1339,6 +1329,13 @@ static int crypto4xx_probe(struct platfo
48 + /* Register for Crypto isr, Crypto Engine IRQ */
49 + core_dev->irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
50 + rc = request_irq(core_dev->irq, crypto4xx_ce_interrupt_handler, 0,
51 + core_dev->dev->name, dev);
53 + goto err_request_irq;
55 /* need to setup pdr, rdr, gdr and sdr before this */
56 crypto4xx_hw_init(core_dev->dev);
58 @@ -1352,11 +1349,11 @@ static int crypto4xx_probe(struct platfo
62 - iounmap(core_dev->dev->ce_base);
64 free_irq(core_dev->irq, dev);
66 irq_dispose_mapping(core_dev->irq);
67 + iounmap(core_dev->dev->ce_base);
69 tasklet_kill(&core_dev->tasklet);
71 crypto4xx_destroy_sdr(core_dev->dev);