From: Zide Chen <zide.chen@intel.com>
To: 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: Chun-Tse Shao <ctshao@google.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Dapeng Mi <dapeng1.mi@linux.intel.com>,
Zide Chen <zide.chen@intel.com>
Subject: [PATCH 03/12] perf/x86/intel/uncore: Replace CTL_OFFS8 box flag with type flag
Date: Fri, 4 Dec 2026 20:22:44 -0700 [thread overview]
Message-ID: <20261205032253.258646-4-zide.chen@intel.com> (raw)
In-Reply-To: <20261205032253.258646-1-zide.chen@intel.com>
Setting UNCORE_BOX_FLAG_CTL_OFFS8 during runtime box initialization
requires custom init_box callbacks, leading to unnecessary custom ops.
Counter control register stride is a static architectural property of
the PMU type, not dynamic runtime state of a box instance. Replacing
UNCORE_BOX_FLAG_CTL_OFFS8 with a 1-bit ctl_offs8 field in struct
intel_uncore_type is not only more accurate, but also allows the stride
to be handled in a more generic way.
Since all discovered PCI types have an 8-byte stride, set ctl_offs8 = 1
in uncore_update_uncore_type(), and set it in all other types whose
boxes currently carry the UNCORE_BOX_FLAG_CTL_OFFS8 flag.
This allows spr_uncore_mmio_offs8_init_box() and the associated ops
to be dropped, paving the way for more generic handling of 8-byte
stride MMIO boxes in DMR and other future platforms.
No functional change intended.
Signed-off-by: Zide Chen <zide.chen@intel.com>
---
arch/x86/events/intel/uncore.h | 7 +++---
arch/x86/events/intel/uncore_discovery.c | 2 +-
arch/x86/events/intel/uncore_snbep.c | 31 +++++++++---------------
3 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
index c8dfa2d21bfd..c88949387b7c 100644
--- a/arch/x86/events/intel/uncore.h
+++ b/arch/x86/events/intel/uncore.h
@@ -91,6 +91,7 @@ struct intel_uncore_type {
unsigned num_shared_regs:8;
unsigned single_fixed:1;
unsigned pair_ctr_ctl:1;
+ unsigned ctl_offs8:1; /* counter control registers are 8 bytes apart */
union {
u64 *msr_offsets;
u64 *pci_offsets;
@@ -197,10 +198,8 @@ struct intel_uncore_box {
#define CFL_UNC_CBO_7_PER_CTR0 0xf76
#define UNCORE_BOX_FLAG_INITIALIZED 0
-/* event config registers are 8-byte apart */
-#define UNCORE_BOX_FLAG_CTL_OFFS8 1
/* CFL 8th CBOX has different MSR space */
-#define UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS 2
+#define UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS 1
struct uncore_event_desc {
struct device_attribute attr;
@@ -327,7 +326,7 @@ static inline unsigned uncore_pci_fixed_ctr(struct intel_uncore_box *box)
static inline
unsigned uncore_pci_event_ctl(struct intel_uncore_box *box, int idx)
{
- if (test_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags))
+ if (box->pmu->type->ctl_offs8)
return idx * 8 + box->pmu->type->event_ctl;
return idx * 4 + box->pmu->type->event_ctl;
diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
index 99a1b974b14f..75fd3e52c540 100644
--- a/arch/x86/events/intel/uncore_discovery.c
+++ b/arch/x86/events/intel/uncore_discovery.c
@@ -585,7 +585,6 @@ int intel_generic_uncore_pci_init_box(struct intel_uncore_box *box)
if (!box_ctl)
return -ENODEV;
- __set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags);
return pci_write_config_dword(box->pci_dev, box_ctl,
GENERIC_PMON_BOX_CTL_INT);
}
@@ -746,6 +745,7 @@ static bool uncore_update_uncore_type(enum uncore_access_type type_id,
break;
case UNCORE_ACCESS_PCI:
uncore->ops = &generic_uncore_pci_ops;
+ uncore->ctl_offs8 = 1;
break;
case UNCORE_ACCESS_MMIO:
uncore->ops = &generic_uncore_mmio_ops;
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 35212195b379..e0be7a35baec 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -4176,7 +4176,6 @@ static int skx_upi_uncore_pci_init_box(struct intel_uncore_box *box)
{
struct pci_dev *pdev = box->pci_dev;
- __set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags);
return pci_write_config_dword(pdev, uncore_pci_box_ctl(box),
IVBEP_PMON_BOX_CTL_INT);
}
@@ -4326,6 +4325,7 @@ static struct intel_uncore_type skx_uncore_upi = {
.event_mask = SNBEP_PMON_RAW_EVENT_MASK,
.event_mask_ext = SKX_UPI_CTL_UMASK_EXT,
.box_ctl = SKX_UPI_PCI_PMON_BOX_CTL,
+ .ctl_offs8 = 1,
.ops = &skx_upi_uncore_pci_ops,
.format_group = &skx_upi_uncore_format_group,
.attr_update = skx_upi_attr_update,
@@ -4338,7 +4338,6 @@ static int skx_m2m_uncore_pci_init_box(struct intel_uncore_box *box)
{
struct pci_dev *pdev = box->pci_dev;
- __set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags);
return pci_write_config_dword(pdev, SKX_M2M_PCI_PMON_BOX_CTL,
IVBEP_PMON_BOX_CTL_INT);
}
@@ -4361,6 +4360,7 @@ static struct intel_uncore_type skx_uncore_m2m = {
.event_ctl = SKX_M2M_PCI_PMON_CTL0,
.event_mask = SNBEP_PMON_RAW_EVENT_MASK,
.box_ctl = SKX_M2M_PCI_PMON_BOX_CTL,
+ .ctl_offs8 = 1,
.ops = &skx_m2m_uncore_pci_ops,
.format_group = &skx_uncore_format_group,
};
@@ -4848,7 +4848,6 @@ static int snr_m2m_uncore_pci_init_box(struct intel_uncore_box *box)
struct pci_dev *pdev = box->pci_dev;
int box_ctl = uncore_pci_box_ctl(box);
- __set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags);
return pci_write_config_dword(pdev, box_ctl, IVBEP_PMON_BOX_CTL_INT);
}
@@ -4885,6 +4884,7 @@ static struct intel_uncore_type snr_uncore_m2m = {
.event_mask = SNBEP_PMON_RAW_EVENT_MASK,
.event_mask_ext = SNR_M2M_PCI_PMON_UMASK_EXT,
.box_ctl = SNR_M2M_PCI_PMON_BOX_CTL,
+ .ctl_offs8 = 1,
.ops = &snr_m2m_uncore_pci_ops,
.format_group = &snr_m2m_uncore_format_group,
};
@@ -4917,6 +4917,7 @@ static struct intel_uncore_type snr_uncore_pcie3 = {
.event_mask = SKX_IIO_PMON_RAW_EVENT_MASK,
.event_mask_ext = SKX_IIO_PMON_RAW_EVENT_MASK_EXT,
.box_ctl = SNR_PCIE3_PCI_PMON_BOX_CTL,
+ .ctl_offs8 = 1,
.ops = &snr_pcie3_uncore_pci_ops,
.format_group = &skx_uncore_iio_format_group,
};
@@ -5450,6 +5451,7 @@ static struct intel_uncore_type icx_uncore_m2m = {
.event_mask = SNBEP_PMON_RAW_EVENT_MASK,
.event_mask_ext = SNR_M2M_PCI_PMON_UMASK_EXT,
.box_ctl = SNR_M2M_PCI_PMON_BOX_CTL,
+ .ctl_offs8 = 1,
.ops = &snr_m2m_uncore_pci_ops,
.format_group = &snr_m2m_uncore_format_group,
};
@@ -5549,6 +5551,7 @@ static struct intel_uncore_type icx_uncore_upi = {
.event_mask = SNBEP_PMON_RAW_EVENT_MASK,
.event_mask_ext = ICX_UPI_CTL_UMASK_EXT,
.box_ctl = ICX_UPI_PCI_PMON_BOX_CTL,
+ .ctl_offs8 = 1,
.ops = &skx_upi_uncore_pci_ops,
.format_group = &icx_upi_uncore_format_group,
.attr_update = icx_upi_attr_update,
@@ -5981,6 +5984,7 @@ static struct intel_uncore_ops spr_uncore_pci_ops = {
#define SPR_UNCORE_PCI_COMMON_FORMAT() \
SPR_UNCORE_COMMON_FORMAT(), \
+ .ctl_offs8 = 1, \
.ops = &spr_uncore_pci_ops
static struct intel_uncore_type spr_uncore_m2m = {
@@ -6020,25 +6024,9 @@ static struct intel_uncore_type spr_uncore_mdf = {
.name = "mdf",
};
-static int spr_uncore_mmio_offs8_init_box(struct intel_uncore_box *box)
-{
- __set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags);
- return intel_generic_uncore_mmio_init_box(box);
-}
-
-static struct intel_uncore_ops spr_uncore_mmio_offs8_ops = {
- .init_box = spr_uncore_mmio_offs8_init_box,
- .exit_box = uncore_mmio_exit_box,
- .disable_box = intel_generic_uncore_mmio_disable_box,
- .enable_box = intel_generic_uncore_mmio_enable_box,
- .disable_event = intel_generic_uncore_mmio_disable_event,
- .enable_event = spr_uncore_mmio_enable_event,
- .read_counter = uncore_mmio_read_counter,
-};
-
#define SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT() \
SPR_UNCORE_COMMON_FORMAT(), \
- .ops = &spr_uncore_mmio_offs8_ops
+ .ctl_offs8 = 1
static struct event_constraint spr_uncore_cxlcm_constraints[] = {
UNCORE_EVENT_CONSTRAINT(0x02, 0x0f),
@@ -6126,6 +6114,7 @@ static struct intel_uncore_type spr_uncore_upi = {
.event_mask = SNBEP_PMON_RAW_EVENT_MASK,
.event_mask_ext = SPR_RAW_EVENT_MASK_EXT,
.format_group = &spr_uncore_raw_format_group,
+ .ctl_offs8 = 1,
.ops = &spr_uncore_pci_ops,
.name = "upi",
.attr_update = spr_upi_attr_update,
@@ -6276,6 +6265,8 @@ static void uncore_type_customized_copy(struct intel_uncore_type *to_type,
to_type->num_shared_regs = from_type->num_shared_regs;
if (from_type->constraints)
to_type->constraints = from_type->constraints;
+ if (from_type->ctl_offs8)
+ to_type->ctl_offs8 = from_type->ctl_offs8;
if (from_type->ops)
to_type->ops = from_type->ops;
if (from_type->event_descs)
--
2.56.1
next prev parent reply other threads:[~2026-12-05 3:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 3:22 [PATCH 00/12] perf/x86/intel/uncore: Fix 64-bit counter config Zide Chen
2026-12-05 3:22 ` [PATCH 01/12] perf/x86/intel/uncore: Fix PCU filter band mask calculation Zide Chen
2026-12-05 3:22 ` [PATCH 02/12] perf/x86/intel/uncore: Fix ICX UPI and M3UPI box control offset Zide Chen
2026-12-05 3:22 ` Zide Chen [this message]
2026-12-05 3:22 ` [PATCH 04/12] perf/x86/intel/uncore: Fix DMR MMIO counter control stride Zide Chen
2026-12-05 3:22 ` [PATCH 05/12] perf/x86/intel/uncore: Drop spr_uncore_mmio_ops for generic MMIO Zide Chen
2026-12-05 3:22 ` [PATCH 06/12] perf/x86/intel/uncore: Fix SPR/EMR/GNR/SRF IMC and HBM event formats Zide Chen
2026-12-05 3:49 ` sashiko-bot
2026-12-05 4:41 ` Chen, Zide
2026-12-05 3:22 ` [PATCH 07/12] perf/x86/intel/uncore: Program upper dword in generic ops Zide Chen
2026-12-05 3:22 ` [PATCH 08/12] perf/x86/intel/uncore: Drop spr_uncore_pci_ops for generic PCI Zide Chen
2026-12-05 3:46 ` sashiko-bot
2026-12-05 4:41 ` Chen, Zide
2026-12-05 3:22 ` [PATCH 09/12] perf/x86/intel/uncore: Fix SKX/SNR/ICX PCI extended umask truncation Zide Chen
2026-12-05 3:22 ` [PATCH 10/12] perf/x86/intel/uncore: Program SNR PCIe3 upper filter before enable Zide Chen
2026-12-05 3:22 ` [PATCH 11/12] perf/x86/intel/uncore: Consolidate SKX, SNR and ICX PCI uncore ops Zide Chen
2026-12-05 3:53 ` sashiko-bot
2026-12-05 4:42 ` Chen, Zide
2026-12-05 3:22 ` [PATCH 12/12] perf/x86/intel/uncore: Fix DMR IMC threshold field Zide Chen
2026-12-05 3:54 ` [PATCH 00/12] perf/x86/intel/uncore: Fix 64-bit counter config sashiko-bot
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=20261205032253.258646-4-zide.chen@intel.com \
--to=zide.chen@intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ctshao@google.com \
--cc=dapeng1.mi@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 \
/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.