From nobody Wed Oct 8 00:42:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86D4F1804A; Thu, 3 Jul 2025 16:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561820; cv=none; b=Lg2DbvBHh4APXxwK1pf9HZnC2TuV+90QtcjUmgJUBRKS2J6mq1cMceNdcRNJxvKh0yQCsjvitlGuS8iJDpiqsc6aQBtoJv8Pc+PTpjecbhNaCUcy/gWnGR3cGosOm4LUgc6uYNoJZ4gJFZ2W6EpAoXzfUP7yeBLzTjWH62Ik8Ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561820; c=relaxed/simple; bh=uBcn1BpOS8GFy7hLHtWB4E5Wau2mNkdI54PtiyFcWU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rbW1wIR5Y5NiCRpFP2Q9OtUE4/ugwgwnSwL+SMMjJpBtoAcZMGxmajDlQouad0R/v+PwHBabfmkVRF1qO4cArOvAJXGAgc0L6uw+zl9jALePOEfh64qeLqOoZ1ozHRJXNvhty3DtgALgtaLCTzmyvUMWB/NJtDTjDwTvyxrr2g4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NGkIbJ7g; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NGkIbJ7g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751561818; x=1783097818; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uBcn1BpOS8GFy7hLHtWB4E5Wau2mNkdI54PtiyFcWU4=; b=NGkIbJ7gR5Kk3yXz1Yvn5A/i/i1PwQJIkvzirXmdWi+LGCW9/Y5nyRBE XLgyPeKNLxFgrNPg+AG3QDgWlm1Z4DNOpR+9SCzXHCkIIHZ/qItRiDHqh 84J39k19bOuFfzTvFmnRSQ2wkeBVqfujXWkDmN0Na19r8VpPIKDk4oefd io9etbt8nic8l23w+N0aPXZZxsZTgGaFAA+QDxSFtJ05wgIR1KBtU6x7B 0jhP/9x5YSDFmoefnIPHFv9IjckTc9blGDUcDzQzAUEfF+FS4jv2HgTU+ lrU0CoOD5ObvOKTRIxI+Tz/YmXP8jCboBHDYGlgKHO+S00E1VENvrs9LU g==; X-CSE-ConnectionGUID: JFH6qw+LReWwY/TyJlEeGQ== X-CSE-MsgGUID: 8eIU9ZdvRtqMv0oxoc49+Q== X-IronPort-AV: E=McAfee;i="6800,10657,11483"; a="53992508" X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="53992508" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2025 09:56:54 -0700 X-CSE-ConnectionGUID: UvBUMJKeQnuZ8kkh5wiU5w== X-CSE-MsgGUID: D5CDvX58SlG6dej/dxK7KQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="154554261" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orviesa007.jf.intel.com with ESMTP; 03 Jul 2025 09:56:53 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, Kan Liang Subject: [PATCH V3 1/4] perf/x86/intel/uncore: Support MSR portal for discovery tables Date: Thu, 3 Jul 2025 09:56:11 -0700 Message-Id: <20250703165614.606446-2-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250703165614.606446-1-kan.liang@linux.intel.com> References: <20250703165614.606446-1-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kan Liang Starting from the Panther Lake, the discovery table mechanism is also supported in client platforms. The difference is that the portal of the global discovery table is retrieved from an MSR. The layout of discovery tables are the same as the server platforms. Factor out __parse_discovery_table() to parse discover tables. The uncore PMON is Die scope. Need to parse the discovery tables for each die. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_discovery.c | 87 ++++++++++++++++++------ arch/x86/events/intel/uncore_discovery.h | 3 + 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/int= el/uncore_discovery.c index 571e44b49691..8680f66c3e34 100644 --- a/arch/x86/events/intel/uncore_discovery.c +++ b/arch/x86/events/intel/uncore_discovery.c @@ -273,32 +273,15 @@ uncore_ignore_unit(struct uncore_unit_discovery *unit= , int *ignore) return false; } =20 -static int parse_discovery_table(struct pci_dev *dev, int die, - u32 bar_offset, bool *parsed, - int *ignore) +static int __parse_discovery_table(resource_size_t addr, int die, + bool *parsed, int *ignore) { struct uncore_global_discovery global; struct uncore_unit_discovery unit; void __iomem *io_addr; - resource_size_t addr; unsigned long size; - u32 val; int i; =20 - pci_read_config_dword(dev, bar_offset, &val); - - if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64) - return -EINVAL; - - addr =3D (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK); -#ifdef CONFIG_PHYS_ADDR_T_64BIT - if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) =3D=3D PCI_BASE_ADDRESS_MEM_TY= PE_64) { - u32 val2; - - pci_read_config_dword(dev, bar_offset + 4, &val2); - addr |=3D ((resource_size_t)val2) << 32; - } -#endif size =3D UNCORE_DISCOVERY_GLOBAL_MAP_SIZE; io_addr =3D ioremap(addr, size); if (!io_addr) @@ -341,7 +324,32 @@ static int parse_discovery_table(struct pci_dev *dev, = int die, return 0; } =20 -bool intel_uncore_has_discovery_tables(int *ignore) +static int parse_discovery_table(struct pci_dev *dev, int die, + u32 bar_offset, bool *parsed, + int *ignore) +{ + resource_size_t addr; + u32 val; + + pci_read_config_dword(dev, bar_offset, &val); + + if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64) + return -EINVAL; + + addr =3D (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK); +#ifdef CONFIG_PHYS_ADDR_T_64BIT + if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) =3D=3D PCI_BASE_ADDRESS_MEM_TY= PE_64) { + u32 val2; + + pci_read_config_dword(dev, bar_offset + 4, &val2); + addr |=3D ((resource_size_t)val2) << 32; + } +#endif + + return __parse_discovery_table(addr, die, parsed, ignore); +} + +static bool intel_uncore_has_discovery_tables_pci(int *ignore) { u32 device, val, entry_id, bar_offset; int die, dvsec =3D 0, ret =3D true; @@ -390,6 +398,45 @@ bool intel_uncore_has_discovery_tables(int *ignore) return ret; } =20 +static bool intel_uncore_has_discovery_tables_msr(int *ignore) +{ + unsigned long *die_mask; + bool parsed =3D false; + int cpu, die; + u64 base; + + die_mask =3D kcalloc(BITS_TO_LONGS(__uncore_max_dies), + sizeof(unsigned long), GFP_KERNEL); + if (!die_mask) + return false; + + cpus_read_lock(); + for_each_online_cpu(cpu) { + die =3D topology_logical_die_id(cpu); + if (__test_and_set_bit(die, die_mask)) + continue; + + if (rdmsrq_safe_on_cpu(cpu, UNCORE_DISCOVERY_MSR, &base)) + continue; + + if (!base) + continue; + + __parse_discovery_table(base, die, &parsed, ignore); + } + + cpus_read_unlock(); + + kfree(die_mask); + return parsed; +} + +bool intel_uncore_has_discovery_tables(int *ignore) +{ + return intel_uncore_has_discovery_tables_msr(ignore) || + intel_uncore_has_discovery_tables_pci(ignore); +} + void intel_uncore_clear_discovery_tables(void) { struct intel_uncore_discovery_type *type, *next; diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/int= el/uncore_discovery.h index 0e94aa7db8e7..690f737e6837 100644 --- a/arch/x86/events/intel/uncore_discovery.h +++ b/arch/x86/events/intel/uncore_discovery.h @@ -1,5 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 +/* Store the full address of the global discovery table */ +#define UNCORE_DISCOVERY_MSR 0x201e + /* Generic device ID of a discovery table device */ #define UNCORE_DISCOVERY_TABLE_DEVICE 0x09a7 /* Capability ID for a discovery table device */ --=20 2.38.1 From nobody Wed Oct 8 00:42:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 035FB258CF1; Thu, 3 Jul 2025 16:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561822; cv=none; b=tlItnVMV+VGDZKGs6MZkF0ynt7c5eO7ah7FuRio3dIflR9ZK03v8RFHhX/CsATKHmn1KtG/EOi0awpMfFRC9kv3NGxzQFbMW91NLmxL88TQsz9GixbSKuA2FvHz2rI2Gx7eRmqI6V/UX9V+3OtW5sMTdn+tnrEo3NaxeCcspkeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561822; c=relaxed/simple; bh=0gNRnHp0lYcF48lsVadyWaPO5wqh2fr3pWkBS9xX3i4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=llgS1DosGU9841bhUUCyJuLmHo2h27xaSZJukQbWmq4B2d0x3KhoYavotRnxilbp9Ec0OCyoUGkK1z+N4imnAB3ia/+LFI7nNEGRPAotZ65fCSUv60wTNY3v1trW5jOhPoGs4pAp3XCpZAFwzGdkAs4IEFGti5zsygpkuLnkxBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DeXGHAXh; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DeXGHAXh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751561821; x=1783097821; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0gNRnHp0lYcF48lsVadyWaPO5wqh2fr3pWkBS9xX3i4=; b=DeXGHAXhvKCECVk1XAUGbEbEoxlzsvfhsBJ6vkXxgCR7YOMOOE16DImZ XXrlf8wyW0g4BZ8fsMqZEBSFbHgcQ9C1B5n4CSvHMoMFyhUb/uzmCL/7k kAH7/DxKCkFbq6S/+bLG+uQoZ7EvOY8NhbbEdAwZ9mIBKBZNq26nu+kV5 zOk5M2+87N5sB4nTVhkW451d5x71DZM1BxMkXj1y6FRTXdquTeL4UY7D9 Ae1uUyU+ouHGglawJD3WqliPXnWDtDkxjFeWh8wOdGurYijBTJENzhxrV S35eB9qxxksv+NO6ghfxUlQrFk56LZ6TkBdIf6Dl70LKIh16ONDG+4thF w==; X-CSE-ConnectionGUID: vNV8CHUKQvmDf1cidN2opA== X-CSE-MsgGUID: aNN2OfjqRQqZIH2/OHleKg== X-IronPort-AV: E=McAfee;i="6800,10657,11483"; a="53992517" X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="53992517" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2025 09:56:54 -0700 X-CSE-ConnectionGUID: e6jn6gNZTquTIpHXvdM/gA== X-CSE-MsgGUID: K6pqvlZNS0itNtLCuLhSbQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="154554262" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orviesa007.jf.intel.com with ESMTP; 03 Jul 2025 09:56:53 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, Kan Liang Subject: [PATCH V3 2/4] perf/x86/intel/uncore: Support customized MMIO map size Date: Thu, 3 Jul 2025 09:56:12 -0700 Message-Id: <20250703165614.606446-3-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250703165614.606446-1-kan.liang@linux.intel.com> References: <20250703165614.606446-1-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kan Liang For a server platform, the MMIO map size is always 0x4000. However, a client platform may have a smaller map size. Make the map size customizable. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_discovery.c | 2 +- arch/x86/events/intel/uncore_snbep.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/int= el/uncore_discovery.c index 8680f66c3e34..142cf714bfe2 100644 --- a/arch/x86/events/intel/uncore_discovery.c +++ b/arch/x86/events/intel/uncore_discovery.c @@ -650,7 +650,7 @@ void intel_generic_uncore_mmio_init_box(struct intel_un= core_box *box) } =20 addr =3D unit->addr; - box->io_addr =3D ioremap(addr, UNCORE_GENERIC_MMIO_SIZE); + box->io_addr =3D ioremap(addr, type->mmio_map_size); if (!box->io_addr) { pr_warn("Uncore type %d box %d: ioremap error for 0x%llx.\n", type->type_id, unit->id, (unsigned long long)addr); diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 76d96df1475a..2f5c2eb1ce0c 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -6408,6 +6408,8 @@ static void uncore_type_customized_copy(struct intel_= uncore_type *to_type, to_type->get_topology =3D from_type->get_topology; if (from_type->cleanup_mapping) to_type->cleanup_mapping =3D from_type->cleanup_mapping; + if (from_type->mmio_map_size) + to_type->mmio_map_size =3D from_type->mmio_map_size; } =20 static struct intel_uncore_type ** --=20 2.38.1 From nobody Wed Oct 8 00:42:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 269ED25A2DE; Thu, 3 Jul 2025 16:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561825; cv=none; b=gDP8xP+Xoyn8CIwUX9sTsD8Qb3ZlAl2/okfw05VDb6g89I86LFlqjOzcMmORJ7Ffb3Lhfv6M9EdULZ7L3OVnNTy24LltVPnhvZZxvQ2uc5iKdCq1BDyPNobbvMfdWw0zwr7IiQtXOFu0gr7BR1SYsW/4qSbkf49N1QzSyLpJwCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561825; c=relaxed/simple; bh=HmSWFEnyVZcq3dmbFhdSejbsJWSd1jjqG2e39rMp8qk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hKUdrPOobzP8iknq/yWdjUW2UR9s9q85qtmZl5iCPf+/fPiBp/13cDe6+R3hAV16fjALbJpfeyzqHcYc5h6frB/4EDg9mOwwR5Tcw04YUGCnU719+0mCWtR2zb1kNDmDCQo09+dXcbqC86yC+vyqIudKmf/jEKs38bQmfJCUcJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jd6h1E5T; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jd6h1E5T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751561822; x=1783097822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmSWFEnyVZcq3dmbFhdSejbsJWSd1jjqG2e39rMp8qk=; b=jd6h1E5TZtA7QYvcsXFaneKguLnQ/DBpML54MP6CP4Z247PHpvuopYjV cRfknW3mx6BN3UL+gX+cs6iyAXuZe53jnD95GJA1k3d9kHEhJihXBZj2a utCWgxhIJmcKGNBMu8C3tVDygeHkld/sUsk969JfwCdupV4wswjHQPgWj kggBm1eXBHbub5fMgl2xyUHtXMKnA3sxBWR+hymoB9bvjp19ElDUAJclw r80c4cfRuqy5fRzGiOnjoqbNNjNaOKWhhhaAtlyFra1QqXQNe7VmGBQAc hfvFVY+XslEau86rcxkdt6vLdKhYttrrwG33hK50LHqy6h1+6D2Q1k06b A==; X-CSE-ConnectionGUID: IG0KY+2zQnqeb8DKE2Ui5g== X-CSE-MsgGUID: og6aPH9YRkavg/3LMrsO8g== X-IronPort-AV: E=McAfee;i="6800,10657,11483"; a="53992523" X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="53992523" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2025 09:56:54 -0700 X-CSE-ConnectionGUID: Ks57F0zwSwaKnt7LnIevWA== X-CSE-MsgGUID: OyiNlkpyQYuzzJbSau/VWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="154554263" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orviesa007.jf.intel.com with ESMTP; 03 Jul 2025 09:56:53 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, Kan Liang Subject: [PATCH V3 3/4] perf/x86/intel/uncore: Add Panther Lake support Date: Thu, 3 Jul 2025 09:56:13 -0700 Message-Id: <20250703165614.606446-4-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250703165614.606446-1-kan.liang@linux.intel.com> References: <20250703165614.606446-1-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kan Liang The Panther Lake supports CBOX, MC, sNCU, and HBO uncore PMON. The CBOX is similar to Lunar Lake. The only difference is the number of CBOX. The other three uncore PMON can be retrieved from the discovery table. The global control register resides in the sNCU. The global freeze bit is set by default. It must be cleared before monitoring any uncore counters. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore.c | 7 +++ arch/x86/events/intel/uncore.h | 2 + arch/x86/events/intel/uncore_discovery.h | 4 ++ arch/x86/events/intel/uncore_snb.c | 71 ++++++++++++++++++++++++ arch/x86/events/intel/uncore_snbep.c | 2 +- 5 files changed, 85 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 5811e172f721..8a4f5a86e18d 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -1806,6 +1806,12 @@ static const struct intel_uncore_init_fun lnl_uncore= _init __initconst =3D { .mmio_init =3D lnl_uncore_mmio_init, }; =20 +static const struct intel_uncore_init_fun ptl_uncore_init __initconst =3D { + .cpu_init =3D ptl_uncore_cpu_init, + .mmio_init =3D ptl_uncore_mmio_init, + .use_discovery =3D true, +}; + static const struct intel_uncore_init_fun icx_uncore_init __initconst =3D { .cpu_init =3D icx_uncore_cpu_init, .pci_init =3D icx_uncore_pci_init, @@ -1887,6 +1893,7 @@ static const struct x86_cpu_id intel_uncore_match[] _= _initconst =3D { X86_MATCH_VFM(INTEL_ARROWLAKE_U, &mtl_uncore_init), X86_MATCH_VFM(INTEL_ARROWLAKE_H, &mtl_uncore_init), X86_MATCH_VFM(INTEL_LUNARLAKE_M, &lnl_uncore_init), + X86_MATCH_VFM(INTEL_PANTHERLAKE_L, &ptl_uncore_init), X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, &spr_uncore_init), X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, &spr_uncore_init), X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init), diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index 3dcb88c0ecfa..d8815fff7588 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -612,10 +612,12 @@ void tgl_uncore_cpu_init(void); void adl_uncore_cpu_init(void); void lnl_uncore_cpu_init(void); void mtl_uncore_cpu_init(void); +void ptl_uncore_cpu_init(void); void tgl_uncore_mmio_init(void); void tgl_l_uncore_mmio_init(void); void adl_uncore_mmio_init(void); void lnl_uncore_mmio_init(void); +void ptl_uncore_mmio_init(void); int snb_pci2phy_map_init(int devid); =20 /* uncore_snbep.c */ diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/int= el/uncore_discovery.h index 690f737e6837..dff75c98e22f 100644 --- a/arch/x86/events/intel/uncore_discovery.h +++ b/arch/x86/events/intel/uncore_discovery.h @@ -171,3 +171,7 @@ bool intel_generic_uncore_assign_hw_event(struct perf_e= vent *event, struct intel_uncore_box *box); void uncore_find_add_unit(struct intel_uncore_discovery_unit *node, struct rb_root *root, u16 *num_units); +struct intel_uncore_type ** +uncore_get_uncores(enum uncore_access_type type_id, int num_extra, + struct intel_uncore_type **extra, int max_num_types, + struct intel_uncore_type **uncores); diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/unc= ore_snb.c index edb7fd50efe0..817dddc1454d 100644 --- a/arch/x86/events/intel/uncore_snb.c +++ b/arch/x86/events/intel/uncore_snb.c @@ -1854,3 +1854,74 @@ void lnl_uncore_mmio_init(void) } =20 /* end of Lunar Lake MMIO uncore support */ + +/* Panther Lake uncore support */ + +#define UNCORE_PTL_MAX_NUM_UNCORE_TYPES 42 +#define UNCORE_PTL_TYPE_IMC 6 +#define UNCORE_PTL_TYPE_SNCU 34 +#define UNCORE_PTL_TYPE_HBO 41 + +#define PTL_UNCORE_GLOBAL_CTL_OFFSET 0x380 + +static struct intel_uncore_type ptl_uncore_imc =3D { + .name =3D "imc", + .mmio_map_size =3D 0xf00, +}; + +static void ptl_uncore_sncu_init_box(struct intel_uncore_box *box) +{ + intel_generic_uncore_mmio_init_box(box); + + /* Clear the global freeze bit */ + if (box->io_addr) + writel(0, box->io_addr + PTL_UNCORE_GLOBAL_CTL_OFFSET); +} + +static struct intel_uncore_ops ptl_uncore_sncu_ops =3D { + .init_box =3D ptl_uncore_sncu_init_box, + .exit_box =3D uncore_mmio_exit_box, + .disable_box =3D intel_generic_uncore_mmio_disable_box, + .enable_box =3D intel_generic_uncore_mmio_enable_box, + .disable_event =3D intel_generic_uncore_mmio_disable_event, + .enable_event =3D intel_generic_uncore_mmio_enable_event, + .read_counter =3D uncore_mmio_read_counter, +}; + +static struct intel_uncore_type ptl_uncore_sncu =3D { + .name =3D "sncu", + .ops =3D &ptl_uncore_sncu_ops, + .mmio_map_size =3D 0xf00, +}; + +static struct intel_uncore_type ptl_uncore_hbo =3D { + .name =3D "hbo", + .mmio_map_size =3D 0xf00, +}; + +static struct intel_uncore_type *ptl_uncores[UNCORE_PTL_MAX_NUM_UNCORE_TYP= ES] =3D { + [UNCORE_PTL_TYPE_IMC] =3D &ptl_uncore_imc, + [UNCORE_PTL_TYPE_SNCU] =3D &ptl_uncore_sncu, + [UNCORE_PTL_TYPE_HBO] =3D &ptl_uncore_hbo, +}; + +void ptl_uncore_mmio_init(void) +{ + uncore_mmio_uncores =3D uncore_get_uncores(UNCORE_ACCESS_MMIO, 0, NULL, + UNCORE_PTL_MAX_NUM_UNCORE_TYPES, + ptl_uncores); +} + +static struct intel_uncore_type *ptl_msr_uncores[] =3D { + &mtl_uncore_cbox, + NULL +}; + +void ptl_uncore_cpu_init(void) +{ + mtl_uncore_cbox.num_boxes =3D 6; + mtl_uncore_cbox.ops =3D &lnl_uncore_msr_ops; + uncore_msr_uncores =3D ptl_msr_uncores; +} + +/* end of Panther Lake uncore support */ diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/u= ncore_snbep.c index 2f5c2eb1ce0c..b19c262d47f5 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -6412,7 +6412,7 @@ static void uncore_type_customized_copy(struct intel_= uncore_type *to_type, to_type->mmio_map_size =3D from_type->mmio_map_size; } =20 -static struct intel_uncore_type ** +struct intel_uncore_type ** uncore_get_uncores(enum uncore_access_type type_id, int num_extra, struct intel_uncore_type **extra, int max_num_types, struct intel_uncore_type **uncores) --=20 2.38.1 From nobody Wed Oct 8 00:42:33 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E76D25A35A; Thu, 3 Jul 2025 16:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561823; cv=none; b=D84Ck2xLgXiQ5C964Pq7nIAMNDPZFg8B6jSqa1zXd6iXvd9OwmC62CKdFolPpZPY/rLHHcY4NBCVfMbgfd6FPyjLRrbgpSCOldy0F/prZVN/S48lGbqokmHSwdtPk+yCUaHwi4+5Im3HfJPmmWBK0N8f51NeUoeEFLoseS2rUUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751561823; c=relaxed/simple; bh=pOUkHTeSo9LMNRHv1Rw3zA1/OZeSTDnWdy8XZfiuXyg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MShTdoWgWz5Lr5/nhsCLqwhyNuEiMi4GXtgb90+175KBHEBkPh9+1L9IEtkC4lmwOYpscolhvq+cV+17eJP7G2jWHNUOv9XBuDZdoL0GpDXzJ10dir3kxhGFtvOccDw7evz9SCrVMALULq4+T1QKiIoxMDbAvOnP/1OLJ7OZc6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OvFiMj41; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OvFiMj41" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751561822; x=1783097822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pOUkHTeSo9LMNRHv1Rw3zA1/OZeSTDnWdy8XZfiuXyg=; b=OvFiMj419M2sJ/Xw0nEO5bVtykVcjxB9tBEPdfnoDpBx4QhJywjNgt3j 9G5BVpZJJS85PqoYMPzQRZ+5FGh3RWTpQAvBejoIV5AnywRMLRa8FyHBA kE4LS3sO2eR5gBhXK40cyo68FL2ZUJ/LyIKUuktIyhTP2J0jfHZJord8b e/lSswl3qniY6AfKcINjhbfeX7b3shBQ/KYZf7D5qgyC/GRaL4RuzIcIG kduq3derLUzBC9PVGYbT/qY/tNo7nJ8+jTH6UI1qgE6UuPALnxz82W0Hf 8o/RhLs/hyyMa5WVQiYiejHvR1eMTjVCnjsSBA4u8M2FYbaUIq4BL1IOG Q==; X-CSE-ConnectionGUID: 5tlyAtjnQySjmdKpJXOd2g== X-CSE-MsgGUID: QcvumkLASoeylKMER2HmHw== X-IronPort-AV: E=McAfee;i="6800,10657,11483"; a="53992528" X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="53992528" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2025 09:56:54 -0700 X-CSE-ConnectionGUID: jgZ1Ay3rSjSPCNSenZGIwg== X-CSE-MsgGUID: fiICh+k+T2i3M4eE289VHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,284,1744095600"; d="scan'208";a="154554264" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orviesa007.jf.intel.com with ESMTP; 03 Jul 2025 09:56:54 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: dapeng1.mi@linux.intel.com, Kan Liang Subject: [PATCH V3 4/4] perf/x86/intel/uncore: Add iMC freerunning for Panther Lake Date: Thu, 3 Jul 2025 09:56:14 -0700 Message-Id: <20250703165614.606446-5-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250703165614.606446-1-kan.liang@linux.intel.com> References: <20250703165614.606446-1-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kan Liang PTL uncore imc freerunning counters are the same as the previous HW. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore_snb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/unc= ore_snb.c index 817dddc1454d..a8c4afc9cdff 100644 --- a/arch/x86/events/intel/uncore_snb.c +++ b/arch/x86/events/intel/uncore_snb.c @@ -1905,9 +1905,17 @@ static struct intel_uncore_type *ptl_uncores[UNCORE_= PTL_MAX_NUM_UNCORE_TYPES] =3D [UNCORE_PTL_TYPE_HBO] =3D &ptl_uncore_hbo, }; =20 +#define UNCORE_PTL_MMIO_EXTRA_UNCORES 1 + +static struct intel_uncore_type *ptl_mmio_extra_uncores[UNCORE_PTL_MMIO_EX= TRA_UNCORES] =3D { + &adl_uncore_imc_free_running, +}; + void ptl_uncore_mmio_init(void) { - uncore_mmio_uncores =3D uncore_get_uncores(UNCORE_ACCESS_MMIO, 0, NULL, + uncore_mmio_uncores =3D uncore_get_uncores(UNCORE_ACCESS_MMIO, + UNCORE_PTL_MMIO_EXTRA_UNCORES, + ptl_mmio_extra_uncores, UNCORE_PTL_MAX_NUM_UNCORE_TYPES, ptl_uncores); } --=20 2.38.1