blob: a137e55e964bc95fd0300d1b384a6e78e45cb796 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From d43acc10c25f01a461a1cb1c1fd0cc72cd29dd42 Mon Sep 17 00:00:00 2001
2From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
3Date: Thu, 2 Aug 2018 16:14:12 +0300
4Subject: [PATCH] soc/fsl/qbman_portals: add APIs to retrieve the probing
5 status
6
7Add a couple of new APIs to check the probing status of the required
8cpu bound qman and bman portals:
9 'int bman_portals_probed()' and 'int qman_portals_probed()'.
10They return the following values.
11 * 1 if qman/bman portals were all probed correctly
12 * 0 if qman/bman portals were not yet probed
13 * -1 if probing of qman/bman portals failed
14Portals are considered successful probed if no error occurred during
15the probing of any of the portals and if enough portals were probed
16to have one available for each cpu.
17The error handling paths were slightly rearranged in order to fit this
18new functionality without being too intrusive.
19Drivers that use qman/bman portal driver services are required to use
20these APIs before calling any functions exported by these drivers or
21otherwise they will crash the kernel.
22First user will be the dpaa1 ethernet driver, coming in a subsequent
23patch.
24
25Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
26---
27 drivers/soc/fsl/qbman/bman_portal.c | 3 +++
28 drivers/soc/fsl/qbman/qman_portal.c | 3 +++
29 include/soc/fsl/qman.h | 9 +++++++++
30 3 files changed, 15 insertions(+)
31
32--- a/drivers/soc/fsl/qbman/bman_portal.c
33+++ b/drivers/soc/fsl/qbman/bman_portal.c
34@@ -164,6 +164,9 @@ static int bman_portal_probe(struct plat
35 }
36
37 cpumask_set_cpu(cpu, &portal_cpus);
38+ if (!__bman_portals_probed &&
39+ cpumask_weight(&portal_cpus) == num_online_cpus())
40+ __bman_portals_probed = 1;
41 spin_unlock(&bman_lock);
42 pcfg->cpu = cpu;
43
44--- a/drivers/soc/fsl/qbman/qman_portal.c
45+++ b/drivers/soc/fsl/qbman/qman_portal.c
46@@ -323,6 +323,9 @@ static int qman_portal_probe(struct plat
47 }
48
49 cpumask_set_cpu(cpu, &portal_cpus);
50+ if (!__qman_portals_probed &&
51+ cpumask_weight(&portal_cpus) == num_online_cpus())
52+ __qman_portals_probed = 1;
53 spin_unlock(&qman_lock);
54 pcfg->cpu = cpu;
55
56--- a/include/soc/fsl/qman.h
57+++ b/include/soc/fsl/qman.h
58@@ -1235,4 +1235,13 @@ void qman_portal_get_iperiod(struct qman
59 */
60 int qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod);
61
62+/**
63+ * qman_portals_probed - Check if all cpu bound qman portals are probed
64+ *
65+ * Returns 1 if all the required cpu bound qman portals successfully probed,
66+ * -1 if probe errors appeared or 0 if the qman portals did not yet finished
67+ * probing.
68+ */
69+int qman_portals_probed(void);
70+
71 #endif /* __FSL_QMAN_H */