All of lore.kernel.org
 help / color / mirror / Atom feed
From: Swati Sharma <swati2.sharma@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v4 3/5] lib/pm: Add helper functions to get runtime suspended time
Date: Fri,  9 Sep 2022 17:19:09 +0530	[thread overview]
Message-ID: <20220909114911.1852-4-swati2.sharma@intel.com> (raw)
In-Reply-To: <20220909114911.1852-1-swati2.sharma@intel.com>

Added helper function to get runtime suspended time.
This will be used to extend dc9 validation.

v2: -created separate helper igt_pm_get_power_attr_fd_rdonly() (imre)
    -fixed igt_pm_get_runtime_suspended_time() (imre)
v3: -revert var name change (imre)
    -add space (imre)
v4: -changed igt_info to igt_debug print

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
Reviewed-by: Imre Deak <imre.deak@intel.com>
---
 lib/igt_pm.c | 32 ++++++++++++++++++++++++++++++++
 lib/igt_pm.h |  1 +
 2 files changed, 33 insertions(+)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 99251b40b..d655356c3 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -953,6 +953,20 @@ static int igt_pm_get_power_attr_fd(struct pci_device *pci_dev, const char *attr
 	return fd;
 }
 
+static int igt_pm_get_power_attr_fd_rdonly(struct pci_device *pci_dev, const char *attr)
+{
+	char name[PATH_MAX];
+	int fd;
+
+	snprintf(name, PATH_MAX, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/power/%s",
+		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, attr);
+
+	fd = open(name, O_RDONLY);
+	igt_assert_f(fd >= 0, "Can't open %s\n", attr);
+
+	return fd;
+}
+
 static bool igt_pm_read_power_attr(int fd, char *attr, int len, bool autosuspend_delay)
 {
 	int size;
@@ -1219,3 +1233,21 @@ bool i915_is_slpc_enabled(int fd)
 	else
 		return strstr(buf, "SLPC state: running");
 }
+
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+{
+	char time_str[64];
+	int time, time_fd;
+
+	time_fd = igt_pm_get_power_attr_fd_rdonly(pci_dev, "runtime_suspended_time");
+	if (igt_pm_read_power_attr(time_fd, time_str, 64, false)) {
+		igt_assert(sscanf(time_str, "%d", &time) > 0);
+
+		igt_debug("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+			  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
+
+		return time;
+	}
+
+	return -1;
+}
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index cbbde12b5..a7d621366 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -80,5 +80,6 @@ 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);
+int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 
 #endif /* IGT_PM_H */
-- 
2.25.1

  parent reply	other threads:[~2022-09-09 11:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09 11:49 [igt-dev] [PATCH i-g-t v6 0/5] Modify dc9 validation Swati Sharma
2022-09-09 11:49 ` [igt-dev] [PATCH i-g-t 1/5] tests/i915/i915_pm_dc: Add test description Swati Sharma
2022-09-12 13:04   ` Imre Deak
2022-09-09 11:49 ` [igt-dev] [PATCH i-g-t v3 2/5] tests/i915/i915_pm_dc: Change debugfs for reading platform info Swati Sharma
2022-09-09 11:49 ` Swati Sharma [this message]
2022-09-09 11:49 ` [igt-dev] [PATCH i-g-t v5 4/5] tests/i915/i915_pm_dc: Modify dc9 test Swati Sharma
2022-09-12 13:23   ` Imre Deak
2022-09-09 11:49 ` [igt-dev] [PATCH i-g-t 5/5] tests/i915/i915_pm_dc: Sleep not reqd. to reset counter Swati Sharma
2022-09-12 13:23   ` Imre Deak
2022-09-09 13:20 ` [igt-dev] ✓ Fi.CI.BAT: success for Modify dc9 validation (rev6) Patchwork
2022-09-09 16:31 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-09-13  9:34 [igt-dev] [PATCH i-g-t v6 0/5] Modify dc9 validation Swati Sharma
2022-09-13  9:34 ` [igt-dev] [PATCH i-g-t v4 3/5] lib/pm: Add helper functions to get runtime suspended time Swati Sharma

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=20220909114911.1852-4-swati2.sharma@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=igt-dev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.