mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
drivers/perf: hisi_pcie: Check the type first in pmu::event_init()
Check whether the event type matches the PMU type firstly in
pmu::event_init() before touching the event. Otherwise we'll
change the events of others and lead to incorrect results.
Since in perf_init_event() we may call every pmu's event_init()
in a certain case, we should not modify the event if it's not
ours.
Fixes: 8404b0fbc7 ("drivers/perf: hisi: Add driver for HiSilicon PCIe PMU")
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20231024092954.42297-2-yangyicong@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
ab33c66fd8
commit
6d7d51e88e
|
|
@ -353,6 +353,10 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)
|
|||
struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
|
||||
struct hw_perf_event *hwc = &event->hw;
|
||||
|
||||
/* Check the type first before going on, otherwise it's not our event */
|
||||
if (event->attr.type != event->pmu->type)
|
||||
return -ENOENT;
|
||||
|
||||
event->cpu = pcie_pmu->on_cpu;
|
||||
|
||||
if (EXT_COUNTER_IS_USED(hisi_pcie_get_event(event)))
|
||||
|
|
@ -360,9 +364,6 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)
|
|||
else
|
||||
hwc->event_base = HISI_PCIE_CNT;
|
||||
|
||||
if (event->attr.type != event->pmu->type)
|
||||
return -ENOENT;
|
||||
|
||||
/* Sampling is not supported. */
|
||||
if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
|
||||
return -EOPNOTSUPP;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user