arm64: arm_pmuv3: Correctly extract and check the PMUVer
authorYicong Yang <yangyicong@hisilicon.com>
Thu, 11 Apr 2024 12:30:30 +0000 (20:30 +0800)
committerWill Deacon <will@kernel.org>
Fri, 12 Apr 2024 11:54:55 +0000 (12:54 +0100)
commitb782e8d07baac95a5ce3f8773cc61f4ed7d0ccbc
tree35bb25978e577fe9ed2b032f1f22b78fe3f2357f
parent8f9f5041c64600b01b71f29fb8e2121e45bfb719
arm64: arm_pmuv3: Correctly extract and check the PMUVer

Currently we're using "sbfx" to extract the PMUVer from ID_AA64DFR0_EL1
and skip the init/reset if no PMU present when the extracted PMUVer is
negative or is zero. However for PMUv3p8 the PMUVer will be 0b1000 and
PMUVer extracted by "sbfx" will always be negative and we'll skip the
init/reset in __init_el2_debug/reset_pmuserenr_el0 unexpectedly.

So this patch use "ubfx" instead of "sbfx" to extract the PMUVer. If
the PMUVer is implementation defined (0b1111) or not implemented(0b0000)
then skip the reset/init. Previously we'll also skip the init/reset
if the PMUVer is higher than the version we known (currently PMUv3p9),
with this patch we'll only skip if the PMU is not implemented or
implementation defined. This keeps consistence with how we probe
the PMU in the driver with pmuv3_implemented().

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20240411123030.7201-1-yangyicong@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/el2_setup.h