From: Alex Hung <alex.hung@amd.com>
To: Tom Chung <chiahsuan.chung@amd.com>, igt-dev@lists.freedesktop.org
Cc: sunpeng.li@amd.com
Subject: Re: [PATCH i-g-t,v2] tests/amdgpu/amd_hotplug: Check the suspend state after resume
Date: Thu, 13 Mar 2025 10:50:48 -0600 [thread overview]
Message-ID: <cb076a48-355e-4838-9769-2d62d6129982@amd.com> (raw)
In-Reply-To: <20250311081457.2396-1-chiahsuan.chung@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
On 3/11/25 02:13, Tom Chung wrote:
> [Why & How]
> Check the last hardware sleep state after resume to make sure
> last suspend really reached hardware sleep state.
>
> Make sure to enable the suspend related settings in kernel config
>
> Linux Kernel Configuration
> └─>Power management and ACPI options
> Suspend to RAM and standby
> ACPI (Advanced Configuration and Power Interface) Support
>
> Signed-off-by: Tom Chung <chiahsuan.chung@amd.com>
> ---
> v2: add kernel config note in commit messages
>
> tests/amdgpu/amd_hotplug.c | 47 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/tests/amdgpu/amd_hotplug.c b/tests/amdgpu/amd_hotplug.c
> index c13bf49d3..ee3256c0b 100644
> --- a/tests/amdgpu/amd_hotplug.c
> +++ b/tests/amdgpu/amd_hotplug.c
> @@ -27,6 +27,8 @@ IGT_TEST_DESCRIPTION("Test simulated hotplugging on connectors");
>
> /* Maximum pipes on any AMD ASIC. */
> #define MAX_PIPES 6
> +#define LAST_HW_SLEEP_PATH "/sys/power/suspend_stats/last_hw_sleep"
> +#define MEM_SLEEP_PATH "/sys/power/mem_sleep"
>
> /* Common test data. */
> typedef struct data {
> @@ -98,6 +100,46 @@ static void test_fini(data_t *data)
> igt_display_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, 0);
> }
>
> +/* Check if mem_sleep is s2idle */
> +static bool is_system_s2idle(void)
> +{
> + int fd;
> + char dst[64];
> + int read_byte;
> +
> + fd = open(MEM_SLEEP_PATH, O_RDONLY);
> + if (fd == -1)
> + igt_skip("Open %s file error\n", MEM_SLEEP_PATH);
> +
> + read_byte = read(fd, dst, sizeof(dst));
> + close(fd);
> +
> + if (read_byte <= 0)
> + igt_skip("Read %s file error\n", MEM_SLEEP_PATH);
> +
> + return strstr(dst, "[s2idle]");
> +}
> +
> +/* return the last hw_sleep duration time */
> +static int get_last_hw_sleep_time(void)
> +{
> + int fd;
> + char dst[64];
> + int read_byte;
> +
> + fd = open(LAST_HW_SLEEP_PATH, O_RDONLY);
> + if (fd == -1)
> + igt_skip("Open HW sleep statistics file error\n");
> +
> + read_byte = read(fd, dst, sizeof(dst));
> + close(fd);
> +
> + if (read_byte <= 0)
> + igt_skip("Read HW sleep statistics file error\n");
> +
> + return strtol(dst, NULL, 10);
> +}
> +
> static void test_hotplug_basic(data_t *data, bool suspend)
> {
> igt_output_t *output;
> @@ -131,8 +173,13 @@ static void test_hotplug_basic(data_t *data, bool suspend)
> }
>
> if (suspend) {
> + if (!is_system_s2idle())
> + igt_skip("System is not configured for s2idle\n");
> +
> igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
> SUSPEND_TEST_NONE);
> + igt_assert_f(get_last_hw_sleep_time() > 0,
> + "Suspend did not reach hardware sleep state\n");
> }
>
> /* Trigger hotplug and confirm reference image is the same. */
prev parent reply other threads:[~2025-03-13 16:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 8:13 [PATCH i-g-t, v2] tests/amdgpu/amd_hotplug: Check the suspend state after resume Tom Chung
2025-03-11 8:48 ` ✓ Xe.CI.BAT: success for tests/amdgpu/amd_hotplug: Check the suspend state after resume (rev2) Patchwork
2025-03-11 9:05 ` ✓ i915.CI.BAT: " Patchwork
2025-03-12 2:23 ` ✗ Xe.CI.Full: failure " Patchwork
2025-03-13 16:50 ` Alex Hung [this message]
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=cb076a48-355e-4838-9769-2d62d6129982@amd.com \
--to=alex.hung@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=sunpeng.li@amd.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