mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-23 15:56:33 +00:00
tests/pm_rpm: add macros to disable/enable screens and wait
This should make the test case functions better to read and write. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
This commit is contained in:
parent
f6ffa3ca7f
commit
1892059842
112
tests/pm_rpm.c
112
tests/pm_rpm.c
@ -235,6 +235,11 @@ static void disable_all_screens(struct mode_set_data *data)
|
|||||||
kmstest_unset_all_crtcs(drm_fd, data->res);
|
kmstest_unset_all_crtcs(drm_fd, data->res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define disable_all_screens_and_wait(data) do { \
|
||||||
|
disable_all_screens(data); \
|
||||||
|
igt_assert(wait_for_suspended()); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static struct scanout_fb *create_fb(struct mode_set_data *data, int width,
|
static struct scanout_fb *create_fb(struct mode_set_data *data, int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
@ -339,6 +344,11 @@ static void enable_one_screen(struct mode_set_data *data)
|
|||||||
igt_require(enable_one_screen_with_type(data, SCREEN_TYPE_ANY));
|
igt_require(enable_one_screen_with_type(data, SCREEN_TYPE_ANY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define enable_one_screen_and_wait(data) do { \
|
||||||
|
enable_one_screen(data); \
|
||||||
|
igt_assert(wait_for_active()); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static drmModePropertyBlobPtr get_connector_edid(drmModeConnectorPtr connector,
|
static drmModePropertyBlobPtr get_connector_edid(drmModeConnectorPtr connector,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
@ -725,11 +735,9 @@ static void teardown_environment(void)
|
|||||||
|
|
||||||
static void basic_subtest(void)
|
static void basic_subtest(void)
|
||||||
{
|
{
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pc8_residency_subtest(void)
|
static void pc8_residency_subtest(void)
|
||||||
@ -788,18 +796,15 @@ static void drm_resources_equal_subtest(void)
|
|||||||
{
|
{
|
||||||
struct compare_data pre_suspend, during_suspend, post_suspend;
|
struct compare_data pre_suspend, during_suspend, post_suspend;
|
||||||
|
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
get_drm_info(&pre_suspend);
|
get_drm_info(&pre_suspend);
|
||||||
igt_assert(wait_for_active());
|
igt_assert(wait_for_active());
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
get_drm_info(&during_suspend);
|
get_drm_info(&during_suspend);
|
||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
|
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
get_drm_info(&post_suspend);
|
get_drm_info(&post_suspend);
|
||||||
igt_assert(wait_for_active());
|
igt_assert(wait_for_active());
|
||||||
|
|
||||||
@ -835,11 +840,9 @@ static void i2c_subtest(void)
|
|||||||
{
|
{
|
||||||
i2c_subtest_check_environment();
|
i2c_subtest_check_environment();
|
||||||
|
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
test_i2c(&ms_data);
|
test_i2c(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
|
|
||||||
@ -917,8 +920,7 @@ static void debugfs_read_subtest(void)
|
|||||||
igt_require_f(dir, "Can't open the debugfs directory\n");
|
igt_require_f(dir, "Can't open the debugfs directory\n");
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
read_files_from_dir(path, 0);
|
read_files_from_dir(path, 0);
|
||||||
}
|
}
|
||||||
@ -933,8 +935,7 @@ static void sysfs_read_subtest(void)
|
|||||||
igt_require_f(dir, "Can't open the sysfs directory\n");
|
igt_require_f(dir, "Can't open the sysfs directory\n");
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
read_files_from_dir(path, 0);
|
read_files_from_dir(path, 0);
|
||||||
}
|
}
|
||||||
@ -946,8 +947,7 @@ static void debugfs_forcewake_user_subtest(void)
|
|||||||
|
|
||||||
igt_require(intel_gen(ms_data.devid) >= 6);
|
igt_require(intel_gen(ms_data.devid) >= 6);
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
fd = igt_open_forcewake_handle();
|
fd = igt_open_forcewake_handle();
|
||||||
igt_require(fd >= 0);
|
igt_require(fd >= 0);
|
||||||
@ -974,8 +974,7 @@ static void gem_mmap_subtest(bool gtt_mmap)
|
|||||||
uint8_t *gem_buf;
|
uint8_t *gem_buf;
|
||||||
|
|
||||||
/* Create, map and set data while the device is active. */
|
/* Create, map and set data while the device is active. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
handle = gem_create(drm_fd, buf_size);
|
handle = gem_create(drm_fd, buf_size);
|
||||||
|
|
||||||
@ -993,8 +992,7 @@ static void gem_mmap_subtest(bool gtt_mmap)
|
|||||||
igt_assert(gem_buf[i] == (i & 0xFF));
|
igt_assert(gem_buf[i] == (i & 0xFF));
|
||||||
|
|
||||||
/* Now suspend, read and modify. */
|
/* Now suspend, read and modify. */
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
for (i = 0; i < buf_size; i++)
|
for (i = 0; i < buf_size; i++)
|
||||||
igt_assert(gem_buf[i] == (i & 0xFF));
|
igt_assert(gem_buf[i] == (i & 0xFF));
|
||||||
@ -1005,8 +1003,7 @@ static void gem_mmap_subtest(bool gtt_mmap)
|
|||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
|
|
||||||
/* Now resume and see if it's still there. */
|
/* Now resume and see if it's still there. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
for (i = 0; i < buf_size; i++)
|
for (i = 0; i < buf_size; i++)
|
||||||
igt_assert(gem_buf[i] == (~i & 0xFF));
|
igt_assert(gem_buf[i] == (~i & 0xFF));
|
||||||
|
|
||||||
@ -1014,8 +1011,7 @@ static void gem_mmap_subtest(bool gtt_mmap)
|
|||||||
|
|
||||||
/* Now the opposite: suspend, and try to create the mmap while
|
/* Now the opposite: suspend, and try to create the mmap while
|
||||||
* suspended. */
|
* suspended. */
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
if (gtt_mmap)
|
if (gtt_mmap)
|
||||||
gem_buf = gem_mmap__gtt(drm_fd, handle, buf_size,
|
gem_buf = gem_mmap__gtt(drm_fd, handle, buf_size,
|
||||||
@ -1034,8 +1030,7 @@ static void gem_mmap_subtest(bool gtt_mmap)
|
|||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
|
|
||||||
/* Resume and check if it's still there. */
|
/* Resume and check if it's still there. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
for (i = 0; i < buf_size; i++)
|
for (i = 0; i < buf_size; i++)
|
||||||
igt_assert(gem_buf[i] == (i & 0xFF));
|
igt_assert(gem_buf[i] == (i & 0xFF));
|
||||||
|
|
||||||
@ -1058,8 +1053,7 @@ static void gem_pread_subtest(void)
|
|||||||
memset(read_buf, 0, buf_size);
|
memset(read_buf, 0, buf_size);
|
||||||
|
|
||||||
/* Create and set data while the device is active. */
|
/* Create and set data while the device is active. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
handle = gem_create(drm_fd, buf_size);
|
handle = gem_create(drm_fd, buf_size);
|
||||||
|
|
||||||
@ -1074,8 +1068,7 @@ static void gem_pread_subtest(void)
|
|||||||
igt_assert(cpu_buf[i] == read_buf[i]);
|
igt_assert(cpu_buf[i] == read_buf[i]);
|
||||||
|
|
||||||
/* Now suspend, read and modify. */
|
/* Now suspend, read and modify. */
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
memset(read_buf, 0, buf_size);
|
memset(read_buf, 0, buf_size);
|
||||||
gem_read(drm_fd, handle, 0, read_buf, buf_size);
|
gem_read(drm_fd, handle, 0, read_buf, buf_size);
|
||||||
@ -1090,8 +1083,7 @@ static void gem_pread_subtest(void)
|
|||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
|
|
||||||
/* Now resume and see if it's still there. */
|
/* Now resume and see if it's still there. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
memset(read_buf, 0, buf_size);
|
memset(read_buf, 0, buf_size);
|
||||||
gem_read(drm_fd, handle, 0, read_buf, buf_size);
|
gem_read(drm_fd, handle, 0, read_buf, buf_size);
|
||||||
@ -1198,8 +1190,7 @@ static void gem_execbuf_subtest(void)
|
|||||||
uint32_t color;
|
uint32_t color;
|
||||||
|
|
||||||
/* Create and set data while the device is active. */
|
/* Create and set data while the device is active. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
handle = gem_create(drm_fd, dst_size);
|
handle = gem_create(drm_fd, dst_size);
|
||||||
|
|
||||||
@ -1209,8 +1200,7 @@ static void gem_execbuf_subtest(void)
|
|||||||
gem_write(drm_fd, handle, 0, cpu_buf, dst_size);
|
gem_write(drm_fd, handle, 0, cpu_buf, dst_size);
|
||||||
|
|
||||||
/* Now suspend and try it. */
|
/* Now suspend and try it. */
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
color = 0x12345678;
|
color = 0x12345678;
|
||||||
submit_blt_cmd(handle, sq_x, sq_y, sq_w, sq_h, pitch, color,
|
submit_blt_cmd(handle, sq_x, sq_y, sq_w, sq_h, pitch, color,
|
||||||
@ -1232,8 +1222,7 @@ static void gem_execbuf_subtest(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now resume and check for it again. */
|
/* Now resume and check for it again. */
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
memset(cpu_buf, 0, dst_size);
|
memset(cpu_buf, 0, dst_size);
|
||||||
gem_read(drm_fd, handle, 0, cpu_buf, dst_size);
|
gem_read(drm_fd, handle, 0, cpu_buf, dst_size);
|
||||||
@ -1256,8 +1245,7 @@ static void gem_execbuf_subtest(void)
|
|||||||
submit_blt_cmd(handle, sq_x, sq_y, sq_w, sq_h, pitch, color,
|
submit_blt_cmd(handle, sq_x, sq_y, sq_w, sq_h, pitch, color,
|
||||||
&presumed_offset);
|
&presumed_offset);
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
memset(cpu_buf, 0, dst_size);
|
memset(cpu_buf, 0, dst_size);
|
||||||
gem_read(drm_fd, handle, 0, cpu_buf, dst_size);
|
gem_read(drm_fd, handle, 0, cpu_buf, dst_size);
|
||||||
@ -1299,8 +1287,7 @@ static void gem_execbuf_stress_subtest(int rounds, int wait_flags)
|
|||||||
batch_buf[i++] = MI_NOOP;
|
batch_buf[i++] = MI_NOOP;
|
||||||
igt_assert(i * sizeof(uint32_t) == batch_size);
|
igt_assert(i * sizeof(uint32_t) == batch_size);
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
handle = gem_create(drm_fd, batch_size);
|
handle = gem_create(drm_fd, batch_size);
|
||||||
gem_write(drm_fd, handle, 0, batch_buf, batch_size);
|
gem_write(drm_fd, handle, 0, batch_buf, batch_size);
|
||||||
@ -1330,8 +1317,7 @@ static void gem_execbuf_stress_subtest(int rounds, int wait_flags)
|
|||||||
/* When this test was written, it triggered WARNs and DRM_ERRORs on dmesg. */
|
/* When this test was written, it triggered WARNs and DRM_ERRORs on dmesg. */
|
||||||
static void gem_idle_subtest(void)
|
static void gem_idle_subtest(void)
|
||||||
{
|
{
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|
||||||
@ -1345,8 +1331,7 @@ static void reg_read_ioctl_subtest(void)
|
|||||||
.offset = 0x2358, /* render ring timestamp */
|
.offset = 0x2358, /* render ring timestamp */
|
||||||
};
|
};
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
do_ioctl(drm_fd, DRM_IOCTL_I915_REG_READ, &rr);
|
do_ioctl(drm_fd, DRM_IOCTL_I915_REG_READ, &rr);
|
||||||
|
|
||||||
@ -1371,21 +1356,18 @@ static void pci_d3_state_subtest(void)
|
|||||||
{
|
{
|
||||||
igt_require(has_runtime_pm);
|
igt_require(has_runtime_pm);
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
igt_assert(device_in_pci_d3());
|
igt_assert(device_in_pci_d3());
|
||||||
|
|
||||||
enable_one_screen(&ms_data);
|
enable_one_screen_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_active());
|
|
||||||
|
|
||||||
igt_assert(!device_in_pci_d3());
|
igt_assert(!device_in_pci_d3());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stay_subtest(void)
|
static void stay_subtest(void)
|
||||||
{
|
{
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
sleep(600);
|
sleep(600);
|
||||||
@ -1393,8 +1375,7 @@ static void stay_subtest(void)
|
|||||||
|
|
||||||
static void system_suspend_subtest(void)
|
static void system_suspend_subtest(void)
|
||||||
{
|
{
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
igt_system_suspend_autoresume();
|
igt_system_suspend_autoresume();
|
||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
}
|
}
|
||||||
@ -1403,8 +1384,7 @@ static void system_suspend_subtest(void)
|
|||||||
* produced WARNs on this case. */
|
* produced WARNs on this case. */
|
||||||
static void dpms_mode_unset_subtest(enum screen_type type)
|
static void dpms_mode_unset_subtest(enum screen_type type)
|
||||||
{
|
{
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
igt_require(enable_one_screen_with_type(&ms_data, type));
|
igt_require(enable_one_screen_with_type(&ms_data, type));
|
||||||
igt_assert(wait_for_active());
|
igt_assert(wait_for_active());
|
||||||
@ -1412,8 +1392,7 @@ static void dpms_mode_unset_subtest(enum screen_type type)
|
|||||||
disable_all_screens_dpms(&ms_data);
|
disable_all_screens_dpms(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
igt_assert(wait_for_suspended());
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_igt_fb(struct igt_fb *fb, uint32_t color)
|
static void fill_igt_fb(struct igt_fb *fb, uint32_t color)
|
||||||
@ -1435,8 +1414,7 @@ static void cursor_subtest(bool dpms)
|
|||||||
int rc;
|
int rc;
|
||||||
struct igt_fb scanout_fb, cursor_fb1, cursor_fb2, cursor_fb3;
|
struct igt_fb scanout_fb, cursor_fb1, cursor_fb2, cursor_fb3;
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
|
igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
|
||||||
&connector_id, &mode));
|
&connector_id, &mode));
|
||||||
@ -1566,8 +1544,7 @@ static void test_one_plane(bool dpms, uint32_t plane_id,
|
|||||||
int32_t crtc_x = 0, crtc_y = 0;
|
int32_t crtc_x = 0, crtc_y = 0;
|
||||||
bool tiling;
|
bool tiling;
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
|
igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
|
||||||
&connector_id, &mode));
|
&connector_id, &mode));
|
||||||
@ -1718,8 +1695,7 @@ static void fences_subtest(bool dpms)
|
|||||||
uint32_t *buf_ptr;
|
uint32_t *buf_ptr;
|
||||||
uint32_t tiling = false, swizzle;
|
uint32_t tiling = false, swizzle;
|
||||||
|
|
||||||
disable_all_screens(&ms_data);
|
disable_all_screens_and_wait(&ms_data);
|
||||||
igt_assert(wait_for_suspended());
|
|
||||||
|
|
||||||
igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
|
igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
|
||||||
&connector_id, &mode));
|
&connector_id, &mode));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user