From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.17 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796441669; b=ZI6FjNkhztbhUcbqv0X4Kee5VeGHRnjWmTnZL6T46PcAmGGS4cMp9WrrbsVVEhgGmcuk EYGkNPY6neEJj1kkZQw5lub3WZImtMQlQOI4d0ZmqHiq8pwglHdDIRYUOJo611BYK7KJx T3W5VvfURyANFXLL4Q5GkKufhIu5zvyeDzDK1nCk8YMWlFvpQBamaNcQ6YdLsKQpF5FTN Fgm2J37AwfgApQk5CYgDvxewVB/UjonCmxeHmH5fCrTHifzKEPNc9AqR7Wo8owAoH2Muf evNENvvkawmbNnVBfbUH0N3B2g0bg2izEAMy9bUT7RhyCDcKaStL2PscbZ23080barQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796441669; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=xXIjIGKNh/zHeonEYBl5Krw0dWPuSPsNvFFGsF2SStg=; b=mJXnIwnm0tZuSAipEEzAf3BAZT0lzCb3xGca0t6DxDuMwuxXTGdVjCL+qNQ37jjKXq0O MouTVeCqEOLas9weXPvmgwEv0jITcS9+UdkGQWlQ66/rWyS+UFj2x/SZFKfC7CKFooTQ5 Ug6Zk86/xKRLttJcdhhOwZGoCWWCpm7Ux21TgsFxy8DslQ85NqNQ3d3An3Eki65PbxJee DQXDP3zvc352+TFVwg4V5A4xbm9KlMD/XfGgIg+mL0Woieh+GdxUKk5s2FLc2+uyfeIDb 9qEmuygJ+lXu8KIGcWksWreiHtYSVsQpaQl5Ntb4Ww+IpsvmlaBsHMNjcFda/kw5UGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CUsd+2Rb; arc=none smtp.remote-ip=192.198.163.17 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F6C7606A339; Sat, 5 Dec 2026 03:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5F6C7606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CUsd+2Rb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796441670; x=1827977670; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xXIjIGKNh/zHeonEYBl5Krw0dWPuSPsNvFFGsF2SStg=; b=CUsd+2RbKZrHLRsgnhMfD/Xjum0ax0sIgDkvBn+aUnoiacqbkyswllog ONKGWERY1eqKa6oWQbCveTm5RMZpOIWIIm3RrIpE23yBdSvfChRqluCfo IYcHmD5UNJaBuk2B5F29rPtmzMgh2qq4vR5F1PRz9H7l3vDQFtJYfbITM nOP+a7nPZyGQ62ZXxwiN3QrwxhuPe4/Y/ejXtWhRk4bJojDk+0Pdoe2wn dWeSTGrq9BXbZ4x/28iGl8/96YFynn7eau/4B3xpuUFxaHLuF6MbeMC1T /DBC3kUg/Vx8lllpHGYI0n1w0wVL8N+eNEio8GAuhXg+TmMTSBMPORlME w==; X-CSE-ConnectionGUID: G6k5Qv/RT9+dDxtSph09zg== X-CSE-MsgGUID: ApHwJPVCR8WJVlZ8H7d3DQ== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5439701" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="5439701" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 19:34:28 -0800 X-CSE-ConnectionGUID: yH52O0WjTze5Os/nGDj6Lg== X-CSE-MsgGUID: avoSTtY/QdCIVO4qGw9Sxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="14787686" Received: from 9cc2c43eec6b.jf.intel.com ([10.54.77.29]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 19:34:27 -0800 From: Zide Chen To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Andi Kleen , Eranian Stephane Cc: Chun-Tse Shao , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Dapeng Mi , Zide Chen 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 Message-ID: <20261205032253.258646-4-zide.chen@intel.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261205032253.258646-1-zide.chen@intel.com> References: <20261205032253.258646-1-zide.chen@intel.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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