Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
	igt-dev@lists.freedesktop.org,  intel-xe@lists.freedesktop.org
Subject: Re: [i-g-t 4/4] tests/xe/mmap: add tests for pci mem barrier
Date: Fri, 15 Nov 2024 10:50:29 +0000	[thread overview]
Message-ID: <e71f0bd6-972a-471d-ba7a-bb081e5d1720@intel.com> (raw)
In-Reply-To: <20241114050129.1381711-5-tejas.upadhyay@intel.com>

On 14/11/2024 05:01, Tejas Upadhyay wrote:
> We want to make sure that mmap do direct mapping of physical
> page at doorbell space and whole page is accessible in order
> to use pci memory barrier effect effectively.
> 
> Following subtests are added,
> ./build/tests/xe_mmap --r pci-membarrier
> ./build/tests/xe_mmap --r pci-membarrier-bad-pagesize
> ./build/tests/xe_mmap --r pci-membarrier-bad-object
 > > Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
>   tests/intel/xe_mmap.c | 96 +++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 96 insertions(+)
> 
> diff --git a/tests/intel/xe_mmap.c b/tests/intel/xe_mmap.c
> index fc5d73d59..ae0363a20 100644
> --- a/tests/intel/xe_mmap.c
> +++ b/tests/intel/xe_mmap.c
> @@ -64,6 +64,74 @@ test_mmap(int fd, uint32_t placement, uint32_t flags)
>   	gem_close(fd, bo);
>   }
>   
> +#define PAGE_SHIFT 12

Looks to be unused.

> +#define PAGE_SIZE 4096
> +
> +/**
> + * SUBTEST: pci-membarrier
> + * Description: create pci memory barrier with write on defined mmap offset.
> + * Test category: functionality test
> + *
> + */
> +static void test_pci_membarrier(int xe)
> +{
> +	uint64_t flags = MAP_SHARED;
> +	unsigned int prot = PROT_WRITE;
> +	uint32_t *ptr;
> +	uint64_t size = PAGE_SIZE;
> +	struct timespec tv;
> +	struct drm_xe_gem_mmap_offset mmo = {
> +		.handle = 0,
> +		.flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
> +	};
> +
> +	igt_assert_eq(igt_ioctl(xe, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);

do_ioctl()

> +	ptr = mmap(NULL, size, prot, flags, xe, mmo.offset);
> +	igt_assert(ptr != MAP_FAILED);
> +
> +	/* Check whole page for any errors, also check as
> +	 * we should not read written values back
> +	 */
> +	for (int i = 0; i < size / sizeof(*ptr); i++) {
> +		/* It is expected unconfigured doorbell space
> +		 * will return read value 0xdeadbeef
> +		 */
> +		igt_assert_eq_u32(READ_ONCE(ptr[i]), 0xdeadbeef);
> +
> +		igt_gettime(&tv);
> +		ptr[i] = i;
> +		if (READ_ONCE(ptr[i]) == i) {
> +			while (READ_ONCE(ptr[i]) == i)
> +				;
> +			igt_info("fd:%d value retained for %"PRId64"ns pos:%d\n",
> +				 xe, igt_nsec_elapsed(&tv), i);
> +		}
> +		igt_assert_neq(READ_ONCE(ptr[i]), i);
> +	}
> +
> +	munmap(ptr, size);
> +}
> +
> +/**
> + * SUBTEST: pci-membarrier-bad-pagesize
> + * Description: Test mmap offset with bad pagesize for pci membarrier.
> + * Test category: negative test
> + *
> + */
> +static void test_bad_pagesize_for_pcimem(int fd)
> +{
> +	uint32_t *map;
> +	uint64_t page_size = PAGE_SIZE * 2;
> +	struct drm_xe_gem_mmap_offset mmo = {
> +		.handle = 0,
> +		.flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
> +	};
> +
> +	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo), 0);

do_ioctl()

> +	map = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED, fd, mmo.offset);
> +	igt_assert(map == MAP_FAILED);
> +}
> +
>   /**
>    * SUBTEST: bad-flags
>    * Description: Test mmap offset with bad flags.
> @@ -126,6 +194,25 @@ static void test_bad_object(int fd)
>   	do_ioctl_err(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo, ENOENT);
>   }
>   
> +/**
> + * SUBTEST: pci-membarrier-bad-object
> + * Description: Test mmap offset with bad object for pci mem barrier.
> + * Test category: negative test
> + *
> + */
> +static void test_bad_object_for_pcimem(int fd)
> +{
> +	uint64_t size = xe_get_default_alignment(fd);
> +	struct drm_xe_gem_mmap_offset mmo = {
> +		.handle = xe_bo_create(fd, 0, size,
> +				       vram_if_possible(fd, 0),
> +				       DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM),
> +		.flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
> +	};
> +
> +	do_ioctl_err(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo, EINVAL);
> +}
> +
>   static jmp_buf jmp;
>   
>   __noreturn static void sigtrap(int sig)
> @@ -273,6 +360,12 @@ igt_main
>   		test_mmap(fd, vram_memory(fd, 0) | system_memory(fd),
>   			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
>   
> +	igt_subtest("pci-membarrier")
> +		test_pci_membarrier(fd);
> +
> +	igt_subtest_f("pci-membarrier-bad-pagesize")

igt_subtest()

Reviewed-by: Matthew Auld <matthew.auld@intel.com>

> +		test_bad_pagesize_for_pcimem(fd);
> +
>   	igt_subtest("bad-flags")
>   		test_bad_flags(fd);
>   
> @@ -282,6 +375,9 @@ igt_main
>   	igt_subtest("bad-object")
>   		test_bad_object(fd);
>   
> +	igt_subtest("pci-membarrier-bad-object")
> +		test_bad_object_for_pcimem(fd);
> +
>   	igt_subtest("small-bar") {
>   		igt_require(xe_visible_vram_size(fd, 0));
>   		igt_require(xe_visible_vram_size(fd, 0) < xe_vram_size(fd, 0));


  reply	other threads:[~2024-11-15 10:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14  5:01 [i-g-t 0/4] Add pci_membarrier test in xe_mmap Tejas Upadhyay
2024-11-14  5:01 ` [i-g-t 1/4] lib/i915_drm_local: Remove macros added via merged kernel Tejas Upadhyay
2024-11-15 10:14   ` Matthew Auld
2024-11-14  5:01 ` [i-g-t 2/4] include/drm-uapi-experimental: Move i915_drm_local.h to drm-uapi-experimental Tejas Upadhyay
2024-11-15 10:22   ` Matthew Auld
2024-11-14  5:01 ` [i-g-t 3/4] include/intel_drm_local.h: Add DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER Tejas Upadhyay
2024-11-15 10:27   ` Matthew Auld
2024-11-14  5:01 ` [i-g-t 4/4] tests/xe/mmap: add tests for pci mem barrier Tejas Upadhyay
2024-11-15 10:50   ` Matthew Auld [this message]
2024-11-14  5:24 ` ✗ CI.Patch_applied: failure for Add pci_membarrier test in xe_mmap (rev2) 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=e71f0bd6-972a-471d-ba7a-bb081e5d1720@intel.com \
    --to=matthew.auld@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=tejas.upadhyay@intel.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