All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Anshuman Gupta <anshuman.gupta@intel.com>
Cc: igt-dev@lists.freedesktop.org, badal.nilawar@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t v3 3/3] test/xe_pm: Add vram_d3cold_threshold subtest
Date: Thu, 20 Jul 2023 17:07:59 -0400	[thread overview]
Message-ID: <ZLmiL9Nq5P3yZZxS@intel.com> (raw)
In-Reply-To: <20230718110852.2965553-4-anshuman.gupta@intel.com>

On Tue, Jul 18, 2023 at 04:38:52PM +0530, Anshuman Gupta wrote:
> Adding a vram_d3cold_threshold subtest, which creates a Xe bo and
> set the vram_d3cold_threshold according to vram used and bo size.
> Test setups the d3cold and expect card to be limited to d3hot.
> 
> v2:
> - Add subtest doc.
> v3:
> - skip the test on igfx. [Riana]
> - Test doc enhancement. [Riana]
> - Create the bo before vram query. [Riana]
> - Use xe_bo_map insead of xe_bo_mmap_offset and mmap. [Riana]
> - Close the bo handle. [Riana]
> 
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> ---
>  tests/xe/xe_pm.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 82 insertions(+)
> 
> diff --git a/tests/xe/xe_pm.c b/tests/xe/xe_pm.c
> index 11a4c3705..a8257b13c 100644
> --- a/tests/xe/xe_pm.c
> +++ b/tests/xe/xe_pm.c
> @@ -20,6 +20,7 @@
>  #include "lib/igt_device.h"
>  #include "lib/igt_kms.h"
>  #include "lib/igt_pm.h"
> +#include "lib/igt_sysfs.h"
>  #include "lib/igt_syncobj.h"
>  #include "lib/intel_reg.h"
>  
> @@ -31,6 +32,8 @@
>  #define NO_SUSPEND -1
>  #define NO_RPM -1
>  
> +#define SIZE (4096 * 1024)
> +
>  typedef struct {
>  	int fd_xe;
>  	struct pci_device *pci_xe;
> @@ -77,6 +80,22 @@ static void set_d3cold_allowed(struct pci_device *pci,
>  	close(fd);
>  }
>  
> +static void set_vram_d3cold_threshold(int sysfs, uint64_t threshold)
> +{
> +	char path[64];
> +	int ret;
> +
> +	sprintf(path, "device/vram_d3cold_threshold");
> +
> +	if (!faccessat(sysfs, path, R_OK | W_OK, 0))
> +		ret = igt_sysfs_printf(sysfs, path, "%lu", threshold);
> +	else
> +		igt_warn("vram_d3cold_threshold is not present\n");
> +
> +	igt_info("ret value %d", ret);
> +	igt_assert(ret > 0);
> +}
> +
>  static bool setup_d3(device_t device, enum igt_acpi_d_state state)
>  {
>  	igt_dpms_turn_off_display(device.fd_xe);
> @@ -349,6 +368,64 @@ NULL));
>  		igt_assert(in_d3(device, d_state));
>  }
>  
> +/**
> + * SUBTEST: vram-d3cold-threshold
> + * Description:
> + *	Validate whether card is limited to d3hot while vram used
> + *	is greater than vram_d3cold_threshold.
> + * Run type: FULL
> + */
> +static void test_vram_d3cold_threshold(device_t device)
> +{
> +	struct drm_xe_query_mem_usage *mem_usage;
> +	struct drm_xe_device_query query = {
> +		.extensions = 0,
> +		.query = DRM_XE_DEVICE_QUERY_MEM_USAGE,
> +		.size = 0,
> +		.data = 0,
> +	};
> +	uint64_t vram_used_mb = 0, vram_total_mb = 0, threshold;
> +	uint32_t bo, flags;
> +	void *map;
> +	int i, sysfs_fd;
> +
> +	flags = vram_memory(device.fd_xe, 0);
> +	igt_require_f(flags, "Device doesn't support vram memory region\n");
> +
> +	igt_assert_eq(igt_ioctl(device.fd_xe, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0);
> +	igt_assert_neq(query.size, 0);
> +
> +	mem_usage = malloc(query.size);
> +	igt_assert(mem_usage);
> +
> +	query.data = to_user_pointer(mem_usage);
> +	igt_assert_eq(igt_ioctl(device.fd_xe, DRM_IOCTL_XE_DEVICE_QUERY, &query), 0);
> +
> +	for (i = 0; i < mem_usage->num_regions; i++) {
> +		if (mem_usage->regions[i].mem_class == XE_MEM_REGION_CLASS_VRAM) {
> +			vram_used_mb +=  (mem_usage->regions[i].used / (1024 * 1024));
> +			vram_total_mb += (mem_usage->regions[i].total_size / (1024 * 1024));
> +		}
> +	}
> +
> +	threshold = vram_used_mb;
> +	igt_require(threshold < vram_total_mb);
> +
> +	bo = xe_bo_create_flags(device.fd_xe, 0, SIZE, flags);
> +	map = xe_bo_map(device.fd_xe, bo, SIZE);
> +	memset(map, 0, SIZE);
> +	munmap(map, SIZE);
> +	sysfs_fd = igt_sysfs_open(device.fd_xe);
> +	set_vram_d3cold_threshold(sysfs_fd, threshold);
> +	close(sysfs_fd);
> +
> +	/* Setup D3Cold but card should be in D3hot */
> +	igt_assert(setup_d3(device, IGT_ACPI_D3Cold));

should we add some wait here to ensure we gave the proper time
for everything to settle?

> +	igt_assert(in_d3(device, IGT_ACPI_D3Hot));
> +	igt_assert(out_of_d3(device, IGT_ACPI_D3Cold));
> +	gem_close(device.fd_xe, bo);
> +}
> +
>  igt_main
>  {
>  	struct drm_xe_engine_class_instance *hwe;
> @@ -449,6 +526,11 @@ igt_main
>  		}
>  	}
>  
> +	igt_describe("Validate whether card is limited to d3hot, if vram used > vram threshold");
> +	igt_subtest("vram-d3cold-threshold") {
> +		test_vram_d3cold_threshold(device);
> +	}

we probably need the other test and confirming that we are really getting
d3cold after touching this sysfs entry.

With the kernel series I just sent that should work.

but let's start with this:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> +
>  	igt_fixture {
>  		set_d3cold_allowed(device.pci_xe, d3cold_allowed);
>  		igt_restore_runtime_pm();
> -- 
> 2.25.1
> 

  reply	other threads:[~2023-07-20 21:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 11:08 [igt-dev] [PATCH i-g-t v3 0/3] vram d3cold threshold test Anshuman Gupta
2023-07-18 11:08 ` [igt-dev] [PATCH i-g-t v3 1/3] lib/igt_kms: Add helper with DPMS to turn on and off the displays Anshuman Gupta
2023-07-18 19:03   ` Rodrigo Vivi
2023-08-07  9:32   ` [igt-dev] [PATCH v4 3/3] " Mohammed Thasleem
2023-08-07 15:13     ` Rodrigo Vivi
2023-08-07 17:04     ` Modem, Bhanuprakash
2023-09-07 19:22     ` [igt-dev] [PATCH i-g-t] lib/igt_kms: Add helper " Mohammed Thasleem
2023-09-08  5:14       ` Modem, Bhanuprakash
2023-09-08  5:17       ` Modem, Bhanuprakash
2023-09-12  8:11       ` Mohammed Thasleem
2023-09-13 11:02         ` Juha-Pekka Heikkila
2023-11-28 21:31         ` [igt-dev] [PATCH v4 2/2] tests/intel/xe_pm: " Mohammed Thasleem
2023-11-29 15:04           ` Kamil Konieczny
2023-07-18 11:08 ` [igt-dev] [PATCH i-g-t v3 2/3] tests/xe_pm : Add support to disable all crtc Anshuman Gupta
2023-07-18 19:04   ` Rodrigo Vivi
2023-11-28 21:30   ` [igt-dev] [PATCH v4 1/2] tests/intel/xe_pm " Mohammed Thasleem
2023-07-18 11:08 ` [igt-dev] [PATCH i-g-t v3 3/3] test/xe_pm: Add vram_d3cold_threshold subtest Anshuman Gupta
2023-07-20 21:07   ` Rodrigo Vivi [this message]
2023-07-21  7:22     ` Gupta, Anshuman
2023-07-21 15:06       ` Vivi, Rodrigo
2023-07-21  4:04   ` Nilawar, Badal
2023-07-21  7:17     ` Gupta, Anshuman
2023-07-18 12:42 ` [igt-dev] ○ CI.xeBAT: info for vram d3cold threshold test (rev3) Patchwork
2023-07-18 12:55 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-07-18 16:56 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-08-07 12:41 ` [igt-dev] ○ CI.xeBAT: info for vram d3cold threshold test (rev4) Patchwork
2023-08-07 12:49 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-07 17:25 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-09-07 19:38 ` [igt-dev] ✗ Fi.CI.BUILD: failure for vram d3cold threshold test (rev5) Patchwork
2023-09-12 11:30 ` [igt-dev] ✗ Fi.CI.BUILD: failure for vram d3cold threshold test (rev6) Patchwork
2023-11-28 21:59 ` [igt-dev] ✗ Fi.CI.BUILD: failure for vram d3cold threshold test (rev8) Patchwork

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=ZLmiL9Nq5P3yZZxS@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.