0001
0002
0003
0004
0005
0006 #include <asm/msr.h>
0007
0008 #include "i915_drv.h"
0009 #include "librapl.h"
0010
0011 bool librapl_supported(const struct drm_i915_private *i915)
0012 {
0013
0014 if (IS_DGFX(i915))
0015 return false;
0016
0017 return librapl_energy_uJ();
0018 }
0019
0020 u64 librapl_energy_uJ(void)
0021 {
0022 unsigned long long power;
0023 u32 units;
0024
0025 if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power))
0026 return 0;
0027
0028 units = (power & 0x1f00) >> 8;
0029
0030 if (rdmsrl_safe(MSR_PP1_ENERGY_STATUS, &power))
0031 return 0;
0032
0033 return (1000000 * power) >> units;
0034 }