From: Huisong Li <[email protected]> The automatic uncore driver detection currently probes drivers by calling their init() and exit() callbacks on package 0 and die 0, which may have side effects on the system.
Add an optional detect() callback to struct rte_power_uncore_ops so a driver can check platform support, e.g. sysfs entries or device nodes, without a full initialization. power_uncore_probe_driver() uses detect() when available and falls back to the existing init/exit probing for drivers without one. Signed-off-by: Huisong Li <[email protected]> Signed-off-by: Shuaisong Yang <[email protected]> --- lib/power/power_uncore_ops.h | 17 +++++++++++++++++ lib/power/rte_power_uncore.c | 11 ++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/power/power_uncore_ops.h b/lib/power/power_uncore_ops.h index 025a55cb97..e3c8f0b741 100644 --- a/lib/power/power_uncore_ops.h +++ b/lib/power/power_uncore_ops.h @@ -183,11 +183,28 @@ typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(void); typedef unsigned int (*rte_power_uncore_get_num_dies_t)(unsigned int pkg); typedef void (*rte_power_uncore_driver_cb_t)(void); +/** + * Detect if the current platform supports this uncore frequency management driver. + * + * This callback is used during automatic driver detection to check whether + * the platform has the necessary hardware/software support (e.g., sysfs + * entries, device nodes) without performing a full initialization that may + * have side effects. + * + * This function should NOT be called in the fast path. + * + * @return + * - 0 on success, the platform supports this driver. + * - Negative on error, the platform does not support this driver. + */ +typedef int (*rte_power_uncore_detect_t)(void); + /** Structure defining uncore power operations structure */ struct rte_power_uncore_ops { RTE_TAILQ_ENTRY(rte_power_uncore_ops) next; /**< Next in list. */ char name[RTE_POWER_UNCORE_DRIVER_NAMESZ]; /**< power mgmt driver. */ rte_power_uncore_driver_cb_t cb; /**< Driver specific callbacks. */ + rte_power_uncore_detect_t detect; /**< Detect platform support. */ rte_power_uncore_init_t init; /**< Initialize power management. */ rte_power_uncore_exit_t exit; /**< Exit power management. */ rte_power_uncore_get_num_pkgs_t get_num_pkgs; diff --git a/lib/power/rte_power_uncore.c b/lib/power/rte_power_uncore.c index cd2b2a51d5..1ec029702b 100644 --- a/lib/power/rte_power_uncore.c +++ b/lib/power/rte_power_uncore.c @@ -66,11 +66,16 @@ power_uncore_probe_driver(void) int ret; global_uncore_ops = NULL; - /* Use package-0 and die-0 to probe uncore driver. */ RTE_TAILQ_FOREACH(ops, &uncore_ops_list, next) { - ret = ops->init(0, 0); + if (ops->detect) { + ret = ops->detect(); + } else { + /* Use package-0 and die-0 to probe uncore driver. */ + ret = ops->init(0, 0); + if (ret == 0) + ops->exit(0, 0); + } if (ret == 0) { - ops->exit(0, 0); env = power_uncore_driver_name2env(ops->name); if (env == UINT32_MAX) continue; -- 2.33.0

