lib/i915/gem_mman: Remove static variables
PATCH v4 1/2 lib/i915/gem_mman: Remove static variables
Since the IOCTL wrappers implemented in gem_mman should only be called once at fixture time there is no need to save the state across multiple calls.
--- lib/i915/gem_mman.c | 61 +++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 33 deletions(-)
lib/i915/gem_mman.c +28 -33
@@ -103,40 +103,35 @@ int gem_munmap(void *ptr, uint64_t size)bool gem_mmap__has_wc (int fd) { -static int has_wc =-1 ; - -if (has_wc ==-1 ) { -struct drm_i915_getparam gp; -int mmap_version =-1 ; -int gtt_version =-1 ; - - has_wc =0 ; - -memset (&gp,0 ,sizeof (gp)); - gp.param =I915_PARAM_MMAP_GTT_VERSION ; - gp.value = >t_version; -ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); - -memset (&gp,0 ,sizeof (gp)); - gp.param =I915_PARAM_MMAP_VERSION ; - gp.value = &mmap_version; -ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); - -/* Do we have the new mmap_ioctl with DOMAIN_WC? */ -if (mmap_version >=1 && gtt_version >=2 ) { -struct drm_i915_gem_mmap arg; - -/* Does this device support wc-mmaps ? */ -memset (&arg,0 ,sizeof (arg)); - arg.handle =gem_create (fd,4096 ); - arg.offset =0 ; - arg.size =4096 ; - arg.flags =I915_MMAP_WC ; - has_wc =igt_ioctl (fd,DRM_IOCTL_I915_GEM_MMAP , &arg) ==0 ; -gem_close (fd, arg.handle); - } - errno =0 ; +struct drm_i915_getparam gp; +int mmap_version =-1 ; +int gtt_version =-1 ; +int has_wc =0 ; + +memset (&gp,0 ,sizeof (gp)); + gp.param =I915_PARAM_MMAP_GTT_VERSION ; + gp.value = >t_version; +ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + +memset (&gp,0 ,sizeof (gp)); + gp.param =I915_PARAM_MMAP_VERSION ; + gp.value = &mmap_version; +ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + +/* Do we have the new mmap_ioctl with DOMAIN_WC? */ +if (mmap_version >=1 && gtt_version >=2 ) { +struct drm_i915_gem_mmap arg; + +/* Does this device support wc-mmaps ? */ +memset (&arg,0 ,sizeof (arg)); + arg.handle =gem_create (fd,4096 ); + arg.offset =0 ; + arg.size =4096 ; + arg.flags =I915_MMAP_WC ; + has_wc =igt_ioctl (fd,DRM_IOCTL_I915_GEM_MMAP , &arg) ==0 ; +gem_close (fd, arg.handle); } + errno =0 ;return has_wc >0 ; }
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH v4 2/2 lib/i915: Add mmap_offset support
From: "Kalamarz, Lukasz" <[email protected]>
With recently proposed changes, IGT need to start supporting new way of mmaping object, which will be used from now by default. This patch modify gem_mmap_wc and gem_mmap functions to be in sync with those changes.
v2:
- Fix IOCTL number. (Daniele)
- Move wrappers to new file. (Chris)
v3:
- Use mmap IOCTL for lower level wrappers. (Chris)
v4:
- Don't use static variables. (Chris)
- Remember gem_ prefix. (Chris)
--- lib/i915/gem_mman.c | 118 ++++++++++++++++++++++++++++++++++++-------- lib/i915/gem_mman.h | 33 +++++++++++++ 2 files changed, 130 insertions(+), 21 deletions(-)
lib/i915/gem_mman.c +97 -21
@@ -103,34 +103,49 @@ int gem_munmap(void *ptr, uint64_t size)bool gem_mmap__has_wc (int fd) { -struct drm_i915_getparam gp; -int mmap_version =-1 ; -int gtt_version =-1 ;int has_wc =0 ; -memset (&gp,0 ,sizeof (gp)); - gp.param =I915_PARAM_MMAP_GTT_VERSION ; - gp.value = >t_version; -ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); - -memset (&gp,0 ,sizeof (gp)); - gp.param =I915_PARAM_MMAP_VERSION ; - gp.value = &mmap_version; -ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); - -/* Do we have the new mmap_ioctl with DOMAIN_WC? */ -if (mmap_version >=1 && gtt_version >=2 ) { -struct drm_i915_gem_mmap arg; +/* Do we have the new mmap_offset ioctl? */ +if (gem_has_mmap_offset (fd)) { +struct local_drm_i915_gem_mmap_offset arg;/* Does this device support wc-mmaps ? */ memset (&arg,0 ,sizeof (arg)); arg.handle =gem_create (fd,4096 ); arg.offset =0 ; - arg.size =4096 ; - arg.flags =I915_MMAP_WC ; - has_wc =igt_ioctl (fd,DRM_IOCTL_I915_GEM_MMAP , &arg) ==0 ; + arg.flags =LOCAL_I915_MMAP_OFFSET_WC ; + has_wc =igt_ioctl (fd,LOCAL_DRM_IOCTL_I915_GEM_MMAP_OFFSET , &arg) ==0 ;gem_close (fd, arg.handle); + }else { +struct drm_i915_getparam gp; +int mmap_version =-1 ; +int gtt_version =-1 ; + +memset (&gp,0 ,sizeof (gp)); + gp.param =I915_PARAM_MMAP_GTT_VERSION ; + gp.value = >t_version; +ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + +memset (&gp,0 ,sizeof (gp)); + gp.param =I915_PARAM_MMAP_VERSION ; + gp.value = &mmap_version; +ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + +/* Do we have the mmap_ioctl with DOMAIN_WC? */ +if (mmap_version >=1 && gtt_version >=2 ) { +struct drm_i915_gem_mmap arg; + +/* Does this device support wc-mmaps ? */ +memset (&arg,0 ,sizeof (arg)); + arg.handle =gem_create (fd,4096 ); + arg.offset =0 ; + arg.size =4096 ; + arg.flags =I915_MMAP_WC ; + has_wc =igt_ioctl (fd,DRM_IOCTL_I915_GEM_MMAP , &arg) ==0 ; +gem_close (fd, arg.handle); + } } + errno =0 ;return has_wc >0 ;
@@ -206,7 +221,12 @@ void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, un*/ void *gem_mmap__wc (int fd,uint32_t handle,uint64_t offset,uint64_t size,unsigned prot) { -void *ptr =__gem_mmap__wc (fd, handle, offset, size, prot); +void *ptr; + + ptr =__gem_mmap_offset (fd, handle, offset, size, prot,LOCAL_I915_MMAP_OFFSET_WC ); +if (!ptr) + ptr =__gem_mmap__wc (fd, handle, offset, size, prot); +igt_assert (ptr);return ptr; }
@@ -243,7 +263,63 @@ void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, u*/ void *gem_mmap__cpu (int fd,uint32_t handle,uint64_t offset,uint64_t size,unsigned prot) { -void *ptr =__gem_mmap__cpu (fd, handle, offset, size, prot); +void *ptr; + + ptr =__gem_mmap_offset (fd, handle, offset, size, prot,LOCAL_I915_MMAP_OFFSET_WB ); +if (!ptr) + ptr =__gem_mmap (fd, handle, offset, size, prot,0 ); +igt_assert (ptr);return ptr; } + +bool gem_has_mmap_offset (int fd) +{ +struct drm_i915_getparam gp; +int has_mmap_offset =0 ; + +memset (&gp,0 ,sizeof (gp)); + gp.param =0x55 ;/* I915_PARAM_MMAP_OFFSET_VERSION */ + gp.value = &has_mmap_offset; +ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + +return has_mmap_offset >0 ; +} + +/** +* __gem_mmap_offset: +* @fd: open i915 drm file descriptor +* @handle: gem buffer object handle +* @offset: offset in the gem buffer of the mmap arena +* @size: size of the mmap arena +* @prot: memory protection bits as used by mmap() +* @flags: flags used to determine caching +* +* Similar to __gem_mmap but use MMAP_OFFSET IOCTL. +* +* Returns: A pointer to the created memory mapping, NULL on failure. +*/ +void +*__gem_mmap_offset (int fd,uint32_t handle,uint64_t offset,uint64_t size,unsigned int prot,uint64_t flags) +{ +struct local_drm_i915_gem_mmap_offset arg; +void *ptr; + +memset (&arg,0 ,sizeof (arg)); + arg.handle = handle; + arg.offset = offset; + arg.flags = flags; + +if (igt_ioctl (fd,LOCAL_DRM_IOCTL_I915_GEM_MMAP_OFFSET , &arg)) +return NULL ; + + ptr =mmap64 (0 , size, prot,MAP_SHARED , fd, arg.offset); + +if (ptr ==MAP_FAILED ) + ptr =NULL ; +else + errno =0 ; + +return ptr; +} +
lib/i915/gem_mman.h +33 -0
@@ -51,5 +51,38 @@ int gem_munmap(void *ptr, uint64_t size);*/ #define gem_require_mmap_wc (fd) igt_require(gem_mmap__has_wc(fd)) +struct local_drm_i915_gem_mmap_offset { +/** Handle for the object being mapped. */ +__u32 handle; +__u32 pad; +/** +* Fake offset to use for subsequent mmap call +* +* This is a fixed-size type for 32/64 compatibility. +*/ +__u64 offset; + +/** +* Flags for extended behaviour. +* +* It is mandatory that either one of the _WC/_WB flags +* should be passed here. +*/ +__u64 flags; +}; + +#define LOCAL_DRM_I915_GEM_MMAP_OFFSET 0x24 +#define LOCAL_I915_MMAP_OFFSET_WC (1 << 0) +#define LOCAL_I915_MMAP_OFFSET_WB (1 << 1) +#define LOCAL_I915_MMAP_OFFSET_UC (1 << 2) + +#define LOCAL_DRM_IOCTL_I915_GEM_MMAP_OFFSET \ + DRM_IOWR(DRM_COMMAND_BASE + LOCAL_DRM_I915_GEM_MMAP_OFFSET, struct local_drm_i915_gem_mmap_offset) + +bool gem_has_mmap_offset (int fd); + +void *__gem_mmap_offset (int fd,uint32_t handle,uint64_t offset,uint64_t size,unsigned int prot,uint64_t flags); + +#endif /* GEM_MMAN_H */
Signature · 6 lines
2.20.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v4,1/2] lib/i915/gem_mman: Remove static variables
In reply to Antonio Argenziano== Series Details ==
== Series Details ==
Series: series starting with [i-g-t,v4,1/2] lib/i915/gem_mman: Remove static variables
URL : https://patchwork.freedesktop.org/series/57265/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_5664 -> IGTPW_2529
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_2529 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_2529, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57265/revisions/1/
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_2529:
### IGT changes ###
#### Possible regressions ####
* igt@gem_exec_fence@basic-await-default:
- fi-skl-6700k2: PASS -> FAIL +2
- fi-hsw-4770r: PASS -> FAIL +3
- fi-byt-n2820: PASS -> FAIL +2
- fi-kbl-7560u: PASS -> FAIL +2
- fi-ivb-3770: PASS -> FAIL +2
- fi-bsw-n3050: PASS -> FAIL +2
- fi-skl-6600u: PASS -> FAIL +2
- fi-hsw-4770: PASS -> FAIL +3
- fi-byt-j1900: PASS -> FAIL +2
- fi-blb-e6850: PASS -> FAIL +3
- fi-kbl-8809g: PASS -> FAIL +2
- fi-kbl-7500u: PASS -> FAIL +2
- fi-kbl-x1275: PASS -> FAIL +2* igt@gem_exec_fence@nb-await-default:
- fi-bsw-kefka: PASS -> FAIL +2
- fi-bxt-j4205: PASS -> FAIL +2
- fi-icl-u3: PASS -> FAIL +2
- fi-ilk-650: PASS -> FAIL +3
- fi-icl-u2: PASS -> FAIL +2
- fi-ivb-3520m: PASS -> FAIL +2
- fi-snb-2520m: PASS -> FAIL +3
- fi-whl-u: PASS -> FAIL +2
- fi-bdw-5557u: PASS -> FAIL +2
- fi-hsw-peppy: PASS -> FAIL +2
- fi-skl-gvtdvm: PASS -> FAIL +2* igt@gem_mmap_gtt@basic-small-bo-tiledy:
- fi-kbl-7567u: PASS -> FAIL +2
- fi-bwr-2160: PASS -> FAIL +1
- fi-bdw-gvtdvm: PASS -> FAIL +2
- fi-kbl-guc: PASS -> FAIL
- fi-cfl-8109u: PASS -> FAIL +2
- fi-kbl-r: PASS -> FAIL +2
- fi-cfl-guc: PASS -> FAIL
- fi-elk-e7500: PASS -> FAIL +3
- fi-cfl-8700k: PASS -> FAIL +2
- fi-apl-guc: PASS -> FAIL
- fi-pnv-d510: PASS -> FAIL +2
- fi-skl-guc: PASS -> FAIL* igt@kms_frontbuffer_tracking@basic:
- fi-bsw-n3050: PASS -> CRASH +1
- fi-bsw-kefka: PASS -> CRASH +1
- fi-ivb-3770: PASS -> CRASH
- fi-skl-6700k2: PASS -> CRASH
- fi-byt-j1900: PASS -> CRASH
- fi-hsw-4770: PASS -> CRASH
- fi-kbl-7560u: PASS -> CRASH
- fi-skl-6600u: PASS -> CRASH
- fi-bdw-5557u: PASS -> CRASH
- fi-kbl-r: PASS -> CRASH
- fi-cfl-8109u: PASS -> CRASH
- fi-hsw-4770r: PASS -> CRASH
- fi-ilk-650: PASS -> CRASH
- fi-byt-n2820: PASS -> CRASH
- fi-snb-2520m: PASS -> CRASH
- fi-whl-u: PASS -> CRASH
- fi-cfl-8700k: PASS -> CRASH
- fi-ivb-3520m: PASS -> CRASH
- fi-bdw-gvtdvm: PASS -> CRASH
- fi-kbl-7567u: PASS -> CRASH
- fi-kbl-x1275: PASS -> CRASH
- fi-skl-gvtdvm: PASS -> CRASHKnown issues
------------
Here are the changes found in IGTPW_2529 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_fence@basic-await-default:
- fi-apl-guc: PASS -> FAIL [fdo#109474]
- fi-kbl-guc: PASS -> FAIL [fdo#109474]
- fi-cfl-guc: PASS -> FAIL [fdo#109474]
- fi-skl-guc: PASS -> FAIL [fdo#109474] * igt@gem_exec_reloc@basic-cpu-noreloc:
- fi-cfl-guc: PASS -> SKIP [fdo#109271] +63
* igt@gem_exec_reloc@basic-gtt-noreloc:
- fi-skl-guc: PASS -> SKIP [fdo#109271] +63
* igt@gem_exec_reloc@basic-write-gtt:
- fi-apl-guc: PASS -> SKIP [fdo#109271] +40
* igt@gem_mmap_gtt@basic-wc:
- fi-pnv-d510: PASS -> FAIL [fdo#107307]
- fi-kbl-guc: PASS -> FAIL [fdo#107307]
- fi-kbl-x1275: PASS -> FAIL [fdo#107307]
- fi-byt-j1900: PASS -> FAIL [fdo#107307]
- fi-kbl-r: PASS -> FAIL [fdo#107307]
- fi-byt-n2820: PASS -> FAIL [fdo#107307]
- fi-kbl-8809g: PASS -> FAIL [fdo#107307]
- fi-skl-gvtdvm: PASS -> FAIL [fdo#107307]
- fi-kbl-7560u: PASS -> FAIL [fdo#107307]
- fi-hsw-4770: PASS -> FAIL [fdo#107307]
- fi-cfl-guc: PASS -> FAIL [fdo#107307]
- fi-whl-u: PASS -> FAIL [fdo#107307]
- fi-skl-guc: PASS -> FAIL [fdo#107307]
- fi-kbl-7567u: PASS -> FAIL [fdo#107307]
- fi-bsw-n3050: PASS -> FAIL [fdo#107307]
- fi-skl-6700k2: PASS -> FAIL [fdo#107307]
- fi-ivb-3770: PASS -> FAIL [fdo#107307]
- fi-blb-e6850: PASS -> FAIL [fdo#107307]
- fi-hsw-peppy: PASS -> FAIL [fdo#107307]
- fi-cfl-8700k: PASS -> FAIL [fdo#107307]
- fi-apl-guc: PASS -> INCOMPLETE [fdo#103927]
- fi-skl-6600u: PASS -> FAIL [fdo#107307]
- fi-kbl-7500u: PASS -> FAIL [fdo#107307]
- fi-gdg-551: PASS -> FAIL [fdo#107307]
- fi-cfl-8109u: PASS -> FAIL [fdo#107307]
- fi-ivb-3520m: PASS -> FAIL [fdo#107307]
- fi-bxt-j4205: PASS -> INCOMPLETE [fdo#103927]
- fi-icl-u3: PASS -> FAIL [fdo#107307]
- fi-ilk-650: PASS -> FAIL [fdo#107307]
- fi-bdw-gvtdvm: PASS -> FAIL [fdo#107307]
- fi-icl-u2: PASS -> FAIL [fdo#107307]
- fi-hsw-4770r: PASS -> FAIL [fdo#107307]
- fi-elk-e7500: PASS -> FAIL [fdo#107307]
- fi-snb-2520m: PASS -> FAIL [fdo#107307]
- fi-bsw-kefka: PASS -> FAIL [fdo#107307]
- fi-bwr-2160: PASS -> FAIL [fdo#107307]
- fi-bdw-5557u: PASS -> FAIL [fdo#107307] * igt@i915_pm_rps@basic-api:
- fi-kbl-guc: PASS -> SKIP [fdo#109271] +71
#### Possible fixes ####
* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-byt-n2820: SKIP [fdo#109271] -> PASS
- fi-bsw-kefka: SKIP [fdo#109271] -> PASS
* igt@i915_pm_rpm@basic-rte:
- fi-byt-n2820: FAIL [fdo#108800] -> PASS
- fi-bsw-kefka: FAIL [fdo#108800] -> PASS
* igt@i915_selftest@live_execlists:
- fi-icl-u3: INCOMPLETE [fdo#109567] -> PASS
* igt@kms_busy@basic-flip-a:
- fi-kbl-7567u: SKIP [fdo#109271] / [fdo#109278] -> PASS +2
* igt@kms_busy@basic-flip-b:
- fi-gdg-551: FAIL [fdo#103182] -> PASS
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#107307]: https://bugs.freedesktop.org/show_bug.cgi?id=107307
[fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109474]: https://bugs.freedesktop.org/show_bug.cgi?id=109474
[fdo#109567]: https://bugs.freedesktop.org/show_bug.cgi?id=109567
Participating hosts (42 -> 38)
------------------------------
Missing (4): fi-icl-y fi-ilk-m540 fi-byt-squawks fi-bsw-cyan
Build changes
-------------
* IGT: IGT_4859 -> IGTPW_2529
CI_DRM_5664: cf7f9ddffea038209e80a3068eb4d7af73db0560 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2529: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2529/
IGT_4859: 1d8f3320cbc06fa73ad1487453a63993f17b9d57 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2529/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev