2024-06-04 21:51:42

by Abhinav Kumar

[permalink] [raw]
Subject: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes

GCC diagnostic pragma method throws below warnings in some of the versions

drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:16:9: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
#pragma GCC diagnostic ignored "-Wunused-const-variable"
^
In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:18:0:
drivers/gpu/drm/msm/adreno/adreno_gen7_0_0_snapshot.h:924:19: warning: 'gen7_0_0_external_core_regs__always_unused' defined but not used [-Wunused-variable]
static const u32 *gen7_0_0_external_core_regs__always_unused[] = {
^
In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:19:0:
drivers/gpu/drm/msm/adreno/adreno_gen7_2_0_snapshot.h:748:19: warning: 'gen7_2_0_external_core_regs' defined but not used [-Wunused-variable]
static const u32 *gen7_2_0_external_core_regs[] = {
^
In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:20:0:
drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1188:43: warning: 'gen7_9_0_sptp_clusters' defined but not used [-Wunused-variable]
static struct gen7_sptp_cluster_registers gen7_9_0_sptp_clusters[] = {
^
drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1438:19: warning: 'gen7_9_0_external_core_regs' defined but not used [-Wunused-variable]
static const u32 *gen7_9_0_external_core_regs[] = {

Remove GCC dependency by using __always_unused for the unused gen7_* includes.

Fixes: 64d6255650d4 ("drm/msm: More fully implement devcoredump for a7xx")
Suggested-by: Rob Clark <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
---
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
index 0a7717a4fc2f..62ca0cf24005 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
@@ -8,19 +8,10 @@
#include "a6xx_gpu_state.h"
#include "a6xx_gmu.xml.h"

-/* Ignore diagnostics about register tables that we aren't using yet. We don't
- * want to modify these headers too much from their original source.
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-const-variable"
-
#include "adreno_gen7_0_0_snapshot.h"
#include "adreno_gen7_2_0_snapshot.h"
#include "adreno_gen7_9_0_snapshot.h"

-#pragma GCC diagnostic pop
-
struct a6xx_gpu_state_obj {
const void *handle;
u32 *data;
@@ -1350,6 +1341,10 @@ static void a7xx_get_registers(struct msm_gpu *gpu,
int index = 0;
const u32 *pre_crashdumper_regs;
const struct gen7_reg_list *reglist;
+ __always_unused const u32 **external_core_regs7_0_0 = gen7_0_0_external_core_regs;
+ __always_unused const u32 **external_core_regs_7_2_0 = gen7_2_0_external_core_regs;
+ __always_unused const u32 **external_core_regs_7_9_0 = gen7_9_0_external_core_regs;
+ __always_unused struct gen7_sptp_cluster_registers *sptp_gen7 = gen7_9_0_sptp_clusters;

if (adreno_is_a730(adreno_gpu)) {
reglist = gen7_0_0_reg_list;
--
2.44.0



2024-06-04 23:59:00

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes

On Tue, Jun 04, 2024 at 02:51:04PM -0700, Abhinav Kumar wrote:
> GCC diagnostic pragma method throws below warnings in some of the versions
>
> drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:16:9: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
> #pragma GCC diagnostic ignored "-Wunused-const-variable"
> ^
> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:18:0:
> drivers/gpu/drm/msm/adreno/adreno_gen7_0_0_snapshot.h:924:19: warning: 'gen7_0_0_external_core_regs__always_unused' defined but not used [-Wunused-variable]
> static const u32 *gen7_0_0_external_core_regs__always_unused[] = {
> ^

I don't see this symbol in upstream.

> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:19:0:
> drivers/gpu/drm/msm/adreno/adreno_gen7_2_0_snapshot.h:748:19: warning: 'gen7_2_0_external_core_regs' defined but not used [-Wunused-variable]
> static const u32 *gen7_2_0_external_core_regs[] = {
> ^
> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:20:0:
> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1188:43: warning: 'gen7_9_0_sptp_clusters' defined but not used [-Wunused-variable]
> static struct gen7_sptp_cluster_registers gen7_9_0_sptp_clusters[] = {
> ^
> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1438:19: warning: 'gen7_9_0_external_core_regs' defined but not used [-Wunused-variable]
> static const u32 *gen7_9_0_external_core_regs[] = {
>
> Remove GCC dependency by using __always_unused for the unused gen7_* includes.
>
> Fixes: 64d6255650d4 ("drm/msm: More fully implement devcoredump for a7xx")
> Suggested-by: Rob Clark <[email protected]>
> Signed-off-by: Abhinav Kumar <[email protected]>
> ---
> drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
> index 0a7717a4fc2f..62ca0cf24005 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
> @@ -8,19 +8,10 @@
> #include "a6xx_gpu_state.h"
> #include "a6xx_gmu.xml.h"
>
> -/* Ignore diagnostics about register tables that we aren't using yet. We don't
> - * want to modify these headers too much from their original source.
> - */
> -#pragma GCC diagnostic push
> -#pragma GCC diagnostic ignored "-Wunused-variable"
> -#pragma GCC diagnostic ignored "-Wunused-const-variable"
> -
> #include "adreno_gen7_0_0_snapshot.h"
> #include "adreno_gen7_2_0_snapshot.h"
> #include "adreno_gen7_9_0_snapshot.h"
>
> -#pragma GCC diagnostic pop
> -
> struct a6xx_gpu_state_obj {
> const void *handle;
> u32 *data;
> @@ -1350,6 +1341,10 @@ static void a7xx_get_registers(struct msm_gpu *gpu,
> int index = 0;
> const u32 *pre_crashdumper_regs;
> const struct gen7_reg_list *reglist;
> + __always_unused const u32 **external_core_regs7_0_0 = gen7_0_0_external_core_regs;
> + __always_unused const u32 **external_core_regs_7_2_0 = gen7_2_0_external_core_regs;
> + __always_unused const u32 **external_core_regs_7_9_0 = gen7_9_0_external_core_regs;
> + __always_unused struct gen7_sptp_cluster_registers *sptp_gen7 = gen7_9_0_sptp_clusters;

Wouldn't it be easier to add something like the following to the
a6xx_gpu_state.c before including the headers:

static const unsigned int *gen7_0_0_external_core_regs[] __attribute((__unused__));
static const unsigned int *gen7_2_0_external_core_regs[] __attribute((__unused__));
static const unsigned int *gen7_9_0_external_core_regs[] __attribute((__unused__));

>
> if (adreno_is_a730(adreno_gpu)) {
> reglist = gen7_0_0_reg_list;
> --
> 2.44.0
>

--
With best wishes
Dmitry

2024-06-05 00:15:47

by Abhinav Kumar

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes



On 6/4/2024 4:58 PM, Dmitry Baryshkov wrote:
> On Tue, Jun 04, 2024 at 02:51:04PM -0700, Abhinav Kumar wrote:
>> GCC diagnostic pragma method throws below warnings in some of the versions
>>
>> drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:16:9: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
>> #pragma GCC diagnostic ignored "-Wunused-const-variable"
>> ^
>> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:18:0:
>> drivers/gpu/drm/msm/adreno/adreno_gen7_0_0_snapshot.h:924:19: warning: 'gen7_0_0_external_core_regs__always_unused' defined but not used [-Wunused-variable]
>> static const u32 *gen7_0_0_external_core_regs__always_unused[] = {
>> ^
>
> I don't see this symbol in upstream.
>

This was a C&P mistake. Instead of pasting the warning message from the
default msm-next, I pasted the warning message from one of my trial runs
(a bad one). I will fix the commit message when I post a v2.

The correct warnings are:

drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:16:9: warning: unknown
option after '#pragma GCC diagnostic' kind [-Wpragmas]
#pragma GCC diagnostic ignored "-Wunused-const-variable"
^
In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:18:0:
drivers/gpu/drm/msm/adreno/adreno_gen7_0_0_snapshot.h:924:19: warning:
'gen7_0_0_external_core_regs' defined but not used [-Wunused-variable]
static const u32 *gen7_0_0_external_core_regs[] = {
^
In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:19:0:
drivers/gpu/drm/msm/adreno/adreno_gen7_2_0_snapshot.h:748:19: warning:
'gen7_2_0_external_core_regs' defined but not used [-Wunused-variable]
static const u32 *gen7_2_0_external_core_regs[] = {
^
In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:20:0:
drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1188:43: warning:
'gen7_9_0_sptp_clusters' defined but not used [-Wunused-variable]
static struct gen7_sptp_cluster_registers gen7_9_0_sptp_clusters[] = {
^
drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1438:19: warning:
'gen7_9_0_external_core_regs' defined but not used [-Wunused-variable]
static const u32 *gen7_9_0_external_core_regs[] = {


>> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:19:0:
>> drivers/gpu/drm/msm/adreno/adreno_gen7_2_0_snapshot.h:748:19: warning: 'gen7_2_0_external_core_regs' defined but not used [-Wunused-variable]
>> static const u32 *gen7_2_0_external_core_regs[] = {
>> ^
>> In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:20:0:
>> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1188:43: warning: 'gen7_9_0_sptp_clusters' defined but not used [-Wunused-variable]
>> static struct gen7_sptp_cluster_registers gen7_9_0_sptp_clusters[] = {
>> ^
>> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:1438:19: warning: 'gen7_9_0_external_core_regs' defined but not used [-Wunused-variable]
>> static const u32 *gen7_9_0_external_core_regs[] = {
>>
>> Remove GCC dependency by using __always_unused for the unused gen7_* includes.
>>
>> Fixes: 64d6255650d4 ("drm/msm: More fully implement devcoredump for a7xx")
>> Suggested-by: Rob Clark <[email protected]>
>> Signed-off-by: Abhinav Kumar <[email protected]>
>> ---
>> drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 13 ++++---------
>> 1 file changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
>> index 0a7717a4fc2f..62ca0cf24005 100644
>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
>> @@ -8,19 +8,10 @@
>> #include "a6xx_gpu_state.h"
>> #include "a6xx_gmu.xml.h"
>>
>> -/* Ignore diagnostics about register tables that we aren't using yet. We don't
>> - * want to modify these headers too much from their original source.
>> - */
>> -#pragma GCC diagnostic push
>> -#pragma GCC diagnostic ignored "-Wunused-variable"
>> -#pragma GCC diagnostic ignored "-Wunused-const-variable"
>> -
>> #include "adreno_gen7_0_0_snapshot.h"
>> #include "adreno_gen7_2_0_snapshot.h"
>> #include "adreno_gen7_9_0_snapshot.h"
>>
>> -#pragma GCC diagnostic pop
>> -
>> struct a6xx_gpu_state_obj {
>> const void *handle;
>> u32 *data;
>> @@ -1350,6 +1341,10 @@ static void a7xx_get_registers(struct msm_gpu *gpu,
>> int index = 0;
>> const u32 *pre_crashdumper_regs;
>> const struct gen7_reg_list *reglist;
>> + __always_unused const u32 **external_core_regs7_0_0 = gen7_0_0_external_core_regs;
>> + __always_unused const u32 **external_core_regs_7_2_0 = gen7_2_0_external_core_regs;
>> + __always_unused const u32 **external_core_regs_7_9_0 = gen7_9_0_external_core_regs;
>> + __always_unused struct gen7_sptp_cluster_registers *sptp_gen7 = gen7_9_0_sptp_clusters;
>
> Wouldn't it be easier to add something like the following to the
> a6xx_gpu_state.c before including the headers:
>
> static const unsigned int *gen7_0_0_external_core_regs[] __attribute((__unused__));
> static const unsigned int *gen7_2_0_external_core_regs[] __attribute((__unused__));
> static const unsigned int *gen7_9_0_external_core_regs[] __attribute((__unused__));
>

Ack, this works too and its cleaner. let me push it this way. Thanks.

>>
>> if (adreno_is_a730(adreno_gpu)) {
>> reglist = gen7_0_0_reg_list;
>> --
>> 2.44.0
>>
>

2024-06-05 04:23:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes

Hi Abhinav,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-intel/for-linux-next-fixes]
[also build test ERROR on drm-tip/drm-tip linus/master v6.10-rc2 next-20240604]
[cannot apply to drm-intel/for-linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Abhinav-Kumar/drm-msm-a6xx-use-__always_unused-to-fix-compiler-warnings-for-gen7_-includes/20240605-055341
base: git://anongit.freedesktop.org/drm-intel for-linux-next-fixes
patch link: https://lore.kernel.org/r/20240604215105.4057278-1-quic_abhinavk%40quicinc.com
patch subject: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes
config: um-allyesconfig (https://download.01.org/0day-ci/archive/20240605/[email protected]/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240605/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:13:
>> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:114:18: error: 'gen7_9_0_cx_debugbus_blocks' defined but not used [-Werror=unused-const-variable=]
114 | static const u32 gen7_9_0_cx_debugbus_blocks[] = {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


vim +/gen7_9_0_cx_debugbus_blocks +114 drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h

6408a1b5a7d7a9 Connor Abbott 2024-05-03 113
6408a1b5a7d7a9 Connor Abbott 2024-05-03 @114 static const u32 gen7_9_0_cx_debugbus_blocks[] = {
106414f8b60346 Connor Abbott 2024-05-03 115 A7XX_DBGBUS_CX,
106414f8b60346 Connor Abbott 2024-05-03 116 A7XX_DBGBUS_GMU_CX,
106414f8b60346 Connor Abbott 2024-05-03 117 A7XX_DBGBUS_GBIF_CX,
6408a1b5a7d7a9 Connor Abbott 2024-05-03 118 };
6408a1b5a7d7a9 Connor Abbott 2024-05-03 119

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-06-05 05:04:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes

Hi Abhinav,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-intel/for-linux-next-fixes]
[also build test WARNING on drm-tip/drm-tip linus/master v6.10-rc2 next-20240604]
[cannot apply to drm-intel/for-linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Abhinav-Kumar/drm-msm-a6xx-use-__always_unused-to-fix-compiler-warnings-for-gen7_-includes/20240605-055341
base: git://anongit.freedesktop.org/drm-intel for-linux-next-fixes
patch link: https://lore.kernel.org/r/20240604215105.4057278-1-quic_abhinavk%40quicinc.com
patch subject: [PATCH] drm/msm/a6xx: use __always_unused to fix compiler warnings for gen7_* includes
config: i386-buildonly-randconfig-001-20240605 (https://download.01.org/0day-ci/archive/20240605/[email protected]/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240605/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c:13:
>> drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h:114:18: warning: 'gen7_9_0_cx_debugbus_blocks' defined but not used [-Wunused-const-variable=]
114 | static const u32 gen7_9_0_cx_debugbus_blocks[] = {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/gen7_9_0_cx_debugbus_blocks +114 drivers/gpu/drm/msm/adreno/adreno_gen7_9_0_snapshot.h

6408a1b5a7d7a9 Connor Abbott 2024-05-03 113
6408a1b5a7d7a9 Connor Abbott 2024-05-03 @114 static const u32 gen7_9_0_cx_debugbus_blocks[] = {
106414f8b60346 Connor Abbott 2024-05-03 115 A7XX_DBGBUS_CX,
106414f8b60346 Connor Abbott 2024-05-03 116 A7XX_DBGBUS_GMU_CX,
106414f8b60346 Connor Abbott 2024-05-03 117 A7XX_DBGBUS_GBIF_CX,
6408a1b5a7d7a9 Connor Abbott 2024-05-03 118 };
6408a1b5a7d7a9 Connor Abbott 2024-05-03 119

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki