archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <>
To: Jani Nikula <>,
	Joonas Lahtinen <>,
	Rodrigo Vivi <>
Cc: Chris Wilson <>,,,,,
	Nathan Chancellor <>
Subject: [PATCH] drm/i915: Remove tautological compare in eb_relocate_vma
Date: Sat, 23 Nov 2019 12:53:22 -0700	[thread overview]
Message-ID: <> (raw)

-Wtautological-compare was recently added to -Wall in LLVM, which
exposed an if statement in i915 that is always false:

../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning:
result of comparison of constant 576460752303423487 with expression of
type 'unsigned int' is always false
        if (unlikely(remain > N_RELOC(ULONG_MAX)))

Since remain is an unsigned int, it can never be larger than UINT_MAX,
which is less than ULONG_MAX / sizeof(struct drm_i915_gem_relocation_entry).
Remove this statement to fix the warning.

Fixes: 2889caa92321 ("drm/i915: Eliminate lots of iterations over the execobjects array")
Signed-off-by: Nathan Chancellor <>

NOTE: Another possible fix for this is to change ULONG_MAX to UINT_MAX
      but I am not sure that is what was intended by this check. I'm
      happy to respin if that is the case.

 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index f0998f1225af..9ed4379b4bc8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1482,8 +1482,6 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
 	urelocs = u64_to_user_ptr(entry->relocs_ptr);
 	remain = entry->relocation_count;
-	if (unlikely(remain > N_RELOC(ULONG_MAX)))
-		return -EINVAL;
 	 * We must check that the entire relocation array is safe

             reply	other threads:[~2019-11-23 19:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 19:53 Nathan Chancellor [this message]
2019-11-23 20:05 ` Chris Wilson
2019-12-02 19:18   ` Nick Desaulniers
2019-12-03 13:42     ` Chris Wilson
2019-12-03 18:45       ` Nick Desaulniers
2019-12-22  3:09         ` Nathan Chancellor

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] drm/i915: Remove tautological compare in eb_relocate_vma' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).