From: Matthew Auld <matthew.auld@intel.com> To: igt-dev@lists.freedesktop.org Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH i-g-t v2 10/11] lib/i915/gem_mman: add helper query for has_device_coherent Date: Wed, 28 Jul 2021 11:30:40 +0100 [thread overview] Message-ID: <20210728103041.1669985-10-matthew.auld@intel.com> (raw) In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> Might be useful in some tests, where we are not explicitly testing WC maps, but rather just require something that is "device coherent", which should also play nice on discrete platforms. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Ramalingam C <ramalingam.c@intel.com> --- lib/i915/gem_mman.c | 43 +++++++++++++++++++++++++++++++++++++++++-- lib/i915/gem_mman.h | 11 +++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 16168a32..27ef97cf 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -196,6 +196,47 @@ bool gem_mmap_offset__has_wc(int fd) return has_wc > 0; } +#define LOCAL_I915_MMAP_OFFSET_FIXED 4 + +bool gem_mmap__has_device_coherent(int fd) +{ + struct drm_i915_gem_mmap_offset arg; + bool supported; + + if (gem_mmap__has_wc(fd)) + return true; + + /* Maybe we still have GTT mmaps? */ + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.flags = I915_MMAP_OFFSET_GTT; + supported = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &arg) == 0; + gem_close(fd, arg.handle); + + errno = 0; + + if (supported) + return true; + + /* + * Maybe this is a discrete device, which only supports fixed mmaps? + * Such mappings should also be considered device coherent. + */ + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.flags = LOCAL_I915_MMAP_OFFSET_FIXED; + supported = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &arg) == 0; + gem_close(fd, arg.handle); + + errno = 0; + + return supported; +} + /** * __gem_mmap: * @fd: open i915 drm file descriptor @@ -504,8 +545,6 @@ void *gem_mmap_offset__cpu(int fd, uint32_t handle, uint64_t offset, return ptr; } -#define LOCAL_I915_MMAP_OFFSET_FIXED 4 - void *__gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) { diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h index 290c997d..5966ddb5 100644 --- a/lib/i915/gem_mman.h +++ b/lib/i915/gem_mman.h @@ -41,6 +41,7 @@ void *gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); +bool gem_mmap__has_device_coherent(int fd); void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); @@ -96,6 +97,16 @@ int gem_munmap(void *ptr, uint64_t size); */ #define gem_require_mmap_offset_wc(fd) igt_require(gem_mmap_offset__has_wc(fd)) +/** + * gem_require_mmap_offset_device_coherent: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether direct (i.e. cpu access path, bypassing + * the gtt) write-combine memory mappings are available, or fixed mapping for + * discrete. Automatically skips through igt_require() if not. + */ +#define gem_require_mmap_device_coherent(fd) igt_require(gem_mmap__has_device_coherent(fd)) + extern const struct mmap_offset { const char *name; unsigned int type; -- 2.26.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Matthew Auld <matthew.auld@intel.com> To: igt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [igt-dev] [PATCH i-g-t v2 10/11] lib/i915/gem_mman: add helper query for has_device_coherent Date: Wed, 28 Jul 2021 11:30:40 +0100 [thread overview] Message-ID: <20210728103041.1669985-10-matthew.auld@intel.com> (raw) In-Reply-To: <20210728103041.1669985-1-matthew.auld@intel.com> Might be useful in some tests, where we are not explicitly testing WC maps, but rather just require something that is "device coherent", which should also play nice on discrete platforms. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Ramalingam C <ramalingam.c@intel.com> --- lib/i915/gem_mman.c | 43 +++++++++++++++++++++++++++++++++++++++++-- lib/i915/gem_mman.h | 11 +++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c index 16168a32..27ef97cf 100644 --- a/lib/i915/gem_mman.c +++ b/lib/i915/gem_mman.c @@ -196,6 +196,47 @@ bool gem_mmap_offset__has_wc(int fd) return has_wc > 0; } +#define LOCAL_I915_MMAP_OFFSET_FIXED 4 + +bool gem_mmap__has_device_coherent(int fd) +{ + struct drm_i915_gem_mmap_offset arg; + bool supported; + + if (gem_mmap__has_wc(fd)) + return true; + + /* Maybe we still have GTT mmaps? */ + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.flags = I915_MMAP_OFFSET_GTT; + supported = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &arg) == 0; + gem_close(fd, arg.handle); + + errno = 0; + + if (supported) + return true; + + /* + * Maybe this is a discrete device, which only supports fixed mmaps? + * Such mappings should also be considered device coherent. + */ + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.flags = LOCAL_I915_MMAP_OFFSET_FIXED; + supported = igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, + &arg) == 0; + gem_close(fd, arg.handle); + + errno = 0; + + return supported; +} + /** * __gem_mmap: * @fd: open i915 drm file descriptor @@ -504,8 +545,6 @@ void *gem_mmap_offset__cpu(int fd, uint32_t handle, uint64_t offset, return ptr; } -#define LOCAL_I915_MMAP_OFFSET_FIXED 4 - void *__gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot) { diff --git a/lib/i915/gem_mman.h b/lib/i915/gem_mman.h index 290c997d..5966ddb5 100644 --- a/lib/i915/gem_mman.h +++ b/lib/i915/gem_mman.h @@ -41,6 +41,7 @@ void *gem_mmap_offset__fixed(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); void *gem_mmap__device_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); +bool gem_mmap__has_device_coherent(int fd); void *gem_mmap__cpu_coherent(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); @@ -96,6 +97,16 @@ int gem_munmap(void *ptr, uint64_t size); */ #define gem_require_mmap_offset_wc(fd) igt_require(gem_mmap_offset__has_wc(fd)) +/** + * gem_require_mmap_offset_device_coherent: + * @fd: open i915 drm file descriptor + * + * Feature test macro to query whether direct (i.e. cpu access path, bypassing + * the gtt) write-combine memory mappings are available, or fixed mapping for + * discrete. Automatically skips through igt_require() if not. + */ +#define gem_require_mmap_device_coherent(fd) igt_require(gem_mmap__has_device_coherent(fd)) + extern const struct mmap_offset { const char *name; unsigned int type; -- 2.26.3 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2021-07-28 10:32 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-28 10:30 [Intel-gfx] [PATCH i-g-t v2 01/11] lib/i915/gem_mman: add FIXED mmap mode Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 02/11] lib/i915/gem_mman: add fixed mode to mmap__device_coherent Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 22:23 ` [Intel-gfx] " Dixit, Ashutosh 2021-07-28 22:23 ` [igt-dev] " Dixit, Ashutosh 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 03/11] lib/i915/gem_mman: add fixed mode to mmap__cpu_coherent Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 22:24 ` [Intel-gfx] " Dixit, Ashutosh 2021-07-28 22:24 ` [igt-dev] " Dixit, Ashutosh 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 04/11] lib/i915/gem_mman: add fixed mode to gem_mmap__cpu Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 23:07 ` [Intel-gfx] " Dixit, Ashutosh 2021-07-28 23:07 ` [igt-dev] " Dixit, Ashutosh 2021-07-29 8:50 ` [Intel-gfx] " Matthew Auld 2021-07-29 8:50 ` [igt-dev] " Matthew Auld 2021-08-02 6:29 ` [Intel-gfx] " Dixit, Ashutosh 2021-08-02 6:29 ` [igt-dev] " Dixit, Ashutosh 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 05/11] lib/i915/gem_mman: update mmap_offset_types with FIXED Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 06/11] lib/ioctl_wrappers: update mmap_{read, write} for discrete Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 07/11] lib/intel_bufops: " Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 08/11] lib/ioctl_wrappers: update set_domain " Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 09/11] tests/i915/module_load: update " Matthew Auld 2021-07-28 10:30 ` Matthew Auld [this message] 2021-07-28 10:30 ` [igt-dev] [PATCH i-g-t v2 10/11] lib/i915/gem_mman: add helper query for has_device_coherent Matthew Auld 2021-07-28 10:30 ` [Intel-gfx] [PATCH i-g-t v2 11/11] tests/i915/gem_exec_fence: use device_coherent mmap Matthew Auld 2021-07-28 10:30 ` [igt-dev] " Matthew Auld 2021-07-28 11:15 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,01/11] lib/i915/gem_mman: add FIXED mmap mode Patchwork 2021-07-28 13:58 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork 2021-07-28 15:52 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork 2021-07-28 22:20 ` [Intel-gfx] [PATCH i-g-t v2 01/11] " Dixit, Ashutosh 2021-07-28 22:20 ` [igt-dev] " Dixit, Ashutosh 2021-07-30 2:03 ` [Intel-gfx] " Dixit, Ashutosh 2021-07-30 2:03 ` [igt-dev] " Dixit, Ashutosh
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=20210728103041.1669985-10-matthew.auld@intel.com \ --to=matthew.auld@intel.com \ --cc=daniel.vetter@ffwll.ch \ --cc=igt-dev@lists.freedesktop.org \ --cc=intel-gfx@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: linkBe 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.