Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250124050411.2189060-3-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

+15 -9
+15 -9
drivers/gpu/drm/xe/xe_pmu.c
··· 117 117 return val; 118 118 } 119 119 120 - static void xe_pmu_event_read(struct perf_event *event) 120 + static void xe_pmu_event_update(struct perf_event *event) 121 121 { 122 - struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base); 123 122 struct hw_perf_event *hwc = &event->hw; 124 - struct xe_pmu *pmu = &xe->pmu; 125 123 u64 prev, new; 126 - 127 - if (!pmu->registered) { 128 - event->hw.state = PERF_HES_STOPPED; 129 - return; 130 - } 131 124 132 125 prev = local64_read(&hwc->prev_count); 133 126 do { ··· 128 135 } while (!local64_try_cmpxchg(&hwc->prev_count, &prev, new)); 129 136 130 137 local64_add(new - prev, &event->count); 138 + } 139 + 140 + static void xe_pmu_event_read(struct perf_event *event) 141 + { 142 + struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base); 143 + struct xe_pmu *pmu = &xe->pmu; 144 + 145 + if (!pmu->registered) { 146 + event->hw.state = PERF_HES_STOPPED; 147 + return; 148 + } 149 + 150 + xe_pmu_event_update(event); 131 151 } 132 152 133 153 static void xe_pmu_enable(struct perf_event *event) ··· 172 166 173 167 if (pmu->registered) 174 168 if (flags & PERF_EF_UPDATE) 175 - xe_pmu_event_read(event); 169 + xe_pmu_event_update(event); 176 170 177 171 event->hw.state = PERF_HES_STOPPED; 178 172 }