diff mbox series

[i-g-t] lib/gem_mman: Stop lying about I915_MMAP_OFFSET_GTT support

Message ID 20241010135023.275507-2-janusz.krzysztofik@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [i-g-t] lib/gem_mman: Stop lying about I915_MMAP_OFFSET_GTT support | expand

Commit Message

Janusz Krzysztofik Oct. 10, 2024, 1:49 p.m. UTC
A few tests depend on for_each_mmap_offset_type() helper used for
selection of device supported mmap_offset types in loops either around
dynamic sub-subtests or inside subtest bodies.  That helper in turn
calls gem_has_mmap_offset_type() to omit unsupported mmap_offset types.
Unfortunately, its code returns GTT as supported mmap_offset type also on
new platforms that no longer support that type.  Poorly coded subtests may
than take unexpected processing paths and return unexpected results that
are not easy to understand and explain.

Fix it.

Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11370
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 lib/i915/gem_mman.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Kamil Konieczny Oct. 11, 2024, 8:21 a.m. UTC | #1
Hi Janusz,
On 2024-10-10 at 15:49:06 +0200, Janusz Krzysztofik wrote:
> A few tests depend on for_each_mmap_offset_type() helper used for
> selection of device supported mmap_offset types in loops either around
> dynamic sub-subtests or inside subtest bodies.  That helper in turn
> calls gem_has_mmap_offset_type() to omit unsupported mmap_offset types.
> Unfortunately, its code returns GTT as supported mmap_offset type also on
> new platforms that no longer support that type.  Poorly coded subtests may
> than take unexpected processing paths and return unexpected results that
> are not easy to understand and explain.
> 
> Fix it.
> 
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11370
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>

LGTM,
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>

> ---
>  lib/i915/gem_mman.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
> index 0b41ba70dd..cd0c65e213 100644
> --- a/lib/i915/gem_mman.c
> +++ b/lib/i915/gem_mman.c
> @@ -90,6 +90,8 @@ bool gem_has_mmap_offset_type(int fd, const struct mmap_offset *t)
>  	if (gem_has_mmap_offset(fd))
>  		if (gem_has_lmem(fd))
>  			return t->type == I915_MMAP_OFFSET_FIXED;
> +		else if (t->type == I915_MMAP_OFFSET_GTT)
> +			return gem_has_mappable_ggtt(fd);
>  		else
>  			return t->type != I915_MMAP_OFFSET_FIXED;
>  	else
> -- 
> 2.46.2
>
diff mbox series

Patch

diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c
index 0b41ba70dd..cd0c65e213 100644
--- a/lib/i915/gem_mman.c
+++ b/lib/i915/gem_mman.c
@@ -90,6 +90,8 @@  bool gem_has_mmap_offset_type(int fd, const struct mmap_offset *t)
 	if (gem_has_mmap_offset(fd))
 		if (gem_has_lmem(fd))
 			return t->type == I915_MMAP_OFFSET_FIXED;
+		else if (t->type == I915_MMAP_OFFSET_GTT)
+			return gem_has_mappable_ggtt(fd);
 		else
 			return t->type != I915_MMAP_OFFSET_FIXED;
 	else