fc8df388673ef32fe0e05a17c4d75497aea2dc9b
[openwrt/openwrt.git] / target / linux / apm821xx / patches-4.14 / 120-0001-crypto-crypto4xx-shuffle-iomap-in-front-of-request_i.patch
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
5
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.
9
10 This way, the ce_base will always be valid in the handler and
11 a branch in an critical path can be avoided.
12
13 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
14 ---
15 drivers/crypto/amcc/crypto4xx_core.c | 21 +++++++++------------
16 1 file changed, 9 insertions(+), 12 deletions(-)
17
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);
23
24 - if (!core_dev->dev->ce_base)
25 - return 0;
26 -
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,
32 (unsigned long) dev);
33
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);
38 - if (rc)
39 - goto err_request_irq;
40 -
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
45 goto err_iomap;
46 }
47
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);
52 + if (rc)
53 + goto err_request_irq;
54 +
55 /* need to setup pdr, rdr, gdr and sdr before this */
56 crypto4xx_hw_init(core_dev->dev);
57
58 @@ -1352,11 +1349,11 @@ static int crypto4xx_probe(struct platfo
59 return 0;
60
61 err_start_dev:
62 - iounmap(core_dev->dev->ce_base);
63 -err_iomap:
64 free_irq(core_dev->irq, dev);
65 err_request_irq:
66 irq_dispose_mapping(core_dev->irq);
67 + iounmap(core_dev->dev->ce_base);
68 +err_iomap:
69 tasklet_kill(&core_dev->tasklet);
70 err_build_sdr:
71 crypto4xx_destroy_sdr(core_dev->dev);