021-0001-crypto-crypto4xx-shuffle-iomap-in-front-of-request_i.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 4baa099377d73ea99c7802a9685815b32e8bf119 Mon Sep 17 00:00:00 2001
  2. From: Christian Lamparter <[email protected]>
  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. It is possible to avoid the ce_base null pointer check in the
  6. drivers' interrupt handler routine "crypto4xx_ce_interrupt_handler()"
  7. by simply doing the iomap in front of the IRQ registration.
  8. This way, the ce_base will always be valid in the handler and
  9. a branch in an critical path can be avoided.
  10. Signed-off-by: Christian Lamparter <[email protected]>
  11. ---
  12. drivers/crypto/amcc/crypto4xx_core.c | 21 +++++++++------------
  13. 1 file changed, 9 insertions(+), 12 deletions(-)
  14. --- a/drivers/crypto/amcc/crypto4xx_core.c
  15. +++ b/drivers/crypto/amcc/crypto4xx_core.c
  16. @@ -1075,9 +1075,6 @@ static irqreturn_t crypto4xx_ce_interrup
  17. struct device *dev = (struct device *)data;
  18. struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev);
  19. - if (!core_dev->dev->ce_base)
  20. - return 0;
  21. -
  22. writel(PPC4XX_INTERRUPT_CLR,
  23. core_dev->dev->ce_base + CRYPTO4XX_INT_CLR);
  24. tasklet_schedule(&core_dev->tasklet);
  25. @@ -1325,13 +1322,6 @@ static int crypto4xx_probe(struct platfo
  26. tasklet_init(&core_dev->tasklet, crypto4xx_bh_tasklet_cb,
  27. (unsigned long) dev);
  28. - /* Register for Crypto isr, Crypto Engine IRQ */
  29. - core_dev->irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
  30. - rc = request_irq(core_dev->irq, crypto4xx_ce_interrupt_handler, 0,
  31. - core_dev->dev->name, dev);
  32. - if (rc)
  33. - goto err_request_irq;
  34. -
  35. core_dev->dev->ce_base = of_iomap(ofdev->dev.of_node, 0);
  36. if (!core_dev->dev->ce_base) {
  37. dev_err(dev, "failed to of_iomap\n");
  38. @@ -1339,6 +1329,13 @@ static int crypto4xx_probe(struct platfo
  39. goto err_iomap;
  40. }
  41. + /* Register for Crypto isr, Crypto Engine IRQ */
  42. + core_dev->irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
  43. + rc = request_irq(core_dev->irq, crypto4xx_ce_interrupt_handler, 0,
  44. + core_dev->dev->name, dev);
  45. + if (rc)
  46. + goto err_request_irq;
  47. +
  48. /* need to setup pdr, rdr, gdr and sdr before this */
  49. crypto4xx_hw_init(core_dev->dev);
  50. @@ -1352,11 +1349,11 @@ static int crypto4xx_probe(struct platfo
  51. return 0;
  52. err_start_dev:
  53. - iounmap(core_dev->dev->ce_base);
  54. -err_iomap:
  55. free_irq(core_dev->irq, dev);
  56. err_request_irq:
  57. irq_dispose_mapping(core_dev->irq);
  58. + iounmap(core_dev->dev->ce_base);
  59. +err_iomap:
  60. tasklet_kill(&core_dev->tasklet);
  61. err_build_sdr:
  62. crypto4xx_destroy_sdr(core_dev->dev);