[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a4c599b3-8dd5-4799-8565-cf07c7e07227@app.fastmail.com>
Date: Fri, 17 Feb 2023 17:15:14 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "Andrzej Hajda" <andrzej.hajda@...el.com>,
"Arnd Bergmann" <arnd@...nel.org>,
"Jani Nikula" <jani.nikula@...ux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@...ux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@...el.com>,
"Tvrtko Ursulin" <tvrtko.ursulin@...ux.intel.com>,
"Dave Airlie" <airlied@...il.com>,
"Daniel Vetter" <daniel@...ll.ch>,
"Matthew Brost" <matthew.brost@...el.com>,
"John Harrison" <John.C.Harrison@...el.com>,
"Michal Wajdeczko" <michal.wajdeczko@...el.com>
Cc: intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915/guc: avoid FIELD_PREP warning
On Fri, Feb 17, 2023, at 16:38, Andrzej Hajda wrote:
> On 17.02.2023 13:46, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@...db.de>
>>
>> With gcc-7 and earlier, there are lots of warnings like
>>
>> In file included from <command-line>:0:0:
>> In function '__guc_context_policy_add_priority.isra.66',
>> inlined from '__guc_context_set_prio.isra.67' at drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3292:3,
>> inlined from 'guc_context_set_prio' at drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3320:2:
>> include/linux/compiler_types.h:399:38: error: call to '__compiletime_assert_631' declared with attribute error: FIELD_PREP: mask is not constant
>> _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>> ^
>> ...
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2422:3: note: in expansion of macro 'FIELD_PREP'
>> FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>> ^~~~~~~~~~
>>
>> Make sure that GUC_KLV_0_KEY is an unsigned value to avoid the warning.
>
> Does it mean __builtin_constant_p in gcc7 returns 0 on signed constants?
> I guess there should be more similar errors.
No, it's not as simple as that, I'm not really sure what the underlying
problem is with the compiler, and this is the only file that triggered
this particular warning.
There are other cases where old compilers had the reverse problem,
where they sometimes report a variable to be __builtin_constant_p()==true
if there is a branch that assigns a constant to it.
I think here it happens because GUC_KLV_0_KEY and GUC_KLV_n_VALUE are
negative.
Arnd
Powered by blists - more mailing lists