mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Zide Chen <zide.chen@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Eranian Stephane <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Xudong Hao <xudong.hao@intel.com>,
	Falcon Thomas <thomas.falcon@intel.com>
Subject: Re: [PATCH V2 01/13] perf/x86/intel/uncore: Move uncore discovery init struct to header
Date: Sun, 4 Jan 2026 09:47:03 +0800	[thread overview]
Message-ID: <9dec5f35-0e9a-4f1c-bcf1-9b15793b17d1@linux.intel.com> (raw)
In-Reply-To: <20251231224233.113839-2-zide.chen@intel.com>


On 1/1/2026 6:42 AM, Zide Chen wrote:
> The discovery base MSR or PCI device is platform-specific and must be
> defined statically in the per-platform init table and passed to the
> discovery code.
>
> Move the definition of struct intel_uncore_init_fun to uncore.h so it
> can be accessed by discovery code, and rename it to reflect that it
> now carries more than just init callbacks.
>
> Shorten intel_uncore_has_discovery_tables[_pci/msr] to
> uncore_discovery[_pci/msr] for improved readability and alignment.
>
> Drop the `intel_` prefix from new names since the code is under the
> intel directory and long identifiers make alignment harder.  Further
> cleanups will continue removing `intel_` prefixes.
>
> No functional change intended.
>
> Signed-off-by: Zide Chen <zide.chen@intel.com>
> ---
> V2: New patch
>
>  arch/x86/events/intel/uncore.c           | 72 ++++++++++--------------
>  arch/x86/events/intel/uncore.h           | 10 ++++
>  arch/x86/events/intel/uncore_discovery.c | 12 ++--
>  arch/x86/events/intel/uncore_discovery.h |  2 +-
>  4 files changed, 49 insertions(+), 47 deletions(-)
>
> diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
> index e228e564b15e..cd561290be8c 100644
> --- a/arch/x86/events/intel/uncore.c
> +++ b/arch/x86/events/intel/uncore.c
> @@ -1697,133 +1697,123 @@ static int __init uncore_mmio_init(void)
>  	return ret;
>  }
>  
> -struct intel_uncore_init_fun {
> -	void	(*cpu_init)(void);
> -	int	(*pci_init)(void);
> -	void	(*mmio_init)(void);
> -	/* Discovery table is required */
> -	bool	use_discovery;
> -	/* The units in the discovery table should be ignored. */
> -	int	*uncore_units_ignore;
> -};
> -
> -static const struct intel_uncore_init_fun nhm_uncore_init __initconst = {
> +static const struct uncore_plat_init nhm_uncore_init __initconst = {
>  	.cpu_init = nhm_uncore_cpu_init,
>  };
>  
> -static const struct intel_uncore_init_fun snb_uncore_init __initconst = {
> +static const struct uncore_plat_init snb_uncore_init __initconst = {
>  	.cpu_init = snb_uncore_cpu_init,
>  	.pci_init = snb_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun ivb_uncore_init __initconst = {
> +static const struct uncore_plat_init ivb_uncore_init __initconst = {
>  	.cpu_init = snb_uncore_cpu_init,
>  	.pci_init = ivb_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun hsw_uncore_init __initconst = {
> +static const struct uncore_plat_init hsw_uncore_init __initconst = {
>  	.cpu_init = snb_uncore_cpu_init,
>  	.pci_init = hsw_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun bdw_uncore_init __initconst = {
> +static const struct uncore_plat_init bdw_uncore_init __initconst = {
>  	.cpu_init = snb_uncore_cpu_init,
>  	.pci_init = bdw_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun snbep_uncore_init __initconst = {
> +static const struct uncore_plat_init snbep_uncore_init __initconst = {
>  	.cpu_init = snbep_uncore_cpu_init,
>  	.pci_init = snbep_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun nhmex_uncore_init __initconst = {
> +static const struct uncore_plat_init nhmex_uncore_init __initconst = {
>  	.cpu_init = nhmex_uncore_cpu_init,
>  };
>  
> -static const struct intel_uncore_init_fun ivbep_uncore_init __initconst = {
> +static const struct uncore_plat_init ivbep_uncore_init __initconst = {
>  	.cpu_init = ivbep_uncore_cpu_init,
>  	.pci_init = ivbep_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun hswep_uncore_init __initconst = {
> +static const struct uncore_plat_init hswep_uncore_init __initconst = {
>  	.cpu_init = hswep_uncore_cpu_init,
>  	.pci_init = hswep_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun bdx_uncore_init __initconst = {
> +static const struct uncore_plat_init bdx_uncore_init __initconst = {
>  	.cpu_init = bdx_uncore_cpu_init,
>  	.pci_init = bdx_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun knl_uncore_init __initconst = {
> +static const struct uncore_plat_init knl_uncore_init __initconst = {
>  	.cpu_init = knl_uncore_cpu_init,
>  	.pci_init = knl_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun skl_uncore_init __initconst = {
> +static const struct uncore_plat_init skl_uncore_init __initconst = {
>  	.cpu_init = skl_uncore_cpu_init,
>  	.pci_init = skl_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun skx_uncore_init __initconst = {
> +static const struct uncore_plat_init skx_uncore_init __initconst = {
>  	.cpu_init = skx_uncore_cpu_init,
>  	.pci_init = skx_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun icl_uncore_init __initconst = {
> +static const struct uncore_plat_init icl_uncore_init __initconst = {
>  	.cpu_init = icl_uncore_cpu_init,
>  	.pci_init = skl_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun tgl_uncore_init __initconst = {
> +static const struct uncore_plat_init tgl_uncore_init __initconst = {
>  	.cpu_init = tgl_uncore_cpu_init,
>  	.mmio_init = tgl_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun tgl_l_uncore_init __initconst = {
> +static const struct uncore_plat_init tgl_l_uncore_init __initconst = {
>  	.cpu_init = tgl_uncore_cpu_init,
>  	.mmio_init = tgl_l_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun rkl_uncore_init __initconst = {
> +static const struct uncore_plat_init rkl_uncore_init __initconst = {
>  	.cpu_init = tgl_uncore_cpu_init,
>  	.pci_init = skl_uncore_pci_init,
>  };
>  
> -static const struct intel_uncore_init_fun adl_uncore_init __initconst = {
> +static const struct uncore_plat_init adl_uncore_init __initconst = {
>  	.cpu_init = adl_uncore_cpu_init,
>  	.mmio_init = adl_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun mtl_uncore_init __initconst = {
> +static const struct uncore_plat_init mtl_uncore_init __initconst = {
>  	.cpu_init = mtl_uncore_cpu_init,
>  	.mmio_init = adl_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun lnl_uncore_init __initconst = {
> +static const struct uncore_plat_init lnl_uncore_init __initconst = {
>  	.cpu_init = lnl_uncore_cpu_init,
>  	.mmio_init = lnl_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun ptl_uncore_init __initconst = {
> +static const struct uncore_plat_init ptl_uncore_init __initconst = {
>  	.cpu_init = ptl_uncore_cpu_init,
>  	.mmio_init = ptl_uncore_mmio_init,
>  	.use_discovery = true,
>  };
>  
> -static const struct intel_uncore_init_fun icx_uncore_init __initconst = {
> +static const struct uncore_plat_init icx_uncore_init __initconst = {
>  	.cpu_init = icx_uncore_cpu_init,
>  	.pci_init = icx_uncore_pci_init,
>  	.mmio_init = icx_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun snr_uncore_init __initconst = {
> +static const struct uncore_plat_init snr_uncore_init __initconst = {
>  	.cpu_init = snr_uncore_cpu_init,
>  	.pci_init = snr_uncore_pci_init,
>  	.mmio_init = snr_uncore_mmio_init,
>  };
>  
> -static const struct intel_uncore_init_fun spr_uncore_init __initconst = {
> +static const struct uncore_plat_init spr_uncore_init __initconst = {
>  	.cpu_init = spr_uncore_cpu_init,
>  	.pci_init = spr_uncore_pci_init,
>  	.mmio_init = spr_uncore_mmio_init,
> @@ -1831,7 +1821,7 @@ static const struct intel_uncore_init_fun spr_uncore_init __initconst = {
>  	.uncore_units_ignore = spr_uncore_units_ignore,
>  };
>  
> -static const struct intel_uncore_init_fun gnr_uncore_init __initconst = {
> +static const struct uncore_plat_init gnr_uncore_init __initconst = {
>  	.cpu_init = gnr_uncore_cpu_init,
>  	.pci_init = gnr_uncore_pci_init,
>  	.mmio_init = gnr_uncore_mmio_init,
> @@ -1839,7 +1829,7 @@ static const struct intel_uncore_init_fun gnr_uncore_init __initconst = {
>  	.uncore_units_ignore = gnr_uncore_units_ignore,
>  };
>  
> -static const struct intel_uncore_init_fun generic_uncore_init __initconst = {
> +static const struct uncore_plat_init generic_uncore_init __initconst = {
>  	.cpu_init = intel_uncore_generic_uncore_cpu_init,
>  	.pci_init = intel_uncore_generic_uncore_pci_init,
>  	.mmio_init = intel_uncore_generic_uncore_mmio_init,
> @@ -1910,7 +1900,7 @@ MODULE_DEVICE_TABLE(x86cpu, intel_uncore_match);
>  static int __init intel_uncore_init(void)
>  {
>  	const struct x86_cpu_id *id;
> -	struct intel_uncore_init_fun *uncore_init;
> +	struct uncore_plat_init *uncore_init;
>  	int pret = 0, cret = 0, mret = 0, ret;
>  
>  	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
> @@ -1921,16 +1911,16 @@ static int __init intel_uncore_init(void)
>  
>  	id = x86_match_cpu(intel_uncore_match);
>  	if (!id) {
> -		if (!uncore_no_discover && intel_uncore_has_discovery_tables(NULL))
> -			uncore_init = (struct intel_uncore_init_fun *)&generic_uncore_init;
> +		if (!uncore_no_discover && uncore_discovery(NULL))
> +			uncore_init = (struct uncore_plat_init *)&generic_uncore_init;
>  		else
>  			return -ENODEV;
>  	} else {
> -		uncore_init = (struct intel_uncore_init_fun *)id->driver_data;
> +		uncore_init = (struct uncore_plat_init *)id->driver_data;
>  		if (uncore_no_discover && uncore_init->use_discovery)
>  			return -ENODEV;
>  		if (uncore_init->use_discovery &&
> -		    !intel_uncore_has_discovery_tables(uncore_init->uncore_units_ignore))
> +		    !uncore_discovery(uncore_init))
>  			return -ENODEV;
>  	}
>  
> diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
> index d8815fff7588..568536ef28ee 100644
> --- a/arch/x86/events/intel/uncore.h
> +++ b/arch/x86/events/intel/uncore.h
> @@ -47,6 +47,16 @@ struct uncore_event_desc;
>  struct freerunning_counters;
>  struct intel_uncore_topology;
>  
> +struct uncore_plat_init {
> +	void	(*cpu_init)(void);
> +	int	(*pci_init)(void);
> +	void	(*mmio_init)(void);
> +	/* Discovery table is required */
> +	bool	use_discovery;
> +	/* The units in the discovery table should be ignored. */
> +	int	*uncore_units_ignore;
> +};
> +
>  struct intel_uncore_type {
>  	const char *name;
>  	int num_counters;
> diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
> index 7d57ce706feb..d39f6a0b8cc3 100644
> --- a/arch/x86/events/intel/uncore_discovery.c
> +++ b/arch/x86/events/intel/uncore_discovery.c
> @@ -350,7 +350,7 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
>  	return __parse_discovery_table(addr, die, parsed, ignore);
>  }
>  
> -static bool intel_uncore_has_discovery_tables_pci(int *ignore)
> +static bool uncore_discovery_pci(int *ignore)
>  {
>  	u32 device, val, entry_id, bar_offset;
>  	int die, dvsec = 0, ret = true;
> @@ -399,7 +399,7 @@ static bool intel_uncore_has_discovery_tables_pci(int *ignore)
>  	return ret;
>  }
>  
> -static bool intel_uncore_has_discovery_tables_msr(int *ignore)
> +static bool uncore_discovery_msr(int *ignore)
>  {
>  	unsigned long *die_mask;
>  	bool parsed = false;
> @@ -432,10 +432,12 @@ static bool intel_uncore_has_discovery_tables_msr(int *ignore)
>  	return parsed;
>  }
>  
> -bool intel_uncore_has_discovery_tables(int *ignore)
> +bool uncore_discovery(struct uncore_plat_init *init)
>  {
> -	return intel_uncore_has_discovery_tables_msr(ignore) ||
> -	       intel_uncore_has_discovery_tables_pci(ignore);
> +	int *ignore = init ? init->uncore_units_ignore : NULL;
> +
> +	return uncore_discovery_msr(ignore) ||
> +	       uncore_discovery_pci(ignore);
>  }
>  
>  void intel_uncore_clear_discovery_tables(void)
> diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/intel/uncore_discovery.h
> index dff75c98e22f..dfc237a2b6df 100644
> --- a/arch/x86/events/intel/uncore_discovery.h
> +++ b/arch/x86/events/intel/uncore_discovery.h
> @@ -136,7 +136,7 @@ struct intel_uncore_discovery_type {
>  	u16		num_units;	/* number of units */
>  };
>  
> -bool intel_uncore_has_discovery_tables(int *ignore);
> +bool uncore_discovery(struct uncore_plat_init *init);
>  void intel_uncore_clear_discovery_tables(void);
>  void intel_uncore_generic_uncore_cpu_init(void);
>  int intel_uncore_generic_uncore_pci_init(void);

LGTM.

Reviewed-by:  Dapeng Mi <dapeng1.mi@linux.intel.com>



  reply	other threads:[~2026-01-04  1:47 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-31 22:42 [PATCH V2 00/13] Add DMR/NVL and missing PTL uncore support Zide Chen
2025-12-31 22:42 ` [PATCH V2 01/13] perf/x86/intel/uncore: Move uncore discovery init struct to header Zide Chen
2026-01-04  1:47   ` Mi, Dapeng [this message]
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 02/13] perf/x86/intel/uncore: Support per-platform discovery base devices Zide Chen
2026-01-04  2:00   ` Mi, Dapeng
2026-01-06 11:01   ` Peter Zijlstra
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 03/13] perf/x86/intel/uncore: Remove has_generic_discovery_table() Zide Chen
2026-01-04  2:03   ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 04/13] perf/x86/intel/uncore: Add IMH PMON support for Diamond Rapids Zide Chen
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 05/13] perf/x86/intel/uncore: Add CBB " Zide Chen
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 06/13] perf/x86/intel/uncore: Add domain global init callback Zide Chen
2026-01-04  2:26   ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 07/13] perf/x86/intel/uncore: Add freerunning event descriptor helper macro Zide Chen
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 08/13] perf/x86/intel/uncore: Support IIO free-running counters on DMR Zide Chen
2026-01-04  2:31   ` Mi, Dapeng
2026-02-06  0:26     ` Chun-Tse Shao
2026-02-06  5:51       ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 09/13] perf/x86/intel/uncore: Support uncore constraint ranges Zide Chen
2026-01-04  2:36   ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 10/13] perf/x86/intel/uncore: Update DMR uncore constraints preliminarily Zide Chen
2026-01-04  2:41   ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 11/13] perf pmu: Relax uncore wildcard matching to allow numeric suffix Zide Chen
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2026-01-21  7:18   ` [PATCH V2 11/13] " Ian Rogers
2026-01-21  8:02     ` Mi, Dapeng
2026-01-21 14:33       ` Ian Rogers
2026-01-21 18:19         ` Ian Rogers
2026-01-21 19:03           ` Chen, Zide
2026-01-22  2:09             ` Mi, Dapeng
2026-01-22  7:10               ` Ian Rogers
2026-02-03 23:33                 ` Ian Rogers
2026-02-04 21:34                   ` Namhyung Kim
2025-12-31 22:42 ` [PATCH V2 12/13] perf/x86/intel/uncore: Add missing PMON units for Panther Lake Zide Chen
2026-01-04  2:48   ` Mi, Dapeng
2026-01-04  2:49   ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2025-12-31 22:42 ` [PATCH V2 13/13] perf/x86/intel/uncore: Add Nova Lake support Zide Chen
2026-01-04  2:51   ` Mi, Dapeng
2026-01-12  8:03   ` [tip: perf/core] " tip-bot2 for Zide Chen
2026-01-06 15:08 ` [PATCH V2 00/13] Add DMR/NVL and missing PTL uncore support Peter Zijlstra
2026-01-06 21:19   ` Chen, Zide

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=9dec5f35-0e9a-4f1c-bcf1-9b15793b17d1@linux.intel.com \
    --to=dapeng1.mi@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=thomas.falcon@intel.com \
    --cc=xudong.hao@intel.com \
    --cc=zide.chen@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®