Re: [PATCH 6/8] drivers/perf: hisi: Refactor the event configuration of L3C PMU

From: Jonathan Cameron
Date: Thu Jul 31 2025 - 08:27:54 EST


On Tue, 29 Jul 2025 23:38:21 +0800
Yushan Wang <wangyushan12@xxxxxxxxxx> wrote:

> From: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
>
> The event register is configured using hisi_pmu::base directly since
> only one address space is supported for L3C PMU. We need to extend if
> events configuration locates in different address space. In order to
> make preparation for such hardware, extract the event register
> configuration to separate function using hw_perf_event::event_base as
> each event's base address. Implement a private
> hisi_uncore_ops::get_event_idx() callback for initialize the event_base
> besides get the hardware index.
>
> No functional changes intended.
>
> Signed-off-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
> Signed-off-by: Yushan Wang <wangyushan12@xxxxxxxxxx>
One tiny thing inline.

Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxx>

> ---
> drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c | 128 ++++++++++++-------
> 1 file changed, 83 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> index 39444f11cbad..6ac0ea74cda3 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> @@ -60,51 +60,86 @@ HISI_PMU_EVENT_ATTR_EXTRACTOR(datasrc_cfg, config1, 15, 11);
> HISI_PMU_EVENT_ATTR_EXTRACTOR(datasrc_skt, config1, 16, 16);
> HISI_PMU_EVENT_ATTR_EXTRACTOR(tt_core, config2, 15, 0);
>
> -static void hisi_l3c_pmu_config_req_tracetag(struct perf_event *event)
> +static int hisi_l3c_pmu_get_event_idx(struct perf_event *event)
> {
> struct hisi_pmu *l3c_pmu = to_hisi_pmu(event->pmu);
> + unsigned long *used_mask = l3c_pmu->pmu_events.used_mask;
> + u32 num_counters = l3c_pmu->num_counters;
> + int idx;
> +
> + idx = find_first_zero_bit(used_mask, num_counters);
> + if (idx == num_counters)
> + return -EAGAIN;
> +
> + set_bit(idx, used_mask);
> + event->hw.event_base = (unsigned long)l3c_pmu->base;

Trivial but blank line here.

> + return idx;
> +}