f9e7940fa8bf6e345e8dc21ce8c560ce683cb51a
[openwrt/openwrt.git] /
1 From 5a359d189f9938d30046aedfc94c9cd7fe383e34 Mon Sep 17 00:00:00 2001
2 From: Andrey Smirnov <andrew.smirnov@gmail.com>
3 Date: Tue, 22 Oct 2019 08:30:11 -0700
4 Subject: [PATCH] crypto: caam - use devres to de-initialize QI
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Use devres to de-initialize the QI and drop explicit de-initialization
10 code in caam_remove().
11
12 Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
13 Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
14 Cc: Chris Healy <cphealy@gmail.com>
15 Cc: Lucas Stach <l.stach@pengutronix.de>
16 Cc: Horia Geantă <horia.geanta@nxp.com>
17 Cc: Herbert Xu <herbert@gondor.apana.org.au>
18 Cc: Iuliana Prodan <iuliana.prodan@nxp.com>
19 Cc: linux-crypto@vger.kernel.org
20 Cc: linux-kernel@vger.kernel.org
21 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
22 (cherry picked from commit f414de2e2fffd89c8a4e5b5e06b0eba5f9d8b1eb)
23 ---
24 drivers/crypto/caam/ctrl.c | 14 +-------------
25 drivers/crypto/caam/intern.h | 3 ---
26 drivers/crypto/caam/qi.c | 8 ++++++--
27 drivers/crypto/caam/qi.h | 1 -
28 4 files changed, 7 insertions(+), 19 deletions(-)
29
30 --- a/drivers/crypto/caam/ctrl.c
31 +++ b/drivers/crypto/caam/ctrl.c
32 @@ -332,11 +332,6 @@ static int caam_remove(struct platform_d
33 /* Remove platform devices under the crypto node */
34 of_platform_depopulate(ctrldev);
35
36 -#ifdef CONFIG_CAAM_QI
37 - if (ctrlpriv->qi_init)
38 - caam_qi_shutdown(ctrldev);
39 -#endif
40 -
41 return 0;
42 }
43
44 @@ -767,7 +762,7 @@ static int caam_probe(struct platform_de
45 ret = of_platform_populate(nprop, caam_match, NULL, dev);
46 if (ret) {
47 dev_err(dev, "JR platform devices creation error\n");
48 - goto shutdown_qi;
49 + return ret;
50 }
51
52 ring = 0;
53 @@ -928,13 +923,6 @@ static int caam_probe(struct platform_de
54 caam_remove:
55 caam_remove(pdev);
56 return ret;
57 -
58 -shutdown_qi:
59 -#ifdef CONFIG_CAAM_QI
60 - if (ctrlpriv->qi_init)
61 - caam_qi_shutdown(dev);
62 -#endif
63 - return ret;
64 }
65
66 static struct platform_driver caam_driver = {
67 --- a/drivers/crypto/caam/intern.h
68 +++ b/drivers/crypto/caam/intern.h
69 @@ -81,9 +81,6 @@ struct caam_drv_private {
70 */
71 u8 total_jobrs; /* Total Job Rings in device */
72 u8 qi_present; /* Nonzero if QI present in device */
73 -#ifdef CONFIG_CAAM_QI
74 - u8 qi_init; /* Nonzero if QI has been initialized */
75 -#endif
76 u8 mc_en; /* Nonzero if MC f/w is active */
77 int secvio_irq; /* Security violation interrupt number */
78 int virt_en; /* Virtualization enabled in CAAM */
79 --- a/drivers/crypto/caam/qi.c
80 +++ b/drivers/crypto/caam/qi.c
81 @@ -500,9 +500,10 @@ void caam_drv_ctx_rel(struct caam_drv_ct
82 }
83 EXPORT_SYMBOL(caam_drv_ctx_rel);
84
85 -void caam_qi_shutdown(struct device *qidev)
86 +static void caam_qi_shutdown(void *data)
87 {
88 int i;
89 + struct device *qidev = data;
90 struct caam_qi_priv *priv = &qipriv;
91 const cpumask_t *cpus = qman_affine_cpus();
92
93 @@ -761,7 +762,10 @@ int caam_qi_init(struct platform_device
94 &times_congested, &caam_fops_u64_ro);
95 #endif
96
97 - ctrlpriv->qi_init = 1;
98 + err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv);
99 + if (err)
100 + return err;
101 +
102 dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n");
103 return 0;
104 }
105 --- a/drivers/crypto/caam/qi.h
106 +++ b/drivers/crypto/caam/qi.h
107 @@ -147,7 +147,6 @@ int caam_drv_ctx_update(struct caam_drv_
108 void caam_drv_ctx_rel(struct caam_drv_ctx *drv_ctx);
109
110 int caam_qi_init(struct platform_device *pdev);
111 -void caam_qi_shutdown(struct device *dev);
112
113 /**
114 * qi_cache_alloc - Allocate buffers from CAAM-QI cache