All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Hawking Zhang <Hawking.Zhang@amd.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Alex Deucher <alexander.deucher@amd.com>,
	Wenhui Sheng <Wenhui.Sheng@amd.com>
Subject: [agd5f:drm-next 429/599] drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?
Date: Mon, 9 May 2022 14:16:48 +0300	[thread overview]
Message-ID: <202205082233.0Gm8B7A4-lkp@intel.com> (raw)

tree:   https://gitlab.freedesktop.org/agd5f/linux.git drm-next
head:   3170f5f234272247989fafee4cba4cbbc822631c
commit: 3d879e81f0f9ed5d33b5eda0fe5226c884bb8073 [429/599] drm/amdgpu: add init support for GFX11 (v2)
config: csky-randconfig-m031-20220508 (https://download.01.org/0day-ci/archive/20220508/202205082233.0Gm8B7A4-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?

vim +1278 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

3d879e81f0f9ed Hawking Zhang 2022-04-13  1250  static void gfx_v11_0_rlc_backdoor_autoload_copy_ucode(struct amdgpu_device *adev,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1251  					      SOC21_FIRMWARE_ID id,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1252  			    		      const void *fw_data,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1253  					      uint32_t fw_size,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1254  					      uint32_t *fw_autoload_mask)

It would be cleaner to just declare fw_autoload_mask as a u64.  I
reviewed the code to see why it's a u32 and could not see a reason.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1255  {
3d879e81f0f9ed Hawking Zhang 2022-04-13  1256  	uint32_t toc_offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1257  	uint32_t toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1258  	char *ptr = adev->gfx.rlc.rlc_autoload_ptr;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1259  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1260  	if (id <= SOC21_FIRMWARE_ID_INVALID || id >= SOC21_FIRMWARE_ID_MAX)

SOC21_FIRMWARE_ID_MAX is 37 which is more than 31 so this but is real.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1261  		return;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1262  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1263  	toc_offset = rlc_autoload_info[id].offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1264  	toc_fw_size = rlc_autoload_info[id].size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1265  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1266  	if (fw_size == 0)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1267  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1268  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1269  	if (fw_size > toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1270  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1271  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1272  	memcpy(ptr + toc_offset, fw_data, fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1273  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1274  	if (fw_size < toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1275  		memset(ptr + toc_offset + fw_size, 0, toc_fw_size - fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1276  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1277  	if ((id != SOC21_FIRMWARE_ID_RS64_PFP) && (id != SOC21_FIRMWARE_ID_RS64_ME))
3d879e81f0f9ed Hawking Zhang 2022-04-13 @1278  		*(uint64_t *)fw_autoload_mask |= 1 << id;
                                                                                         ^^^^^^^^

This needs to be 1ULL < id.  Otherwise if id is >= 32 the shift will
wrap.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1279  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [agd5f:drm-next 429/599] drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?
Date: Sun, 08 May 2022 22:13:31 +0800	[thread overview]
Message-ID: <202205082233.0Gm8B7A4-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3487 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Hawking Zhang <Hawking.Zhang@amd.com>
CC: Alex Deucher <alexander.deucher@amd.com>
CC: Wenhui Sheng <Wenhui.Sheng@amd.com>

tree:   https://gitlab.freedesktop.org/agd5f/linux.git drm-next
head:   3170f5f234272247989fafee4cba4cbbc822631c
commit: 3d879e81f0f9ed5d33b5eda0fe5226c884bb8073 [429/599] drm/amdgpu: add init support for GFX11 (v2)
:::::: branch date: 2 days ago
:::::: commit date: 4 days ago
config: csky-randconfig-m031-20220508 (https://download.01.org/0day-ci/archive/20220508/202205082233.0Gm8B7A4-lkp(a)intel.com/config)
compiler: csky-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?

vim +1278 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

3d879e81f0f9ed Hawking Zhang 2022-04-13  1249  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1250  static void gfx_v11_0_rlc_backdoor_autoload_copy_ucode(struct amdgpu_device *adev,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1251  					      SOC21_FIRMWARE_ID id,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1252  			    		      const void *fw_data,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1253  					      uint32_t fw_size,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1254  					      uint32_t *fw_autoload_mask)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1255  {
3d879e81f0f9ed Hawking Zhang 2022-04-13  1256  	uint32_t toc_offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1257  	uint32_t toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1258  	char *ptr = adev->gfx.rlc.rlc_autoload_ptr;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1259  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1260  	if (id <= SOC21_FIRMWARE_ID_INVALID || id >= SOC21_FIRMWARE_ID_MAX)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1261  		return;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1262  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1263  	toc_offset = rlc_autoload_info[id].offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1264  	toc_fw_size = rlc_autoload_info[id].size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1265  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1266  	if (fw_size == 0)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1267  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1268  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1269  	if (fw_size > toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1270  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1271  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1272  	memcpy(ptr + toc_offset, fw_data, fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1273  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1274  	if (fw_size < toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1275  		memset(ptr + toc_offset + fw_size, 0, toc_fw_size - fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1276  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1277  	if ((id != SOC21_FIRMWARE_ID_RS64_PFP) && (id != SOC21_FIRMWARE_ID_RS64_ME))
3d879e81f0f9ed Hawking Zhang 2022-04-13 @1278  		*(uint64_t *)fw_autoload_mask |= 1 << id;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1279  }
3d879e81f0f9ed Hawking Zhang 2022-04-13  1280  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [agd5f:drm-next 429/599] drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?
Date: Mon, 09 May 2022 14:16:48 +0300	[thread overview]
Message-ID: <202205082233.0Gm8B7A4-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3502 bytes --]

tree:   https://gitlab.freedesktop.org/agd5f/linux.git drm-next
head:   3170f5f234272247989fafee4cba4cbbc822631c
commit: 3d879e81f0f9ed5d33b5eda0fe5226c884bb8073 [429/599] drm/amdgpu: add init support for GFX11 (v2)
config: csky-randconfig-m031-20220508 (https://download.01.org/0day-ci/archive/20220508/202205082233.0Gm8B7A4-lkp(a)intel.com/config)
compiler: csky-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type?

vim +1278 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

3d879e81f0f9ed Hawking Zhang 2022-04-13  1250  static void gfx_v11_0_rlc_backdoor_autoload_copy_ucode(struct amdgpu_device *adev,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1251  					      SOC21_FIRMWARE_ID id,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1252  			    		      const void *fw_data,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1253  					      uint32_t fw_size,
3d879e81f0f9ed Hawking Zhang 2022-04-13  1254  					      uint32_t *fw_autoload_mask)

It would be cleaner to just declare fw_autoload_mask as a u64.  I
reviewed the code to see why it's a u32 and could not see a reason.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1255  {
3d879e81f0f9ed Hawking Zhang 2022-04-13  1256  	uint32_t toc_offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1257  	uint32_t toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1258  	char *ptr = adev->gfx.rlc.rlc_autoload_ptr;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1259  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1260  	if (id <= SOC21_FIRMWARE_ID_INVALID || id >= SOC21_FIRMWARE_ID_MAX)

SOC21_FIRMWARE_ID_MAX is 37 which is more than 31 so this but is real.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1261  		return;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1262  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1263  	toc_offset = rlc_autoload_info[id].offset;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1264  	toc_fw_size = rlc_autoload_info[id].size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1265  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1266  	if (fw_size == 0)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1267  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1268  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1269  	if (fw_size > toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1270  		fw_size = toc_fw_size;
3d879e81f0f9ed Hawking Zhang 2022-04-13  1271  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1272  	memcpy(ptr + toc_offset, fw_data, fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1273  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1274  	if (fw_size < toc_fw_size)
3d879e81f0f9ed Hawking Zhang 2022-04-13  1275  		memset(ptr + toc_offset + fw_size, 0, toc_fw_size - fw_size);
3d879e81f0f9ed Hawking Zhang 2022-04-13  1276  
3d879e81f0f9ed Hawking Zhang 2022-04-13  1277  	if ((id != SOC21_FIRMWARE_ID_RS64_PFP) && (id != SOC21_FIRMWARE_ID_RS64_ME))
3d879e81f0f9ed Hawking Zhang 2022-04-13 @1278  		*(uint64_t *)fw_autoload_mask |= 1 << id;
                                                                                         ^^^^^^^^

This needs to be 1ULL < id.  Otherwise if id is >= 32 the shift will
wrap.

3d879e81f0f9ed Hawking Zhang 2022-04-13  1279  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

             reply	other threads:[~2022-05-09 11:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08 14:13 kernel test robot [this message]
2022-05-09 11:16 ` [agd5f:drm-next 429/599] drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1278 gfx_v11_0_rlc_backdoor_autoload_copy_ucode() warn: should '1 << id' be a 64 bit type? Dan Carpenter
2022-05-09 11:16 ` Dan Carpenter

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=202205082233.0Gm8B7A4-lkp@intel.com \
    --to=dan.carpenter@oracle.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=Wenhui.Sheng@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    /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.