[PATCH i-g-t v6 2/4] lib/igt_pm: Add helper to get/set auto_suspenddelay_ms
Kamil Konieczny
kamil.konieczny at linux.intel.com
Wed Jan 24 13:32:45 UTC 2024
Hi Anshuman,
On 2024-01-24 at 17:20:17 +0530, Anshuman Gupta wrote:
> Sometimes we want to test pm igt test with an explicit auto
> suspend delay, therefore adding helpers to get/set the pci_dev
> auto_suspenddelay_ms.
I have few more nits, see below.
>
> v2:
> close delay_fd. [Kamil]
>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta at intel.com>
> ---
> lib/igt_pm.c | 56 +++++++++++++++++++++++++++++++++++++++++-----------
> lib/igt_pm.h | 2 ++
> 2 files changed, 46 insertions(+), 12 deletions(-)
>
> diff --git a/lib/igt_pm.c b/lib/igt_pm.c
> index c2d98fceb..bb8563214 100644
> --- a/lib/igt_pm.c
> +++ b/lib/igt_pm.c
> @@ -1068,18 +1068,6 @@ static void igt_pm_write_power_attr(int fd, const char *val, int len)
> igt_assert(strncmp(buf, val, len) == 0);
> }
>
> -static int igt_pm_get_autosuspend_delay(struct pci_device *pci_dev)
> -{
> - char delay_str[64];
> - int delay, delay_fd;
> -
> - delay_fd = igt_pm_get_power_attr_fd(pci_dev, "autosuspend_delay_ms");
> - if (igt_pm_read_power_attr(delay_fd, delay_str, 64, true))
> - igt_assert(sscanf(delay_str, "%d", &delay) > 0);
> -
> - return delay;
> -}
> -
> static void
> igt_pm_setup_pci_dev_power_attrs(struct pci_device *pci_dev,
> struct igt_pm_pci_dev_pwrattr *pwrattr, int delay_ms)
> @@ -1165,6 +1153,50 @@ igt_pm_setup_pci_card_power_attrs(struct pci_device *pci_dev, bool save_attrs, i
> pci_iterator_destroy(iter);
> }
>
> +/**
> + * igt_pm_get_autosuspend_delay:
> + * @pci_dev: pci_dev.
Add newline here with ' *' so next line will be separated.
> + * Get pci_dev autosuspend delay value from pci sysfs "autosuspend_delay_ms".
-------------------------------------------------------- ^^^^^^^^^^^^^^^^^^^^^
Drop "autosuspend_delay_ms" from description.
> + *
> + * Returns:
> + * autosuspend_delay_ms.
-----------------^-----^
autosuspend delay in miliseconds
> + */
> +int igt_pm_get_autosuspend_delay(struct pci_device *pci_dev)
> +{
> + char delay_str[64];
> + int delay, delay_fd;
> +
> + delay_fd = igt_pm_get_power_attr_fd(pci_dev, "autosuspend_delay_ms");
> + if (igt_pm_read_power_attr(delay_fd, delay_str, 64, true))
> + igt_assert(sscanf(delay_str, "%d", &delay) > 0);
> +
> + close(delay_fd);
> + return delay;
> +}
> +
> +/**
> + * igt_pm_set_autosuspend_delay:
> + * @pci_dev: pci_dev.
> + * @delay_ms: autosuspend delay in ms.
Add newline here with ' *' so next line will be separated.
> + * Set pci_dev autosuspend delay value through pci sysfs "autosuspend_delay_ms".
----------------------------------------------------------- ^^^^^^^^^^^^^^^^^^^^^
Same here, drop this from description.
With that:
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> + */
> +void igt_pm_set_autosuspend_delay(struct pci_device *pci_dev, int delay_ms)
> +{
> + char delay_str[64];
> + int delay_fd;
> +
> + delay_fd = igt_pm_get_power_attr_fd(pci_dev, "autosuspend_delay_ms");
> +
> + if (delay_ms >= 0) {
> + int wc;
> +
> + wc = snprintf(delay_str, 64, "%d\n", delay_ms);
> + igt_pm_write_power_attr(delay_fd, delay_str, wc);
> + }
> +
> + close(delay_fd);
> +}
> +
> /**
> * igt_pm_enable_pci_card_runtime_pm:
> * @root: root port pci_dev.
> diff --git a/lib/igt_pm.h b/lib/igt_pm.h
> index 538b6e39e..91ee05cd1 100644
> --- a/lib/igt_pm.h
> +++ b/lib/igt_pm.h
> @@ -82,6 +82,8 @@ int igt_pm_get_pcie_acpihp_slot(struct pci_device *pci_dev);
> bool igt_pm_acpi_d3cold_supported(struct pci_device *pci_dev);
> enum igt_acpi_d_state
> igt_pm_get_acpi_real_d_state(struct pci_device *pci_dev);
> +int igt_pm_get_autosuspend_delay(struct pci_device *pci_dev);
> +void igt_pm_set_autosuspend_delay(struct pci_device *pci_dev, int delay_ms);
> void igt_pm_enable_pci_card_runtime_pm(struct pci_device *root,
> struct pci_device *i915);
> void igt_pm_get_d3cold_allowed(const char *pci_slot_name, uint32_t *value);
> --
> 2.25.1
>
More information about the igt-dev
mailing list