summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurentiu Tudor <laurentiu.tudor@nxp.com>2019-04-27 03:10:24 -0400
committerLi Yang <leoyang.li@nxp.com>2019-05-20 15:28:16 -0400
commit5d1d046e2868fc876a69231eb2f24f000b521f1c (patch)
tree0167f1d24f1bec27a959feb8d1da515c337c2814
parentd9ebd99d9a2ff7857b8dbfebd4604f80064d749c (diff)
soc: fsl: qbman_portals: add APIs to retrieve the probing status
Add a couple of new APIs to check the probing status of the required cpu bound qman and bman portals: 'int bman_portals_probed()' and 'int qman_portals_probed()'. They return the following values. * 1 if qman/bman portals were all probed correctly * 0 if qman/bman portals were not yet probed * -1 if probing of qman/bman portals failed Portals are considered successful probed if no error occurred during the probing of any of the portals and if enough portals were probed to have one available for each cpu. The error handling paths were slightly rearranged in order to fit this new functionality without being too intrusive. Drivers that use qman/bman portal driver services are required to use these APIs before calling any functions exported by these drivers or otherwise they will crash the kernel. First user will be the dpaa1 ethernet driver, coming in a subsequent patch. Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Signed-off-by: Li Yang <leoyang.li@nxp.com>
-rw-r--r--drivers/soc/fsl/qbman/bman_portal.c20
-rw-r--r--drivers/soc/fsl/qbman/qman_portal.c21
-rw-r--r--include/soc/fsl/bman.h8
-rw-r--r--include/soc/fsl/qman.h9
4 files changed, 50 insertions, 8 deletions
diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c
index 2c95cf59f3e7..cf4f10d6f590 100644
--- a/drivers/soc/fsl/qbman/bman_portal.c
+++ b/drivers/soc/fsl/qbman/bman_portal.c
@@ -32,6 +32,7 @@
32 32
33static struct bman_portal *affine_bportals[NR_CPUS]; 33static struct bman_portal *affine_bportals[NR_CPUS];
34static struct cpumask portal_cpus; 34static struct cpumask portal_cpus;
35static int __bman_portals_probed;
35/* protect bman global registers and global data shared among portals */ 36/* protect bman global registers and global data shared among portals */
36static DEFINE_SPINLOCK(bman_lock); 37static DEFINE_SPINLOCK(bman_lock);
37 38
@@ -87,6 +88,12 @@ static int bman_online_cpu(unsigned int cpu)
87 return 0; 88 return 0;
88} 89}
89 90
91int bman_portals_probed(void)
92{
93 return __bman_portals_probed;
94}
95EXPORT_SYMBOL_GPL(bman_portals_probed);
96
90static int bman_portal_probe(struct platform_device *pdev) 97static int bman_portal_probe(struct platform_device *pdev)
91{ 98{
92 struct device *dev = &pdev->dev; 99 struct device *dev = &pdev->dev;
@@ -104,8 +111,10 @@ static int bman_portal_probe(struct platform_device *pdev)
104 } 111 }
105 112
106 pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); 113 pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL);
107 if (!pcfg) 114 if (!pcfg) {
115 __bman_portals_probed = -1;
108 return -ENOMEM; 116 return -ENOMEM;
117 }
109 118
110 pcfg->dev = dev; 119 pcfg->dev = dev;
111 120
@@ -113,14 +122,14 @@ static int bman_portal_probe(struct platform_device *pdev)
113 DPAA_PORTAL_CE); 122 DPAA_PORTAL_CE);
114 if (!addr_phys[0]) { 123 if (!addr_phys[0]) {
115 dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); 124 dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node);
116 return -ENXIO; 125 goto err_ioremap1;
117 } 126 }
118 127
119 addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, 128 addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM,
120 DPAA_PORTAL_CI); 129 DPAA_PORTAL_CI);
121 if (!addr_phys[1]) { 130 if (!addr_phys[1]) {
122 dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); 131 dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node);
123 return -ENXIO; 132 goto err_ioremap1;
124 } 133 }
125 134
126 pcfg->cpu = -1; 135 pcfg->cpu = -1;
@@ -128,7 +137,7 @@ static int bman_portal_probe(struct platform_device *pdev)
128 irq = platform_get_irq(pdev, 0); 137 irq = platform_get_irq(pdev, 0);
129 if (irq <= 0) { 138 if (irq <= 0) {
130 dev_err(dev, "Can't get %pOF IRQ'\n", node); 139 dev_err(dev, "Can't get %pOF IRQ'\n", node);
131 return -ENXIO; 140 goto err_ioremap1;
132 } 141 }
133 pcfg->irq = irq; 142 pcfg->irq = irq;
134 143
@@ -150,6 +159,7 @@ static int bman_portal_probe(struct platform_device *pdev)
150 spin_lock(&bman_lock); 159 spin_lock(&bman_lock);
151 cpu = cpumask_next_zero(-1, &portal_cpus); 160 cpu = cpumask_next_zero(-1, &portal_cpus);
152 if (cpu >= nr_cpu_ids) { 161 if (cpu >= nr_cpu_ids) {
162 __bman_portals_probed = 1;
153 /* unassigned portal, skip init */ 163 /* unassigned portal, skip init */
154 spin_unlock(&bman_lock); 164 spin_unlock(&bman_lock);
155 return 0; 165 return 0;
@@ -175,6 +185,8 @@ err_portal_init:
175err_ioremap2: 185err_ioremap2:
176 memunmap(pcfg->addr_virt_ce); 186 memunmap(pcfg->addr_virt_ce);
177err_ioremap1: 187err_ioremap1:
188 __bman_portals_probed = -1;
189
178 return -ENXIO; 190 return -ENXIO;
179} 191}
180 192
diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
index 661c9b234d32..e2186b681d87 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -38,6 +38,7 @@ EXPORT_SYMBOL(qman_dma_portal);
38#define CONFIG_FSL_DPA_PIRQ_FAST 1 38#define CONFIG_FSL_DPA_PIRQ_FAST 1
39 39
40static struct cpumask portal_cpus; 40static struct cpumask portal_cpus;
41static int __qman_portals_probed;
41/* protect qman global registers and global data shared among portals */ 42/* protect qman global registers and global data shared among portals */
42static DEFINE_SPINLOCK(qman_lock); 43static DEFINE_SPINLOCK(qman_lock);
43 44
@@ -220,6 +221,12 @@ static int qman_online_cpu(unsigned int cpu)
220 return 0; 221 return 0;
221} 222}
222 223
224int qman_portals_probed(void)
225{
226 return __qman_portals_probed;
227}
228EXPORT_SYMBOL_GPL(qman_portals_probed);
229
223static int qman_portal_probe(struct platform_device *pdev) 230static int qman_portal_probe(struct platform_device *pdev)
224{ 231{
225 struct device *dev = &pdev->dev; 232 struct device *dev = &pdev->dev;
@@ -238,8 +245,10 @@ static int qman_portal_probe(struct platform_device *pdev)
238 } 245 }
239 246
240 pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); 247 pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL);
241 if (!pcfg) 248 if (!pcfg) {
249 __qman_portals_probed = -1;
242 return -ENOMEM; 250 return -ENOMEM;
251 }
243 252
244 pcfg->dev = dev; 253 pcfg->dev = dev;
245 254
@@ -247,19 +256,20 @@ static int qman_portal_probe(struct platform_device *pdev)
247 DPAA_PORTAL_CE); 256 DPAA_PORTAL_CE);
248 if (!addr_phys[0]) { 257 if (!addr_phys[0]) {
249 dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); 258 dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node);
250 return -ENXIO; 259 goto err_ioremap1;
251 } 260 }
252 261
253 addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, 262 addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM,
254 DPAA_PORTAL_CI); 263 DPAA_PORTAL_CI);
255 if (!addr_phys[1]) { 264 if (!addr_phys[1]) {
256 dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); 265 dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node);
257 return -ENXIO; 266 goto err_ioremap1;
258 } 267 }
259 268
260 err = of_property_read_u32(node, "cell-index", &val); 269 err = of_property_read_u32(node, "cell-index", &val);
261 if (err) { 270 if (err) {
262 dev_err(dev, "Can't get %pOF property 'cell-index'\n", node); 271 dev_err(dev, "Can't get %pOF property 'cell-index'\n", node);
272 __qman_portals_probed = -1;
263 return err; 273 return err;
264 } 274 }
265 pcfg->channel = val; 275 pcfg->channel = val;
@@ -267,7 +277,7 @@ static int qman_portal_probe(struct platform_device *pdev)
267 irq = platform_get_irq(pdev, 0); 277 irq = platform_get_irq(pdev, 0);
268 if (irq <= 0) { 278 if (irq <= 0) {
269 dev_err(dev, "Can't get %pOF IRQ\n", node); 279 dev_err(dev, "Can't get %pOF IRQ\n", node);
270 return -ENXIO; 280 goto err_ioremap1;
271 } 281 }
272 pcfg->irq = irq; 282 pcfg->irq = irq;
273 283
@@ -291,6 +301,7 @@ static int qman_portal_probe(struct platform_device *pdev)
291 spin_lock(&qman_lock); 301 spin_lock(&qman_lock);
292 cpu = cpumask_next_zero(-1, &portal_cpus); 302 cpu = cpumask_next_zero(-1, &portal_cpus);
293 if (cpu >= nr_cpu_ids) { 303 if (cpu >= nr_cpu_ids) {
304 __qman_portals_probed = 1;
294 /* unassigned portal, skip init */ 305 /* unassigned portal, skip init */
295 spin_unlock(&qman_lock); 306 spin_unlock(&qman_lock);
296 return 0; 307 return 0;
@@ -321,6 +332,8 @@ err_portal_init:
321err_ioremap2: 332err_ioremap2:
322 memunmap(pcfg->addr_virt_ce); 333 memunmap(pcfg->addr_virt_ce);
323err_ioremap1: 334err_ioremap1:
335 __qman_portals_probed = -1;
336
324 return -ENXIO; 337 return -ENXIO;
325} 338}
326 339
diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h
index 5b99cb2ea5ef..173e4049d963 100644
--- a/include/soc/fsl/bman.h
+++ b/include/soc/fsl/bman.h
@@ -133,5 +133,13 @@ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num);
133 * failed to probe or 0 if the bman driver did not probed yet. 133 * failed to probe or 0 if the bman driver did not probed yet.
134 */ 134 */
135int bman_is_probed(void); 135int bman_is_probed(void);
136/**
137 * bman_portals_probed - Check if all cpu bound bman portals are probed
138 *
139 * Returns 1 if all the required cpu bound bman portals successfully probed,
140 * -1 if probe errors appeared or 0 if the bman portals did not yet finished
141 * probing.
142 */
143int bman_portals_probed(void);
136 144
137#endif /* __FSL_BMAN_H */ 145#endif /* __FSL_BMAN_H */
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index 5cc7af06c1ba..aa31c05a103a 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -1195,6 +1195,15 @@ int qman_release_cgrid(u32 id);
1195int qman_is_probed(void); 1195int qman_is_probed(void);
1196 1196
1197/** 1197/**
1198 * qman_portals_probed - Check if all cpu bound qman portals are probed
1199 *
1200 * Returns 1 if all the required cpu bound qman portals successfully probed,
1201 * -1 if probe errors appeared or 0 if the qman portals did not yet finished
1202 * probing.
1203 */
1204int qman_portals_probed(void);
1205
1206/**
1198 * qman_dqrr_get_ithresh - Get coalesce interrupt threshold 1207 * qman_dqrr_get_ithresh - Get coalesce interrupt threshold
1199 * @portal: portal to get the value for 1208 * @portal: portal to get the value for
1200 * @ithresh: threshold pointer 1209 * @ithresh: threshold pointer