RISC-V: Create unique identification for SoC PMU
authorJoão Mário Domingos <joao.mario@tecnico.ulisboa.pt>
Tue, 16 Nov 2021 15:48:09 +0000 (15:48 +0000)
committerminda.chen <minda.chen@starfivetech.com>
Tue, 3 Jan 2023 06:26:18 +0000 (14:26 +0800)
commit3b2c5c55290627bc6b022fb187370a8b1fed09ef
treec560936d1b45e81a9d3248b5ac8f8369f2522c90
parent296d7fb66f601e843a2555448d9a93d5d6aebb2a
RISC-V: Create unique identification for SoC PMU

The SBI PMU platform driver did not provide any identification for
perf events matching. This patch introduces a new sysfs file inside the
platform device (soc:pmu/id) for pmu identification.

The identification is a 64-bit value generated as:
[63-32]: mvendorid;
[31]: marchid[MSB];
[30-16]: marchid[15-0];
[15-0]: mimpid[15MSBs];

The CSRs are detailed in the RISC-V privileged spec [1].
The marchid is split in MSB + 15LSBs, due to the MSB being used for
open-source architecture identification.

[1] https://github.com/riscv/riscv-isa-manual

Signed-off-by: João Mário Domingos <joao.mario@tecnico.ulisboa.pt>
arch/riscv/kernel/sbi.c
drivers/perf/riscv_pmu_sbi.c