diff mbox series

drm/i915/guc: fix compile issue of guc_klvs_abi.h

Message ID 20230825050029.1122-1-quic_linyyuan@quicinc.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/guc: fix compile issue of guc_klvs_abi.h | expand

Commit Message

Linyu Yuan Aug. 25, 2023, 5 a.m. UTC
GCC report GUC_KLV_0_KEY and GUC_KLV_0_LEN is not constant when do
preprocessing.

Change to use GENMASK() to avoid the issue.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michal Wajdeczko Aug. 28, 2023, 9:42 p.m. UTC | #1
On 25.08.2023 07:50, Linyu Yuan wrote:
> 
> On 8/25/2023 1:37 PM, Jani Nikula wrote:
>> On Fri, 25 Aug 2023, Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
>>> GCC report GUC_KLV_0_KEY and GUC_KLV_0_LEN is not constant when do
>>> preprocessing.
>> Please paste the actual compiler warning.
> 
> 
>   CC      drivers/gpu/drm/i915/gt/uc/intel_guc_submission.o
> In file included from <command-line>:0:0:
> In function ‘__guc_context_policy_add_priority.isra.47’,
>     inlined from ‘__guc_context_set_prio.isra.48’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3332:3,
>     inlined from ‘guc_context_set_prio’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3360:2:
> ././include/linux/compiler_types.h:397:38: error: call to
> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
> mask is not constant
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                       ^
> ././include/linux/compiler_types.h:378:4: note: in definition of macro
> ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^~~~~~
> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
> ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:65:3: note: in expansion of macro
> ‘BUILD_BUG_ON_MSG’
>    BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:114:3: note: in expansion of macro
> ‘__BF_FIELD_CHECK’
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
> expansion of macro ‘FIELD_PREP’
>    FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>    ^~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>  MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>  ^~~~~~~~~~~~~~~~~~~~~~~
> In function ‘__guc_context_policy_add_preemption_timeout.isra.51’,
>     inlined from ‘__guc_context_set_preemption_timeout’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3005:3:
> ././include/linux/compiler_types.h:397:38: error: call to
> ‘__compiletime_assert_1793’ declared with attribute error: FIELD_PREP:
> mask is not constant
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                       ^
> ././include/linux/compiler_types.h:378:4: note: in definition of macro
> ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^~~~~~
> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
> ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:65:3: note: in expansion of macro
> ‘BUILD_BUG_ON_MSG’
>    BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:114:3: note: in expansion of macro
> ‘__BF_FIELD_CHECK’
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
> expansion of macro ‘FIELD_PREP’
>    FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>    ^~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2468:1: note: in
> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>  MAKE_CONTEXT_POLICY_ADD(preemption_timeout, PREEMPTION_TIMEOUT)
>  ^~~~~~~~~~~~~~~~~~~~~~~
> In function ‘__guc_context_policy_add_priority.isra.47’,
>     inlined from ‘__guc_add_request’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2503:2:
> ././include/linux/compiler_types.h:397:38: error: call to
> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
> mask is not constant
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                       ^
> ././include/linux/compiler_types.h:378:4: note: in definition of macro
> ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^~~~~~
> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
> ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:65:3: note: in expansion of macro
> ‘BUILD_BUG_ON_MSG’
>    BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:114:3: note: in expansion of macro
> ‘__BF_FIELD_CHECK’
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
> expansion of macro ‘FIELD_PREP’
>    FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>    ^~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>  MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>  ^~~~~~~~~~~~~~~~~~~~~~~
> In function ‘__guc_context_policy_add_priority.isra.47’,
>     inlined from ‘register_context’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2503:2:
> ././include/linux/compiler_types.h:397:38: error: call to
> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
> mask is not constant
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                       ^
> ././include/linux/compiler_types.h:378:4: note: in definition of macro
> ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^~~~~~
> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
> ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:65:3: note: in expansion of macro
> ‘BUILD_BUG_ON_MSG’
>    BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:114:3: note: in expansion of macro
> ‘__BF_FIELD_CHECK’
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
> expansion of macro ‘FIELD_PREP’
>    FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>    ^~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>  MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>  ^~~~~~~~~~~~~~~~~~~~~~~
> In function ‘__guc_scheduling_policy_add_klv.isra.56’,
>     inlined from ‘guc_init_global_schedule_policy’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4449:3,
>     inlined from ‘intel_guc_submission_enable’ at
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4490:6:
> ././include/linux/compiler_types.h:397:38: error: call to
> ‘__compiletime_assert_1882’ declared with attribute error: FIELD_PREP:
> mask is not constant
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                       ^
> ././include/linux/compiler_types.h:378:4: note: in definition of macro
> ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^~~~~~
> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
> ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>   ^~~~~~~~~~~~~~~~~~~
> ./include/linux/build_bug.h:39:37: note: in expansion of macro
> ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^~~~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:65:3: note: in expansion of macro
> ‘BUILD_BUG_ON_MSG’
>    BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>    ^~~~~~~~~~~~~~~~
> ./include/linux/bitfield.h:114:3: note: in expansion of macro
> ‘__BF_FIELD_CHECK’
>    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>    ^~~~~~~~~~~~~~~~
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4401:17: note: in
> expansion of macro ‘FIELD_PREP’
>   *(klv_ptr++) = FIELD_PREP(GUC_KLV_0_KEY, action) |
>                  ^~~~~~~~~~
> scripts/Makefile.build:243: recipe for target
> 'drivers/gpu/drm/i915/gt/uc/intel_guc_submission.o' failed
> 

What GCC/.config was it?

In the meantime, can you try simpler fix below (we want to avoid
external dependencies in GuC ABI headers)

-#define GUC_KLV_0_KEY                          (0xffff << 16)
+#define GUC_KLV_0_KEY                          (0xffffu << 16)

Michal

> 
>>
>> BR,
>> Jani.
>>
>>
>>
>>> Change to use GENMASK() to avoid the issue.
>>>
>>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>>> ---
>>>   drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>> b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>> index 58012edd4eb0..fd3c16695e5f 100644
>>> --- a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>> +++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>> @@ -29,8 +29,8 @@
>>>    */
>>>     #define GUC_KLV_LEN_MIN                1u
>>> -#define GUC_KLV_0_KEY                (0xffff << 16)
>>> -#define GUC_KLV_0_LEN                (0xffff << 0)
>>> +#define GUC_KLV_0_KEY                GENMASK(31, 16)
>>> +#define GUC_KLV_0_LEN                GENMASK(15, 0)
>>>   #define GUC_KLV_n_VALUE                (0xffffffff << 0)
>>>     /**
Linyu Yuan Aug. 30, 2023, 2:01 a.m. UTC | #2
On 8/29/2023 5:42 AM, Michal Wajdeczko wrote:
>
> On 25.08.2023 07:50, Linyu Yuan wrote:
>> On 8/25/2023 1:37 PM, Jani Nikula wrote:
>>> On Fri, 25 Aug 2023, Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
>>>> GCC report GUC_KLV_0_KEY and GUC_KLV_0_LEN is not constant when do
>>>> preprocessing.
>>> Please paste the actual compiler warning.
>>
>>    CC      drivers/gpu/drm/i915/gt/uc/intel_guc_submission.o
>> In file included from <command-line>:0:0:
>> In function ‘__guc_context_policy_add_priority.isra.47’,
>>      inlined from ‘__guc_context_set_prio.isra.48’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3332:3,
>>      inlined from ‘guc_context_set_prio’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3360:2:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_context_policy_add_preemption_timeout.isra.51’,
>>      inlined from ‘__guc_context_set_preemption_timeout’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3005:3:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1793’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2468:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(preemption_timeout, PREEMPTION_TIMEOUT)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_context_policy_add_priority.isra.47’,
>>      inlined from ‘__guc_add_request’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2503:2:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_context_policy_add_priority.isra.47’,
>>      inlined from ‘register_context’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2503:2:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_scheduling_policy_add_klv.isra.56’,
>>      inlined from ‘guc_init_global_schedule_policy’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4449:3,
>>      inlined from ‘intel_guc_submission_enable’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4490:6:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1882’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4401:17: note: in
>> expansion of macro ‘FIELD_PREP’
>>    *(klv_ptr++) = FIELD_PREP(GUC_KLV_0_KEY, action) |
>>                   ^~~~~~~~~~
>> scripts/Makefile.build:243: recipe for target
>> 'drivers/gpu/drm/i915/gt/uc/intel_guc_submission.o' failed
>>
> What GCC/.config was it?
>
> In the meantime, can you try simpler fix below (we want to avoid
> external dependencies in GuC ABI headers)
>
> -#define GUC_KLV_0_KEY                          (0xffff << 16)
> +#define GUC_KLV_0_KEY                          (0xffffu << 16)


i test it, this change can solve the issue, please submit a change.


> Michal
>
>>> BR,
>>> Jani.
>>>
>>>
>>>
>>>> Change to use GENMASK() to avoid the issue.
>>>>
>>>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>>>> ---
>>>>    drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h | 4 ++--
>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> index 58012edd4eb0..fd3c16695e5f 100644
>>>> --- a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> +++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> @@ -29,8 +29,8 @@
>>>>     */
>>>>      #define GUC_KLV_LEN_MIN                1u
>>>> -#define GUC_KLV_0_KEY                (0xffff << 16)
>>>> -#define GUC_KLV_0_LEN                (0xffff << 0)
>>>> +#define GUC_KLV_0_KEY                GENMASK(31, 16)
>>>> +#define GUC_KLV_0_LEN                GENMASK(15, 0)
>>>>    #define GUC_KLV_n_VALUE                (0xffffffff << 0)
>>>>      /**
Linyu Yuan Aug. 30, 2023, 2:05 a.m. UTC | #3
On 8/29/2023 5:42 AM, Michal Wajdeczko wrote:
>
> On 25.08.2023 07:50, Linyu Yuan wrote:
>> On 8/25/2023 1:37 PM, Jani Nikula wrote:
>>> On Fri, 25 Aug 2023, Linyu Yuan <quic_linyyuan@quicinc.com> wrote:
>>>> GCC report GUC_KLV_0_KEY and GUC_KLV_0_LEN is not constant when do
>>>> preprocessing.
>>> Please paste the actual compiler warning.
>>
>>    CC      drivers/gpu/drm/i915/gt/uc/intel_guc_submission.o
>> In file included from <command-line>:0:0:
>> In function ‘__guc_context_policy_add_priority.isra.47’,
>>      inlined from ‘__guc_context_set_prio.isra.48’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3332:3,
>>      inlined from ‘guc_context_set_prio’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3360:2:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_context_policy_add_preemption_timeout.isra.51’,
>>      inlined from ‘__guc_context_set_preemption_timeout’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:3005:3:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1793’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2468:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(preemption_timeout, PREEMPTION_TIMEOUT)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_context_policy_add_priority.isra.47’,
>>      inlined from ‘__guc_add_request’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2503:2:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_context_policy_add_priority.isra.47’,
>>      inlined from ‘register_context’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2503:2:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1803’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2461:3: note: in
>> expansion of macro ‘FIELD_PREP’
>>     FIELD_PREP(GUC_KLV_0_KEY, GUC_CONTEXT_POLICIES_KLV_ID_##id) | \
>>     ^~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2469:1: note: in
>> expansion of macro ‘MAKE_CONTEXT_POLICY_ADD’
>>   MAKE_CONTEXT_POLICY_ADD(priority, SCHEDULING_PRIORITY)
>>   ^~~~~~~~~~~~~~~~~~~~~~~
>> In function ‘__guc_scheduling_policy_add_klv.isra.56’,
>>      inlined from ‘guc_init_global_schedule_policy’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4449:3,
>>      inlined from ‘intel_guc_submission_enable’ at
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4490:6:
>> ././include/linux/compiler_types.h:397:38: error: call to
>> ‘__compiletime_assert_1882’ declared with attribute error: FIELD_PREP:
>> mask is not constant
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>                                        ^
>> ././include/linux/compiler_types.h:378:4: note: in definition of macro
>> ‘__compiletime_assert’
>>      prefix ## suffix();    \
>>      ^~~~~~
>> ././include/linux/compiler_types.h:397:2: note: in expansion of macro
>> ‘_compiletime_assert’
>>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>>    ^~~~~~~~~~~~~~~~~~~
>> ./include/linux/build_bug.h:39:37: note: in expansion of macro
>> ‘compiletime_assert’
>>   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>                                       ^~~~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:65:3: note: in expansion of macro
>> ‘BUILD_BUG_ON_MSG’
>>     BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask),  \
>>     ^~~~~~~~~~~~~~~~
>> ./include/linux/bitfield.h:114:3: note: in expansion of macro
>> ‘__BF_FIELD_CHECK’
>>     __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
>>     ^~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4401:17: note: in
>> expansion of macro ‘FIELD_PREP’
>>    *(klv_ptr++) = FIELD_PREP(GUC_KLV_0_KEY, action) |
>>                   ^~~~~~~~~~
>> scripts/Makefile.build:243: recipe for target
>> 'drivers/gpu/drm/i915/gt/uc/intel_guc_submission.o' failed
>>
> What GCC/.config was it?


gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0


make ARCH=x86 allyesconfig


>
> In the meantime, can you try simpler fix below (we want to avoid
> external dependencies in GuC ABI headers)
>
> -#define GUC_KLV_0_KEY                          (0xffff << 16)
> +#define GUC_KLV_0_KEY                          (0xffffu << 16)
>
> Michal
>
>>> BR,
>>> Jani.
>>>
>>>
>>>
>>>> Change to use GENMASK() to avoid the issue.
>>>>
>>>> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>>>> ---
>>>>    drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h | 4 ++--
>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> index 58012edd4eb0..fd3c16695e5f 100644
>>>> --- a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> +++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
>>>> @@ -29,8 +29,8 @@
>>>>     */
>>>>      #define GUC_KLV_LEN_MIN                1u
>>>> -#define GUC_KLV_0_KEY                (0xffff << 16)
>>>> -#define GUC_KLV_0_LEN                (0xffff << 0)
>>>> +#define GUC_KLV_0_KEY                GENMASK(31, 16)
>>>> +#define GUC_KLV_0_LEN                GENMASK(15, 0)
>>>>    #define GUC_KLV_n_VALUE                (0xffffffff << 0)
>>>>      /**
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
index 58012edd4eb0..fd3c16695e5f 100644
--- a/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
+++ b/drivers/gpu/drm/i915/gt/uc/abi/guc_klvs_abi.h
@@ -29,8 +29,8 @@ 
  */
 
 #define GUC_KLV_LEN_MIN				1u
-#define GUC_KLV_0_KEY				(0xffff << 16)
-#define GUC_KLV_0_LEN				(0xffff << 0)
+#define GUC_KLV_0_KEY				GENMASK(31, 16)
+#define GUC_KLV_0_LEN				GENMASK(15, 0)
 #define GUC_KLV_n_VALUE				(0xffffffff << 0)
 
 /**