Re: [PATCH V2 02/13] perf/x86/intel/uncore: Support per-platform discovery base devices
From: Peter Zijlstra
Date: Tue Jan 06 2026 - 06:01:15 EST
On Wed, Dec 31, 2025 at 02:42:19PM -0800, Zide Chen wrote:
> @@ -1897,6 +1899,17 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {
> };
> MODULE_DEVICE_TABLE(x86cpu, intel_uncore_match);
>
> +static bool ucore_use_discovery(struct uncore_plat_init *config)
> +{
> + int i;
> +
> + for (i = 0; i < UNCORE_DISCOVERY_DOMAINS; i++)
> + if (config->domain[i].discovery_base)
> + return true;
> +
> + return false;
> +}
> +
> static int __init intel_uncore_init(void)
> {
> const struct x86_cpu_id *id;
> @@ -1911,15 +1924,14 @@ static int __init intel_uncore_init(void)
>
> id = x86_match_cpu(intel_uncore_match);
> if (!id) {
> - if (!uncore_no_discover && uncore_discovery(NULL))
> - uncore_init = (struct uncore_plat_init *)&generic_uncore_init;
> - else
> + uncore_init = (struct uncore_plat_init *)&generic_uncore_init;
> + if (uncore_no_discover || !uncore_discovery(uncore_init))
> return -ENODEV;
> } else {
> uncore_init = (struct uncore_plat_init *)id->driver_data;
> - if (uncore_no_discover && uncore_init->use_discovery)
> + if (uncore_no_discover && ucore_use_discovery(uncore_init))
> return -ENODEV;
> - if (uncore_init->use_discovery &&
> + if (ucore_use_discovery(uncore_init) &&
> !uncore_discovery(uncore_init))
> return -ENODEV;
> }
I got triggered by that naming oddity, but then couldn't help but also
fix the lack of { } and then use for-scoped variables.
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -1899,13 +1899,12 @@ static const struct x86_cpu_id intel_unc
};
MODULE_DEVICE_TABLE(x86cpu, intel_uncore_match);
-static bool ucore_use_discovery(struct uncore_plat_init *config)
+static bool uncore_use_discovery(struct uncore_plat_init *config)
{
- int i;
-
- for (i = 0; i < UNCORE_DISCOVERY_DOMAINS; i++)
+ for (int i = 0; i < UNCORE_DISCOVERY_DOMAINS; i++) {
if (config->domain[i].discovery_base)
return true;
+ }
return false;
}
@@ -1929,9 +1928,9 @@ static int __init intel_uncore_init(void
return -ENODEV;
} else {
uncore_init = (struct uncore_plat_init *)id->driver_data;
- if (uncore_no_discover && ucore_use_discovery(uncore_init))
+ if (uncore_no_discover && uncore_use_discovery(uncore_init))
return -ENODEV;
- if (ucore_use_discovery(uncore_init) &&
+ if (uncore_use_discovery(uncore_init) &&
!uncore_discovery(uncore_init))
return -ENODEV;
}