Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [i-g-t V2] lib/i915: Handle QUERY_MEMORY_REGIONS on older kernels
Date: Mon, 26 Jul 2021 13:54:04 -0700	[thread overview]
Message-ID: <87r1fkokyb.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20210726122636.159703-1-bhanuprakash.modem@intel.com>

On Mon, 26 Jul 2021 05:26:36 -0700, Bhanuprakash Modem wrote:
>
> While checking for LMEM support on older kernels with the
> DRM_I915_QUERY_MEMORY_REGIONS, it may fail with EINVAL.
>
> Instead of abort/asserting the test, we must handle this
> case properly.

The patch is fine now. But I would still state clearly in the commit
message what the objective for the patch is. So something like:

"Instead of abort/asserting the test make sure gem_has_lmem remains
functional".

With a suitable commit message this is:

Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>

> V2:
> * Rebase
>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Cc: Vidya Srinivas <vidya.srinivas@intel.com>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> ---
>  lib/i915/intel_memory_region.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index e1e210f2c..72e337af3 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -114,7 +114,7 @@ uint32_t gem_get_batch_size(int fd, uint8_t mem_region_type)
>  struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd)
>  {
>	struct drm_i915_query_item item;
> -	struct drm_i915_query_memory_regions *query_info;
> +	struct drm_i915_query_memory_regions *query_info = NULL;
>
>	memset(&item, 0, sizeof(item));
>	item.query_id = DRM_I915_QUERY_MEMORY_REGIONS;
> @@ -123,15 +123,18 @@ struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd)
>	 * Any DRM_I915_QUERY_MEMORY_REGIONS specific errors are encoded in the
>	 * item.length, even though the ioctl might still return success.
>	 */
> -	igt_assert_f(item.length > 0,
> -		     "DRM_I915_QUERY_MEMORY_REGIONS failed with %d\n",
> -		     item.length);
> +	if (item.length < 0) {
> +		igt_critical("DRM_I915_QUERY_MEMORY_REGIONS failed with %d\n",
> +			     item.length);
> +		goto out;
> +	}
>
>	query_info = calloc(1, item.length);
>
>	item.data_ptr = to_user_pointer(query_info);
>	i915_query_items(fd, &item, 1);
>
> +out:
>	return query_info;
>  }
>
> @@ -150,6 +153,9 @@ uint8_t gem_get_lmem_region_count(int fd)
>	uint8_t lmem_regions = 0;
>
>	query_info = gem_get_query_memory_regions(fd);
> +	if (!query_info)
> +		goto out;
> +
>	num_regions = query_info->num_regions;
>
>	for (int i = 0; i < num_regions; i++) {
> @@ -158,6 +164,7 @@ uint8_t gem_get_lmem_region_count(int fd)
>	}
>	free(query_info);
>
> +out:
>	return lmem_regions;
>  }
>
> --
> 2.32.0
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2021-07-26 21:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26  9:49 [igt-dev] [PATCH i-g-t] lib/i915: Handle QUERY_MEMORY_REGIONS on older kernels Bhanuprakash Modem
2021-07-26 11:33 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " Patchwork
2021-07-26 12:26 ` [igt-dev] [i-g-t V2] " Bhanuprakash Modem
2021-07-26 20:54   ` Dixit, Ashutosh [this message]
2021-07-27  1:32   ` [igt-dev] [i-g-t V3] " Bhanuprakash Modem
2021-07-26 13:50 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Handle QUERY_MEMORY_REGIONS on older kernels (rev2) Patchwork
2021-07-26 17:31 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2021-07-27  1:44   ` Modem, Bhanuprakash
2021-07-27  1:44   ` Modem, Bhanuprakash
2021-07-27  4:57     ` Vudum, Lakshminarayana
2021-07-27  1:57 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
2021-07-27  2:02 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915: Handle QUERY_MEMORY_REGIONS on older kernels (rev3) Patchwork
2021-07-27  6:31 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=87r1fkokyb.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=bhanuprakash.modem@intel.com \
    --cc=igt-dev@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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox