[igt-dev] [PATCH i-g-t] lib/i915: Return false in gem_has_lmem for kernels not having DRM_I915_QUERY_MEMORY_REGIONS support
Modem, Bhanuprakash
bhanuprakash.modem at intel.com
Mon Jul 26 06:52:35 UTC 2021
> From: Srinivas, Vidya <vidya.srinivas at intel.com>
> Sent: Monday, July 26, 2021 11:37 AM
> To: igt-dev at lists.freedesktop.org
> Cc: Modem, Bhanuprakash <bhanuprakash.modem at intel.com>; Shankar, Uma
> <uma.shankar at intel.com>; Almahallawy, Khaled <khaled.almahallawy at intel.com>;
> Joshi, Kunal1 <kunal1.joshi at intel.com>; Heikkila, Juha-pekka <juha-
> pekka.heikkila at intel.com>; Lin, Charlton <charlton.lin at intel.com>; Latvala,
> Petri <petri.latvala at intel.com>; Dixit, Ashutosh <ashutosh.dixit at intel.com>;
> Srinivas, Vidya <vidya.srinivas at intel.com>; Lin, Charlton
> <charlton.lin at intel.com>
> Subject: [PATCH i-g-t] lib/i915: Return false in gem_has_lmem for kernels not
> having DRM_I915_QUERY_MEMORY_REGIONS support
>
> Starting commit (tests/kms: Create buffer object from LMEM for discrete)
> it checks for LMEM. This is breaking older kernels like 5.4 without
> DRM_I915_QUERY_MEMORY_REGIONS support.
>
> Kernel writes length back to userspace if ret and
> length differ, indicating an error condition. In this case, the length
> written back is -22 which is EINVAL. Patch checks negative item length
> and returns false from gem_has_lmem.
>
> Credits-to: Ashutosh Dixit <ashutosh.dixit at intel.com>
> Signed-off-by: Lin Charlton <charlton.lin at intel.com>
> Signed-off-by: Vidya Srinivas <vidya.srinivas at intel.com>
> Change-Id: Ia404b77fbe4c1fc22ca462a15f26640f9ffa4120
> ---
> lib/i915/intel_memory_region.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 144ae12ca7a0..8db3e69e9913 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -164,6 +164,15 @@ uint8_t gem_get_lmem_region_count(int fd)
> */
> bool gem_has_lmem(int fd)
> {
> + struct drm_i915_query_item item;
> + int ret;
> +
> + memset(&item, 0, sizeof(item));
> + item.query_id = DRM_I915_QUERY_MEMORY_REGIONS;
> + ret = __i915_query_items(fd, &item, 1);
> + if (ret != 0 || item.length < 0)
> + return false;
> +
I guess, this logic is redundant. As Ashutosh mentioned in earlier revisions,
we need to fix this at gem_get_query_memory_regions()
gem_has_lmem --> gem_get_lmem_region_count --> gem_get_query_memory_regions
> return gem_get_lmem_region_count(fd) > 0;
> }
>
> --
> 2.32.0
More information about the igt-dev
mailing list