[igt-dev] [PATCH i-g-t 2/2] lib/i915/gem_mman: mmap to the CPU instead of the GTT in some tests
Chris Wilson
chris at chris-wilson.co.uk
Tue Nov 19 18:25:24 UTC 2019
Quoting Stuart Summers (2019-11-19 18:16:19)
> Do not limit to the GTT for tests which are not specifically testing
> capability in the GTT.
>
> Signed-off-by: Stuart Summers <stuart.summers at intel.com>
> ---
> lib/i915/gem_mman.c | 19 +++++++++++++++++++
> lib/i915/gem_mman.h | 1 +
> tests/i915/gem_ctx_shared.c | 20 +++++---------------
> tests/i915/gem_exec_schedule.c | 3 +--
> 4 files changed, 26 insertions(+), 17 deletions(-)
>
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index a0e34aef..d37840f7 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -40,6 +40,25 @@
> #define VG(x) do {} while (0)
> #endif
>
> +void *gem_mmap_host(int fd, uint32_t handle, uint64_t size, unsigned prot)
> +{
> + void *ptr;
> + uint32_t domain;
> +
> + if (gem_has_mappable_ggtt(fd)) {
> + ptr = gem_mmap__gtt(fd, handle, size, prot);
> + domain = I915_GEM_DOMAIN_GTT;
> + } else {
> + ptr = gem_mmap__cpu(fd, handle, 0, size, prot);
> + domain = I915_GEM_DOMAIN_CPU;
> + }
> +
> + gem_set_domain(fd, handle, /* no write hazard lies! */
> + domain, domain);
And be very careful putting the set-domain in here; as the lies are
integral to the test and not suitable for libraries. Domain handling is
sadly of paramount importance for most tests.
-Chris
More information about the igt-dev
mailing list