[PATCH i-g-t 6/6] lib/igt_pm: Convert suspended_time from int to uint64_t
Rodrigo Vivi
rodrigo.vivi at intel.com
Tue May 21 15:16:40 UTC 2024
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 at intel.com>
Suggested-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi at 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
More information about the igt-dev
mailing list