tests/intel/xe_pm: Update runtime pm conditions
PATCH 1/4 tests/intel/xe_pm: Update runtime pm conditions
Xe is no longer holding a runtime pm reference for the life of a VM or exec_queue.
Also, IGT changes autosuspend time to a minimal time, so we cannot guarantee that rpm is still suspended after the execution has finished.
So, the reference usage is not a reliable reference.
Hence, start using runtime_active_time as the indicator that runtime_pm resumed upon our actions.
v2: Usage of runtime_active_pm and inclusion of mmap tests.
--- lib/igt_pm.c | 18 +++++++++++ lib/igt_pm.h | 1 + tests/intel/xe_pm.c | 77 +++++++++++++++++---------------------------- 3 files changed, 47 insertions(+), 49 deletions(-)
lib/igt_pm.c +18 -0
@@ -1412,6 +1412,24 @@ int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev)return -1 ; } +int igt_pm_get_runtime_active_time (struct pci_device *pci_dev) +{ +char time_str[64 ]; +int time, time_fd; + + time_fd =igt_pm_get_power_attr_fd_rdonly (pci_dev,"runtime_active_time" ); +if (igt_pm_read_power_attr (time_fd, time_str,64 , false)) { +igt_assert (sscanf (time_str,"%d" , &time) >0 ); + +igt_debug ("runtime active time for PCI '%04x:%02x:%02x.%01x' = %d\n" , + pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func, time); + +return time; + } + +return -1 ; +} +/** * igt_pm_get_runtime_usage: * @pci_dev: pci device
lib/igt_pm.h +1 -0
@@ -94,6 +94,7 @@ 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); +int 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);
tests/intel/xe_pm.c +28 -49
160 lines not on this page · raw message
Signature · 1 line
2.44.0
PATCH 2/4 tests/intel/xe_pm: Also disable display for mmap_system test
If display is enabled, the always-on components will always keeps runtime pm references, unless you put DPMS_OFF.
--- tests/intel/xe_pm.c | 2 ++ 1 file changed, 2 insertions(+)
tests/intel/xe_pm.c +2 -0
@@ -780,7 +780,9 @@ igt_mainigt_describe ("Validate mmap memory mappings with system region," "when device along with parent bridge in d3" ); igt_subtest("d3-mmap-system") { +dpms_on_off (device,DRM_MODE_DPMS_OFF );test_mmap (device,system_memory (device.fd_xe),0 ); +dpms_on_off (device,DRM_MODE_DPMS_ON ); } igt_describe("Validate mmap memory mappings with vram region,"
Signature · 1 line
2.44.0
PATCH 3/4 tests/intel/xe_pm: Only check the rpm resume after the first mmap operation
In reply to Rodrigo ViviThe very first memory operation on a mmaped region after runtime suspend, the device will be resumed if the memory used is vram. However, after this first operation with page fault, the memory can be migrated to the system memory.
During this migration, Xe kernel will get a notification at xe_bo_move_notify, and the bo will be removed from the vram_userfault list. Then, on the next suspend, we won't mark bo for page fault and resume won't happen and the active count won't increase. This is okay, since the bo is now in the system memory we don't need to wake up the device. But the current test is wrong, because it assumes that the bo keeps forever in vram, what is the issue here.
Only checking the resume after the first operation is the enough. But also, ensure that both read and write operations are actually validated.
--- tests/intel/xe_pm.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
tests/intel/xe_pm.c +25 -11
@@ -37,6 +37,11 @@#define PREFETCH (0x1 << 1)#define UNBIND_ALL (0x1 << 2) +enum mem_op { +READ , +WRITE , +}; + typedef struct { int fd_xe; struct pci_device *pci_xe;
@@ -525,7 +530,8 @@ static void test_vram_d3cold_threshold(device_t device, int sysfs_fd)* * Functionality: pm-d3 */ -static void test_mmap (device_t device,uint32_t placement,uint32_t flags) +static void test_mmap (device_t device,uint32_t placement,uint32_t flags, +enum mem_op first_op) {size_t bo_size =8192 ;uint32_t *map =NULL ;
@@ -563,8 +569,12 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags)igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED )); active_time =igt_pm_get_runtime_active_time (device.pci_xe); -for (i =0 ; i < bo_size /sizeof (*map); i++) -igt_assert (map[i] ==MAGIC_1 ); +for (i =0 ; i < bo_size /sizeof (*map); i++) { +if (first_op ==READ ) +igt_assert (map[i] ==MAGIC_1 ); +else + map[i] =MAGIC_2 ; + }/* dgfx page-fault on mmaping should wake the gpu */ if (xe_has_vram (device.fd_xe) && flags &DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM )
@@ -574,12 +584,12 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags)igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED )); active_time =igt_pm_get_runtime_active_time (device.pci_xe); -for (i =0 ; i < bo_size /sizeof (*map); i++) - map[i] =MAGIC_2 ; - -if (xe_has_vram (device.fd_xe) && flags &DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ) -igt_assert (igt_pm_get_runtime_active_time (device.pci_xe) > - active_time); +for (i =0 ; i < bo_size /sizeof (*map); i++) { +if (first_op ==READ ) + map[i] =MAGIC_2 ; +else +igt_assert (map[i] ==MAGIC_2 ); + }igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED ));
@@ -781,7 +791,8 @@ igt_main "when device along with parent bridge in d3"); igt_subtest("d3-mmap-system") {dpms_on_off (device,DRM_MODE_DPMS_OFF ); -test_mmap (device,system_memory (device.fd_xe),0 ); +test_mmap (device,system_memory (device.fd_xe),0 ,READ ); +test_mmap (device,system_memory (device.fd_xe),0 ,WRITE );dpms_on_off (device,DRM_MODE_DPMS_ON ); }
@@ -800,7 +811,10 @@ igt_main/* Give some auto suspend delay to validate rpm active during page fault */ igt_pm_set_autosuspend_delay (device.pci_xe,1000 );dpms_on_off (device,DRM_MODE_DPMS_OFF ); -test_mmap (device,vram_memory (device.fd_xe,0 ),DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ); +test_mmap (device,vram_memory (device.fd_xe,0 ), +DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ,READ ); +test_mmap (device,vram_memory (device.fd_xe,0 ), +DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ,WRITE );dpms_on_off (device,DRM_MODE_DPMS_ON );igt_pm_set_autosuspend_delay (device.pci_xe, delay_ms); }
Signature · 1 line
2.44.0
PATCH 4/4 tests/intel/xe_pm: Convert mmap tests to use existing d3 helpers
In reply to Rodrigo ViviStandardize d3 setup and ensure that it tests with D3cold and D3hot.
--- tests/intel/xe_pm.c | 80 ++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 38 deletions(-)
tests/intel/xe_pm.c +42 -38
@@ -519,19 +519,25 @@ static void test_vram_d3cold_threshold(device_t device, int sysfs_fd) }/** -* SUBTEST: d3-mmap-%s +* SUBTEST: %s-mmap-%s * Description: * Validate mmap memory mapping with d3 state, for %arg[1] region, * if supported by device. +* * arg[1]: * +* @d3hot: d3hot +* @d3cold: d3cold +* +* arg[2]: +* * @vram: vram region * @system: system region * * Functionality: pm-d3 */ static void test_mmap (device_t device,uint32_t placement,uint32_t flags, -enum mem_op first_op) +enum mem_op first_op,enum igt_acpi_d_state d_state) {size_t bo_size =8192 ;uint32_t *map =NULL ;
@@ -540,7 +546,7 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags,igt_require_f (placement,"Device doesn't support such memory region\n" ); -igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED )); +igt_assert (in_d3 (device, d_state)); active_time =igt_pm_get_runtime_active_time (device.pci_xe); bo_size =ALIGN (bo_size,xe_get_default_alignment (device.fd_xe));
@@ -566,7 +572,7 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags,close (fw_handle);sleep (1 ); -igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED )); +igt_assert (in_d3 (device, d_state)); active_time =igt_pm_get_runtime_active_time (device.pci_xe);for (i =0 ; i < bo_size /sizeof (*map); i++) {
@@ -581,7 +587,7 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags,igt_assert (igt_pm_get_runtime_active_time (device.pci_xe) > active_time); -igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED )); +igt_assert (in_d3 (device, d_state)); active_time =igt_pm_get_runtime_active_time (device.pci_xe);for (i =0 ; i < bo_size /sizeof (*map); i++) {
@@ -591,7 +597,7 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags,igt_assert (map[i] ==MAGIC_2 ); } -igt_assert (igt_wait_for_pm_status (IGT_RUNTIME_PM_STATUS_SUSPENDED )); +igt_assert (in_d3 (device, d_state));/* Runtime resume and check the pattern */ fw_handle =igt_debugfs_open (device.fd_xe,"forcewake_all" ,O_RDONLY );
@@ -772,6 +778,36 @@ igt_main NO_SUSPEND, d->state, 0);cleanup_d3 (device); } + +igt_describe_f ("Validate mmap memory mappings with system region," +"when device along with parent bridge in %s" , d->name); + igt_subtest_f("%s-mmap-system", d->name) { +igt_assert (setup_d3 (device, d->state)); +test_mmap (device,system_memory (device.fd_xe),0 , +READ , d->state); +test_mmap (device,system_memory (device.fd_xe),0 , +WRITE , d->state); +cleanup_d3 (device); + } + +igt_describe_f ("Validate mmap memory mappings with vram region," +"when device along with parent bridge in %s" , d->name); + igt_subtest_f("%s-mmap-vram", d->name) { +int delay_ms =igt_pm_get_autosuspend_delay (device.pci_xe); + +/* Give some auto suspend delay to validate rpm active during page fault */ +igt_pm_set_autosuspend_delay (device.pci_xe,1000 ); +igt_assert (setup_d3 (device, d->state)); +test_mmap (device,vram_memory (device.fd_xe,0 ), +DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM , +READ , d->state); +test_mmap (device,vram_memory (device.fd_xe,0 ), +DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM , +WRITE , d->state); +cleanup_d3 (device); + +igt_pm_set_autosuspend_delay (device.pci_xe, delay_ms); + } } igt_subtest_group {
@@ -787,38 +823,6 @@ igt_maintest_vram_d3cold_threshold (device, sysfs_fd); } -igt_describe ("Validate mmap memory mappings with system region," -"when device along with parent bridge in d3" ); - igt_subtest("d3-mmap-system") { -dpms_on_off (device,DRM_MODE_DPMS_OFF ); -test_mmap (device,system_memory (device.fd_xe),0 ,READ ); -test_mmap (device,system_memory (device.fd_xe),0 ,WRITE ); -dpms_on_off (device,DRM_MODE_DPMS_ON ); - } - -igt_describe ("Validate mmap memory mappings with vram region," -"when device along with parent bridge in d3" ); - igt_subtest("d3-mmap-vram") { -int delay_ms; - -if (device.pci_root != device.pci_xe) { -igt_pm_enable_pci_card_runtime_pm (device.pci_root,NULL ); -igt_pm_set_d3cold_allowed (device.pci_slot_name,1 ); - } - - delay_ms =igt_pm_get_autosuspend_delay (device.pci_xe); - -/* Give some auto suspend delay to validate rpm active during page fault */ -igt_pm_set_autosuspend_delay (device.pci_xe,1000 ); -dpms_on_off (device,DRM_MODE_DPMS_OFF ); -test_mmap (device,vram_memory (device.fd_xe,0 ), -DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ,READ ); -test_mmap (device,vram_memory (device.fd_xe,0 ), -DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM ,WRITE ); -dpms_on_off (device,DRM_MODE_DPMS_ON ); -igt_pm_set_autosuspend_delay (device.pci_xe, delay_ms); - } - igt_subtest("mocs_suspend_resume")test_mocs_suspend_resume (device,1 ,0 ); }
Signature · 1 line
2.44.0
Patchwork
CI✗ CI.Patch_applied: failure for series starting with [1/4] tests/intel/xe_pm: Update runtime pm conditions
In reply to Rodrigo Vivi== Series Details ==
== Series Details ==
Series: series starting with [1/4] tests/intel/xe_pm: Update runtime pm conditions
URL : https://patchwork.freedesktop.org/series/133414/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 20edf912c45c drm-tip: 2024y-05m-09d-21h-02m-22s UTC integration manifest === git am output follows ===
error: lib/igt_pm.c: does not exist in index
error: lib/igt_pm.h: does not exist in index
error: tests/intel/xe_pm.c: does not exist in index
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: tests/intel/xe_pm: Update runtime pm conditions
Patch failed at 0001 tests/intel/xe_pm: Update runtime pm conditions When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".