[igt-dev] [PATCH i-g-t v2 3/8] lib/igt_power: Add hwmon interface to igt_power
Dixit, Ashutosh
ashutosh.dixit at intel.com
Tue Sep 20 19:57:29 UTC 2022
On Mon, 19 Sep 2022 07:44:03 -0700, Riana Tauro wrote:
>
> Modify igt_power to expose functions to read energy, power
> using hwmon and rapl interface
Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
> +/**
> + * igt_power_get_mJ:
> + * @igt_power : power struct
> + * @power_sample: sample of energy and time
> + *
> + * Calculates energy difference between two power samples
Maybe quickly mention the units of energy here too, for hwmon it is micro
joules and rapl it's joules.
> + *
> + * Returns
> + * energy in mJ from hwmon/rapl
> + */
> +double igt_power_get_mJ(const struct igt_power *power,
> + const struct power_sample *p0, const struct power_sample *p1)
> +{
> + if (power->hwmon_fd >= 0)
> + return (p1->energy - p0->energy) * 1e-3;
> + else if (power->rapl.fd >= 0)
> + return ((p1->energy - p0->energy) * power->rapl.scale) * 1e3;
> +
> + return 0;
> +}
More information about the igt-dev
mailing list