From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EB03C4332F for ; Thu, 17 Nov 2022 12:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239900AbiKQM3d (ORCPT ); Thu, 17 Nov 2022 07:29:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239881AbiKQM3B (ORCPT ); Thu, 17 Nov 2022 07:29:01 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED22716DE for ; Thu, 17 Nov 2022 04:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688128; x=1700224128; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EPUf8Bflc7Y6pe+wdNVgXoQATuG+LzCvaEWFItwhHeg=; b=frR+fX9uPX3AlGCibVOLHwHhhg9vtGK2DuBFYbjXDlp4O/n1cJ3hvFhN vwftE2GdTp7MFEvq1MmKFJYK5aCA/nd2tuaPVP5rvu6IQ8YSTx9TWmx/Z DPXgB+rpyIYOwK5I5nywIrzPREg4/if6qbPR4oRtWuUXUfMU1mB6b9DUU iKpEH1tVYWE1LhKib1DeSvNMo7Tq4ujObrvmzOwt9SHRCQNnIg6AvpJKk MYy1oPDxmXRI46Nset6YYt5wIdG572qlc9I/mJcuqDSRrGub4QwYsT2lk fuljYydSyWPfdNNZxnJJeneufY2VLNIVUp1xpSHlAbuSQAGKE1e8XbJNQ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199866" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199866" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604551" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604551" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 01/11] perf/x86/intel/uncore: Generalize IIO topology support Date: Thu, 17 Nov 2022 12:28:23 +0000 Message-Id: <20221117122833.3103580-2-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov Current implementation of uncore mapping doesn't support different types of uncore PMUs which have its own topology context. This patch generalizes Intel uncore topology implementation to be able easily introduce support for new uncore blocks. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore.h | 14 ++- arch/x86/events/intel/uncore_snbep.c | 152 +++++++++++++++++++-------- 2 files changed, 122 insertions(+), 44 deletions(-) diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index 2adeaf4de4df..917cff1e7815 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -88,7 +88,7 @@ struct intel_uncore_type { * to identify which platform component each PMON block of that type is * supposed to monitor. */ - struct intel_uncore_topology *topology; + struct intel_uncore_topology **topology; /* * Optional callbacks for managing mapping of Uncore units to PMONs */ @@ -178,11 +178,19 @@ struct freerunning_counters { unsigned *box_offsets; }; =20 -struct intel_uncore_topology { - u64 configuration; +struct uncore_iio_topology { + int pci_bus_no; int segment; }; =20 +struct intel_uncore_topology { + int pmu_idx; + union { + void *untyped; + struct uncore_iio_topology *iio; + }; +}; + struct pci2phy_map { struct list_head list; int segment; diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index ed869443efb2..469ff889ea08 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3699,10 +3699,16 @@ static struct intel_uncore_ops skx_uncore_iio_ops = =3D { .read_counter =3D uncore_msr_read_counter, }; =20 -static inline u8 skx_iio_stack(struct intel_uncore_pmu *pmu, int die) +static struct intel_uncore_topology *pmu_topology(struct intel_uncore_pmu = *pmu, int die) { - return pmu->type->topology[die].configuration >> - (pmu->pmu_idx * BUS_NUM_STRIDE); + int idx; + + for (idx =3D 0; idx < pmu->type->num_boxes; idx++) { + if (pmu->type->topology[die][idx].pmu_idx =3D=3D pmu->pmu_idx) + return &pmu->type->topology[die][idx]; + } + + return NULL; } =20 static umode_t @@ -3710,8 +3716,9 @@ pmu_iio_mapping_visible(struct kobject *kobj, struct = attribute *attr, int die, int zero_bus_pmu) { struct intel_uncore_pmu *pmu =3D dev_to_uncore_pmu(kobj_to_dev(kobj)); + struct intel_uncore_topology *pmut =3D pmu_topology(pmu, die); =20 - return (!skx_iio_stack(pmu, die) && pmu->pmu_idx !=3D zero_bus_pmu) ? 0 := attr->mode; + return (pmut && !pmut->iio->pci_bus_no && pmu->pmu_idx !=3D zero_bus_pmu)= ? 0 : attr->mode; } =20 static umode_t @@ -3727,9 +3734,10 @@ static ssize_t skx_iio_mapping_show(struct device *d= ev, struct intel_uncore_pmu *pmu =3D dev_to_uncore_pmu(dev); struct dev_ext_attribute *ea =3D to_dev_ext_attribute(attr); long die =3D (long)ea->var; + struct intel_uncore_topology *pmut =3D pmu_topology(pmu, die); =20 - return sprintf(buf, "%04x:%02x\n", pmu->type->topology[die].segment, - skx_iio_stack(pmu, die)); + return sprintf(buf, "%04x:%02x\n", pmut ? pmut->iio->segment : 0, + pmut ? pmut->iio->pci_bus_no : 0); } =20 static int skx_msr_cpu_bus_read(int cpu, u64 *topology) @@ -3764,18 +3772,77 @@ static int die_to_cpu(int die) return res; } =20 +enum { + IIO_TOPOLOGY_TYPE, + TOPOLOGY_MAX +}; + +static const size_t topology_size[TOPOLOGY_MAX] =3D { + sizeof(*((struct intel_uncore_topology *)NULL)->iio) +}; + +static int pmu_alloc_topology(struct intel_uncore_type *type, int topology= _type) +{ + int die, idx; + struct intel_uncore_topology **topology; + + if (!type->num_boxes) + return -EPERM; + + topology =3D kcalloc(uncore_max_dies(), sizeof(*topology), GFP_KERNEL); + if (!topology) + goto err; + + for (die =3D 0; die < uncore_max_dies(); die++) { + topology[die] =3D kcalloc(type->num_boxes, sizeof(**topology), GFP_KERNE= L); + if (!topology[die]) + goto clear; + for (idx =3D 0; idx < type->num_boxes; idx++) { + topology[die][idx].untyped =3D kcalloc(type->num_boxes, + topology_size[topology_type], + GFP_KERNEL); + if (!topology[die][idx].untyped) + goto clear; + } + } + + type->topology =3D topology; + + return 0; +clear: + for (; die >=3D 0; die--) { + for (idx =3D 0; idx < type->num_boxes; idx++) + kfree(topology[die][idx].untyped); + kfree(topology[die]); + } + kfree(topology); +err: + return -ENOMEM; +} + +static void pmu_free_topology(struct intel_uncore_type *type) +{ + int die, idx; + + if (type->topology) { + for (die =3D 0; die < uncore_max_dies(); die++) { + for (idx =3D 0; idx < type->num_boxes; idx++) + kfree(type->topology[die][idx].untyped); + kfree(type->topology[die]); + } + kfree(type->topology); + type->topology =3D NULL; + } +} + static int skx_iio_get_topology(struct intel_uncore_type *type) { int die, ret =3D -EPERM; - - type->topology =3D kcalloc(uncore_max_dies(), sizeof(*type->topology), - GFP_KERNEL); - if (!type->topology) - return -ENOMEM; + u64 configuration; + int idx; =20 for (die =3D 0; die < uncore_max_dies(); die++) { - ret =3D skx_msr_cpu_bus_read(die_to_cpu(die), - &type->topology[die].configuration); + ret =3D skx_msr_cpu_bus_read(die_to_cpu(die), &configuration); if (ret) break; =20 @@ -3783,12 +3850,12 @@ static int skx_iio_get_topology(struct intel_uncore= _type *type) if (ret < 0) break; =20 - type->topology[die].segment =3D ret; - } - - if (ret < 0) { - kfree(type->topology); - type->topology =3D NULL; + for (idx =3D 0; idx < type->num_boxes; idx++) { + type->topology[die][idx].pmu_idx =3D idx; + type->topology[die][idx].iio->segment =3D ret; + type->topology[die][idx].iio->pci_bus_no =3D + (configuration >> (idx * BUS_NUM_STRIDE)) & 0xff; + } } =20 return ret; @@ -3804,7 +3871,9 @@ static const struct attribute_group *skx_iio_attr_upd= ate[] =3D { }; =20 static int -pmu_iio_set_mapping(struct intel_uncore_type *type, struct attribute_group= *ag) +pmu_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag, + ssize_t (*show)(struct device*, struct device_attribute*, char*), + int topology_type) { char buf[64]; int ret; @@ -3812,10 +3881,14 @@ pmu_iio_set_mapping(struct intel_uncore_type *type,= struct attribute_group *ag) struct attribute **attrs =3D NULL; struct dev_ext_attribute *eas =3D NULL; =20 - ret =3D type->get_topology(type); + ret =3D pmu_alloc_topology(type, topology_type); if (ret < 0) goto clear_attr_update; =20 + ret =3D type->get_topology(type); + if (ret < 0) + goto clear_topology; + ret =3D -ENOMEM; =20 /* One more for NULL. */ @@ -3828,13 +3901,13 @@ pmu_iio_set_mapping(struct intel_uncore_type *type,= struct attribute_group *ag) goto clear_attrs; =20 for (die =3D 0; die < uncore_max_dies(); die++) { - sprintf(buf, "die%ld", die); + snprintf(buf, sizeof(buf), "die%ld", die); sysfs_attr_init(&eas[die].attr.attr); eas[die].attr.attr.name =3D kstrdup(buf, GFP_KERNEL); if (!eas[die].attr.attr.name) goto err; eas[die].attr.attr.mode =3D 0444; - eas[die].attr.show =3D skx_iio_mapping_show; + eas[die].attr.show =3D show; eas[die].attr.store =3D NULL; eas[die].var =3D (void *)die; attrs[die] =3D &eas[die].attr.attr; @@ -3849,14 +3922,14 @@ pmu_iio_set_mapping(struct intel_uncore_type *type,= struct attribute_group *ag) clear_attrs: kfree(attrs); clear_topology: - kfree(type->topology); + pmu_free_topology(type); clear_attr_update: type->attr_update =3D NULL; return ret; } =20 static void -pmu_iio_cleanup_mapping(struct intel_uncore_type *type, struct attribute_g= roup *ag) +pmu_cleanup_mapping(struct intel_uncore_type *type, struct attribute_group= *ag) { struct attribute **attr =3D ag->attrs; =20 @@ -3868,7 +3941,13 @@ pmu_iio_cleanup_mapping(struct intel_uncore_type *ty= pe, struct attribute_group * kfree(attr_to_ext_attr(*ag->attrs)); kfree(ag->attrs); ag->attrs =3D NULL; - kfree(type->topology); + pmu_free_topology(type); +} + +static int +pmu_iio_set_mapping(struct intel_uncore_type *type, struct attribute_group= *ag) +{ + return pmu_set_mapping(type, ag, skx_iio_mapping_show, IIO_TOPOLOGY_TYPE); } =20 static int skx_iio_set_mapping(struct intel_uncore_type *type) @@ -3878,7 +3957,7 @@ static int skx_iio_set_mapping(struct intel_uncore_ty= pe *type) =20 static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) { - pmu_iio_cleanup_mapping(type, &skx_iio_mapping_group); + pmu_cleanup_mapping(type, &skx_iio_mapping_group); } =20 static struct intel_uncore_type skx_uncore_iio =3D { @@ -4461,11 +4540,6 @@ static int sad_cfg_iio_topology(struct intel_uncore_= type *type, u8 *sad_pmon_map int die, stack_id, ret =3D -EPERM; struct pci_dev *dev =3D NULL; =20 - type->topology =3D kcalloc(uncore_max_dies(), sizeof(*type->topology), - GFP_KERNEL); - if (!type->topology) - return -ENOMEM; - while ((dev =3D pci_get_device(PCI_VENDOR_ID_INTEL, SNR_ICX_MESH2IIO_MMAP= _DID, dev))) { ret =3D pci_read_config_dword(dev, SNR_ICX_SAD_CONTROL_CFG, &sad_cfg); if (ret) { @@ -4483,13 +4557,9 @@ static int sad_cfg_iio_topology(struct intel_uncore_= type *type, u8 *sad_pmon_map /* Convert stack id from SAD_CONTROL to PMON notation. */ stack_id =3D sad_pmon_mapping[stack_id]; =20 - ((u8 *)&(type->topology[die].configuration))[stack_id] =3D dev->bus->num= ber; - type->topology[die].segment =3D pci_domain_nr(dev->bus); - } - - if (ret) { - kfree(type->topology); - type->topology =3D NULL; + type->topology[die][stack_id].iio->segment =3D pci_domain_nr(dev->bus); + type->topology[die][stack_id].pmu_idx =3D stack_id; + type->topology[die][stack_id].iio->pci_bus_no =3D dev->bus->number; } =20 return ret; @@ -4526,7 +4596,7 @@ static int snr_iio_set_mapping(struct intel_uncore_ty= pe *type) =20 static void snr_iio_cleanup_mapping(struct intel_uncore_type *type) { - pmu_iio_cleanup_mapping(type, &snr_iio_mapping_group); + pmu_cleanup_mapping(type, &snr_iio_mapping_group); } =20 static struct event_constraint snr_uncore_iio_constraints[] =3D { @@ -5144,7 +5214,7 @@ static int icx_iio_set_mapping(struct intel_uncore_ty= pe *type) =20 static void icx_iio_cleanup_mapping(struct intel_uncore_type *type) { - pmu_iio_cleanup_mapping(type, &icx_iio_mapping_group); + pmu_cleanup_mapping(type, &icx_iio_mapping_group); } =20 static struct intel_uncore_type icx_uncore_iio =3D { --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDC25C433FE for ; Thu, 17 Nov 2022 12:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240153AbiKQM35 (ORCPT ); Thu, 17 Nov 2022 07:29:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239857AbiKQM3B (ORCPT ); Thu, 17 Nov 2022 07:29:01 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B04F71F29 for ; Thu, 17 Nov 2022 04:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688129; x=1700224129; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oSACIbszHk4Xt5Uru3pdS6y+bivSOIaxBarw+nw5xOU=; b=VnWlItOKtKUFt3QqNpgBivcI5LnZb5Lfjzwn6U3J3NCu96mrvwi8FB2G gNEemdYlVcZTZuUdzLEsa4x+tOJp/90axtc+nM1yj73v1ekd7gk3GtYzZ Xqgbz6kCrrbPnoPUNkenXQ/9M0Kpadn87MNDWAOGIOxBx5mOCIkxPDRVm AusTHybGEC3szwkWOducjNRCF2MLPWBI4vDnXNNbrnaOnRl8Y5ITwAq94 RePysSit9tzaZh6hUS3h7o0Ki/4g+OJljrrsWMRnU8AZI1vk/JeNZm5/I i8LTNpyestEX+pbotlL12xRiHjFcF9Xt7CaM3D0Ioj2jaxUBwdChu9WlU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199867" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199867" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604552" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604552" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 02/11] perf/x86/intel/uncore: Introduce UPI topology type Date: Thu, 17 Nov 2022 12:28:24 +0000 Message-Id: <20221117122833.3103580-3-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov This patch introduces new 'uncore_upi_topology' topology type to support UPI topology discovery. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore.h | 7 +++++++ arch/x86/events/intel/uncore_snbep.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index 917cff1e7815..ef1414957623 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -183,11 +183,18 @@ struct uncore_iio_topology { int segment; }; =20 +struct uncore_upi_topology { + int die_to; + int pmu_idx_to; + int enabled; +}; + struct intel_uncore_topology { int pmu_idx; union { void *untyped; struct uncore_iio_topology *iio; + struct uncore_upi_topology *upi; }; }; =20 diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 469ff889ea08..d3323f13c304 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3774,11 +3774,13 @@ static int die_to_cpu(int die) =20 enum { IIO_TOPOLOGY_TYPE, + UPI_TOPOLOGY_TYPE, TOPOLOGY_MAX }; =20 static const size_t topology_size[TOPOLOGY_MAX] =3D { - sizeof(*((struct intel_uncore_topology *)NULL)->iio) + sizeof(*((struct intel_uncore_topology *)NULL)->iio), + sizeof(*((struct intel_uncore_topology *)NULL)->upi) }; =20 static int pmu_alloc_topology(struct intel_uncore_type *type, int topology= _type) --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97A07C433FE for ; Thu, 17 Nov 2022 12:29:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239837AbiKQM3x (ORCPT ); Thu, 17 Nov 2022 07:29:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240046AbiKQM3C (ORCPT ); Thu, 17 Nov 2022 07:29:02 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B28F71F0B for ; Thu, 17 Nov 2022 04:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688130; x=1700224130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Tu5hfH1gOVi8ggjfgqKXzyBxrujRcHxaUOVPTnTNUmQ=; b=KegWIQoACO7JAC46xwHixt8VEAJ8od798RGR9MVf4AmmeVzPh//PBQBB lWGMk+k//4sCDMAuBRB1zyqGR/kupBSwTCnJlbs6rgrAuehizzlcWvMum 9mds3et4Sk6h+seOa/aZOguJwuCRnfh4o2a1jGpG5ny55Vbgh8aiNl/Yv QoeQgHoM/XtSYF+PDLrZJCw1DahG+XSjl/4nef1ZHhkknu5bEhRr4Mk5D NqxcbOZSeTNXxMIMBne7cdLX8b3pkZ7DY+rU0hD+JZ/Uwla+E7QbgCPiw DKKpq+IswbbdFqG/SGuXYr80HuEHV6PDlS3LRUYscVKUp0Wa33eqemIzs g==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199868" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199868" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604553" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604553" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 03/11] perf/x86/intel/uncore: Clear attr_update properly Date: Thu, 17 Nov 2022 12:28:25 +0000 Message-Id: <20221117122833.3103580-4-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov Current clear_attr_update procedure in pmu_set_mapping() sets attr_update field in NULL that is not correct because intel_uncore_type pmu types can contain several groups in attr_update field. For example, SPR platform already has uncore_alias_group to update and then UPI topology group will be added in next patches. Fix current behavior and clear attr_update group related to mapping only. Fixes: bb42b3d39781 ("perf/x86/intel/uncore: Expose an Uncore unit to IIO P= MON mapping") Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang Cc: stable@vger.kernel.org --- arch/x86/events/intel/uncore_snbep.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index d3323f13c304..0d06b56b8a33 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3872,6 +3872,21 @@ static const struct attribute_group *skx_iio_attr_up= date[] =3D { NULL, }; =20 +static void pmu_clear_mapping_attr(const struct attribute_group **groups, + struct attribute_group *ag) +{ + int i; + + for (i =3D 0; groups[i]; i++) { + if (groups[i] =3D=3D ag) { + for (i++; groups[i]; i++) + groups[i - 1] =3D groups[i]; + groups[i - 1] =3D NULL; + break; + } + } +} + static int pmu_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag, ssize_t (*show)(struct device*, struct device_attribute*, char*), @@ -3926,7 +3941,7 @@ pmu_set_mapping(struct intel_uncore_type *type, struc= t attribute_group *ag, clear_topology: pmu_free_topology(type); clear_attr_update: - type->attr_update =3D NULL; + pmu_clear_mapping_attr(type->attr_update, ag); return ret; } =20 --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F270C433FE for ; Thu, 17 Nov 2022 12:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240008AbiKQM3u (ORCPT ); Thu, 17 Nov 2022 07:29:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240018AbiKQM3C (ORCPT ); Thu, 17 Nov 2022 07:29:02 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC00D725C7 for ; Thu, 17 Nov 2022 04:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688130; x=1700224130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FHFDzLFxzPtKeK1rQOcaRmfpaD4Wy5sTRwK3r/Iltxc=; b=bdsTKTfm0DLmegDtkuhduBybHhUXEhJmJaAhXB5Pl8jvqqJujgbo3JTO 48Sk4ZFoE+snvn0PVNmYJFRxC9MWz5t96aeJOrwC2qxX07QEsu0Wcewll fQPXFTq8Gva2E3mR1LugDazqZrovPGfGov27bqZjvmTeU4nSc/hJpJkiU F/0rEbmTe1UPIMxWeHtFPUT4TxMN+tg8s0YVqt88n1MAOq0ms8f79laZN 2CRbVMsnHCCLNFD6X307OQWQT6/vQkaREOYn7ps6p28dmtmfq4D1UEdrk vspTgj1/nslMwVLee4ieMHoEVaZT7Mqg59bCeo1ZJebJsBD9/iAigHxhq Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199869" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199869" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604554" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604554" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 04/11] perf/x86/intel/uncore: Disable I/O stacks to PMU mapping on ICX-D Date: Thu, 17 Nov 2022 12:28:26 +0000 Message-Id: <20221117122833.3103580-5-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov Current implementation of I/O stacks to PMU mapping doesn't support ICX-D. Detect ICX-D system to disable mapping. Fixes: 10337e95e04c ("perf/x86/intel/uncore: Enable I/O stacks to IIO PMON = mapping on ICX") Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang Cc: stable@vger.kernel.org --- arch/x86/events/intel/uncore.h | 1 + arch/x86/events/intel/uncore_snbep.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index ef1414957623..fac3612289f1 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -2,6 +2,7 @@ #include #include #include +#include #include =20 #include diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 0d06b56b8a33..e14b96398377 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -5226,6 +5226,11 @@ static int icx_iio_get_topology(struct intel_uncore_= type *type) =20 static int icx_iio_set_mapping(struct intel_uncore_type *type) { + /* Detect ICX-D system. This case is not supported */ + if (boot_cpu_data.x86_model =3D=3D INTEL_FAM6_ICELAKE_D) { + pmu_clear_mapping_attr(type->attr_update, &icx_iio_mapping_group); + return -EPERM; + } return pmu_iio_set_mapping(type, &icx_iio_mapping_group); } =20 --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 327E4C433FE for ; Thu, 17 Nov 2022 12:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239251AbiKQM3m (ORCPT ); Thu, 17 Nov 2022 07:29:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240008AbiKQM3C (ORCPT ); Thu, 17 Nov 2022 07:29:02 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5512571F3E for ; Thu, 17 Nov 2022 04:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688130; x=1700224130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AcazR/H20mISo14KS0UTsyO1aBphJqbxGL1MXlKHjqU=; b=eT3i2dXRs21nQZVRFfhdaBfpjjcLePvajbtaUZNjXNdP1nWe9B8WUJfW lPzs06VuOTS2nafCZmle1kuEBTAOZEJjz38khrY3yB1Jk3wFfMuo9hI/5 BcM0p1DcGi4hYPEXfqs7xx8dASOoIAGAw9w+a7zewtwU36VHFJsR8zjqJ wy9IQ/oaJQuHJKzAV9sgjpRsntZY8Sld/KRxlEYF/m8C6gSCqwhwgWIpq FOsxVEyj2Bs9ftZo1Px4bAx7I7YTimBWjY+0MIuTEVrFzENd2cEGn6sJ3 cHHTE8qKQfTd1eDk10YX8JoVa3eBOEuhy50eNo4jyBMdRnekZiVQOmUUT A==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199871" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199871" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604555" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604555" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 05/11] perf/x86/intel/uncore: Generalize get_topology() for SKX PMUs Date: Thu, 17 Nov 2022 12:28:27 +0000 Message-Id: <20221117122833.3103580-6-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov Factor out a generic code from skx_iio_get_topology() to skx_pmu_get_topolo= gy() to avoid code duplication. This code will be used by get_topology() procedu= re for SKX UPI PMUs in the further patch. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 38 ++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index e14b96398377..254ba0ad650a 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3837,14 +3837,14 @@ static void pmu_free_topology(struct intel_uncore_t= ype *type) } } =20 -static int skx_iio_get_topology(struct intel_uncore_type *type) +static int skx_pmu_get_topology(struct intel_uncore_type *type, + int (*topology_cb)(struct intel_uncore_type*, int, int, u64)) { int die, ret =3D -EPERM; - u64 configuration; - int idx; + u64 cpu_bus_msr; =20 for (die =3D 0; die < uncore_max_dies(); die++) { - ret =3D skx_msr_cpu_bus_read(die_to_cpu(die), &configuration); + ret =3D skx_msr_cpu_bus_read(die_to_cpu(die), &cpu_bus_msr); if (ret) break; =20 @@ -3852,17 +3852,35 @@ static int skx_iio_get_topology(struct intel_uncore= _type *type) if (ret < 0) break; =20 - for (idx =3D 0; idx < type->num_boxes; idx++) { - type->topology[die][idx].pmu_idx =3D idx; - type->topology[die][idx].iio->segment =3D ret; - type->topology[die][idx].iio->pci_bus_no =3D - (configuration >> (idx * BUS_NUM_STRIDE)) & 0xff; - } + ret =3D topology_cb(type, ret, die, cpu_bus_msr); + if (ret) + break; } =20 return ret; } =20 +static int skx_iio_topology_cb(struct intel_uncore_type *type, int segment, + int die, u64 cpu_bus_msr) +{ + int idx; + struct intel_uncore_topology *t; + + for (idx =3D 0; idx < type->num_boxes; idx++) { + t =3D &type->topology[die][idx]; + t->pmu_idx =3D idx; + t->iio->segment =3D segment; + t->iio->pci_bus_no =3D (cpu_bus_msr >> (idx * BUS_NUM_STRIDE)) & 0xff; + } + + return 0; +} + +static int skx_iio_get_topology(struct intel_uncore_type *type) +{ + return skx_pmu_get_topology(type, skx_iio_topology_cb); +} + static struct attribute_group skx_iio_mapping_group =3D { .is_visible =3D skx_iio_mapping_visible, }; --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AD59C4332F for ; Thu, 17 Nov 2022 12:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239434AbiKQM3h (ORCPT ); Thu, 17 Nov 2022 07:29:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239884AbiKQM3B (ORCPT ); Thu, 17 Nov 2022 07:29:01 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B40271F2C for ; Thu, 17 Nov 2022 04:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688130; x=1700224130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z6j0Pc9MvHQ/hPI7Pcd93d1sFA3q3F7tY1V7r+uFvZw=; b=P6Rcvm97q0MdIYaEoTqYiO/93cI1Vi1CI5Zzn/WgqZc6MKxDC+eu4lGw UcpTRGCmebzvPf3FUbYh9lSC8yose5Qc5dL1/M/SgK8PcHdUCxms6iK5B allNHzeN/uSaYB102DQPVsbrnhN2P5dZdxVYPfWP/4aheA+X8q+pJ6DZL 1MDAsuOkPO/W8Xp2inRD1aUMNVc640/im7XMm4FzRs2cUFgGK6GDUhgSc tXHBz8+g4Ofakef3IwOXUzpgjK/FrBuvzjKJCl6GnJAygbQhBoz1eu9lL iMOYLrCuh34uvmNHssRax+8V51qDr3XC6n92duWCBbc5kyIGBDDkKf8aX Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199872" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199872" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604556" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604556" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 06/11] perf/x86/intel/uncore: Enable UPI topology discovery for Skylake Server Date: Thu, 17 Nov 2022 12:28:28 +0000 Message-Id: <20221117122833.3103580-7-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Antonov UPI topology discovery relies on data from KTILP0 (offset 0x94) and KTIPCSTS (offset 0x120) registers which reside under IIO bus(3) on SKX/CLX. This patch enable UPI topology discovery on Skylake Server. Topology is exposed through attributes /sys/devices/uncore_upi_/dieX, where dieX is file which holds "upi_:die_" connected to this UPI link. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 130 +++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 254ba0ad650a..f682a9a0f562 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -4253,6 +4253,132 @@ static struct intel_uncore_ops skx_upi_uncore_pci_o= ps =3D { .read_counter =3D snbep_uncore_pci_read_counter, }; =20 +static umode_t +skx_upi_mapping_visible(struct kobject *kobj, struct attribute *attr, int = die) +{ + struct intel_uncore_pmu *pmu =3D dev_to_uncore_pmu(kobj_to_dev(kobj)); + + return pmu->type->topology[die][pmu->pmu_idx].upi->enabled ? attr->mode := 0; +} + +static ssize_t skx_upi_mapping_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct intel_uncore_pmu *pmu =3D dev_to_uncore_pmu(dev); + struct dev_ext_attribute *ea =3D to_dev_ext_attribute(attr); + long die =3D (long)ea->var; + struct uncore_upi_topology *upi =3D pmu->type->topology[die][pmu->pmu_idx= ].upi; + + return sysfs_emit(buf, "upi_%d,die_%d\n", upi->pmu_idx_to, upi->die_to); +} + +#define SKX_UPI_REG_DID 0x2058 +#define SKX_UPI_REGS_ADDR_DEVICE_LINK0 0x0e +#define SKX_UPI_REGS_ADDR_FUNCTION 0x00 + +/* + * UPI Link Parameter 0 + * | Bit | Default | Description + * | 19:16 | 0h | base_nodeid - The NodeID of the sending socket. + * | 12:8 | 00h | sending_port - The processor die port number of t= he sending port. + */ +#define SKX_KTILP0_OFFSET 0x94 + +/* + * UPI Pcode Status. This register is used by PCode to store the link trai= ning status. + * | Bit | Default | Description + * | 4 | 0h | ll_status_valid =E2=80=94 Bit indicates the valid= training status + * logged from PCode to the BIOS. + */ +#define SKX_KTIPCSTS_OFFSET 0x120 + +static int upi_fill_topology(struct pci_dev *dev, struct intel_uncore_topo= logy *tp, + int pmu_idx) +{ + int ret; + u32 upi_conf; + struct uncore_upi_topology *upi =3D tp->upi; + + tp->pmu_idx =3D pmu_idx; + ret =3D pci_read_config_dword(dev, SKX_KTIPCSTS_OFFSET, &upi_conf); + if (ret) { + ret =3D pcibios_err_to_errno(ret); + goto err; + } + upi->enabled =3D (upi_conf >> 4) & 1; + if (upi->enabled) { + ret =3D pci_read_config_dword(dev, SKX_KTILP0_OFFSET, + &upi_conf); + if (ret) { + ret =3D pcibios_err_to_errno(ret); + goto err; + } + upi->die_to =3D (upi_conf >> 16) & 0xf; + upi->pmu_idx_to =3D (upi_conf >> 8) & 0x1f; + } +err: + return ret; +} + +static int skx_upi_topology_cb(struct intel_uncore_type *type, int segment, + int die, u64 cpu_bus_msr) +{ + int idx, ret; + struct intel_uncore_topology *upi; + unsigned int devfn; + struct pci_dev *dev =3D NULL; + u8 bus =3D cpu_bus_msr >> (3 * BUS_NUM_STRIDE); + + for (idx =3D 0; idx < type->num_boxes; idx++) { + upi =3D &type->topology[die][idx]; + devfn =3D PCI_DEVFN(SKX_UPI_REGS_ADDR_DEVICE_LINK0 + idx, + SKX_UPI_REGS_ADDR_FUNCTION); + dev =3D pci_get_domain_bus_and_slot(segment, bus, devfn); + if (dev) { + ret =3D upi_fill_topology(dev, upi, idx); + if (ret) + break; + } + } + + pci_dev_put(dev); + return ret; +} + +static int skx_upi_get_topology(struct intel_uncore_type *type) +{ + /* CPX case is not supported */ + if (boot_cpu_data.x86_stepping =3D=3D 11) + return -EPERM; + + return skx_pmu_get_topology(type, skx_upi_topology_cb); +} + +static struct attribute_group skx_upi_mapping_group =3D { + .is_visible =3D skx_upi_mapping_visible, +}; + +static const struct attribute_group *skx_upi_attr_update[] =3D { + &skx_upi_mapping_group, + NULL +}; + +static int +pmu_upi_set_mapping(struct intel_uncore_type *type, struct attribute_group= *ag) +{ + return pmu_set_mapping(type, ag, skx_upi_mapping_show, UPI_TOPOLOGY_TYPE); +} + +static int skx_upi_set_mapping(struct intel_uncore_type *type) +{ + return pmu_upi_set_mapping(type, &skx_upi_mapping_group); +} + +static void skx_upi_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_cleanup_mapping(type, &skx_upi_mapping_group); +} + static struct intel_uncore_type skx_uncore_upi =3D { .name =3D "upi", .num_counters =3D 4, @@ -4265,6 +4391,10 @@ static struct intel_uncore_type skx_uncore_upi =3D { .box_ctl =3D SKX_UPI_PCI_PMON_BOX_CTL, .ops =3D &skx_upi_uncore_pci_ops, .format_group =3D &skx_upi_uncore_format_group, + .attr_update =3D skx_upi_attr_update, + .get_topology =3D skx_upi_get_topology, + .set_mapping =3D skx_upi_set_mapping, + .cleanup_mapping =3D skx_upi_cleanup_mapping, }; =20 static void skx_m2m_uncore_pci_init_box(struct intel_uncore_box *box) --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FEB4C4332F for ; Thu, 17 Nov 2022 12:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239936AbiKQM3q (ORCPT ); Thu, 17 Nov 2022 07:29:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240078AbiKQM3C (ORCPT ); Thu, 17 Nov 2022 07:29:02 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A11725CB for ; Thu, 17 Nov 2022 04:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688131; x=1700224131; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4+L4macmpM66/vEIz+MAvlGT/49BgkmRfbdg36NVQp8=; b=F6tEVnXCansAS7lNFydnF7GGhc8JQ9muOoIUnGE+m842jgZrf+Avc3p2 8YMqjPWqTVY1wejX04yEFk3lzOxHpbK0NHtGKU0IdZy7GFZXRfrHCtcGH +sfqr56bG3KfXHGPvRs0gq1nv25vcQztGeIsLVvL8ALYqw25qevWR8ssQ R44PkyApuBTmmJXHvr3JdhKz87U0BCKbCQzfc9Mz3RJoy6Gg4Dg23y+OP Z5WcaUOwk9KneWWypDNaa/xeN7mOGB4XSIZ0baFr3S9sJvIDNNJ6CpaVx UMXkKeWsZLl9FquyPUjjtiuqi4VOAjvgDPpp2jcYQ4cLLO1aXIDwtdXUy w==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199873" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199873" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604557" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604557" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 07/11] perf/x86/intel/uncore: Get UPI NodeID and GroupID Date: Thu, 17 Nov 2022 12:28:29 +0000 Message-Id: <20221117122833.3103580-8-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov The GIDNIDMAP register of UBOX device is used to get the topology information in the snbep_pci2phy_map_init(). The same approach will be used to discover UPI topology for ICX and SPR platforms. Move common code that will be reused in next patches. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 33 +++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index f682a9a0f562..6da5f692afea 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -1372,6 +1372,28 @@ static struct pci_driver snbep_uncore_pci_driver =3D= { =20 #define NODE_ID_MASK 0x7 =20 +/* Each three bits from 0 to 23 of GIDNIDMAP register correspond Node ID. = */ +#define GIDNIDMAP(config, id) (((config) >> (3 * (id))) & 0x7) + +static int upi_nodeid_groupid(struct pci_dev *ubox_dev, int nodeid_loc, in= t idmap_loc, + int *nodeid, int *groupid) +{ + int ret; + + /* get the Node ID of the local register */ + ret =3D pci_read_config_dword(ubox_dev, nodeid_loc, nodeid); + if (ret) + goto err; + + *nodeid =3D *nodeid & NODE_ID_MASK; + /* get the Node ID mapping */ + ret =3D pci_read_config_dword(ubox_dev, idmap_loc, groupid); + if (ret) + goto err; +err: + return ret; +} + /* * build pci bus to socket mapping */ @@ -1397,13 +1419,8 @@ static int snbep_pci2phy_map_init(int devid, int nod= eid_loc, int idmap_loc, bool * the topology. */ if (nr_node_ids <=3D 8) { - /* get the Node ID of the local register */ - err =3D pci_read_config_dword(ubox_dev, nodeid_loc, &config); - if (err) - break; - nodeid =3D config & NODE_ID_MASK; - /* get the Node ID mapping */ - err =3D pci_read_config_dword(ubox_dev, idmap_loc, &config); + err =3D upi_nodeid_groupid(ubox_dev, nodeid_loc, idmap_loc, + &nodeid, &config); if (err) break; =20 @@ -1421,7 +1438,7 @@ static int snbep_pci2phy_map_init(int devid, int node= id_loc, int idmap_loc, bool * to a particular node. */ for (i =3D 0; i < 8; i++) { - if (nodeid =3D=3D ((config >> (3 * i)) & 0x7)) { + if (nodeid =3D=3D GIDNIDMAP(config, i)) { if (topology_max_die_per_package() > 1) die_id =3D i; else --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C47EDC433FE for ; Thu, 17 Nov 2022 12:30:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239437AbiKQMaH (ORCPT ); Thu, 17 Nov 2022 07:30:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240115AbiKQM3E (ORCPT ); Thu, 17 Nov 2022 07:29:04 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9587C725CE for ; Thu, 17 Nov 2022 04:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688131; x=1700224131; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dnUBqcl+k9EQthz+I0/JrzM1OicW378SnZoRnnRQKFU=; b=HRUMyYekRoe894F9yo/aJ35LCSmD1/Jprqesy2syAG6uupJOXnt2/fhz w1FJx/I4I/q+F3G1bp5+WZDmZ4zAPl0Sh5vQKd3RH/PuGNFg7I/t0EVRE FdDO8saFIjzAWhu2JUzC92lwjtX+Vr0fyKa3dyeKP+BSrm63ZepNuEzyb YngF+Oqdhk6i47JIM5wjzahiBGRvkXZKZgxkYNHVl3YkAoej9w1sKpRD5 ZSLEy2m8Ap0ST6Th47lzwJVadLK87RGTOP7KU6dd7fNrz+2oMe2qD4OdV YmUTGMaRm1tqO0KkxA7nHw7Rf0gJzbGeDisFJ9PfpTyZQMOkiEMZjrZkk g==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199874" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199874" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604558" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604558" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:46 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 08/11] perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server Date: Thu, 17 Nov 2022 12:28:30 +0000 Message-Id: <20221117122833.3103580-9-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov UPI topology discovery relies on data from KTILP0 (offset 0x94) and KTIPCSTS (offset 0x120) as well as on SKX but on Icelake Server these registers reside under UBOX (Device ID 0x3450) bus. This patch enables /sys/devices/uncore_upi_*/die* attributes on Icelake Server. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 6da5f692afea..d45f5843444d 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -445,6 +445,7 @@ #define ICX_UPI_PCI_PMON_CTR0 0x320 #define ICX_UPI_PCI_PMON_BOX_CTL 0x318 #define ICX_UPI_CTL_UMASK_EXT 0xffffff +#define ICX_UBOX_DID 0x3450 =20 /* ICX M3UPI*/ #define ICX_M3UPI_PCI_PMON_CTL0 0xd8 @@ -5594,6 +5595,76 @@ static const struct attribute_group icx_upi_uncore_f= ormat_group =3D { .attrs =3D icx_upi_uncore_formats_attr, }; =20 +#define ICX_UPI_REGS_ADDR_DEVICE_LINK0 0x02 +#define ICX_UPI_REGS_ADDR_FUNCTION 0x01 + +static int discover_upi_topology(struct intel_uncore_type *type, int ubox_= did, int dev_link0) +{ + struct pci_dev *ubox =3D NULL; + struct pci_dev *dev =3D NULL; + u32 nid, gid; + int i, idx, ret =3D -EPERM; + struct intel_uncore_topology *upi; + unsigned int devfn; + + /* GIDNIDMAP method supports machines which have less than 8 sockets. */ + if (uncore_max_dies() > 8) + goto err; + + while ((ubox =3D pci_get_device(PCI_VENDOR_ID_INTEL, ubox_did, ubox))) { + ret =3D upi_nodeid_groupid(ubox, SKX_CPUNODEID, SKX_GIDNIDMAP, &nid, &gi= d); + if (ret) { + ret =3D pcibios_err_to_errno(ret); + break; + } + + for (i =3D 0; i < 8; i++) { + if (nid !=3D GIDNIDMAP(gid, i)) + continue; + for (idx =3D 0; idx < type->num_boxes; idx++) { + upi =3D &type->topology[nid][idx]; + devfn =3D PCI_DEVFN(dev_link0 + idx, ICX_UPI_REGS_ADDR_FUNCTION); + dev =3D pci_get_domain_bus_and_slot(pci_domain_nr(ubox->bus), + ubox->bus->number, + devfn); + if (dev) { + ret =3D upi_fill_topology(dev, upi, idx); + if (ret) + goto err; + } + } + } + } +err: + pci_dev_put(ubox); + pci_dev_put(dev); + return ret; +} + +static int icx_upi_get_topology(struct intel_uncore_type *type) +{ + return discover_upi_topology(type, ICX_UBOX_DID, ICX_UPI_REGS_ADDR_DEVICE= _LINK0); +} + +static struct attribute_group icx_upi_mapping_group =3D { + .is_visible =3D skx_upi_mapping_visible, +}; + +static const struct attribute_group *icx_upi_attr_update[] =3D { + &icx_upi_mapping_group, + NULL +}; + +static int icx_upi_set_mapping(struct intel_uncore_type *type) +{ + return pmu_upi_set_mapping(type, &icx_upi_mapping_group); +} + +static void icx_upi_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_cleanup_mapping(type, &icx_upi_mapping_group); +} + static struct intel_uncore_type icx_uncore_upi =3D { .name =3D "upi", .num_counters =3D 4, @@ -5606,6 +5677,10 @@ static struct intel_uncore_type icx_uncore_upi =3D { .box_ctl =3D ICX_UPI_PCI_PMON_BOX_CTL, .ops =3D &skx_upi_uncore_pci_ops, .format_group =3D &icx_upi_uncore_format_group, + .attr_update =3D icx_upi_attr_update, + .get_topology =3D icx_upi_get_topology, + .set_mapping =3D icx_upi_set_mapping, + .cleanup_mapping =3D icx_upi_cleanup_mapping, }; =20 static struct event_constraint icx_uncore_m3upi_constraints[] =3D { --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F61CC4332F for ; Thu, 17 Nov 2022 12:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239816AbiKQMaR (ORCPT ); Thu, 17 Nov 2022 07:30:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240124AbiKQM3F (ORCPT ); Thu, 17 Nov 2022 07:29:05 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B984725D2 for ; Thu, 17 Nov 2022 04:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688131; x=1700224131; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yiguIHAQUyFA/n7ZpCGUHKImucX21MgsisSqebhnJ/k=; b=erRHWQBSTGrub6kMrBne1LI3JnphPK6bK8ONleM0YkwbIHVxuhWN4gy5 qmYQK7a28FqesUenSCt1mh4QLHE3579Hm3ET9yIk9VPVbQJSekjVXM32a Er+/xcMm1KRbjAqL95RLOrU8XmAQTD0S5ILNdhIH4PqkZZJlj5BNxaEhH 19tPN7gYAPqgWw/fAJ/fqGeaI7RbMwq1n/Tj5bMh/68jP20Le4/lwT2oM VVpcFxdxuGPxfZ2VLacKJN3+wJq4S6KMzvdIgsUGBQuwLXJGdfmdSb2vg D1Hi9YleXPCw0KcJM3G3fRSl3z+kqLWjFfZlK53tUXooMkLYgUJ3wlGcW g==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199875" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199875" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604559" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604559" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:47 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 09/11] perf/x86/intel/uncore: Enable UPI topology discovery for Sapphire Rapids Date: Thu, 17 Nov 2022 12:28:31 +0000 Message-Id: <20221117122833.3103580-10-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov UPI topology discovery on SPR is same as in ICX but UBOX device has different Device ID 0x3250. This patch enables /sys/devices/uncore_upi_*/die* attributes on SPR. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore_snbep.c | 43 +++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index d45f5843444d..4c2d5b5ea445 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -458,6 +458,7 @@ =20 /* SPR */ #define SPR_RAW_EVENT_MASK_EXT 0xffffff +#define SPR_UBOX_DID 0x3250 =20 /* SPR CHA */ #define SPR_CHA_PMON_CTL_TID_EN (1 << 16) @@ -6112,9 +6113,43 @@ static struct intel_uncore_type spr_uncore_m2m =3D { .name =3D "m2m", }; =20 +static struct attribute_group spr_upi_mapping_group =3D { + .is_visible =3D skx_upi_mapping_visible, +}; + +static const struct attribute_group *spr_upi_attr_update[] =3D { + &uncore_alias_group, + &spr_upi_mapping_group, + NULL +}; + +#define SPR_UPI_REGS_ADDR_DEVICE_LINK0 0x01 + +static int spr_upi_set_mapping(struct intel_uncore_type *type) +{ + return pmu_upi_set_mapping(type, &spr_upi_mapping_group); +} + +static void spr_upi_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_cleanup_mapping(type, &spr_upi_mapping_group); +} + +static int spr_upi_get_topology(struct intel_uncore_type *type) +{ + return discover_upi_topology(type, SPR_UBOX_DID, SPR_UPI_REGS_ADDR_DEVICE= _LINK0); +} + static struct intel_uncore_type spr_uncore_upi =3D { - SPR_UNCORE_PCI_COMMON_FORMAT(), + .event_mask =3D SNBEP_PMON_RAW_EVENT_MASK, + .event_mask_ext =3D SPR_RAW_EVENT_MASK_EXT, + .format_group =3D &spr_uncore_raw_format_group, + .ops =3D &spr_uncore_pci_ops, .name =3D "upi", + .attr_update =3D spr_upi_attr_update, + .get_topology =3D spr_upi_get_topology, + .set_mapping =3D spr_upi_set_mapping, + .cleanup_mapping =3D spr_upi_cleanup_mapping, }; =20 static struct intel_uncore_type spr_uncore_m3upi =3D { @@ -6318,6 +6353,12 @@ static void uncore_type_customized_copy(struct intel= _uncore_type *to_type, to_type->format_group =3D from_type->format_group; if (from_type->attr_update) to_type->attr_update =3D from_type->attr_update; + if (from_type->set_mapping) + to_type->set_mapping =3D from_type->set_mapping; + if (from_type->get_topology) + to_type->get_topology =3D from_type->get_topology; + if (from_type->cleanup_mapping) + to_type->cleanup_mapping =3D from_type->cleanup_mapping; } =20 static struct intel_uncore_type ** --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 723A0C4332F for ; Thu, 17 Nov 2022 12:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240164AbiKQMaK (ORCPT ); Thu, 17 Nov 2022 07:30:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbiKQM3G (ORCPT ); Thu, 17 Nov 2022 07:29:06 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA882725D5 for ; Thu, 17 Nov 2022 04:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688131; x=1700224131; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LS4csCspXL+rIOXLV2JQBdKyVNCUcCeKYclRfWXseug=; b=bUxte9pkKdrlx6CiJv/6NNWRcSFPWXd1KE9M1L2RAfX5QmN2LtdQN5zR ioIDGL0trAivSx2dqiKDWGH2VRQJiOL2KFkrGkH0GRL0824eVSxPv5u4S nnrcfaYWq4Sj5e7fomSHaE95RdkhuuAsifKtKP4KqVz8I1euWNiwbNzeX HQDJm6jh7zb1QR1uR/XyKLZWlGA2nhGOxK6XvmyhPHAfls2QBfmdXPZls fQHRcduhjdYm0s6n+zLqsXjf0ol6UmuLR0K2CXOzaHBzVqc7DGSTsjAnQ m4gF8VuGEOT7udGpdjq7L5XSHcrAF5WTREwJxzeaCH2O48Jh/Rou5BSCA Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199876" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199876" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604560" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604560" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:47 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 10/11] perf/x86/intel/uncore: Update sysfs-devices-mapping file Date: Thu, 17 Nov 2022 12:28:32 +0000 Message-Id: <20221117122833.3103580-11-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov Add description for /sys/devices/uncore_upi_*/die* attributes to sysfs-devices-mapping. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- .../ABI/testing/sysfs-devices-mapping | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-devices-mapping b/Documentatio= n/ABI/testing/sysfs-devices-mapping index 8d202bac9394..2eee1446ad4c 100644 --- a/Documentation/ABI/testing/sysfs-devices-mapping +++ b/Documentation/ABI/testing/sysfs-devices-mapping @@ -1,6 +1,6 @@ What: /sys/devices/uncore_iio_x/dieX Date: February 2020 -Contact: Roman Sudarikov +Contact: Alexander Antonov Description: Each IIO stack (PCIe root port) has its own IIO PMON block= , so each dieX file (where X is die number) holds "Segment:Root= Bus" @@ -32,3 +32,31 @@ Description: IIO PMU 0 on die 1 belongs to PCI RP on bus 0x40, domain 0x0000 IIO PMU 0 on die 2 belongs to PCI RP on bus 0x80, domain 0x0000 IIO PMU 0 on die 3 belongs to PCI RP on bus 0xc0, domain 0x0000 + +What: /sys/devices/uncore_upi_x/dieX +Date: March 2022 +Contact: Alexander Antonov +Description: + Each /sys/devices/uncore_upi_X/dieY file holds "upi_Z,die_= W" + value that means UPI link number X on die Y is connected t= o UPI + link Z on die W and this link between sockets can be monit= ored + by UPI PMON block. + For example, 4-die Sapphire Rapids platform has the follow= ing + UPI 0 topology:: + + # tail /sys/devices/uncore_upi_0/die* + =3D=3D> /sys/devices/uncore_upi_0/die0 <=3D=3D + upi_1,die_1 + =3D=3D> /sys/devices/uncore_upi_0/die1 <=3D=3D + upi_0,die_3 + =3D=3D> /sys/devices/uncore_upi_0/die2 <=3D=3D + upi_1,die_3 + =3D=3D> /sys/devices/uncore_upi_0/die3 <=3D=3D + upi_0,die_1 + + Which means:: + + UPI link 0 on die 0 is connected to UPI link 1 on die 1 + UPI link 0 on die 1 is connected to UPI link 0 on die 3 + UPI link 0 on die 2 is connected to UPI link 1 on die 3 + UPI link 0 on die 3 is connected to UPI link 0 on die 1 \ No newline at end of file --=20 2.25.1 From nobody Fri Apr 17 09:09:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE3E1C4332F for ; Thu, 17 Nov 2022 12:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240168AbiKQMaX (ORCPT ); Thu, 17 Nov 2022 07:30:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbiKQM3G (ORCPT ); Thu, 17 Nov 2022 07:29:06 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBE2F725D7 for ; Thu, 17 Nov 2022 04:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668688132; x=1700224132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IWN+Jc3bIdcog99k6C0X9y70oAbhT4EqrD0N2igtiLI=; b=OYb2zRG3JKMyjTXGN2TZn22p5Gx3M/KRkiHMf+2o/kb4sS/TaXrPJx7Z 5EeVLKBegohq8pRhAzHOrfsksFe0g2K4EH5Y2U+7zeDTESSRyl9jLL/Yq 4Jz/9eJ9gLaL4/ims+ymz7/KmQSRQ95y/ERks0RIF3o3BvVtjLPsRvtXF JjQXuFJXd7x3cA0Btyx/4zcrHYorAMjjQTXCDb5vsqNl1jjMSD8COP1Bz /vbutgWh0lF4L09ZX0/zOgo7vvvbhv6yEH0RFcr0XwlI3K6QugCzclRN/ hmiJMq7KCUAx/i5yGIbaw0xczcJv7SY9your/GHfsWKpOLRTQVk+EJX+B w==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="296199878" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="296199878" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 04:28:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="590604561" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="590604561" Received: from jfdev013vml03.jf.intel.com ([10.23.26.52]) by orsmga003.jf.intel.com with ESMTP; 17 Nov 2022 04:28:47 -0800 From: alexander.antonov@linux.intel.com To: peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com, alexander.antonov@linux.intel.com Subject: [PATCH 11/11] perf/x86/intel/uncore: Make set_mapping() procedure void Date: Thu, 17 Nov 2022 12:28:33 +0000 Message-Id: <20221117122833.3103580-12-alexander.antonov@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Antonov Return value of set_mapping() is not needed to be checked anymore. So, make this procedure void. Signed-off-by: Alexander Antonov Reviewed-by: Kan Liang --- arch/x86/events/intel/uncore.h | 2 +- arch/x86/events/intel/uncore_snbep.c | 41 +++++++++++++--------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index fac3612289f1..e278e2e7c051 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -94,7 +94,7 @@ struct intel_uncore_type { * Optional callbacks for managing mapping of Uncore units to PMONs */ int (*get_topology)(struct intel_uncore_type *type); - int (*set_mapping)(struct intel_uncore_type *type); + void (*set_mapping)(struct intel_uncore_type *type); void (*cleanup_mapping)(struct intel_uncore_type *type); }; =20 diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 4c2d5b5ea445..b8f9bd150b42 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3924,7 +3924,7 @@ static void pmu_clear_mapping_attr(const struct attri= bute_group **groups, } } =20 -static int +static void pmu_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag, ssize_t (*show)(struct device*, struct device_attribute*, char*), int topology_type) @@ -3943,8 +3943,6 @@ pmu_set_mapping(struct intel_uncore_type *type, struc= t attribute_group *ag, if (ret < 0) goto clear_topology; =20 - ret =3D -ENOMEM; - /* One more for NULL. */ attrs =3D kcalloc((uncore_max_dies() + 1), sizeof(*attrs), GFP_KERNEL); if (!attrs) @@ -3968,7 +3966,7 @@ pmu_set_mapping(struct intel_uncore_type *type, struc= t attribute_group *ag, } ag->attrs =3D attrs; =20 - return 0; + return; err: for (; die >=3D 0; die--) kfree(eas[die].attr.attr.name); @@ -3979,7 +3977,6 @@ pmu_set_mapping(struct intel_uncore_type *type, struc= t attribute_group *ag, pmu_free_topology(type); clear_attr_update: pmu_clear_mapping_attr(type->attr_update, ag); - return ret; } =20 static void @@ -3998,15 +3995,15 @@ pmu_cleanup_mapping(struct intel_uncore_type *type,= struct attribute_group *ag) pmu_free_topology(type); } =20 -static int +static void pmu_iio_set_mapping(struct intel_uncore_type *type, struct attribute_group= *ag) { - return pmu_set_mapping(type, ag, skx_iio_mapping_show, IIO_TOPOLOGY_TYPE); + pmu_set_mapping(type, ag, skx_iio_mapping_show, IIO_TOPOLOGY_TYPE); } =20 -static int skx_iio_set_mapping(struct intel_uncore_type *type) +static void skx_iio_set_mapping(struct intel_uncore_type *type) { - return pmu_iio_set_mapping(type, &skx_iio_mapping_group); + pmu_iio_set_mapping(type, &skx_iio_mapping_group); } =20 static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) @@ -4382,15 +4379,15 @@ static const struct attribute_group *skx_upi_attr_u= pdate[] =3D { NULL }; =20 -static int +static void pmu_upi_set_mapping(struct intel_uncore_type *type, struct attribute_group= *ag) { - return pmu_set_mapping(type, ag, skx_upi_mapping_show, UPI_TOPOLOGY_TYPE); + pmu_set_mapping(type, ag, skx_upi_mapping_show, UPI_TOPOLOGY_TYPE); } =20 -static int skx_upi_set_mapping(struct intel_uncore_type *type) +static void skx_upi_set_mapping(struct intel_uncore_type *type) { - return pmu_upi_set_mapping(type, &skx_upi_mapping_group); + pmu_upi_set_mapping(type, &skx_upi_mapping_group); } =20 static void skx_upi_cleanup_mapping(struct intel_uncore_type *type) @@ -4773,9 +4770,9 @@ static int snr_iio_get_topology(struct intel_uncore_t= ype *type) return sad_cfg_iio_topology(type, snr_sad_pmon_mapping); } =20 -static int snr_iio_set_mapping(struct intel_uncore_type *type) +static void snr_iio_set_mapping(struct intel_uncore_type *type) { - return pmu_iio_set_mapping(type, &snr_iio_mapping_group); + pmu_iio_set_mapping(type, &snr_iio_mapping_group); } =20 static void snr_iio_cleanup_mapping(struct intel_uncore_type *type) @@ -5391,14 +5388,14 @@ static int icx_iio_get_topology(struct intel_uncore= _type *type) return sad_cfg_iio_topology(type, icx_sad_pmon_mapping); } =20 -static int icx_iio_set_mapping(struct intel_uncore_type *type) +static void icx_iio_set_mapping(struct intel_uncore_type *type) { /* Detect ICX-D system. This case is not supported */ if (boot_cpu_data.x86_model =3D=3D INTEL_FAM6_ICELAKE_D) { pmu_clear_mapping_attr(type->attr_update, &icx_iio_mapping_group); - return -EPERM; + return; } - return pmu_iio_set_mapping(type, &icx_iio_mapping_group); + pmu_iio_set_mapping(type, &icx_iio_mapping_group); } =20 static void icx_iio_cleanup_mapping(struct intel_uncore_type *type) @@ -5656,9 +5653,9 @@ static const struct attribute_group *icx_upi_attr_upd= ate[] =3D { NULL }; =20 -static int icx_upi_set_mapping(struct intel_uncore_type *type) +static void icx_upi_set_mapping(struct intel_uncore_type *type) { - return pmu_upi_set_mapping(type, &icx_upi_mapping_group); + pmu_upi_set_mapping(type, &icx_upi_mapping_group); } =20 static void icx_upi_cleanup_mapping(struct intel_uncore_type *type) @@ -6125,9 +6122,9 @@ static const struct attribute_group *spr_upi_attr_upd= ate[] =3D { =20 #define SPR_UPI_REGS_ADDR_DEVICE_LINK0 0x01 =20 -static int spr_upi_set_mapping(struct intel_uncore_type *type) +static void spr_upi_set_mapping(struct intel_uncore_type *type) { - return pmu_upi_set_mapping(type, &spr_upi_mapping_group); + pmu_upi_set_mapping(type, &spr_upi_mapping_group); } =20 static void spr_upi_cleanup_mapping(struct intel_uncore_type *type) --=20 2.25.1