[PATCH i-g-t 6/6] lib/igt_pm: Convert suspended_time from int to uint64_t

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue May 21 08:42:17 UTC 2024


Hi Rodrigo,
On 2024-05-20 at 15:03:47 -0400, Rodrigo Vivi wrote:
> Suspended time is in miliseconds printed from u64 variable in kernel.
> Convert to a more appropriate variable type.
> 
> Cc: Swati Sharma <swati2.sharma at intel.com>
> Suggested-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> ---
>  lib/igt_pm.c            | 9 +++++----
>  lib/igt_pm.h            | 2 +-
>  tests/intel/kms_pm_dc.c | 9 +++++----
>  3 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index d54549d11..057634203 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -1392,16 +1392,17 @@ bool i915_is_slpc_enabled(int drm_fd)
>   *
>   * Return: The total time that the device has been suspended.
----------------------------^
Add in description what units are used, for example:

 * Return: The total time in miliseconds that the device has been
 * suspended.

With that,
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

Regards,
Kamil

>   */
> -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 suspend time for PCI '%04x:%02x:%02x.%01x' = %ld\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