Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: <igt-dev@lists.freedesktop.org>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Swati Sharma <swati2.sharma@intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>
Subject: [PATCH i-g-t 6/6] lib/igt_pm: Convert suspended_time from int to uint64_t
Date: Tue, 21 May 2024 11:16:40 -0400	[thread overview]
Message-ID: <20240521151640.280354-6-rodrigo.vivi@intel.com> (raw)
In-Reply-To: <20240521151640.280354-1-rodrigo.vivi@intel.com>

Suspended time is in miliseconds printed from u64 variable in kernel.
Convert to a more appropriate variable type.

v2: - Use PRInt macros instead of %ld (Kamil)
    - Explicit time units (Kamil)
    - s/suspend/suspended in the debug msg

Cc: Swati Sharma <swati2.sharma@intel.com>
Suggested-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 lib/igt_pm.c            | 11 ++++++-----
 lib/igt_pm.h            |  2 +-
 tests/intel/kms_pm_dc.c |  9 +++++----
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index c6c0a592b..8aa3d920d 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -1390,18 +1390,19 @@ bool i915_is_slpc_enabled(int drm_fd)
  * igt_pm_get_runtime_suspended_time:
  * @pci_dev: PCI device struct
  *
- * Return: The total time that the device has been suspended.
+ * Return: The total time in miliseconds that the device has been suspended.
  */
-int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
+uint64_t igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)
 {
 	char time_str[64];
-	int time, time_fd;
+	int time_fd;
+	uint64_t time;
 
 	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_assert(sscanf(time_str, "%ld", &time) > 0);
 
-		igt_debug("runtime suspend time for PCI '%04x:%02x:%02x.%01x' = %d\n",
+		igt_debug("runtime suspended time for PCI '%04x:%02x:%02x.%01x' = %" PRIu64 "\n",
 			  pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time);
 
 		return time;
diff --git a/lib/igt_pm.h b/lib/igt_pm.h
index 15e301533..6b428f53e 100644
--- a/lib/igt_pm.h
+++ b/lib/igt_pm.h
@@ -93,7 +93,7 @@ void igt_pm_restore_pci_card_runtime_pm(void);
 void igt_pm_print_pci_card_runtime_status(void);
 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);
+uint64_t igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 uint64_t igt_pm_get_runtime_active_time(struct pci_device *pci_dev);
 int igt_pm_get_runtime_usage(struct pci_device *pci_dev);
 void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);
diff --git a/tests/intel/kms_pm_dc.c b/tests/intel/kms_pm_dc.c
index 176f7a04b..7766d34d7 100644
--- a/tests/intel/kms_pm_dc.c
+++ b/tests/intel/kms_pm_dc.c
@@ -488,10 +488,10 @@ static bool support_dc6(int debugfs_fd)
 	return strstr(buf, "DC5 -> DC6 count");
 }
 
-static int read_runtime_suspended_time(int drm_fd)
+static uint64_t read_runtime_suspended_time(int drm_fd)
 {
 	struct pci_device *i915;
-	int ret;
+	uint64_t ret;
 
 	i915 = igt_device_get_pci_device(drm_fd);
 	ret = igt_pm_get_runtime_suspended_time(i915);
@@ -500,7 +500,7 @@ static int read_runtime_suspended_time(int drm_fd)
 	return ret;
 }
 
-static bool dc9_wait_entry(data_t *data, int dc_target, int prev_dc, int prev_rpm, int msecs)
+static bool dc9_wait_entry(data_t *data, int dc_target, int prev_dc, uint64_t prev_rpm, int msecs)
 {
 	/*
 	 * Runtime suspended residency should increment once DC9 is achieved;
@@ -522,7 +522,8 @@ static void check_dc9(data_t *data, int dc_target, int prev_dc, int prev_rpm)
 
 static void setup_dc9_dpms(data_t *data, int dc_target)
 {
-	int prev_dc = 0, prev_rpm, sysfs_fd;
+	uint64_t prev_rpm;
+	int prev_dc = 0, sysfs_fd;
 
 	igt_require((sysfs_fd = open(KMS_HELPER, O_RDONLY)) >= 0);
 	__igt_sysfs_get_boolean(sysfs_fd, "poll", &kms_poll_saved_state);
-- 
2.44.0


  parent reply	other threads:[~2024-05-21 15:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 15:16 [PATCH i-g-t 1/6] tests/intel/xe_pm: Update runtime pm conditions Rodrigo Vivi
2024-05-21 15:16 ` [PATCH i-g-t 2/6] lib/igt_pm: Fix and standardize IGT PM library documentation Rodrigo Vivi
2024-05-21 15:16 ` [PATCH i-g-t 3/6] tests/intel/xe_pm: Also disable display for mmap_system test Rodrigo Vivi
2024-05-21 15:16 ` [PATCH i-g-t 4/6] tests/intel/xe_pm: Only check the rpm resume after the first mmap operation Rodrigo Vivi
2024-05-21 15:16 ` [PATCH i-g-t 5/6] tests/intel/xe_pm: Convert mmap tests to use existing d3 helpers Rodrigo Vivi
2024-05-21 15:16 ` Rodrigo Vivi [this message]
2024-05-21 17:56 ` ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/6] tests/intel/xe_pm: Update runtime pm conditions Patchwork
2024-05-21 18:11 ` ✓ CI.xeBAT: " Patchwork
2024-05-22  0:17 ` ✗ CI.xeFULL: failure " Patchwork
2024-05-22  7:26 ` ✓ Fi.CI.IGT: success " Patchwork
2024-05-22 12:46 ` [PATCH i-g-t 1/6] " Francois Dugast
2024-05-22 14:25   ` Rodrigo Vivi
  -- strict thread matches above, loose matches on Subject: below --
2024-05-20 19:03 Rodrigo Vivi
2024-05-20 19:03 ` [PATCH i-g-t 6/6] lib/igt_pm: Convert suspended_time from int to uint64_t Rodrigo Vivi
2024-05-21  8:42   ` Kamil Konieczny
2024-05-21 13:04   ` Kamil Konieczny

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=20240521151640.280354-6-rodrigo.vivi@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=swati2.sharma@intel.com \
    /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