From nobody Thu Dec 18 03:19:09 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 B774C25DCF3 for ; Wed, 7 May 2025 14:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628491; cv=none; b=J84Yfs0Jdv2XeMtuoYK06ocRc1eTWDBn2VtN1wn2cZvATXi2sZ82G+xSIE0UVRecuWQ/w6ce3s0uSxAKywm7vfN7Gr4/TzzkW2SlEF2tuslPFcZgHZQsOToYKFAushw/RxpAKNdh6d8ZD4rsCcA8plYGVdejBhxZd866TYV47rQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628491; c=relaxed/simple; bh=1vx2zeheeJDoHFOHKcduICilW7sEdCX7aHfLVEa9SvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XSaDrTjYphQYXVYTrIqhgDFb+SjzIozSYVKNT6nkVsbgFkBQmlanwRfo1xb8yO6oT9RShp2V+q4WEnO6ygA7MP2GHmGTK/J+HW/HAan2/lL2YihxVfZcrfxXWTYhyhqHsmUA40/fXISr4Obo26ncOUBUvKWz1iP9EuB/80JOos4= 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=W0LrLdSG; arc=none smtp.client-ip=198.175.65.17 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="W0LrLdSG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746628490; x=1778164490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1vx2zeheeJDoHFOHKcduICilW7sEdCX7aHfLVEa9SvU=; b=W0LrLdSGRrb8563oQ+Q8EJ0AwVtwEJbrA5GI4OHwyaqG63Cem2KxY8TS lMP/BYBpcl4DOBjyOlQoC8m7Bzi+e9Wdq062wMZFmv6STaT75yyHaGT38 md/aexrnIWKhhyKV/g3aAH53al+ZOXxKhzPv0nhiu2fiFP/3n4AKWRP2M PI9Awyub0xTZlU4meuIWK6DhVCBaEcQOeX/A4tF8T7YMAY/bY51Qm2CEn 1NxxblpgpDSbjDXvAh7tVMV3LRtgt7zV060ecbsF6C+ZzVbw3cUxeHvOX F+sE2UD5EhSOzIJEDcxoZtsYuP/UmLH9E7qBUzpsOcvaH59cFRWmtuIbm Q==; X-CSE-ConnectionGUID: Yne/3xTHQl+trkp5oK59/Q== X-CSE-MsgGUID: IX20omZNTWq77mhNprVQOQ== X-IronPort-AV: E=McAfee;i="6700,10204,11426"; a="48378077" X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="48378077" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2025 07:34:48 -0700 X-CSE-ConnectionGUID: EguQwi7PTqCWB/sS3Tupbg== X-CSE-MsgGUID: 1fMu9fjbRsKBP3XdnFa0fQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="135943610" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa006.fm.intel.com with ESMTP; 07 May 2025 07:34:47 -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 Cc: Kan Liang Subject: [RESEND PATCH V2 1/4] perf/x86/intel/uncore: Support MSR portal for discovery tables Date: Wed, 7 May 2025 07:34:24 -0700 Message-Id: <20250507143427.1319818-2-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250507143427.1319818-1-kan.liang@linux.intel.com> References: <20250507143427.1319818-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 (rdmsrl_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 Thu Dec 18 03:19:09 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 500DF286D64 for ; Wed, 7 May 2025 14:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628491; cv=none; b=ZfXhi4lZ/pXIqc2Ze8RpA42cNGyAdhzJ33uwhbr7ny5UPk2D6fb+cHf0a3dMZkUszjUvIHiddPG7om6ozSVtdKbcAyipOhZRRoqZBLTEMHWBJJAci+wroffhpo+AMn2/LaL0SmWEgjim8shnaF1bl9l6M6edEqncpQvVhX+b8k0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628491; c=relaxed/simple; bh=0gNRnHp0lYcF48lsVadyWaPO5wqh2fr3pWkBS9xX3i4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aR5tdchY1sI0Uvw1nys8s8yPZS82uz1HLCh4U8O/9FMz+o1J/HVL1xXYm3dBlRnKeepacRFFlDaMluQNT7hkt/R2TX6kLlTPXupDlmx+8sRIU7XN5o+qP4pmgVdY/fdLAL9/UC9EHs5EOTtCaeKS4b6C1PM8PhSJfUpfTmb3Q8k= 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=MV+0X/Mh; arc=none smtp.client-ip=198.175.65.17 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="MV+0X/Mh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746628491; x=1778164491; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0gNRnHp0lYcF48lsVadyWaPO5wqh2fr3pWkBS9xX3i4=; b=MV+0X/Mh4S/P91BK+oIOp4vfn0kSuuY1nIa4XnrDIhYvP/A09k7VOpH6 RQCQ8zn9sxT44iYk7XRMkGxj0F4Aq1ojfTiq8j1+eTepwxr+YR8uDCt+O 4RJLmwSbZu0BnO5qxh9Dwx3yoo7yCntRGYmSp6D2+ALZhiKvakkvIcJGS tuHqQXUcwjbaXiemCfSGaaN/F/QaLWaDPaNeJcNPa+jVkgigmpT5ZxIHs HZq8cGEuiO5K4uEoK8ce9g8vpVl2vl9sUuNQQjSKkj+ivZniTqYD/qttm FjxB7Gf8VllMHtx8NQukVy+ZqIqQ1V6iJb9rfCLAZ/uKmDnvkr/8SG5NO w==; X-CSE-ConnectionGUID: x+R1Uj1JS52J7b4ZJ1jkBQ== X-CSE-MsgGUID: hEySKInBTSCPkddh1ZJwCw== X-IronPort-AV: E=McAfee;i="6700,10204,11426"; a="48378079" X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="48378079" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2025 07:34:48 -0700 X-CSE-ConnectionGUID: YDbV30CyRTqBUTloa0auZg== X-CSE-MsgGUID: /feiHKp+QZO3rpUnMm/+Ow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="135943612" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa006.fm.intel.com with ESMTP; 07 May 2025 07:34:47 -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 Cc: Kan Liang Subject: [RESEND PATCH V2 2/4] perf/x86/intel/uncore: Support customized MMIO map size Date: Wed, 7 May 2025 07:34:25 -0700 Message-Id: <20250507143427.1319818-3-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250507143427.1319818-1-kan.liang@linux.intel.com> References: <20250507143427.1319818-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 Thu Dec 18 03:19:09 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 DDD29289371 for ; Wed, 7 May 2025 14:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628493; cv=none; b=EdAdWqgLM8DCo9bkkkKaQLs6ihfZDglMzqLYPVa6CfDcPiFA9qoONL3vkcIh3VxNPUZn38YsVF3lPlAICiZJTxlcNMmzntM14CATzNZpf06nmeXDL5bhnrI66hmAIXN6T2WSMEeovKxHmSS7buUnVjiL9XmzFjfLotYdOKvogcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628493; c=relaxed/simple; bh=HmSWFEnyVZcq3dmbFhdSejbsJWSd1jjqG2e39rMp8qk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QvZGEzp+u6HuXEw5NOvZRIy6GJwckM3s+NubWKE+Xq3jzT4z6yfHn+grEEjh7CuaYLFxgFyxKvEIg5wyK8Ei9JDk5OLTZppLVlTpBK5ZqZlonv3D1kUUu05uoRYtP0H8aYWyRubYzW5ie3aV1pGZ7xTw7bnbeKbJqXAtehXp3UY= 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=IMdooezO; arc=none smtp.client-ip=198.175.65.17 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="IMdooezO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746628492; x=1778164492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HmSWFEnyVZcq3dmbFhdSejbsJWSd1jjqG2e39rMp8qk=; b=IMdooezOtdxEvINiZoFmNclioEOwcpn7kGD4vKThUMQDpwaLJKh5Lboz ZOLHFj8xzk7Wp8hIxiLWi0Jpw+37F3ZZRvomVjd8SB34DEh6Hq7aZm2Dw vT6m2ygw63uE7HVoCnPbUJ5b8SbX39y9UohWvX3RaIm75n9n6F4kRtsbk jfYjEkCXjowbhy3Cg0DYds/gyngoP0y+t3da9glE1eEmKkbTNFk6FFnB1 yth8mXfCN0zqlH//Pcj5Z55Zsw4m3YIqFyw9pNYNvAn/uxDf8aCRL9swB n2pVg/qP7xxKKrz4/zHjChkwNcMVbjxZCmOOYd7sgN1TjGGR2Y3RAbiGv Q==; X-CSE-ConnectionGUID: V8kV/w5YRMeZYZDRRijEMg== X-CSE-MsgGUID: HRuu8dVrQiCvU2aPlq2H5A== X-IronPort-AV: E=McAfee;i="6700,10204,11426"; a="48378084" X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="48378084" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2025 07:34:48 -0700 X-CSE-ConnectionGUID: gS3cmzmZTZ+ppZh+gV9k9g== X-CSE-MsgGUID: cRNGbg9bTDi5WtGKOoLJVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="135943613" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa006.fm.intel.com with ESMTP; 07 May 2025 07:34:47 -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 Cc: Kan Liang Subject: [RESEND PATCH V2 3/4] perf/x86/intel/uncore: Add Panther Lake support Date: Wed, 7 May 2025 07:34:26 -0700 Message-Id: <20250507143427.1319818-4-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250507143427.1319818-1-kan.liang@linux.intel.com> References: <20250507143427.1319818-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 Thu Dec 18 03:19:09 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 311FA289362 for ; Wed, 7 May 2025 14:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628493; cv=none; b=Si/9x94pRiIo5RwcVpir57Xg7NO/qgID933LGXrzOxcqQwGFZm7wEOJZarE7Wz82W0RGYVTLJpvY7kvjF/QLMNV+u0IyWOE2YcNs0wsognYKd2dMCj6lwkwSVTYpD8W233kPJ14XpUe9SiDiMNhC+K3CIcArxi9GDDRL7Hgqous= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746628493; c=relaxed/simple; bh=pOUkHTeSo9LMNRHv1Rw3zA1/OZeSTDnWdy8XZfiuXyg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sS7QiCPhhzaO3K7ccHzJIYh0xkXif52CmfmO5ZPY8i/uc96Njdo2BSxPIbRSe4tUIrEbg5r9KgggaCvmURJYoBwa7Nq/wxO5SVNslAxG7Yn8kTSjDX83LTuz8F8SEBfYT4E+TPmXON5WEgtkgsQtjgnSPiVt9ZR96fi3htC4wHE= 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=lG9QfylI; arc=none smtp.client-ip=198.175.65.17 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="lG9QfylI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746628493; x=1778164493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pOUkHTeSo9LMNRHv1Rw3zA1/OZeSTDnWdy8XZfiuXyg=; b=lG9QfylIE4OqqT2P3rxXSBtxhIxAvHdM2nnlfqm10AnHK2onFivi4Goe 29ehfiEi+NOob6E5RMSrrO5JzV2cnhiW5aKKetyFlH0vmjX2cKfs6Lq1t C71J95rrqI7n+xqe7A0B2I+pf5HgxWNdbfEPU60DFGUrtPSlHgom3rQgh CqbXcbGTCiPt28GEnNLskBhE7YxIDCpbA2812hI7Vvp9tg0gEkqGkc0oh Fk1KMN+0HhxMLF0Vo9uiorF82mvmAzmXCnmCOrRXh1yOlXBWFLwCo7oso DTSv0pLX3tpHg3iIQhHsNt58N7kDHXPjJTgXGPL+oAxPeAR5K6dDBH9km A==; X-CSE-ConnectionGUID: guK5lQkwSoC5a2X1yh3C7A== X-CSE-MsgGUID: T/5d59VNRUW5tIIUgiIiIg== X-IronPort-AV: E=McAfee;i="6700,10204,11426"; a="48378089" X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="48378089" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2025 07:34:48 -0700 X-CSE-ConnectionGUID: NFGKn0qpQA+IjMh9RR5LeA== X-CSE-MsgGUID: FjehlFa0Sa6FXcXQHvZ6GA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,269,1739865600"; d="scan'208";a="135943615" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmviesa006.fm.intel.com with ESMTP; 07 May 2025 07:34:48 -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 Cc: Kan Liang Subject: [RESEND PATCH V2 4/4] perf/x86/intel/uncore: Add iMC freerunning for Panther Lake Date: Wed, 7 May 2025 07:34:27 -0700 Message-Id: <20250507143427.1319818-5-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250507143427.1319818-1-kan.liang@linux.intel.com> References: <20250507143427.1319818-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