1 // SPDX-License-Identifier: GPL-2.0-only
3 * Common code for Intel Running Average Power Limit (RAPL) support.
4 * Copyright (c) 2019, Intel Corporation.
6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/list.h>
11 #include <linux/types.h>
12 #include <linux/device.h>
13 #include <linux/slab.h>
14 #include <linux/log2.h>
15 #include <linux/bitmap.h>
16 #include <linux/delay.h>
17 #include <linux/sysfs.h>
18 #include <linux/cpu.h>
19 #include <linux/powercap.h>
20 #include <linux/suspend.h>
21 #include <linux/intel_rapl.h>
22 #include <linux/processor.h>
23 #include <linux/platform_device.h>
25 #include <asm/iosf_mbi.h>
26 #include <asm/cpu_device_id.h>
27 #include <asm/intel-family.h>
29 /* bitmasks for RAPL MSRs, used by primitive access functions */
30 #define ENERGY_STATUS_MASK 0xffffffff
32 #define POWER_LIMIT1_MASK 0x7FFF
33 #define POWER_LIMIT1_ENABLE BIT(15)
34 #define POWER_LIMIT1_CLAMP BIT(16)
36 #define POWER_LIMIT2_MASK (0x7FFFULL<<32)
37 #define POWER_LIMIT2_ENABLE BIT_ULL(47)
38 #define POWER_LIMIT2_CLAMP BIT_ULL(48)
39 #define POWER_HIGH_LOCK BIT_ULL(63)
40 #define POWER_LOW_LOCK BIT(31)
42 #define POWER_LIMIT4_MASK 0x1FFF
44 #define TIME_WINDOW1_MASK (0x7FULL<<17)
45 #define TIME_WINDOW2_MASK (0x7FULL<<49)
47 #define POWER_UNIT_OFFSET 0
48 #define POWER_UNIT_MASK 0x0F
50 #define ENERGY_UNIT_OFFSET 0x08
51 #define ENERGY_UNIT_MASK 0x1F00
53 #define TIME_UNIT_OFFSET 0x10
54 #define TIME_UNIT_MASK 0xF0000
56 #define POWER_INFO_MAX_MASK (0x7fffULL<<32)
57 #define POWER_INFO_MIN_MASK (0x7fffULL<<16)
58 #define POWER_INFO_MAX_TIME_WIN_MASK (0x3fULL<<48)
59 #define POWER_INFO_THERMAL_SPEC_MASK 0x7fff
61 #define PERF_STATUS_THROTTLE_TIME_MASK 0xffffffff
62 #define PP_POLICY_MASK 0x1F
64 /* Non HW constants */
65 #define RAPL_PRIMITIVE_DERIVED BIT(1) /* not from raw data */
66 #define RAPL_PRIMITIVE_DUMMY BIT(2)
68 #define TIME_WINDOW_MAX_MSEC 40000
69 #define TIME_WINDOW_MIN_MSEC 250
70 #define ENERGY_UNIT_SCALE 1000 /* scale from driver unit to powercap unit */
72 ARBITRARY_UNIT, /* no translation */
78 /* per domain data, some are optional */
79 #define NR_RAW_PRIMITIVES (NR_RAPL_PRIMITIVES - 2)
81 #define DOMAIN_STATE_INACTIVE BIT(0)
82 #define DOMAIN_STATE_POWER_LIMIT_SET BIT(1)
83 #define DOMAIN_STATE_BIOS_LOCKED BIT(2)
85 static const char pl1_name[] = "long_term";
86 static const char pl2_name[] = "short_term";
87 static const char pl4_name[] = "peak_power";
89 #define power_zone_to_rapl_domain(_zone) \
90 container_of(_zone, struct rapl_domain, power_zone)
92 struct rapl_defaults {
93 u8 floor_freq_reg_addr;
94 int (*check_unit)(struct rapl_package *rp, int cpu);
95 void (*set_floor_freq)(struct rapl_domain *rd, bool mode);
96 u64 (*compute_time_window)(struct rapl_package *rp, u64 val,
98 unsigned int dram_domain_energy_unit;
99 unsigned int psys_domain_energy_unit;
101 static struct rapl_defaults *rapl_defaults;
103 /* Sideband MBI registers */
104 #define IOSF_CPU_POWER_BUDGET_CTL_BYT (0x2)
105 #define IOSF_CPU_POWER_BUDGET_CTL_TNG (0xdf)
107 #define PACKAGE_PLN_INT_SAVED BIT(0)
108 #define MAX_PRIM_NAME (32)
110 /* per domain data. used to describe individual knobs such that access function
111 * can be consolidated into one instead of many inline functions.
113 struct rapl_primitive_info {
117 enum rapl_domain_reg_id id;
122 #define PRIMITIVE_INFO_INIT(p, m, s, i, u, f) { \
131 static void rapl_init_domains(struct rapl_package *rp);
132 static int rapl_read_data_raw(struct rapl_domain *rd,
133 enum rapl_primitives prim,
134 bool xlate, u64 *data);
135 static int rapl_write_data_raw(struct rapl_domain *rd,
136 enum rapl_primitives prim,
137 unsigned long long value);
138 static u64 rapl_unit_xlate(struct rapl_domain *rd,
139 enum unit_type type, u64 value, int to_raw);
140 static void package_power_limit_irq_save(struct rapl_package *rp);
142 static LIST_HEAD(rapl_packages); /* guarded by CPU hotplug lock */
144 static const char *const rapl_domain_names[] = {
152 static int get_energy_counter(struct powercap_zone *power_zone,
155 struct rapl_domain *rd;
158 /* prevent CPU hotplug, make sure the RAPL domain does not go
159 * away while reading the counter.
162 rd = power_zone_to_rapl_domain(power_zone);
164 if (!rapl_read_data_raw(rd, ENERGY_COUNTER, true, &energy_now)) {
165 *energy_raw = energy_now;
175 static int get_max_energy_counter(struct powercap_zone *pcd_dev, u64 *energy)
177 struct rapl_domain *rd = power_zone_to_rapl_domain(pcd_dev);
179 *energy = rapl_unit_xlate(rd, ENERGY_UNIT, ENERGY_STATUS_MASK, 0);
183 static int release_zone(struct powercap_zone *power_zone)
185 struct rapl_domain *rd = power_zone_to_rapl_domain(power_zone);
186 struct rapl_package *rp = rd->rp;
188 /* package zone is the last zone of a package, we can free
189 * memory here since all children has been unregistered.
191 if (rd->id == RAPL_DOMAIN_PACKAGE) {
200 static int find_nr_power_limit(struct rapl_domain *rd)
204 for (i = 0; i < NR_POWER_LIMITS; i++) {
212 static int set_domain_enable(struct powercap_zone *power_zone, bool mode)
214 struct rapl_domain *rd = power_zone_to_rapl_domain(power_zone);
216 if (rd->state & DOMAIN_STATE_BIOS_LOCKED)
220 rapl_write_data_raw(rd, PL1_ENABLE, mode);
221 if (rapl_defaults->set_floor_freq)
222 rapl_defaults->set_floor_freq(rd, mode);
228 static int get_domain_enable(struct powercap_zone *power_zone, bool *mode)
230 struct rapl_domain *rd = power_zone_to_rapl_domain(power_zone);
233 if (rd->state & DOMAIN_STATE_BIOS_LOCKED) {
238 if (rapl_read_data_raw(rd, PL1_ENABLE, true, &val)) {
248 /* per RAPL domain ops, in the order of rapl_domain_type */
249 static const struct powercap_zone_ops zone_ops[] = {
250 /* RAPL_DOMAIN_PACKAGE */
252 .get_energy_uj = get_energy_counter,
253 .get_max_energy_range_uj = get_max_energy_counter,
254 .release = release_zone,
255 .set_enable = set_domain_enable,
256 .get_enable = get_domain_enable,
258 /* RAPL_DOMAIN_PP0 */
260 .get_energy_uj = get_energy_counter,
261 .get_max_energy_range_uj = get_max_energy_counter,
262 .release = release_zone,
263 .set_enable = set_domain_enable,
264 .get_enable = get_domain_enable,
266 /* RAPL_DOMAIN_PP1 */
268 .get_energy_uj = get_energy_counter,
269 .get_max_energy_range_uj = get_max_energy_counter,
270 .release = release_zone,
271 .set_enable = set_domain_enable,
272 .get_enable = get_domain_enable,
274 /* RAPL_DOMAIN_DRAM */
276 .get_energy_uj = get_energy_counter,
277 .get_max_energy_range_uj = get_max_energy_counter,
278 .release = release_zone,
279 .set_enable = set_domain_enable,
280 .get_enable = get_domain_enable,
282 /* RAPL_DOMAIN_PLATFORM */
284 .get_energy_uj = get_energy_counter,
285 .get_max_energy_range_uj = get_max_energy_counter,
286 .release = release_zone,
287 .set_enable = set_domain_enable,
288 .get_enable = get_domain_enable,
293 * Constraint index used by powercap can be different than power limit (PL)
294 * index in that some PLs maybe missing due to non-existent MSRs. So we
295 * need to convert here by finding the valid PLs only (name populated).
297 static int contraint_to_pl(struct rapl_domain *rd, int cid)
301 for (i = 0, j = 0; i < NR_POWER_LIMITS; i++) {
302 if ((rd->rpl[i].name) && j++ == cid) {
303 pr_debug("%s: index %d\n", __func__, i);
307 pr_err("Cannot find matching power limit for constraint %d\n", cid);
312 static int set_power_limit(struct powercap_zone *power_zone, int cid,
315 struct rapl_domain *rd;
316 struct rapl_package *rp;
321 rd = power_zone_to_rapl_domain(power_zone);
322 id = contraint_to_pl(rd, cid);
330 if (rd->state & DOMAIN_STATE_BIOS_LOCKED) {
331 dev_warn(&power_zone->dev,
332 "%s locked by BIOS, monitoring only\n", rd->name);
337 switch (rd->rpl[id].prim_id) {
339 rapl_write_data_raw(rd, POWER_LIMIT1, power_limit);
342 rapl_write_data_raw(rd, POWER_LIMIT2, power_limit);
345 rapl_write_data_raw(rd, POWER_LIMIT4, power_limit);
351 package_power_limit_irq_save(rp);
357 static int get_current_power_limit(struct powercap_zone *power_zone, int cid,
360 struct rapl_domain *rd;
367 rd = power_zone_to_rapl_domain(power_zone);
368 id = contraint_to_pl(rd, cid);
374 switch (rd->rpl[id].prim_id) {
388 if (rapl_read_data_raw(rd, prim, true, &val))
399 static int set_time_window(struct powercap_zone *power_zone, int cid,
402 struct rapl_domain *rd;
407 rd = power_zone_to_rapl_domain(power_zone);
408 id = contraint_to_pl(rd, cid);
414 switch (rd->rpl[id].prim_id) {
416 rapl_write_data_raw(rd, TIME_WINDOW1, window);
419 rapl_write_data_raw(rd, TIME_WINDOW2, window);
430 static int get_time_window(struct powercap_zone *power_zone, int cid,
433 struct rapl_domain *rd;
439 rd = power_zone_to_rapl_domain(power_zone);
440 id = contraint_to_pl(rd, cid);
446 switch (rd->rpl[id].prim_id) {
448 ret = rapl_read_data_raw(rd, TIME_WINDOW1, true, &val);
451 ret = rapl_read_data_raw(rd, TIME_WINDOW2, true, &val);
455 * Time window parameter is not applicable for PL4 entry
456 * so assigining '0' as default value.
473 static const char *get_constraint_name(struct powercap_zone *power_zone,
476 struct rapl_domain *rd;
479 rd = power_zone_to_rapl_domain(power_zone);
480 id = contraint_to_pl(rd, cid);
482 return rd->rpl[id].name;
487 static int get_max_power(struct powercap_zone *power_zone, int id, u64 *data)
489 struct rapl_domain *rd;
495 rd = power_zone_to_rapl_domain(power_zone);
496 switch (rd->rpl[id].prim_id) {
498 prim = THERMAL_SPEC_POWER;
510 if (rapl_read_data_raw(rd, prim, true, &val))
515 /* As a generalization rule, PL4 would be around two times PL2. */
516 if (rd->rpl[id].prim_id == PL4_ENABLE)
524 static const struct powercap_zone_constraint_ops constraint_ops = {
525 .set_power_limit_uw = set_power_limit,
526 .get_power_limit_uw = get_current_power_limit,
527 .set_time_window_us = set_time_window,
528 .get_time_window_us = get_time_window,
529 .get_max_power_uw = get_max_power,
530 .get_name = get_constraint_name,
533 /* called after domain detection and package level data are set */
534 static void rapl_init_domains(struct rapl_package *rp)
536 enum rapl_domain_type i;
537 enum rapl_domain_reg_id j;
538 struct rapl_domain *rd = rp->domains;
540 for (i = 0; i < RAPL_DOMAIN_MAX; i++) {
541 unsigned int mask = rp->domain_map & (1 << i);
547 rd->name = rapl_domain_names[i];
549 rd->rpl[0].prim_id = PL1_ENABLE;
550 rd->rpl[0].name = pl1_name;
553 * The PL2 power domain is applicable for limits two
556 if (rp->priv->limits[i] >= 2) {
557 rd->rpl[1].prim_id = PL2_ENABLE;
558 rd->rpl[1].name = pl2_name;
561 /* Enable PL4 domain if the total power limits are three */
562 if (rp->priv->limits[i] == 3) {
563 rd->rpl[2].prim_id = PL4_ENABLE;
564 rd->rpl[2].name = pl4_name;
567 for (j = 0; j < RAPL_DOMAIN_REG_MAX; j++)
568 rd->regs[j] = rp->priv->regs[i][j];
571 case RAPL_DOMAIN_DRAM:
572 rd->domain_energy_unit =
573 rapl_defaults->dram_domain_energy_unit;
574 if (rd->domain_energy_unit)
575 pr_info("DRAM domain energy unit %dpj\n",
576 rd->domain_energy_unit);
578 case RAPL_DOMAIN_PLATFORM:
579 rd->domain_energy_unit =
580 rapl_defaults->psys_domain_energy_unit;
581 if (rd->domain_energy_unit)
582 pr_info("Platform domain energy unit %dpj\n",
583 rd->domain_energy_unit);
592 static u64 rapl_unit_xlate(struct rapl_domain *rd, enum unit_type type,
593 u64 value, int to_raw)
596 struct rapl_package *rp = rd->rp;
601 units = rp->power_unit;
604 scale = ENERGY_UNIT_SCALE;
605 /* per domain unit takes precedence */
606 if (rd->domain_energy_unit)
607 units = rd->domain_energy_unit;
609 units = rp->energy_unit;
612 return rapl_defaults->compute_time_window(rp, value, to_raw);
619 return div64_u64(value, units) * scale;
623 return div64_u64(value, scale);
626 /* in the order of enum rapl_primitives */
627 static struct rapl_primitive_info rpi[] = {
628 /* name, mask, shift, msr index, unit divisor */
629 PRIMITIVE_INFO_INIT(ENERGY_COUNTER, ENERGY_STATUS_MASK, 0,
630 RAPL_DOMAIN_REG_STATUS, ENERGY_UNIT, 0),
631 PRIMITIVE_INFO_INIT(POWER_LIMIT1, POWER_LIMIT1_MASK, 0,
632 RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
633 PRIMITIVE_INFO_INIT(POWER_LIMIT2, POWER_LIMIT2_MASK, 32,
634 RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
635 PRIMITIVE_INFO_INIT(POWER_LIMIT4, POWER_LIMIT4_MASK, 0,
636 RAPL_DOMAIN_REG_PL4, POWER_UNIT, 0),
637 PRIMITIVE_INFO_INIT(FW_LOCK, POWER_LOW_LOCK, 31,
638 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
639 PRIMITIVE_INFO_INIT(PL1_ENABLE, POWER_LIMIT1_ENABLE, 15,
640 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
641 PRIMITIVE_INFO_INIT(PL1_CLAMP, POWER_LIMIT1_CLAMP, 16,
642 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
643 PRIMITIVE_INFO_INIT(PL2_ENABLE, POWER_LIMIT2_ENABLE, 47,
644 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
645 PRIMITIVE_INFO_INIT(PL2_CLAMP, POWER_LIMIT2_CLAMP, 48,
646 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
647 PRIMITIVE_INFO_INIT(PL4_ENABLE, POWER_LIMIT4_MASK, 0,
648 RAPL_DOMAIN_REG_PL4, ARBITRARY_UNIT, 0),
649 PRIMITIVE_INFO_INIT(TIME_WINDOW1, TIME_WINDOW1_MASK, 17,
650 RAPL_DOMAIN_REG_LIMIT, TIME_UNIT, 0),
651 PRIMITIVE_INFO_INIT(TIME_WINDOW2, TIME_WINDOW2_MASK, 49,
652 RAPL_DOMAIN_REG_LIMIT, TIME_UNIT, 0),
653 PRIMITIVE_INFO_INIT(THERMAL_SPEC_POWER, POWER_INFO_THERMAL_SPEC_MASK,
654 0, RAPL_DOMAIN_REG_INFO, POWER_UNIT, 0),
655 PRIMITIVE_INFO_INIT(MAX_POWER, POWER_INFO_MAX_MASK, 32,
656 RAPL_DOMAIN_REG_INFO, POWER_UNIT, 0),
657 PRIMITIVE_INFO_INIT(MIN_POWER, POWER_INFO_MIN_MASK, 16,
658 RAPL_DOMAIN_REG_INFO, POWER_UNIT, 0),
659 PRIMITIVE_INFO_INIT(MAX_TIME_WINDOW, POWER_INFO_MAX_TIME_WIN_MASK, 48,
660 RAPL_DOMAIN_REG_INFO, TIME_UNIT, 0),
661 PRIMITIVE_INFO_INIT(THROTTLED_TIME, PERF_STATUS_THROTTLE_TIME_MASK, 0,
662 RAPL_DOMAIN_REG_PERF, TIME_UNIT, 0),
663 PRIMITIVE_INFO_INIT(PRIORITY_LEVEL, PP_POLICY_MASK, 0,
664 RAPL_DOMAIN_REG_POLICY, ARBITRARY_UNIT, 0),
666 PRIMITIVE_INFO_INIT(AVERAGE_POWER, 0, 0, 0, POWER_UNIT,
667 RAPL_PRIMITIVE_DERIVED),
671 /* Read primitive data based on its related struct rapl_primitive_info.
672 * if xlate flag is set, return translated data based on data units, i.e.
673 * time, energy, and power.
674 * RAPL MSRs are non-architectual and are laid out not consistently across
675 * domains. Here we use primitive info to allow writing consolidated access
677 * For a given primitive, it is processed by MSR mask and shift. Unit conversion
678 * is pre-assigned based on RAPL unit MSRs read at init time.
679 * 63-------------------------- 31--------------------------- 0
681 * | |<- shift ----------------|
682 * 63-------------------------- 31--------------------------- 0
684 static int rapl_read_data_raw(struct rapl_domain *rd,
685 enum rapl_primitives prim, bool xlate, u64 *data)
688 struct rapl_primitive_info *rp = &rpi[prim];
689 struct reg_action ra;
692 if (!rp->name || rp->flag & RAPL_PRIMITIVE_DUMMY)
695 ra.reg = rd->regs[rp->id];
699 cpu = rd->rp->lead_cpu;
701 /* domain with 2 limits has different bit */
702 if (prim == FW_LOCK && rd->rp->priv->limits[rd->id] == 2) {
703 rp->mask = POWER_HIGH_LOCK;
706 /* non-hardware data are collected by the polling thread */
707 if (rp->flag & RAPL_PRIMITIVE_DERIVED) {
708 *data = rd->rdd.primitives[prim];
714 if (rd->rp->priv->read_raw(cpu, &ra)) {
715 pr_debug("failed to read reg 0x%llx on cpu %d\n", ra.reg, cpu);
719 value = ra.value >> rp->shift;
722 *data = rapl_unit_xlate(rd, rp->unit, value, 0);
729 /* Similar use of primitive info in the read counterpart */
730 static int rapl_write_data_raw(struct rapl_domain *rd,
731 enum rapl_primitives prim,
732 unsigned long long value)
734 struct rapl_primitive_info *rp = &rpi[prim];
737 struct reg_action ra;
740 cpu = rd->rp->lead_cpu;
741 bits = rapl_unit_xlate(rd, rp->unit, value, 1);
745 memset(&ra, 0, sizeof(ra));
747 ra.reg = rd->regs[rp->id];
751 ret = rd->rp->priv->write_raw(cpu, &ra);
757 * Raw RAPL data stored in MSRs are in certain scales. We need to
758 * convert them into standard units based on the units reported in
759 * the RAPL unit MSRs. This is specific to CPUs as the method to
760 * calculate units differ on different CPUs.
761 * We convert the units to below format based on CPUs.
763 * energy unit: picoJoules : Represented in picoJoules by default
764 * power unit : microWatts : Represented in milliWatts by default
765 * time unit : microseconds: Represented in seconds by default
767 static int rapl_check_unit_core(struct rapl_package *rp, int cpu)
769 struct reg_action ra;
772 ra.reg = rp->priv->reg_unit;
774 if (rp->priv->read_raw(cpu, &ra)) {
775 pr_err("Failed to read power unit REG 0x%llx on CPU %d, exit.\n",
776 rp->priv->reg_unit, cpu);
780 value = (ra.value & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
781 rp->energy_unit = ENERGY_UNIT_SCALE * 1000000 / (1 << value);
783 value = (ra.value & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET;
784 rp->power_unit = 1000000 / (1 << value);
786 value = (ra.value & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET;
787 rp->time_unit = 1000000 / (1 << value);
789 pr_debug("Core CPU %s energy=%dpJ, time=%dus, power=%duW\n",
790 rp->name, rp->energy_unit, rp->time_unit, rp->power_unit);
795 static int rapl_check_unit_atom(struct rapl_package *rp, int cpu)
797 struct reg_action ra;
800 ra.reg = rp->priv->reg_unit;
802 if (rp->priv->read_raw(cpu, &ra)) {
803 pr_err("Failed to read power unit REG 0x%llx on CPU %d, exit.\n",
804 rp->priv->reg_unit, cpu);
808 value = (ra.value & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
809 rp->energy_unit = ENERGY_UNIT_SCALE * 1 << value;
811 value = (ra.value & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET;
812 rp->power_unit = (1 << value) * 1000;
814 value = (ra.value & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET;
815 rp->time_unit = 1000000 / (1 << value);
817 pr_debug("Atom %s energy=%dpJ, time=%dus, power=%duW\n",
818 rp->name, rp->energy_unit, rp->time_unit, rp->power_unit);
823 static void power_limit_irq_save_cpu(void *info)
826 struct rapl_package *rp = (struct rapl_package *)info;
828 /* save the state of PLN irq mask bit before disabling it */
829 rdmsr_safe(MSR_IA32_PACKAGE_THERM_INTERRUPT, &l, &h);
830 if (!(rp->power_limit_irq & PACKAGE_PLN_INT_SAVED)) {
831 rp->power_limit_irq = l & PACKAGE_THERM_INT_PLN_ENABLE;
832 rp->power_limit_irq |= PACKAGE_PLN_INT_SAVED;
834 l &= ~PACKAGE_THERM_INT_PLN_ENABLE;
835 wrmsr_safe(MSR_IA32_PACKAGE_THERM_INTERRUPT, l, h);
839 * When package power limit is set artificially low by RAPL, LVT
840 * thermal interrupt for package power limit should be ignored
841 * since we are not really exceeding the real limit. The intention
842 * is to avoid excessive interrupts while we are trying to save power.
843 * A useful feature might be routing the package_power_limit interrupt
844 * to userspace via eventfd. once we have a usecase, this is simple
845 * to do by adding an atomic notifier.
848 static void package_power_limit_irq_save(struct rapl_package *rp)
850 if (!boot_cpu_has(X86_FEATURE_PTS) || !boot_cpu_has(X86_FEATURE_PLN))
853 smp_call_function_single(rp->lead_cpu, power_limit_irq_save_cpu, rp, 1);
857 * Restore per package power limit interrupt enable state. Called from cpu
858 * hotplug code on package removal.
860 static void package_power_limit_irq_restore(struct rapl_package *rp)
864 if (!boot_cpu_has(X86_FEATURE_PTS) || !boot_cpu_has(X86_FEATURE_PLN))
867 /* irq enable state not saved, nothing to restore */
868 if (!(rp->power_limit_irq & PACKAGE_PLN_INT_SAVED))
871 rdmsr_safe(MSR_IA32_PACKAGE_THERM_INTERRUPT, &l, &h);
873 if (rp->power_limit_irq & PACKAGE_THERM_INT_PLN_ENABLE)
874 l |= PACKAGE_THERM_INT_PLN_ENABLE;
876 l &= ~PACKAGE_THERM_INT_PLN_ENABLE;
878 wrmsr_safe(MSR_IA32_PACKAGE_THERM_INTERRUPT, l, h);
881 static void set_floor_freq_default(struct rapl_domain *rd, bool mode)
883 int nr_powerlimit = find_nr_power_limit(rd);
885 /* always enable clamp such that p-state can go below OS requested
886 * range. power capping priority over guranteed frequency.
888 rapl_write_data_raw(rd, PL1_CLAMP, mode);
890 /* some domains have pl2 */
891 if (nr_powerlimit > 1) {
892 rapl_write_data_raw(rd, PL2_ENABLE, mode);
893 rapl_write_data_raw(rd, PL2_CLAMP, mode);
897 static void set_floor_freq_atom(struct rapl_domain *rd, bool enable)
899 static u32 power_ctrl_orig_val;
902 if (!rapl_defaults->floor_freq_reg_addr) {
903 pr_err("Invalid floor frequency config register\n");
907 if (!power_ctrl_orig_val)
908 iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_CR_READ,
909 rapl_defaults->floor_freq_reg_addr,
910 &power_ctrl_orig_val);
911 mdata = power_ctrl_orig_val;
913 mdata &= ~(0x7f << 8);
916 iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_CR_WRITE,
917 rapl_defaults->floor_freq_reg_addr, mdata);
920 static u64 rapl_compute_time_window_core(struct rapl_package *rp, u64 value,
923 u64 f, y; /* fraction and exp. used for time unit */
926 * Special processing based on 2^Y*(1+F/4), refer
927 * to Intel Software Developer's manual Vol.3B: CH 14.9.3.
930 f = (value & 0x60) >> 5;
932 value = (1 << y) * (4 + f) * rp->time_unit / 4;
934 do_div(value, rp->time_unit);
936 f = div64_u64(4 * (value - (1 << y)), 1 << y);
937 value = (y & 0x1f) | ((f & 0x3) << 5);
942 static u64 rapl_compute_time_window_atom(struct rapl_package *rp, u64 value,
946 * Atom time unit encoding is straight forward val * time_unit,
947 * where time_unit is default to 1 sec. Never 0.
950 return (value) ? value *= rp->time_unit : rp->time_unit;
952 value = div64_u64(value, rp->time_unit);
957 static const struct rapl_defaults rapl_defaults_core = {
958 .floor_freq_reg_addr = 0,
959 .check_unit = rapl_check_unit_core,
960 .set_floor_freq = set_floor_freq_default,
961 .compute_time_window = rapl_compute_time_window_core,
964 static const struct rapl_defaults rapl_defaults_hsw_server = {
965 .check_unit = rapl_check_unit_core,
966 .set_floor_freq = set_floor_freq_default,
967 .compute_time_window = rapl_compute_time_window_core,
968 .dram_domain_energy_unit = 15300,
971 static const struct rapl_defaults rapl_defaults_spr_server = {
972 .check_unit = rapl_check_unit_core,
973 .set_floor_freq = set_floor_freq_default,
974 .compute_time_window = rapl_compute_time_window_core,
975 .dram_domain_energy_unit = 15300,
976 .psys_domain_energy_unit = 1000000000,
979 static const struct rapl_defaults rapl_defaults_byt = {
980 .floor_freq_reg_addr = IOSF_CPU_POWER_BUDGET_CTL_BYT,
981 .check_unit = rapl_check_unit_atom,
982 .set_floor_freq = set_floor_freq_atom,
983 .compute_time_window = rapl_compute_time_window_atom,
986 static const struct rapl_defaults rapl_defaults_tng = {
987 .floor_freq_reg_addr = IOSF_CPU_POWER_BUDGET_CTL_TNG,
988 .check_unit = rapl_check_unit_atom,
989 .set_floor_freq = set_floor_freq_atom,
990 .compute_time_window = rapl_compute_time_window_atom,
993 static const struct rapl_defaults rapl_defaults_ann = {
994 .floor_freq_reg_addr = 0,
995 .check_unit = rapl_check_unit_atom,
996 .set_floor_freq = NULL,
997 .compute_time_window = rapl_compute_time_window_atom,
1000 static const struct rapl_defaults rapl_defaults_cht = {
1001 .floor_freq_reg_addr = 0,
1002 .check_unit = rapl_check_unit_atom,
1003 .set_floor_freq = NULL,
1004 .compute_time_window = rapl_compute_time_window_atom,
1007 static const struct x86_cpu_id rapl_ids[] __initconst = {
1008 X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &rapl_defaults_core),
1009 X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &rapl_defaults_core),
1011 X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE, &rapl_defaults_core),
1012 X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE_X, &rapl_defaults_core),
1014 X86_MATCH_INTEL_FAM6_MODEL(HASWELL, &rapl_defaults_core),
1015 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_L, &rapl_defaults_core),
1016 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_G, &rapl_defaults_core),
1017 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, &rapl_defaults_hsw_server),
1019 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL, &rapl_defaults_core),
1020 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_G, &rapl_defaults_core),
1021 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_D, &rapl_defaults_core),
1022 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, &rapl_defaults_hsw_server),
1024 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, &rapl_defaults_core),
1025 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, &rapl_defaults_core),
1026 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &rapl_defaults_hsw_server),
1027 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, &rapl_defaults_core),
1028 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, &rapl_defaults_core),
1029 X86_MATCH_INTEL_FAM6_MODEL(CANNONLAKE_L, &rapl_defaults_core),
1030 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L, &rapl_defaults_core),
1031 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE, &rapl_defaults_core),
1032 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_NNPI, &rapl_defaults_core),
1033 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &rapl_defaults_hsw_server),
1034 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, &rapl_defaults_hsw_server),
1035 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L, &rapl_defaults_core),
1036 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, &rapl_defaults_core),
1037 X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L, &rapl_defaults_core),
1038 X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE, &rapl_defaults_core),
1039 X86_MATCH_INTEL_FAM6_MODEL(ROCKETLAKE, &rapl_defaults_core),
1040 X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &rapl_defaults_spr_server),
1042 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, &rapl_defaults_byt),
1043 X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, &rapl_defaults_cht),
1044 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &rapl_defaults_tng),
1045 X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT_MID, &rapl_defaults_ann),
1046 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, &rapl_defaults_core),
1047 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_PLUS, &rapl_defaults_core),
1048 X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D, &rapl_defaults_core),
1049 X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT, &rapl_defaults_core),
1050 X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &rapl_defaults_core),
1051 X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_L, &rapl_defaults_core),
1053 X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &rapl_defaults_hsw_server),
1054 X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &rapl_defaults_hsw_server),
1057 MODULE_DEVICE_TABLE(x86cpu, rapl_ids);
1059 /* Read once for all raw primitive data for domains */
1060 static void rapl_update_domain_data(struct rapl_package *rp)
1065 for (dmn = 0; dmn < rp->nr_domains; dmn++) {
1066 pr_debug("update %s domain %s data\n", rp->name,
1067 rp->domains[dmn].name);
1068 /* exclude non-raw primitives */
1069 for (prim = 0; prim < NR_RAW_PRIMITIVES; prim++) {
1070 if (!rapl_read_data_raw(&rp->domains[dmn], prim,
1071 rpi[prim].unit, &val))
1072 rp->domains[dmn].rdd.primitives[prim] = val;
1078 static int rapl_package_register_powercap(struct rapl_package *rp)
1080 struct rapl_domain *rd;
1081 struct powercap_zone *power_zone = NULL;
1084 /* Update the domain data of the new package */
1085 rapl_update_domain_data(rp);
1087 /* first we register package domain as the parent zone */
1088 for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
1089 if (rd->id == RAPL_DOMAIN_PACKAGE) {
1090 nr_pl = find_nr_power_limit(rd);
1091 pr_debug("register package domain %s\n", rp->name);
1092 power_zone = powercap_register_zone(&rd->power_zone,
1093 rp->priv->control_type, rp->name,
1094 NULL, &zone_ops[rd->id], nr_pl,
1096 if (IS_ERR(power_zone)) {
1097 pr_debug("failed to register power zone %s\n",
1099 return PTR_ERR(power_zone);
1101 /* track parent zone in per package/socket data */
1102 rp->power_zone = power_zone;
1103 /* done, only one package domain per socket */
1108 pr_err("no package domain found, unknown topology!\n");
1111 /* now register domains as children of the socket/package */
1112 for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
1113 if (rd->id == RAPL_DOMAIN_PACKAGE)
1115 /* number of power limits per domain varies */
1116 nr_pl = find_nr_power_limit(rd);
1117 power_zone = powercap_register_zone(&rd->power_zone,
1118 rp->priv->control_type,
1119 rd->name, rp->power_zone,
1120 &zone_ops[rd->id], nr_pl,
1123 if (IS_ERR(power_zone)) {
1124 pr_debug("failed to register power_zone, %s:%s\n",
1125 rp->name, rd->name);
1126 ret = PTR_ERR(power_zone);
1134 * Clean up previously initialized domains within the package if we
1135 * failed after the first domain setup.
1137 while (--rd >= rp->domains) {
1138 pr_debug("unregister %s domain %s\n", rp->name, rd->name);
1139 powercap_unregister_zone(rp->priv->control_type,
1146 int rapl_add_platform_domain(struct rapl_if_priv *priv)
1148 struct rapl_domain *rd;
1149 struct powercap_zone *power_zone;
1150 struct reg_action ra;
1153 ra.reg = priv->regs[RAPL_DOMAIN_PLATFORM][RAPL_DOMAIN_REG_STATUS];
1155 ret = priv->read_raw(0, &ra);
1156 if (ret || !ra.value)
1159 ra.reg = priv->regs[RAPL_DOMAIN_PLATFORM][RAPL_DOMAIN_REG_LIMIT];
1161 ret = priv->read_raw(0, &ra);
1162 if (ret || !ra.value)
1165 rd = kzalloc(sizeof(*rd), GFP_KERNEL);
1169 rd->name = rapl_domain_names[RAPL_DOMAIN_PLATFORM];
1170 rd->id = RAPL_DOMAIN_PLATFORM;
1171 rd->regs[RAPL_DOMAIN_REG_LIMIT] =
1172 priv->regs[RAPL_DOMAIN_PLATFORM][RAPL_DOMAIN_REG_LIMIT];
1173 rd->regs[RAPL_DOMAIN_REG_STATUS] =
1174 priv->regs[RAPL_DOMAIN_PLATFORM][RAPL_DOMAIN_REG_STATUS];
1175 rd->rpl[0].prim_id = PL1_ENABLE;
1176 rd->rpl[0].name = pl1_name;
1177 rd->rpl[1].prim_id = PL2_ENABLE;
1178 rd->rpl[1].name = pl2_name;
1179 rd->rp = rapl_find_package_domain(0, priv);
1181 power_zone = powercap_register_zone(&rd->power_zone, priv->control_type,
1183 &zone_ops[RAPL_DOMAIN_PLATFORM],
1184 2, &constraint_ops);
1186 if (IS_ERR(power_zone)) {
1188 return PTR_ERR(power_zone);
1191 priv->platform_rapl_domain = rd;
1195 EXPORT_SYMBOL_GPL(rapl_add_platform_domain);
1197 void rapl_remove_platform_domain(struct rapl_if_priv *priv)
1199 if (priv->platform_rapl_domain) {
1200 powercap_unregister_zone(priv->control_type,
1201 &priv->platform_rapl_domain->power_zone);
1202 kfree(priv->platform_rapl_domain);
1205 EXPORT_SYMBOL_GPL(rapl_remove_platform_domain);
1207 static int rapl_check_domain(int cpu, int domain, struct rapl_package *rp)
1209 struct reg_action ra;
1212 case RAPL_DOMAIN_PACKAGE:
1213 case RAPL_DOMAIN_PP0:
1214 case RAPL_DOMAIN_PP1:
1215 case RAPL_DOMAIN_DRAM:
1216 ra.reg = rp->priv->regs[domain][RAPL_DOMAIN_REG_STATUS];
1218 case RAPL_DOMAIN_PLATFORM:
1219 /* PSYS(PLATFORM) is not a CPU domain, so avoid printng error */
1222 pr_err("invalid domain id %d\n", domain);
1225 /* make sure domain counters are available and contains non-zero
1226 * values, otherwise skip it.
1230 if (rp->priv->read_raw(cpu, &ra) || !ra.value)
1237 * Check if power limits are available. Two cases when they are not available:
1238 * 1. Locked by BIOS, in this case we still provide read-only access so that
1239 * users can see what limit is set by the BIOS.
1240 * 2. Some CPUs make some domains monitoring only which means PLx MSRs may not
1241 * exist at all. In this case, we do not show the constraints in powercap.
1243 * Called after domains are detected and initialized.
1245 static void rapl_detect_powerlimit(struct rapl_domain *rd)
1250 /* check if the domain is locked by BIOS, ignore if MSR doesn't exist */
1251 if (!rapl_read_data_raw(rd, FW_LOCK, false, &val64)) {
1253 pr_info("RAPL %s domain %s locked by BIOS\n",
1254 rd->rp->name, rd->name);
1255 rd->state |= DOMAIN_STATE_BIOS_LOCKED;
1258 /* check if power limit MSR exists, otherwise domain is monitoring only */
1259 for (i = 0; i < NR_POWER_LIMITS; i++) {
1260 int prim = rd->rpl[i].prim_id;
1262 if (rapl_read_data_raw(rd, prim, false, &val64))
1263 rd->rpl[i].name = NULL;
1267 /* Detect active and valid domains for the given CPU, caller must
1268 * ensure the CPU belongs to the targeted package and CPU hotlug is disabled.
1270 static int rapl_detect_domains(struct rapl_package *rp, int cpu)
1272 struct rapl_domain *rd;
1275 for (i = 0; i < RAPL_DOMAIN_MAX; i++) {
1276 /* use physical package id to read counters */
1277 if (!rapl_check_domain(cpu, i, rp)) {
1278 rp->domain_map |= 1 << i;
1279 pr_info("Found RAPL domain %s\n", rapl_domain_names[i]);
1282 rp->nr_domains = bitmap_weight(&rp->domain_map, RAPL_DOMAIN_MAX);
1283 if (!rp->nr_domains) {
1284 pr_debug("no valid rapl domains found in %s\n", rp->name);
1287 pr_debug("found %d domains on %s\n", rp->nr_domains, rp->name);
1289 rp->domains = kcalloc(rp->nr_domains + 1, sizeof(struct rapl_domain),
1294 rapl_init_domains(rp);
1296 for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++)
1297 rapl_detect_powerlimit(rd);
1302 /* called from CPU hotplug notifier, hotplug lock held */
1303 void rapl_remove_package(struct rapl_package *rp)
1305 struct rapl_domain *rd, *rd_package = NULL;
1307 package_power_limit_irq_restore(rp);
1309 for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
1310 rapl_write_data_raw(rd, PL1_ENABLE, 0);
1311 rapl_write_data_raw(rd, PL1_CLAMP, 0);
1312 if (find_nr_power_limit(rd) > 1) {
1313 rapl_write_data_raw(rd, PL2_ENABLE, 0);
1314 rapl_write_data_raw(rd, PL2_CLAMP, 0);
1315 rapl_write_data_raw(rd, PL4_ENABLE, 0);
1317 if (rd->id == RAPL_DOMAIN_PACKAGE) {
1321 pr_debug("remove package, undo power limit on %s: %s\n",
1322 rp->name, rd->name);
1323 powercap_unregister_zone(rp->priv->control_type,
1326 /* do parent zone last */
1327 powercap_unregister_zone(rp->priv->control_type,
1328 &rd_package->power_zone);
1329 list_del(&rp->plist);
1332 EXPORT_SYMBOL_GPL(rapl_remove_package);
1334 /* caller to ensure CPU hotplug lock is held */
1335 struct rapl_package *rapl_find_package_domain(int cpu, struct rapl_if_priv *priv)
1337 int id = topology_logical_die_id(cpu);
1338 struct rapl_package *rp;
1340 list_for_each_entry(rp, &rapl_packages, plist) {
1342 && rp->priv->control_type == priv->control_type)
1348 EXPORT_SYMBOL_GPL(rapl_find_package_domain);
1350 /* called from CPU hotplug notifier, hotplug lock held */
1351 struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
1353 int id = topology_logical_die_id(cpu);
1354 struct rapl_package *rp;
1355 struct cpuinfo_x86 *c = &cpu_data(cpu);
1359 return ERR_PTR(-ENODEV);
1361 rp = kzalloc(sizeof(struct rapl_package), GFP_KERNEL);
1363 return ERR_PTR(-ENOMEM);
1365 /* add the new package to the list */
1370 if (topology_max_die_per_package() > 1)
1371 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH,
1372 "package-%d-die-%d", c->phys_proc_id, c->cpu_die_id);
1374 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH, "package-%d",
1377 /* check if the package contains valid domains */
1378 if (rapl_detect_domains(rp, cpu) || rapl_defaults->check_unit(rp, cpu)) {
1380 goto err_free_package;
1382 ret = rapl_package_register_powercap(rp);
1384 INIT_LIST_HEAD(&rp->plist);
1385 list_add(&rp->plist, &rapl_packages);
1392 return ERR_PTR(ret);
1394 EXPORT_SYMBOL_GPL(rapl_add_package);
1396 static void power_limit_state_save(void)
1398 struct rapl_package *rp;
1399 struct rapl_domain *rd;
1403 list_for_each_entry(rp, &rapl_packages, plist) {
1404 if (!rp->power_zone)
1406 rd = power_zone_to_rapl_domain(rp->power_zone);
1407 nr_pl = find_nr_power_limit(rd);
1408 for (i = 0; i < nr_pl; i++) {
1409 switch (rd->rpl[i].prim_id) {
1411 ret = rapl_read_data_raw(rd,
1413 &rd->rpl[i].last_power_limit);
1415 rd->rpl[i].last_power_limit = 0;
1418 ret = rapl_read_data_raw(rd,
1420 &rd->rpl[i].last_power_limit);
1422 rd->rpl[i].last_power_limit = 0;
1425 ret = rapl_read_data_raw(rd,
1427 &rd->rpl[i].last_power_limit);
1429 rd->rpl[i].last_power_limit = 0;
1437 static void power_limit_state_restore(void)
1439 struct rapl_package *rp;
1440 struct rapl_domain *rd;
1444 list_for_each_entry(rp, &rapl_packages, plist) {
1445 if (!rp->power_zone)
1447 rd = power_zone_to_rapl_domain(rp->power_zone);
1448 nr_pl = find_nr_power_limit(rd);
1449 for (i = 0; i < nr_pl; i++) {
1450 switch (rd->rpl[i].prim_id) {
1452 if (rd->rpl[i].last_power_limit)
1453 rapl_write_data_raw(rd, POWER_LIMIT1,
1454 rd->rpl[i].last_power_limit);
1457 if (rd->rpl[i].last_power_limit)
1458 rapl_write_data_raw(rd, POWER_LIMIT2,
1459 rd->rpl[i].last_power_limit);
1462 if (rd->rpl[i].last_power_limit)
1463 rapl_write_data_raw(rd, POWER_LIMIT4,
1464 rd->rpl[i].last_power_limit);
1472 static int rapl_pm_callback(struct notifier_block *nb,
1473 unsigned long mode, void *_unused)
1476 case PM_SUSPEND_PREPARE:
1477 power_limit_state_save();
1479 case PM_POST_SUSPEND:
1480 power_limit_state_restore();
1486 static struct notifier_block rapl_pm_notifier = {
1487 .notifier_call = rapl_pm_callback,
1490 static struct platform_device *rapl_msr_platdev;
1492 static int __init rapl_init(void)
1494 const struct x86_cpu_id *id;
1497 id = x86_match_cpu(rapl_ids);
1499 pr_err("driver does not support CPU family %d model %d\n",
1500 boot_cpu_data.x86, boot_cpu_data.x86_model);
1505 rapl_defaults = (struct rapl_defaults *)id->driver_data;
1507 ret = register_pm_notifier(&rapl_pm_notifier);
1511 rapl_msr_platdev = platform_device_alloc("intel_rapl_msr", 0);
1512 if (!rapl_msr_platdev) {
1517 ret = platform_device_add(rapl_msr_platdev);
1519 platform_device_put(rapl_msr_platdev);
1523 unregister_pm_notifier(&rapl_pm_notifier);
1528 static void __exit rapl_exit(void)
1530 platform_device_unregister(rapl_msr_platdev);
1531 unregister_pm_notifier(&rapl_pm_notifier);
1534 fs_initcall(rapl_init);
1535 module_exit(rapl_exit);
1537 MODULE_DESCRIPTION("Intel Runtime Average Power Limit (RAPL) common code");
1538 MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>");
1539 MODULE_LICENSE("GPL v2");