From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org, fengchengwen@huawei.com
Cc: hemant.agrawal@nxp.com, Gagandeep Singh <g.singh@nxp.com>
Subject: [PATCH v6 1/5] bus/platform: match device by devicetree compatible string
Date: Wed, 14 Oct 2026 09:27:42 +0530 [thread overview]
Message-ID: <20261014035746.509685-2-g.singh@nxp.com> (raw)
In-Reply-To: <20261014035746.509685-1-g.singh@nxp.com>
The platform bus currently matches a DPDK driver to a device only by
comparing the kernel driver name bound to the device against the DPDK
driver name. Devices bound to the generic vfio-platform kernel driver
all report the same driver name, which carries no device identity, so a
specific DPDK driver cannot claim its device this way.
Add of_device_is_compatible(), which reads the device-tree "compatible"
strings exposed under the device's of_node in sysfs and compares them
against a requested string. platform_bus_match() now falls back to
matching the DPDK driver name or its alias against these compatible
strings, letting a driver bind to a device identified by its
device-tree "compatible" value.
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/rel_notes/release_26_11.rst | 9 +++++
drivers/bus/platform/platform.c | 49 +++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index f93a5ab960..c44b4de604 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -20,6 +20,15 @@ DPDK Release 26.11
ninja -C build doc
xdg-open build/doc/guides/html/rel_notes/release_26_11.html
+* **bus/platform: match devices by device-tree compatible string.**
+
+ The platform bus now matches DPDK drivers against the device-tree
+ ``compatible`` sysfs strings exposed by each platform device, in
+ addition to the existing kernel driver name and device name checks.
+ This allows drivers to be probed by DT compatible string when the
+ kernel driver is the generic ``vfio-platform``, which carries no
+ device identity in its name.
+
New Features
------------
diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c
index 950306e2d9..c684177d32 100644
--- a/drivers/bus/platform/platform.c
+++ b/drivers/bus/platform/platform.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(C) 2023 Marvell.
+ * Copyright 2026 NXP
*/
#include <uapi/linux/vfio.h>
@@ -230,6 +231,41 @@ of_resource_name(const char *dev_name, int index)
return NULL;
}
+/*
+ * Check whether any of the NUL-separated device-tree "compatible" strings
+ * exposed by the platform device matches the given string.
+ */
+static bool
+of_device_is_compatible(const char *dev_name, const char *compat)
+{
+ char path[PATH_MAX], buf[BUFSIZ] = { };
+ const char *s;
+ FILE *f;
+ size_t len;
+
+ if (compat == NULL)
+ return false;
+
+ snprintf(path, sizeof(path), PLATFORM_BUS_DEVICES_PATH "/%s/of_node/compatible", dev_name);
+ f = fopen(path, "r");
+ if (f == NULL)
+ return false;
+
+ /* Read the raw contents, preserving embedded NULL separators. */
+ len = fread(buf, 1, sizeof(buf) - 1, f);
+ fclose(f);
+ if (len == 0)
+ return false;
+
+ /* Bound the walk by the read length: some kernels omit the trailing NULL. */
+ for (s = buf; s < buf + len; s += strlen(s) + 1) {
+ if (!strcmp(s, compat))
+ return true;
+ }
+
+ return false;
+}
+
static int
device_map_resources(struct rte_platform_device *pdev, unsigned int num)
{
@@ -393,7 +429,18 @@ platform_bus_match(const struct rte_driver *drv, const struct rte_device *dev)
}
/* match by device name */
- if (!strcmp(pdev->name, pdrv->driver.name))
+ if (!strcmp(pdev->name, pdrv->driver.name)) {
+ match = true;
+ goto out;
+ }
+
+ /*
+ * The generic vfio-platform kernel driver name carries no device
+ * identity, so fall back to matching the device-tree "compatible"
+ * strings against the DPDK driver name or alias.
+ */
+ if (of_device_is_compatible(pdev->name, pdrv->driver.name) ||
+ of_device_is_compatible(pdev->name, pdrv->driver.alias))
match = true;
out:
--
2.25.1
next prev parent reply other threads:[~2026-10-14 3:57 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 8:42 [PATCH 0/4] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver Gagandeep Singh
2026-08-06 8:42 ` [PATCH 1/4] dma/imx_edma5: introduce eDMA5 dmadev skeleton Gagandeep Singh
2026-08-06 8:42 ` [PATCH 2/4] dma/imx_edma5: add device configuration Gagandeep Singh
2026-08-06 8:42 ` [PATCH 3/4] dma/imx_edma5: add data path Gagandeep Singh
2026-08-06 8:42 ` [PATCH 4/4] dma/imx_edma5: add statistics and dump Gagandeep Singh
2026-08-06 16:21 ` Stephen Hemminger
2026-08-07 7:05 ` Gagandeep Singh
2026-08-06 17:11 ` [PATCH 0/4] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver Stephen Hemminger
2026-08-07 6:54 ` Gagandeep Singh
2026-08-07 6:48 ` [PATCH v2 0/5] " Gagandeep Singh
2026-08-07 6:48 ` [PATCH v2 1/5] bus/platform: match device by devicetree compatible string Gagandeep Singh
2026-08-07 6:48 ` [PATCH v2 2/5] dma/imx_edma5: introduce eDMA5 dmadev skeleton Gagandeep Singh
2026-08-07 6:48 ` [PATCH v2 3/5] dma/imx_edma5: add device configuration Gagandeep Singh
2026-08-07 6:48 ` [PATCH v2 4/5] dma/imx_edma5: add data path Gagandeep Singh
2026-08-07 6:48 ` [PATCH v2 5/5] dma/imx_edma5: add statistics and dump Gagandeep Singh
2026-08-10 15:37 ` [PATCH v2 0/5] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver Stephen Hemminger
2026-08-11 10:49 ` [PATCH v3 " Gagandeep Singh
2026-08-11 10:49 ` [PATCH v3 1/5] bus/platform: match device by devicetree compatible string Gagandeep Singh
2026-08-11 10:49 ` [PATCH v3 2/5] dma/imx_edma5: introduce eDMA5 dmadev skeleton Gagandeep Singh
2026-08-11 10:49 ` [PATCH v3 3/5] dma/imx_edma5: add device configuration Gagandeep Singh
2026-08-11 10:49 ` [PATCH v3 4/5] dma/imx_edma5: add data path Gagandeep Singh
2026-08-11 10:49 ` [PATCH v3 5/5] dma/imx_edma5: add statistics and dump Gagandeep Singh
2026-08-11 17:00 ` [PATCH v3 0/5] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver Stephen Hemminger
2026-08-12 9:29 ` [PATCH v4 " Gagandeep Singh
2026-08-12 9:29 ` [PATCH v4 1/5] bus/platform: match device by devicetree compatible string Gagandeep Singh
2026-10-08 17:24 ` David Marchand
2026-10-09 7:31 ` David Marchand
2026-10-13 10:12 ` David Marchand
2026-10-10 9:29 ` fengchengwen
2026-08-12 9:29 ` [PATCH v4 2/5] dma/imx_edma5: introduce eDMA5 dmadev skeleton Gagandeep Singh
2026-10-10 6:45 ` fengchengwen
2026-08-12 9:29 ` [PATCH v4 3/5] dma/imx_edma5: add device configuration Gagandeep Singh
2026-10-10 7:01 ` fengchengwen
2026-08-12 9:29 ` [PATCH v4 4/5] dma/imx_edma5: add data path Gagandeep Singh
2026-10-10 7:24 ` fengchengwen
2026-08-12 9:29 ` [PATCH v4 5/5] dma/imx_edma5: add statistics and dump Gagandeep Singh
2026-10-10 7:26 ` fengchengwen
2026-10-08 17:27 ` [PATCH v4 0/5] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver David Marchand
2026-10-10 9:31 ` fengchengwen
2026-10-13 6:51 ` [PATCH v5 " Gagandeep Singh
2026-10-13 6:51 ` [PATCH v5 1/5] bus/platform: match device by devicetree compatible string Gagandeep Singh
2026-10-13 6:51 ` [PATCH v5 2/5] dma/imx_edma5: introduce eDMA5 dmadev skeleton Gagandeep Singh
2026-10-13 6:51 ` [PATCH v5 3/5] dma/imx_edma5: add device configuration Gagandeep Singh
2026-10-13 6:51 ` [PATCH v5 4/5] dma/imx_edma5: add data path Gagandeep Singh
2026-10-13 6:51 ` [PATCH v5 5/5] dma/imx_edma5: add statistics and dump Gagandeep Singh
2026-10-14 3:57 ` [PATCH v6 0/5] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver Gagandeep Singh
2026-10-14 3:57 ` Gagandeep Singh [this message]
2026-10-14 3:57 ` [PATCH v6 2/5] dma/imx_edma5: introduce eDMA5 dmadev skeleton Gagandeep Singh
2026-10-14 3:57 ` [PATCH v6 3/5] dma/imx_edma5: add device configuration Gagandeep Singh
2026-10-14 3:57 ` [PATCH v6 4/5] dma/imx_edma5: add data path Gagandeep Singh
2026-10-14 3:57 ` [PATCH v6 5/5] dma/imx_edma5: add statistics and dump Gagandeep Singh
2026-10-14 7:28 ` [PATCH v6 0/5] dma/imx_edma5: introduce NXP i.MX95 eDMA5 driver David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014035746.509685-2-g.singh@nxp.com \
--to=g.singh@nxp.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=hemant.agrawal@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.