Commit ef7ce393 authored by Lucas De Marchi's avatar Lucas De Marchi
Browse files

drm/xe/pmu: Extract xe_pmu_event_update()



Like other pmu drivers, keep the update separate from the read so it can
be called from other methods (like stop()) without side effects.

Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250124050411.2189060-3-lucas.demarchi@intel.com


Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 257a10c1
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -117,18 +117,11 @@ static u64 __xe_pmu_event_read(struct perf_event *event)
	return val;
}

static void xe_pmu_event_read(struct perf_event *event)
static void xe_pmu_event_update(struct perf_event *event)
{
	struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base);
	struct hw_perf_event *hwc = &event->hw;
	struct xe_pmu *pmu = &xe->pmu;
	u64 prev, new;

	if (!pmu->registered) {
		event->hw.state = PERF_HES_STOPPED;
		return;
	}

	prev = local64_read(&hwc->prev_count);
	do {
		new = __xe_pmu_event_read(event);
@@ -137,6 +130,19 @@ static void xe_pmu_event_read(struct perf_event *event)
	local64_add(new - prev, &event->count);
}

static void xe_pmu_event_read(struct perf_event *event)
{
	struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base);
	struct xe_pmu *pmu = &xe->pmu;

	if (!pmu->registered) {
		event->hw.state = PERF_HES_STOPPED;
		return;
	}

	xe_pmu_event_update(event);
}

static void xe_pmu_enable(struct perf_event *event)
{
	/*
@@ -166,7 +172,7 @@ static void xe_pmu_event_stop(struct perf_event *event, int flags)

	if (pmu->registered)
		if (flags & PERF_EF_UPDATE)
			xe_pmu_event_read(event);
			xe_pmu_event_update(event);

	event->hw.state = PERF_HES_STOPPED;
}