Lines Matching +full:micro +full:- +full:watts
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Performance events - AMD Processor Power Reporting Mechanism
5 * Copyright (C) 2016 Advanced Micro Devices, Inc.
16 /* Event code: LSB 8 bits, passed in attr->config any other bit is reserved. */
45 struct hw_perf_event *hwc = &event->hw; in event_update()
49 prev_pwr_acc = hwc->pwr_acc; in event_update()
50 prev_ptsc = hwc->ptsc; in event_update()
56 * final value (delta) is micro-Watts. Then add it to the event count. in event_update()
60 delta -= prev_pwr_acc; in event_update()
62 delta = new_pwr_acc - prev_pwr_acc; in event_update()
65 tdelta = new_ptsc - prev_ptsc; in event_update()
68 local64_add(delta, &event->count); in event_update()
73 if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED))) in __pmu_event_start()
76 event->hw.state = 0; in __pmu_event_start()
78 rdmsrl(MSR_F15H_PTSC, event->hw.ptsc); in __pmu_event_start()
79 rdmsrl(MSR_F15H_CU_PWR_ACCUMULATOR, event->hw.pwr_acc); in __pmu_event_start()
89 struct hw_perf_event *hwc = &event->hw; in pmu_event_stop()
92 if (!(hwc->state & PERF_HES_STOPPED)) in pmu_event_stop()
93 hwc->state |= PERF_HES_STOPPED; in pmu_event_stop()
96 if ((mode & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) { in pmu_event_stop()
102 hwc->state |= PERF_HES_UPTODATE; in pmu_event_stop()
108 struct hw_perf_event *hwc = &event->hw; in pmu_event_add()
110 hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED; in pmu_event_add()
125 u64 cfg = event->attr.config & AMD_POWER_EVENT_MASK; in pmu_event_init()
128 if (event->attr.type != pmu_class.type) in pmu_event_init()
129 return -ENOENT; in pmu_event_init()
132 if (event->attr.sample_period) in pmu_event_init()
133 return -EINVAL; in pmu_event_init()
136 return -EINVAL; in pmu_event_init()
167 EVENT_ATTR_STR(power-pkg, power_pkg, "event=0x01");
169 EVENT_ATTR_STR(power-pkg.unit, power_pkg_unit, "mWatts");
171 /* Convert the count from micro-Watts to milli-Watts. */
172 EVENT_ATTR_STR(power-pkg.scale, power_pkg_scale, "1.000000e-3");
186 PMU_FORMAT_ATTR(event, "config:0-7");
207 /* system-wide only */
268 return -ENODEV; in amd_power_pmu_init()
271 return -ENODEV; in amd_power_pmu_init()
277 return -ENODEV; in amd_power_pmu_init()
285 ret = perf_pmu_register(&pmu_class, "power", -1); in amd_power_pmu_init()