Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
To: intel-gfx@lists.freedesktop.org, igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/4] lib: Make SLPC helper function per GT
Date: Tue, 25 Apr 2023 09:24:03 -0700	[thread overview]
Message-ID: <20230425162405.1730513-3-vinay.belgaumkar@intel.com> (raw)
In-Reply-To: <20230425162405.1730513-1-vinay.belgaumkar@intel.com>

Use default of 0 where GT id is not being used.

Fixes: https://gitlab.freedesktop.org/drm/intel/-/issues/8308

v2: Add a helper for GT 0 (Ashutosh)
v3: Additional review comments (Ashutosh)
v4: Return false if slpc debugfs is not found

Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 lib/igt_pm.c | 37 ++++++++++++++++++++++++++++---------
 lib/igt_pm.h |  3 ++-
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 704acf7d..e60b09a7 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1329,21 +1329,40 @@ void igt_pm_print_pci_card_runtime_status(void)
 	}
 }
 
-bool i915_is_slpc_enabled(int fd)
+/**
+ * i915_is_slpc_enabled_gt:
+ * @drm_fd: DRM file descriptor
+ * @gt: GT id
+ * Check if SLPC is enabled on a GT
+ */
+bool i915_is_slpc_enabled_gt(int drm_fd, int gt)
 {
-	int debugfs_fd = igt_debugfs_dir(fd);
+	int dir, debugfs_fd;
 	char buf[4096] = {};
-	int len;
 
-	igt_require(debugfs_fd != -1);
+	dir = igt_debugfs_gt_dir(drm_fd, gt);
+	igt_require(dir);
+
+	debugfs_fd = openat(dir, "uc/guc_slpc_info", O_RDONLY);
+	/* if guc_slpc_info not present then return false */
+	if (debugfs_fd < 0)
+		return false;
+
+	read(debugfs_fd, buf, sizeof(buf)-1);
 
-	len = igt_debugfs_simple_read(debugfs_fd, "gt/uc/guc_slpc_info", buf, sizeof(buf));
 	close(debugfs_fd);
 
-	if (len < 0)
-		return false;
-	else
-		return strstr(buf, "SLPC state: running");
+	return strstr(buf, "SLPC state: running");
+}
+
+/**
+ * i915_is_slpc_enabled:
+ * @drm_fd: DRM file descriptor
+ * Check if SLPC is enabled for the device
+ */
+bool i915_is_slpc_enabled(int drm_fd)
+{
+	return i915_is_slpc_enabled_gt(drm_fd, 0);
 }
 
 int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index d0d6d673..448cf42d 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -84,7 +84,8 @@ void igt_pm_set_d3cold_allowed(struct igt_device_card *card, const char *val);
 void igt_pm_setup_pci_card_runtime_pm(struct pci_device *pci_dev);
 void igt_pm_restore_pci_card_runtime_pm(void);
 void igt_pm_print_pci_card_runtime_status(void);
-bool i915_is_slpc_enabled(int fd);
+bool i915_is_slpc_enabled_gt(int drm_fd, int gt);
+bool i915_is_slpc_enabled(int drm_fd);
 int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 int igt_pm_get_runtime_usage(struct pci_device *pci_dev);
 
-- 
2.38.1

  parent reply	other threads:[~2023-04-25 16:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 16:24 [igt-dev] [PATCH v7 i-g-t 0/4] tests/slpc: Add basic IGT test Vinay Belgaumkar
2023-04-25 16:24 ` [igt-dev] [PATCH i-g-t 1/4] lib/debugfs: Add per GT debugfs helpers Vinay Belgaumkar
2023-04-25 16:24 ` Vinay Belgaumkar [this message]
2023-04-25 16:24 ` [igt-dev] [PATCH i-g-t 3/4] i915_pm_freq_api: Add some basic SLPC igt tests Vinay Belgaumkar
2023-04-26 20:40   ` Dixit, Ashutosh
2023-04-27 16:24     ` [igt-dev] [Intel-gfx] " Kamil Konieczny
2023-04-27 16:40       ` Dixit, Ashutosh
2023-04-25 16:24 ` [igt-dev] [PATCH i-g-t 4/4] HAX: tests/i915: Try out the SLPC IGT tests Vinay Belgaumkar
2023-04-25 20:54 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/slpc: Add basic IGT test (rev8) Patchwork
2023-04-25 22:44   ` Belgaumkar, Vinay
  -- strict thread matches above, loose matches on Subject: below --
2023-04-22  1:00 [igt-dev] [PATCH v7 i-g-t 0/4] tests/slpc: Add basic IGT test Vinay Belgaumkar
2023-04-22  1:01 ` [igt-dev] [PATCH i-g-t 2/4] lib: Make SLPC helper function per GT Vinay Belgaumkar
2023-04-14 19:16 [igt-dev] [PATCH v6 i-g-t 0/4] tests/slpc: Add basic IGT test Vinay Belgaumkar
2023-04-14 19:16 ` [igt-dev] [PATCH i-g-t 2/4] lib: Make SLPC helper function per GT Vinay Belgaumkar
2023-04-14 20:25   ` Dixit, Ashutosh
2023-04-18  0:26     ` Belgaumkar, Vinay
2023-04-23 20:16     ` Belgaumkar, Vinay
2023-04-24 16:55       ` Dixit, Ashutosh
2023-04-24 17:07         ` Dixit, Ashutosh
2023-04-24 17:13           ` Dixit, Ashutosh
2023-04-13 22:44 [igt-dev] [PATCH v5 i-g-t 0/4] tests/slpc: Add basic IGT test Vinay Belgaumkar
2023-04-13 22:44 ` [igt-dev] [PATCH i-g-t 2/4] lib: Make SLPC helper function per GT Vinay Belgaumkar
2023-04-14 18:10   ` Dixit, Ashutosh
2023-04-14 19:15     ` Belgaumkar, Vinay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230425162405.1730513-3-vinay.belgaumkar@intel.com \
    --to=vinay.belgaumkar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox