The fslmc bus initialization (register the sequence number mbuf
dynfield, set up the VFIO group, DMA map the memory segments) needs the
DPDK heap and the memory segment list in shared (hugepage) memory for
multi-process sharing. But these are not available during the bus scan
(EAL runs rte_bus_scan() before memzone, memory and malloc heap init),
so it fails there.
Device discovery does not need it, and get_iommu_class() only checks
sysfs paths to report the IOVA mode, so the init is not needed in scan.
Move it back to probe.
Fixes: cdefd2e980bd ("drivers/bus: initialize NXP bus specifics in scan")
Signed-off-by: Prashant Gupta <[email protected]>
---
drivers/bus/fslmc/fslmc_bus.c | 92 +++++++++++++++++++----------------
1 file changed, 51 insertions(+), 41 deletions(-)
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 3626b12316..ee162b0ed8 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -368,46 +368,6 @@ rte_fslmc_scan(void)
/* If debugging is enabled, device list is dumped to log output */
dump_device_list();
- /* Bus initialization - only if devices were found */
- if (!TAILQ_EMPTY(&rte_fslmc_bus.device_list)) {
- static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc
= {
- .name = DPAA2_SEQN_DYNFIELD_NAME,
- .size = sizeof(dpaa2_seqn_t),
- .align = alignof(dpaa2_seqn_t),
- };
-
- dpaa2_seqn_dynfield_offset =
- rte_mbuf_dynfield_register(&dpaa2_seqn_dynfield_desc);
- if (dpaa2_seqn_dynfield_offset < 0) {
- DPAA2_BUS_ERR("Failed to register mbuf field for dpaa
sequence number");
- return 0;
- }
-
- ret = fslmc_vfio_setup_group();
- if (ret) {
- DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
- return 0;
- }
-
- /* Map existing segments as well as, in case of hotpluggable
memory,
- * install callback handler.
- */
- if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- ret = fslmc_vfio_dmamap();
- if (ret) {
- DPAA2_BUS_ERR("Unable to DMA map existing VAs:
(%d)", ret);
- DPAA2_BUS_ERR("FSLMC VFIO Mapping failed");
- return 0;
- }
- }
-
- ret = fslmc_vfio_process_group();
- if (ret) {
- DPAA2_BUS_ERR("Unable to setup devices %d", ret);
- return 0;
- }
- }
-
process_once = 1;
return 0;
@@ -423,6 +383,56 @@ rte_fslmc_scan(void)
return 0;
}
+/* Bus initialization needs the DPDK heap and DMA mapping of the memory
+ * segments, which EAL only sets up after the bus scan, so it is done here.
+ */
+static int
+rte_fslmc_probe(struct rte_bus *bus)
+{
+ static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc = {
+ .name = DPAA2_SEQN_DYNFIELD_NAME,
+ .size = sizeof(dpaa2_seqn_t),
+ .align = alignof(dpaa2_seqn_t),
+ };
+ int ret;
+
+ if (TAILQ_EMPTY(&rte_fslmc_bus.device_list))
+ return 0;
+
+ dpaa2_seqn_dynfield_offset =
+ rte_mbuf_dynfield_register(&dpaa2_seqn_dynfield_desc);
+ if (dpaa2_seqn_dynfield_offset < 0) {
+ DPAA2_BUS_ERR("Failed to register mbuf field for dpaa sequence
number");
+ return 0;
+ }
+
+ ret = fslmc_vfio_setup_group();
+ if (ret) {
+ DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
+ return 0;
+ }
+
+ /* Map existing segments as well as, in case of hotpluggable memory,
+ * install callback handler.
+ */
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ ret = fslmc_vfio_dmamap();
+ if (ret) {
+ DPAA2_BUS_ERR("Unable to DMA map existing VAs: (%d)",
ret);
+ DPAA2_BUS_ERR("FSLMC VFIO Mapping failed");
+ return 0;
+ }
+ }
+
+ ret = fslmc_vfio_process_group();
+ if (ret) {
+ DPAA2_BUS_ERR("Unable to setup devices %d", ret);
+ return 0;
+ }
+
+ return rte_bus_generic_probe(bus);
+}
+
static bool
fslmc_bus_match(const struct rte_driver *drv, const struct rte_device *dev)
{
@@ -544,7 +554,7 @@ fslmc_bus_unplug_device(struct rte_device *rte_dev)
struct rte_bus rte_fslmc_bus = {
.scan = rte_fslmc_scan,
- .probe = rte_bus_generic_probe,
+ .probe = rte_fslmc_probe,
.cleanup = rte_fslmc_close,
.parse = rte_fslmc_parse,
.dev_compare = fslmc_dev_compare,
--
2.43.0