Commit Graph

1228197 Commits

Author SHA1 Message Date
Jianping Liu c92c287ac7 drivers,mlnx: add sha256 check for MLNX tgz
To ensure the down load file is correct, add sha256 check for MLNX tgz.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-28 14:32:34 +08:00
Jianping Liu 3353ce662c dist: delete useless code in kernel.template.spec
Now release-drivers is in three, so it needn't to judge whether
drivers/thirdparty/release-drivers/mlnx is exist.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-28 14:07:21 +08:00
Jianping Liu c99409f7fe Merge OKC next branch to TK5 master branch 2024-08-27 19:48:02 +08:00
leoliu-oc f12c637287 i2c/zhaoxin: switch i2c registration to devm functions
zhaoxin inclusion
category: feature

-------------------

Switch from i2c_add_adapter() to resource managed devm_i2c_add_adapter()
for matching rest of driver initialization, and more concise code.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
2024-08-27 11:46:33 +00:00
Zheng Wu 3970408988 lkp: intel: selftests/bpf: Add netlink helper library
commit 51f1892b5289f0c09745d3bedb36493555d6d90c upstream.

Add a minimal netlink helper library for the BPF selftests. This has been
taken and cut down and cleaned up from iproute2. This covers basics such
as netdevice creation which we need for BPF selftests / BPF CI given
iproute2 package cannot cover it yet.

Stanislav Fomichev suggested that this could be replaced in future by ynl
tool generated C code once it has RTNL support to create devices. Once we
get to this point the BPF CI would also need to add libmnl. If no further
extensions are needed, a second option could be that we remove this code
again once iproute2 package has support.

Intel-SIG: commit 51f1892b5289 lkp: intel: selftests/bpf:
Add netlink helper library.
This patch is to fix this issue of building bpf failed.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://lore.kernel.org/r/20231024214904.29825-7-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
[ Zheng Wu: amend commit log ]
Signed-off-by: Zheng Wu <wu.zheng@intel.com>
2024-08-27 11:46:12 +00:00
Jianping Liu c3c178d349 dist: fix make dist-srpm warning
Fix warning as below:
Macro expanded in comment on line 520: %{?dist}" != ".tl4" && "%{?dist}" != ".oc9" && "%{?dist}" != ".tl3"

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-27 19:35:15 +08:00
Jianping Liu 8b5cff9dfa dist: exit 1 if download mlnx commercial drivers fail
If download mlnx commercial drivers fail, exit 1 to let users known
about it.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-27 19:32:42 +08:00
Jianping Liu 4eb6f1908f dist: not integrate mlnx commercial drivers in oc9
Some oc9 partners have nic driver, and the driver support RDMA and
the driver only compatble with kernel native infiniband.

If integrate mlnx driver, oc9 partners RDMA nic driver cloud not run.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-27 19:01:43 +08:00
Jianping Liu 3db1e8157b drivers/thirdparty: put release-drivers in tree
Only the size of mlnx driver tgz is very big, other drivers source size
is not very big. So, remove release-drivers submoule (sub git repo).

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-27 17:10:54 +08:00
Jianping Liu d791bba469 dist: add perl-sigtrap build requires
When building mlnx drivers, needing perl-sigtrap rpm. Otherwise,
it will have errors as below:
Can't locate sigtrap.pm in @INC (you may need to install the sigtrap module)
BEGIN failed--compilation aborted at ./install.pl line 44.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-27 16:12:17 +08:00
Jianping Liu 880dd21ab3 dist: release 6.6.47-11
Upstream: no

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
2024-08-27 10:59:09 +08:00
Jianping Liu 2482dd4821 config: update x86 config without manual change
Update configs by the commands as below:
make dist-config
make savedefconfig
mv defconfig arch/x86/configs/tencent.config

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-26 20:05:30 +08:00
Jianping Liu 4d78ab6896 dist: fix mlnx driver compile error on oc9
When building kernel rpm on oc9, will have error as below:
cc1: error: code model kernel does not support PIC mode
OFED_topdir/BUILD/mlnx-ofa_kernel-23.10/obj/default/compat/main.o] Error 1

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-26 19:26:46 +08:00
Jianping Liu 63e2660c48 config,oc: support WLAN and MTD and more SND drivers
OpenCloud partner want use wireless card, sound card, so open the
config to support.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-26 16:33:47 +08:00
Jianping Liu 0569444d2a Merge linux 6.6.47
Conflicts:
	net/sunrpc/svc.c
2024-08-24 09:43:23 +08:00
Jianping Liu 0a76ebf09a Merge linux 6.6.46
Conflicts:
	drivers/platform/x86/intel/ifs/core.c
	drivers/platform/x86/intel/ifs/ifs.h
	kernel/sched/core.c
2024-08-24 09:37:59 +08:00
Jianping Liu e580bc83c2 Merge linux 6.6.45 2024-08-23 19:54:49 +08:00
Jianping Liu d6563b9042 Merge OCK next branch to TK5 master branch 2024-08-23 19:52:09 +08:00
frankjpliu 897ad8fab4 Merge branch 'zegao/scx3' into 'master' (merge request !150)
Add some general scx in-kernel support
5aec0abf10 rue/scx: Kill user tasks in SCHED_EXT when scheduler is gone
a1752a5760 rue/scx: Add readonly sysctl knob kernel.cpu_qos for SCHED_BT compatibility
ed0889e48a rue/scx: Add /proc/bt_stat to maintain SCHED_BT compatibility
8c320a09af rue/scx: Add cpu.offline to maintain SCHED_BT compatibility
2b9d28baab rue/scx: Add cpu.scx to the cpu cgroup controller
576ee0803a rue/scx: Add /proc/scx_stat to do scx cputime accounting
67d151255e rue/scx: Fix lockdep warn on printk with rq lock held
ebf91df4dc rue/scx: Reorder scx_fork_rwsem, cpu_hotplug_lock and scx_cgroup_rwsem
2024-08-23 11:40:38 +00:00
Yongliang Gao 44f5072e76 Revert "sched: adaptive default skew_tick value"
This reverts commit ca7d96bf43.

Maintain consistency and alignment with upstream, and this patch
is not very friendly to virtualization.

Signed-off-by: Yongliang Gao <leonylgao@tencent.com>
Reviewed-by: Jianping Liu <frankjpliu@tencent.com>
2024-08-23 11:32:30 +00:00
frankjpliu a1aa259039 Merge branch 'likexu/kvm/cube-optimization' into 'master' (merge request !158)
KVM optimization: skip srcu-sync && fix guest-tsc jump
Backport four KVM upstream commits for cube use cases:

```
d8992b97df KVM: x86: Don't sync user-written TSC against startup values
c4201bd24f4ae KVM: s390: Don't re-setup dummy routing when KVM_CREATE_IRQCHIP
e3c89f5dd11df KVM: x86: Don't re-setup empty IRQ routing when KVM_CAP_SPLIT_IRQCHIP
fbe4a7e881d44 KVM: Setup empty IRQ routing when creating a VM
```

For the top one commit: KVM: x86: Don't sync user-written TSC against startup values

Add a flag, kvm->arch.user_set_tsc, protected by
kvm->arch.tsc_write_lock, to record that a TSC for at least one vCPU in
the VM *has* been set by userspace, and make the 1-second slop hack only
trigger if user_set_tsc is already set.

For the left commis: KVM: irqchip: synchronize srcu only if needed

We found that it may cost more than 20 milliseconds very accidentally
to enable cap of KVM_CAP_SPLIT_IRQCHIP on a host which has many vms
already.

The reason is that when vmm(qemu/CloudHypervisor) invokes
KVM_CAP_SPLIT_IRQCHIP kvm will call synchronize_srcu_expedited() and
might_sleep and kworker of srcu may cost some delay during this period.
One way makes sence is setup empty irq routing when creating vm and
so that x86/s390 don't need to setup empty/dummy irq routing.

Link: https://lore.kernel.org/all/20240506101751.3145407-1-foxywang@tencent.com/
Link: https://lore.kernel.org/r/20231008025335.7419-1-likexu@tencent.com
Signed-off-by: Like Xu likexu@tencent.com
2024-08-23 11:31:54 +00:00
Yongliang Gao 04ee57b1e7 kabi: Introduce CONFIG_KABI_RESERVE
Disable for images if kabi compatibility is explicitly not needed.

Signed-off-by: Yongliang Gao <leonylgao@tencent.com>
Reviewed-by: Jianping Liu <frankjpliu@tencent.com>
2024-08-23 11:27:49 +00:00
Damien Le Moal 77c6eb435d null_blk: Fix return value of nullb_device_power_store()
[ Upstream commit d9ff882b54f99f96787fa3df7cd938966843c418 ]

Fix CVE: CVE-2024-36478

When powering on a null_blk device that is not already on, the return
value ret that is initialized to be count is reused to check the return
value of null_add_dev(), leading to nullb_device_power_store() to return
null_add_dev() return value (0 on success) instead of "count".
So make sure to set ret to be equal to count when there are no errors.

Fixes: a2db328b0839 ("null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20240527043445.235267-1-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Haisu Wang <haisuwang@tencent.com>
2024-08-23 11:24:47 +00:00
Yu Kuai b5a603a720 null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'
[ Upstream commit a2db328b0839312c169eb42746ec46fc1ab53ed2 ]

Fix CVE: CVE-2024-36478

Writing 'power' and 'submit_queues' concurrently will trigger kernel
panic:

Test script:

modprobe null_blk nr_devices=0
mkdir -p /sys/kernel/config/nullb/nullb0
while true; do echo 1 > submit_queues; echo 4 > submit_queues; done &
while true; do echo 1 > power; echo 0 > power; done

Test result:

BUG: kernel NULL pointer dereference, address: 0000000000000148
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:__lock_acquire+0x41d/0x28f0
Call Trace:
 <TASK>
 lock_acquire+0x121/0x450
 down_write+0x5f/0x1d0
 simple_recursive_removal+0x12f/0x5c0
 blk_mq_debugfs_unregister_hctxs+0x7c/0x100
 blk_mq_update_nr_hw_queues+0x4a3/0x720
 nullb_update_nr_hw_queues+0x71/0xf0 [null_blk]
 nullb_device_submit_queues_store+0x79/0xf0 [null_blk]
 configfs_write_iter+0x119/0x1e0
 vfs_write+0x326/0x730
 ksys_write+0x74/0x150

This is because del_gendisk() can concurrent with
blk_mq_update_nr_hw_queues():

nullb_device_power_store	nullb_apply_submit_queues
 null_del_dev
 del_gendisk
				 nullb_update_nr_hw_queues
				  if (!dev->nullb)
				  // still set while gendisk is deleted
				   return 0
				  blk_mq_update_nr_hw_queues
 dev->nullb = NULL

Fix this problem by resuing the global mutex to protect
nullb_device_power_store() and nullb_update_nr_hw_queues() from configfs.

Fixes: 45919fbfe1 ("null_blk: Enable modifying 'submit_queues' after an instance has been configured")
Reported-and-tested-by: Yi Zhang <yi.zhang@redhat.com>
Closes: https://lore.kernel.org/all/CAHj4cs9LgsHLnjg8z06LQ3Pr5cax-+Ps+xT7AP7TPnEjStuwZA@mail.gmail.com/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Link: https://lore.kernel.org/r/20240523153934.1937851-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Haisu Wang <haisuwang@tencent.com>
2024-08-23 11:24:47 +00:00
frankjpliu 1541ee2d1b Merge branch 'remotes/origin/huntazhang/cmdlog' into 'master' (merge request !140)
Adapt cmdlog
2024-08-23 11:21:29 +00:00
Jianping Liu 3a97f7bf0d dist: provide mlnx-ofed-dist rpm
Provide mlnx-ofed-dist-%{kernel_unamer}.rpm, which include the complete
set of MLNX drivers, such as mlnx's user space tools / libs.

Certainly, the kernel modules in mlnx-ofed-dist-%{kernel_unamer}.rpm have
been signed.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-22 11:42:59 +08:00
Jianping Liu 703faa70ad drivers,dist: add mlnx commercial quality drivers
Add mlnx driver of version MLNX_OFED_LINUX-23.10-3.2.2.0 .

Note: MLNX_OFED_LINUX-23.10-3.2.2.0-rhel9.4-x86_64.tgz have a sub tgz
which named MLNX_OFED_SRC-23.10-3.2.2.0.tgz. In MLNX_OFED_SRC-23.10-3.2.2.0.tgz,
there is mlnx-ofa_kernel-23.10-OFED.23.10.3.2.2.1.src.rpm .

Compile mlnx-ofa_kernel-23.10-OFED.23.10.3.2.2.1.src.rpm in ts4 mock env
(koji task using the env) will have lots of errors. So, don't compile
mlnx-ofa_kernel-23.10-OFED.23.10.3.2.2.1.src.rpm as a independent rpm.

MLNX_OFED_LINUX-23.10-3.2.2.0-rhel9.4-x86_64.tgz is too big, it's more
than 220MB. So, download it at first, and then integrate it into kernel
src rpm.

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-20 19:05:53 +08:00
刘诗 304e016392
!217 [next] x86/hpet: Read HPET directly if panic in progress
Merge pull request !217 from LeoLiu-oc/next-6.6-89-hpet
2024-08-20 07:06:29 +00:00
刘诗 646d491276
!216 [next] i2c/zhaoxin: I2C controller driver enhancement and optimization
Merge pull request !216 from LeoLiu-oc/next-6.6-87-i2c-update
2024-08-20 07:05:18 +00:00
刘诗 b3bd45ba94
!215 [next] x86/mce: Add NMIs setup in machine_check func
Merge pull request !215 from LeoLiu-oc/next-6.6-86-mce-nmi
2024-08-20 07:04:44 +00:00
刘诗 550da69b1f
!214 [next] x86/mce/zhaoxin: Enable mcelog to decode PCIE, ZDI/ZPI, and DRAM errors
Merge pull request !214 from LeoLiu-oc/next-6.6-82-mcelog
2024-08-20 07:01:00 +00:00
刘诗 ed7628767e
!213 [next] x86/mce: Set bios_cmci_threshold for CMCI threshold
Merge pull request !213 from LeoLiu-oc/next-6.6-81-mce-bios-cmci
2024-08-20 06:58:51 +00:00
Jianping Liu f03179c2a4 submodule: update emm and thirdparty/release-drivers
emm update to v0.1.7.2
release-drivers update to v1.0

Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
Reviewed-by: Yongliang Gao <leonylgao@tencent.com>
2024-08-20 14:53:00 +08:00
刘诗 0d9dcb130f
!212 [next] perf/x86/zhaoxin/uncore: update KX-7000 support
Merge pull request !212 from LeoLiu-oc/next-6.6-85-pmu-update
2024-08-20 03:11:54 +00:00
刘诗 47fb33a17b
!211 [next] Fix the issue of RMRR reserver iova on multiple devices in the same group
Merge pull request !211 from LeoLiu-oc/next-6.6-77-iova
2024-08-20 03:10:57 +00:00
Dapeng Mi 920f2a1442 perf/x86/intel: Correct incorrect 'or' operation for PMU capabilities
Upstream commit: e8df9d9f4209c04161321d8c12640ae560f65939
Conflict: none

When running perf-stat command on Intel hybrid platform, perf-stat
reports the following errors:

  sudo taskset -c 7 ./perf stat -vvvv -e cpu_atom/instructions/ sleep 1

  Opening: cpu/cycles/:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xa00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
  sys_perf_event_open failed, error -16

   Performance counter stats for 'sleep 1':

       <not counted>      cpu_atom/instructions/

It looks the cpu_atom/instructions/ event can't be enabled on atom PMU
even when the process is pinned on atom core. Investigation shows that
exclusive_event_init() helper always returns -EBUSY error in the perf
event creation. That's strange since the atom PMU should not be an
exclusive PMU.

Further investigation shows the issue was introduced by commit:

  97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")

The commit originally intents to clear the bit PERF_PMU_CAP_AUX_OUTPUT
from PMU capabilities if intel_cap.pebs_output_pt_available is not set,
but it incorrectly uses 'or' operation and leads to all PMU capabilities
bits are set to 1 except bit PERF_PMU_CAP_AUX_OUTPUT.

Testing this fix on Intel hybrid platforms, the observed issues
disappear.

Intel-SIG: commit e8df9d9f4209 ("perf/x86/intel: Correct incorrect 'or' operation for PMU capabilities")
Backport following hybrid pmu bugfixes for commit 97588df87b56

Fixes: 97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231121014628.729989-1-dapeng1.mi@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:17 +08:00
Kan Liang eef2e3cea8 perf/x86/intel: Fix broken fixed event constraints extension
Upstream commit: 950ecdc672aec9cd29036b2e2535b07c103af494
Conflict: none

Unnecessary multiplexing is triggered when running an "instructions"
event on an MTL.

perf stat -e cpu_core/instructions/,cpu_core/instructions/ -a sleep 1

 Performance counter stats for 'system wide':

       115,489,000      cpu_core/instructions/                (50.02%)
       127,433,777      cpu_core/instructions/                (49.98%)

       1.002294504 seconds time elapsed

Linux architectural perf events, e.g., cycles and instructions, usually
have dedicated fixed counters. These events also have equivalent events
which can be used in the general-purpose counters. The counters are
precious. In the intel_pmu_check_event_constraints(), perf check/extend
the event constraints of these events. So these events can utilize both
fixed counters and general-purpose counters.

The following cleanup commit:

  97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")

forgot adding the intel_pmu_check_event_constraints() into update_pmu_cap().
The architectural perf events cannot utilize the general-purpose counters.

The code to check and update the counters, event constraints and
extra_regs is the same among hybrid systems. Move
intel_pmu_check_hybrid_pmus() to init_hybrid_pmu(), and
emove the duplicate check in update_pmu_cap().

Intel-SIG: commit 950ecdc672ae ("perf/x86/intel: Fix broken fixed event constraints extension")
Backport following hybrid pmu bugfixes for commit 97588df87b56

Fixes: 97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230911135128.2322833-1-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:16 +08:00
Kan Liang 2f5a3cb57b perf/x86/intel: Add a distinct name for Granite Rapids
Upstream commit: fa0c1c9d283b37fdb7fc1dcccbb88fc8f48a4aa4
Conflict: none

Currently, the Sapphire Rapids and Granite Rapids share the same PMU
name, sapphire_rapids. Because from the kernel’s perspective, GNR is
similar to SPR. The only key difference is that they support different
extra MSRs. The code path and the PMU name are shared.

However, from end users' perspective, they are quite different. Besides
the extra MSRs, GNR has a newer PEBS format, supports Retire Latency,
supports new CPUID enumeration architecture, doesn't required the
load-latency AUX event, has additional TMA Level 1 Architectural Events,
etc. The differences can be enumerated by CPUID or the PERF_CAPABILITIES
MSR. They weren't reflected in the model-specific kernel setup.
But it is worth to have a distinct PMU name for GNR.

Intel-SIG: commit fa0c1c9d283b ("perf/x86/intel: Add a distinct name for Granite Rapids")
Backport 3 core pmu bugfixes to kernel v6.6

Fixes: a6742cb90b ("perf/x86/intel: Fix the FRONTEND encoding on GNR and MTL")
Suggested-by: Ahmad Yasin <ahmad.yasin@intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20240708193336.1192217-3-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:15 +08:00
Kan Liang c84d490fd6 perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated
Upstream commit: 556a7c039a52c21da33eaae9269984a1ef59189b
Conflict: none

The below error is observed on Ice Lake VM.

$ perf stat
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument)
for event (slots).
/bin/dmesg | grep -i perf may provide additional information.

In a virtualization env, the Topdown metrics and the slots event haven't
been supported yet. The guest CPUID doesn't enumerate them. However, the
current kernel unconditionally exposes the slots event and the Topdown
metrics events to sysfs, which misleads the perf tool and triggers the
error.

Hide the perf-metrics topdown events and the slots event if the
perf-metrics feature is not enumerated.

The big core of a hybrid platform can also supports the perf-metrics
feature. Fix the hybrid platform as well.

Intel-SIG: commit 556a7c039a52 ("perf/x86/intel: Hide Topdown metrics events if the feature is not enumerated")
Backport 3 core pmu bugfixes to kernel v6.6

Closes: https://lore.kernel.org/lkml/CAM9d7cj8z+ryyzUHR+P1Dcpot2jjW+Qcc4CPQpfafTXN=LEU0Q@mail.gmail.com/
Reported-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Dongli Zhang <dongli.zhang@oracle.com>
Link: https://lkml.kernel.org/r/20240708193336.1192217-2-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:15 +08:00
Kan Liang eb30ed744a perf/x86/intel: Add common intel_pmu_init_hybrid()
Upstream commit: 97588df87b56e27fd2b5d928d61c7a53e38afbb0
Conflict: none

The current hybrid initialization codes aren't well organized and are
hard to read.

Factor out intel_pmu_init_hybrid() to do a common setup for each
hybrid PMU. The PMU-specific capability will be updated later via either
hard code (ADL) or CPUID hybrid enumeration (MTL).

Splitting the ADL and MTL initialization codes, since they have
different uarches. The hard code PMU capabilities are not required for
MTL either. They can be enumerated by the new leaf 0x23 and
IA32_PERF_CAPABILITIES MSR.

The hybrid enumeration of the IA32_PERF_CAPABILITIES MSR is broken on
MTL. Using the default value.

Intel-SIG: commit 97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")
Backport as a dependency needed by the GNR distinct pmu name fix

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230829125806.3016082-7-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:14 +08:00
Kan Liang bb663fd105 perf/x86/intel: Clean up the hybrid CPU type handling code
Upstream commit: b0560bfd4b70277a4936c82e50e940aa253c95bf
Conflict: none

There is a fairly long list of grievances about the current code. The
main beefs:

   1. hybrid_big_small assumes that the *HARDWARE* (CPUID) provided
      core types are a bitmap. They are not. If Intel happened to
      make a core type of 0xff, hilarity would ensue.
   2. adl_get_hybrid_cpu_type() utterly inscrutable.  There are
      precisely zero comments and zero changelog about what it is
      attempting to do.

According to Kan, the adl_get_hybrid_cpu_type() is there because some
Alder Lake (ADL) CPUs can do some silly things. Some ADL models are
*supposed* to be hybrid CPUs with big and little cores, but there are
some SKUs that only have big cores. CPUID(0x1a) on those CPUs does
not say that the CPUs are big cores. It apparently just returns 0x0.
It confuses perf because it expects to see either 0x40 (Core) or
0x20 (Atom).

The perf workaround for this is to watch for a CPU core saying it is
type 0x0. If that happens on an Alder Lake, it calls
x86_pmu.get_hybrid_cpu_type() and just assumes that the core is a
Core (0x40) CPU.

To fix up the mess, separate out the CPU types and the 'pmu' types.
This allows 'hybrid_pmu_type' bitmaps without worrying that some
future CPU type will set multiple bits.

Since the types are now separate, add a function to glue them back
together again. Actual comment on the situation in the glue
function (find_hybrid_pmu_for_cpu()).

Also, give ->get_hybrid_cpu_type() a real return type and make it
clear that it is overriding the *CPU* type, not the PMU type.

Rename cpu_type to pmu_type in the struct x86_hybrid_pmu to reflect the
change.

Intel-SIG: commit b0560bfd4b70 ("perf/x86/intel: Clean up the hybrid CPU type handling code")
Backport as a dependency needed by the GNR distinct pmu name fix

Originally-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230829125806.3016082-6-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:12 +08:00
Kan Liang f6509bdbc4 perf/x86/intel: Apply the common initialization code for ADL
Upstream commit: 299a5fc8e783eed705015e83e381912dbbf3eabc
Conflict: none

Use the intel_pmu_init_glc() and intel_pmu_init_grt() to replace the
duplicate code for ADL.

The current code already checks the PERF_X86_EVENT_TOPDOWN flag before
invoking the Topdown metrics functions. (The PERF_X86_EVENT_TOPDOWN flag
is to indicate the Topdown metric feature, which is only available for
the p-core.) Drop the unnecessary adl_set_topdown_event_period() and
adl_update_topdown_event().

Intel-SIG: commit 299a5fc8e783 ("perf/x86/intel: Apply the common initialization code for ADL")
Backport as a dependency needed by the GNR distinct pmu name fix

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230829125806.3016082-5-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:11 +08:00
Kan Liang e4d9ed45e0 perf/x86/intel: Factor out the initialization code for ADL e-core
Upstream commit: d87d221f854b62f5e8026505497d33404ef6050c
Conflict: none

From PMU's perspective, the ADL e-core and newer SRF/GRR have a similar
uarch. Most of the initialization code can be shared.

Factor out intel_pmu_init_grt() for the common initialization code.
The common part of the ADL e-core will be replaced by the later patch.

Intel-SIG: commit d87d221f854b ("perf/x86/intel: Factor out the initialization code for ADL e-core")
Backport as a dependency needed by the GNR distinct pmu name fix

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230829125806.3016082-4-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:10 +08:00
Kan Liang aafa358c77 perf/x86/intel: Factor out the initialization code for SPR
Upstream commit: 0ba0c03528e918a8f6b5aa63d502fdc6a9d80fc7
Conflict: none

The SPR and ADL p-core have a similar uarch. Most of the initialization
code can be shared.

Factor out intel_pmu_init_glc() for the common initialization code.
The common part of the ADL p-core will be replaced by the later patch.

Intel-SIG: commit 0ba0c03528e9 ("perf/x86/intel: Factor out the initialization code for SPR")
Backport as a dependency needed by the GNR distinct pmu name fix

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230829125806.3016082-3-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:10 +08:00
Kan Liang 6968fa9590 perf/x86/intel: Use the common uarch name for the shared functions
Upstream commit: d4b5694c75d4eba8238d541a55da0c67e876213e
Conflict: none

From PMU's perspective, the SPR/GNR server has a similar uarch to the
ADL/MTL client p-core. Many functions are shared. However, the shared
function name uses the abbreviation of the server product code name,
rather than the common uarch code name.

Rename these internal shared functions by the common uarch name.

Intel-SIG: commit d4b5694c75d4 ("perf/x86/intel: Use the common uarch name for the shared functions")
Backport as a dependency needed by the GNR distinct pmu name fix

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230829125806.3016082-2-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:08 +08:00
Kan Liang 384c947507 perf/x86/intel/uncore: Support HBM and CXL PMON counters
Upstream commit: f8a86a9bb5f7e65d8c4405052de062639a8783bb
Conflict: none

Unknown uncore PMON types can be found in both SPR and EMR with HBM or
CXL.

 $ls /sys/devices/ | grep type
 uncore_type_12_16
 uncore_type_12_18
 uncore_type_12_2
 uncore_type_12_4
 uncore_type_12_6
 uncore_type_12_8
 uncore_type_13_17
 uncore_type_13_19
 uncore_type_13_3
 uncore_type_13_5
 uncore_type_13_7
 uncore_type_13_9

The unknown PMON types are HBM and CXL PMON. Except for the name, the
other information regarding the HBM and CXL PMON counters can be
retrieved via the discovery table. Add them into the uncores tables for
SPR and EMR.

The event config registers for all CXL related units are 8-byte apart.
Add SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT to specially handle it.

Intel-SIG: commit f8a86a9bb5f7 ("perf/x86/intel/uncore: Support HBM and CXL PMON counters")
Backport SPR/EMR HBM and CXL PMON support to kernel v6.6

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Yunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-9-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:07 +08:00
Kan Liang c032216403 perf/x86/uncore: Cleanup unused unit structure
Upstream commit: 15a4bd51853b9c67f49bb03c20b6b6cb60fd204f
Conflict: none

The unit control and ID information are retrieved from the unit control
RB tree. No one uses the old structure anymore. Remove them.

Intel-SIG: commit 15a4bd51853b ("perf/x86/uncore: Cleanup unused unit structure")
Backport SPR/EMR HBM and CXL PMON support to kernel v6.6

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Yunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-8-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:06 +08:00
Kan Liang de017fd17a perf/x86/uncore: Apply the unit control RB tree to PCI uncore units
Upstream commit: f76a8420444beb1c3968504c8176a67d2d5fe18f
Conflict: none

The unit control RB tree has the unit control and unit ID information
for all the PCI units. Use them to replace the box_ctls/pci_offsets to
get an accurate unit control address for PCI uncore units.

The UPI/M3UPI units in the discovery table are ignored. Please see the
commit 65248a9a9e ("perf/x86/uncore: Add a quirk for UPI on SPR").
Manually allocate a unit control RB tree for UPI/M3UPI.
Add cleanup_extra_boxes to release such manual allocation.

Intel-SIG: commit f76a8420444b ("perf/x86/uncore: Apply the unit control RB tree to PCI uncore units")
Backport SPR/EMR HBM and CXL PMON support to kernel v6.6

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Yunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-7-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:04 +08:00
Kan Liang 31ec83bdd4 perf/x86/uncore: Apply the unit control RB tree to MSR uncore units
Upstream commit: b1d9ea2e1ca44987c8409cc628dfb0c84e93dce9
Conflict: none

The unit control RB tree has the unit control and unit ID information
for all the MSR units. Use them to replace the box_ctl and
uncore_msr_box_ctl() to get an accurate unit control address for MSR
uncore units.

Add intel_generic_uncore_assign_hw_event(), which utilizes the accurate
unit control address from the unit control RB tree to calculate the
config_base and event_base.

The unit id related information should be retrieved from the unit
control RB tree as well.

Intel-SIG: commit b1d9ea2e1ca4 ("perf/x86/uncore: Apply the unit control RB tree to MSR uncore units")
Backport SPR/EMR HBM and CXL PMON support to kernel v6.6

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Yunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-6-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:02 +08:00
Kan Liang 4d95acc8ae perf/x86/uncore: Apply the unit control RB tree to MMIO uncore units
Upstream commit: 80580dae65b941eb681bd79f31f64f91b58232b4
Conflict: none

The unit control RB tree has the unit control and unit ID information
for all the units. Use it to replace the box_ctls/mmio_offsets to get
an accurate unit control address for MMIO uncore units.

Intel-SIG: commit 80580dae65b9 ("perf/x86/uncore: Apply the unit control RB tree to MMIO uncore units")
Backport SPR/EMR HBM and CXL PMON support to kernel v6.6

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Yunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-5-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
2024-08-20 10:58:01 +08:00