Commit 01439286 authored by Sandipan Das's avatar Sandipan Das Committed by Ingo Molnar
Browse files

perf/x86/amd/uncore: Fix the return value of amd_uncore_df_event_init() on error

If amd_uncore_event_init() fails, return an error irrespective of the
pmu_version. Setting hwc->config should be safe even if there is an
error so use this opportunity to simplify the code.

Closes: https://lore.kernel.org/all/aTaI0ci3vZ44lmBn@stanley.mountain/



Fixes: d6389d3c ("perf/x86/amd/uncore: Refactor uncore management")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarSandipan Das <sandipan.das@amd.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/076935e23a70335d33bd6e23308b75ae0ad35ba2.1765268667.git.sandipan.das@amd.com
parent 92546f6b
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -656,14 +656,11 @@ static int amd_uncore_df_event_init(struct perf_event *event)
	struct hw_perf_event *hwc = &event->hw;
	int ret = amd_uncore_event_init(event);

	if (ret || pmu_version < 2)
		return ret;

	hwc->config = event->attr.config &
		      (pmu_version >= 2 ? AMD64_PERFMON_V2_RAW_EVENT_MASK_NB :
					  AMD64_RAW_EVENT_MASK_NB);

	return 0;
	return ret;
}

static int amd_uncore_df_add(struct perf_event *event, int flags)