From: Vineet Gupta <vineet.gupta@linux.dev>
To: "Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
"Will Deacon" <will@kernel.org>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: Vineet Gupta <vineet.gupta@linux.dev>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, intel-xe@lists.freedesktop.org,
llvm@lists.linux.dev
Subject: [PATCH 4/4] drm/i915: Avoid -Wconstant-logical-operand with GCC 17
Date: Wed, 4 Nov 2026 08:07:21 -0800 [thread overview]
Message-ID: <20261104160722.1637541-5-vineet.gupta@linux.dev> (raw)
In-Reply-To: <20261104160722.1637541-1-vineet.gupta@linux.dev>
GCC 17 adds -Wconstant-logical-operand to -Wall. It warns when an operand
of && or || folds to a constant other than 0 or 1. Three places break the
build with CONFIG_WERROR=y:
include/drm/intel/reg_bits.h:27:48: error: use of logical '&&' with constant operand '256' [-Werror=constant-logical-operand]
drivers/gpu/drm/i915/i915_config.c:13:43: error: use of logical '&&' with constant operand '10000' [-Werror=constant-logical-operand]
drivers/gpu/drm/i915/gem/i915_gem_context.c:999:45: error: use of logical '&&' with constant operand '20000' [-Werror=constant-logical-operand]
clang has the same warning, but it checks only a constant right operand
outside a macro. Here each constant is a left operand, and
IS_POWER_OF_2() is also a macro.
Commit 1a839e016e49 ("drm/i915: remove IS_ACTIVE") moved
CONFIG_DRM_I915_FENCE_TIMEOUT to the left of && to avoid the clang
warning. That does not help with GCC 17.
Compare each constant against 0, as commit aeedd3a82678 ("drm/i915: Avoid
-Wconstant-logical-operand in nsecs_to_jiffies_timeout()") did.
Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
---
drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +-
drivers/gpu/drm/i915/i915_config.c | 2 +-
include/drm/intel/reg_bits.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index c58ffa5a8fa6..1639639dd290 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -996,7 +996,7 @@ static int intel_context_set_gem(struct intel_context *ce,
intel_engine_has_semaphores(ce->engine))
__set_bit(CONTEXT_USE_SEMAPHORES, &ce->flags);
- if (CONFIG_DRM_I915_REQUEST_TIMEOUT &&
+ if (CONFIG_DRM_I915_REQUEST_TIMEOUT != 0 &&
ctx->i915->params.request_timeout_ms) {
unsigned int timeout_ms = ctx->i915->params.request_timeout_ms;
diff --git a/drivers/gpu/drm/i915/i915_config.c b/drivers/gpu/drm/i915/i915_config.c
index 9e13b1be407c..9bbebe0a6a70 100644
--- a/drivers/gpu/drm/i915/i915_config.c
+++ b/drivers/gpu/drm/i915/i915_config.c
@@ -10,7 +10,7 @@
unsigned long i915_fence_context_timeout(u64 context)
{
- if (CONFIG_DRM_I915_FENCE_TIMEOUT && context)
+ if (CONFIG_DRM_I915_FENCE_TIMEOUT != 0 && context)
return msecs_to_jiffies_timeout(CONFIG_DRM_I915_FENCE_TIMEOUT);
return 0;
diff --git a/include/drm/intel/reg_bits.h b/include/drm/intel/reg_bits.h
index 2a9066e1d808..f913c3e61f39 100644
--- a/include/drm/intel/reg_bits.h
+++ b/include/drm/intel/reg_bits.h
@@ -24,7 +24,7 @@
/*
* Local integer constant expression version of is_power_of_2().
*/
-#define IS_POWER_OF_2(__x) ((__x) && (((__x) & ((__x) - 1)) == 0))
+#define IS_POWER_OF_2(__x) ((__x) != 0 && (((__x) & ((__x) - 1)) == 0))
/**
* REG_FIELD_PREP8() - Prepare a u8 bitfield value
--
2.53.0-Meta
next prev parent reply other threads:[~2026-11-04 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:07 [PATCH 0/4] Fix the x86 defconfig build with GCC 17 Vineet Gupta
2026-11-04 16:07 ` [PATCH 1/4] x86/cpufeatures: Make {REQUIRED,DISABLED}_MASK_BIT_SET() return 0 or 1 Vineet Gupta
2026-11-04 16:07 ` [PATCH 2/4] wait: Make ___wait_is_interruptible() " Vineet Gupta
2026-11-05 9:03 ` Peter Zijlstra
2026-11-05 17:43 ` Vineet Gupta
2026-11-04 16:07 ` [PATCH 3/4] iommupt: Make PT_SUPPORTED_FEATURE() " Vineet Gupta
2026-11-04 16:07 ` Vineet Gupta [this message]
2026-11-04 16:27 ` [PATCH 0/4] Fix the x86 defconfig build with GCC 17 Borislav Petkov
2026-11-04 18:05 ` Vineet Gupta
2026-11-04 21:18 ` Borislav Petkov
2026-11-05 9:04 ` Peter Zijlstra
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=20261104160722.1637541-5-vineet.gupta@linux.dev \
--to=vineet.gupta@linux.dev \
--cc=airlied@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=joro@8bytes.org \
--cc=juri.lelli@redhat.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=matthew.brost@intel.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=tglx@kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
--cc=vincent.guittot@linaro.org \
--cc=will@kernel.org \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.