Skip to content

Commit 2d7a824

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-ni: Fix and optimise register offset calculation
LKP points out an operator precedence oversight in the new NoC S3 support that, annoyingly, my local W=1 build didn't flag. In fixing that, we can also take the similarly-missed opportunity to cache the version check itself at event_init time. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202511041749.ok8zDP6u-lkp@intel.com/ Fixes: 8fa08f8 ("perf/arm-ni: Add NoC S3 support") Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 989b40b commit 2d7a824

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

drivers/perf/arm-ni.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,26 @@ static int arm_ni_validate_group(struct perf_event *event)
323323
return 0;
324324
}
325325

326+
static bool arm_ni_is_7xx(const struct arm_ni *ni)
327+
{
328+
return ni->part == PART_NI_700 || ni->part == PART_NI_710AE;
329+
}
330+
326331
static int arm_ni_event_init(struct perf_event *event)
327332
{
328333
struct arm_ni_cd *cd = pmu_to_cd(event->pmu);
334+
struct arm_ni *ni;
329335

330336
if (event->attr.type != event->pmu->type)
331337
return -ENOENT;
332338

333339
if (is_sampling_event(event))
334340
return -EINVAL;
335341

336-
event->cpu = cd_to_ni(cd)->cpu;
342+
ni = cd_to_ni(cd);
343+
event->cpu = ni->cpu;
344+
event->hw.flags = arm_ni_is_7xx(ni);
345+
337346
if (NI_EVENT_TYPE(event) == NI_PMU)
338347
return arm_ni_validate_group(event);
339348

@@ -411,26 +420,20 @@ static void arm_ni_init_evcnt(struct hw_perf_event *hw)
411420
writel_relaxed(S32_MIN, (void __iomem *)hw->event_base);
412421
}
413422

414-
static bool arm_ni_is_7xx(const struct arm_ni *ni)
415-
{
416-
return ni->part == PART_NI_700 || ni->part == PART_NI_710AE;
417-
}
418-
419423
static int arm_ni_event_add(struct perf_event *event, int flags)
420424
{
421425
struct arm_ni_cd *cd = pmu_to_cd(event->pmu);
422426
struct hw_perf_event *hw = &event->hw;
423427
struct arm_ni_unit *unit;
424428
enum ni_node_type type = NI_EVENT_TYPE(event);
425-
bool is_7xx = arm_ni_is_7xx(cd_to_ni(cd));
426429
u32 reg;
427430

428431
if (type == NI_PMU) {
429432
if (cd->ccnt)
430433
return -ENOSPC;
431434
hw->idx = NI_CCNT_IDX;
432435
hw->event_base = (unsigned long)cd->pmu_base +
433-
is_7xx ? NI700_PMCCNTR_L : NI_PMCCNTR_L;
436+
(hw->flags ? NI700_PMCCNTR_L : NI_PMCCNTR_L);
434437
cd->ccnt = event;
435438
arm_ni_init_ccnt(hw);
436439
} else {
@@ -443,7 +446,7 @@ static int arm_ni_event_add(struct perf_event *event, int flags)
443446
unit = (void *)hw->config_base;
444447
unit->event[hw->idx] = NI_EVENT_EVENTID(event);
445448
hw->event_base = (unsigned long)cd->pmu_base +
446-
is_7xx ? NI700_PMEVCNTR(hw->idx) : NI_PMEVCNTR(hw->idx);
449+
(hw->flags ? NI700_PMEVCNTR(hw->idx) : NI_PMEVCNTR(hw->idx));
447450
arm_ni_init_evcnt(hw);
448451
lo_hi_writeq_relaxed(le64_to_cpu(unit->pmusel), unit->pmusela);
449452

0 commit comments

Comments
 (0)