Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / selftests / librapl.c
blob58710ac3f9799b519d8ee16adce7a5ca15375d7e
1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright © 2020 Intel Corporation
4 */
6 #include <asm/msr.h>
8 #include "librapl.h"
10 u64 librapl_energy_uJ(void)
12 unsigned long long power;
13 u32 units;
15 if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &power))
16 return 0;
18 units = (power & 0x1f00) >> 8;
20 if (rdmsrl_safe(MSR_PP1_ENERGY_STATUS, &power))
21 return 0;
23 return (1000000 * power) >> units; /* convert to uJ */