mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 00:20:52 -05:00
tools/power turbostat: Add support for /sys/class/drm/card1
On some machines, the graphics device is enumerated as /sys/class/drm/card1 instead of /sys/class/drm/card0. The current implementation does not handle this scenario, resulting in the loss of graphics C6 residency and frequency information. Add support for /sys/class/drm/card1, ensuring that turbostat can retrieve and display the graphics columns for these platforms. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
c7538f3385
commit
03109e2f0d
1 changed files with 34 additions and 14 deletions
|
@ -6476,8 +6476,14 @@ static void set_graphics_fp(char *path, int idx)
|
||||||
gfx_info[idx].fp = fopen_or_die(path, "r");
|
gfx_info[idx].fp = fopen_or_die(path, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enlarge this if there are /sys/class/drm/card2 ... */
|
||||||
|
#define GFX_MAX_CARDS 2
|
||||||
|
|
||||||
static void probe_graphics(void)
|
static void probe_graphics(void)
|
||||||
{
|
{
|
||||||
|
char path[PATH_MAX];
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Xe graphics sysfs knobs */
|
/* Xe graphics sysfs knobs */
|
||||||
if (!access("/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms", R_OK)) {
|
if (!access("/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms", R_OK)) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -6518,22 +6524,36 @@ static void probe_graphics(void)
|
||||||
|
|
||||||
next:
|
next:
|
||||||
/* New i915 graphics sysfs knobs */
|
/* New i915 graphics sysfs knobs */
|
||||||
if (!access("/sys/class/drm/card0/gt/gt0/rc6_residency_ms", R_OK)) {
|
for (i = 0; i < GFX_MAX_CARDS; i++) {
|
||||||
set_graphics_fp("/sys/class/drm/card0/gt/gt0/rc6_residency_ms", GFX_rc6);
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt0/rc6_residency_ms", i);
|
||||||
|
if (!access(path, R_OK))
|
||||||
set_graphics_fp("/sys/class/drm/card0/gt/gt0/rps_cur_freq_mhz", GFX_MHz);
|
break;
|
||||||
|
|
||||||
set_graphics_fp("/sys/class/drm/card0/gt/gt0/rps_act_freq_mhz", GFX_ACTMHz);
|
|
||||||
|
|
||||||
set_graphics_fp("/sys/class/drm/card0/gt/gt1/rc6_residency_ms", SAM_mc6);
|
|
||||||
|
|
||||||
set_graphics_fp("/sys/class/drm/card0/gt/gt1/rps_cur_freq_mhz", SAM_MHz);
|
|
||||||
|
|
||||||
set_graphics_fp("/sys/class/drm/card0/gt/gt1/rps_act_freq_mhz", SAM_ACTMHz);
|
|
||||||
|
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == GFX_MAX_CARDS)
|
||||||
|
goto legacy_i915;
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt0/rc6_residency_ms", i);
|
||||||
|
set_graphics_fp(path, GFX_rc6);
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt0/rps_cur_freq_mhz", i);
|
||||||
|
set_graphics_fp(path, GFX_MHz);
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt0/rps_act_freq_mhz", i);
|
||||||
|
set_graphics_fp(path, GFX_ACTMHz);
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt1/rc6_residency_ms", i);
|
||||||
|
set_graphics_fp(path, SAM_mc6);
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt1/rps_cur_freq_mhz", i);
|
||||||
|
set_graphics_fp(path, SAM_MHz);
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/class/drm/card%d/gt/gt1/rps_act_freq_mhz", i);
|
||||||
|
set_graphics_fp(path, SAM_ACTMHz);
|
||||||
|
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
legacy_i915:
|
||||||
/* Fall back to traditional i915 graphics sysfs knobs */
|
/* Fall back to traditional i915 graphics sysfs knobs */
|
||||||
set_graphics_fp("/sys/class/drm/card0/power/rc6_residency_ms", GFX_rc6);
|
set_graphics_fp("/sys/class/drm/card0/power/rc6_residency_ms", GFX_rc6);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue