public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init()
@ 2026-04-24  0:52 Yury Norov
  2026-04-24  1:27 ` Yury Norov
  2026-04-25 15:57 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Yury Norov @ 2026-04-24  0:52 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Airlie,
	Simona Vetter, amd-gfx, dri-devel, linux-kernel
  Cc: Yury Norov

The bitmap_clear() works OK with both compile- and runtime nbits. But the
comment says it doesn't work, and opencodes the call for nothing. Drop
the misleading comment, and use bitmap_clear() as it should.

As a side effect, the patch switches from a series of atomics to
a single non-atomic operation, which is easier on caches.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index d9e283f3b57d..47d52cb2f1ba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -194,14 +194,11 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
 				  adev->gfx.mec_bitmap[0].queue_bitmap,
 				  AMDGPU_MAX_QUEUES);
 
-		/* According to linux/bitmap.h we shouldn't use bitmap_clear if
-		 * nbits is not compile time constant
-		 */
 		last_valid_bit = 1 /* only first MEC can have compute queues */
 				* adev->gfx.mec.num_pipe_per_mec
 				* adev->gfx.mec.num_queue_per_pipe;
-		for (i = last_valid_bit; i < AMDGPU_MAX_QUEUES; ++i)
-			clear_bit(i, gpu_resources.cp_queue_bitmap);
+		bitmap_clear(gpu_resources.cp_queue_bitmap, last_valid_bit,
+					AMDGPU_MAX_QUEUES - last_valid_bit);
 
 		amdgpu_doorbell_get_kfd_info(adev,
 				&gpu_resources.doorbell_physical_address,
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init()
  2026-04-24  0:52 [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init() Yury Norov
@ 2026-04-24  1:27 ` Yury Norov
  2026-04-25 15:57 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Yury Norov @ 2026-04-24  1:27 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Airlie,
	Simona Vetter, amd-gfx, dri-devel, linux-kernel

On Thu, Apr 23, 2026 at 08:52:17PM -0400, Yury Norov wrote:
> The bitmap_clear() works OK with both compile- and runtime nbits. But the
> comment says it doesn't work, and opencodes the call for nothing. Drop
> the misleading comment, and use bitmap_clear() as it should.
> 
> As a side effect, the patch switches from a series of atomics to
> a single non-atomic operation, which is easier on caches.
> 
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index d9e283f3b57d..47d52cb2f1ba 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -194,14 +194,11 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
>  				  adev->gfx.mec_bitmap[0].queue_bitmap,
>  				  AMDGPU_MAX_QUEUES);
>  
> -		/* According to linux/bitmap.h we shouldn't use bitmap_clear if
> -		 * nbits is not compile time constant
> -		 */
>  		last_valid_bit = 1 /* only first MEC can have compute queues */
>  				* adev->gfx.mec.num_pipe_per_mec
>  				* adev->gfx.mec.num_queue_per_pipe;
> -		for (i = last_valid_bit; i < AMDGPU_MAX_QUEUES; ++i)
> -			clear_bit(i, gpu_resources.cp_queue_bitmap);

Please disregard. This patch accidentally dropped a chunk removing 'i'
declaration. I'll resend shortly.

> +		bitmap_clear(gpu_resources.cp_queue_bitmap, last_valid_bit,
> +					AMDGPU_MAX_QUEUES - last_valid_bit);
>  
>  		amdgpu_doorbell_get_kfd_info(adev,
>  				&gpu_resources.doorbell_physical_address,
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init()
  2026-04-24  0:52 [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init() Yury Norov
  2026-04-24  1:27 ` Yury Norov
@ 2026-04-25 15:57 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-04-25 15:57 UTC (permalink / raw)
  To: Yury Norov, Felix Kuehling, Alex Deucher, Christian König,
	David Airlie, Simona Vetter, amd-gfx, dri-devel, linux-kernel
  Cc: oe-kbuild-all, Yury Norov

Hi Yury,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v7.0 next-20260424]
[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/Yury-Norov/drm-amdgpu-use-bitmap_clear-in-amdgpu_amdkfd_device_init/20260424-111821
base:   https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link:    https://lore.kernel.org/r/20260424005218.147961-1-ynorov%40nvidia.com
patch subject: [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init()
config: csky-allmodconfig (https://download.01.org/0day-ci/archive/20260425/202604252305.5nmLNigU-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260425/202604252305.5nmLNigU-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604252305.5nmLNigU-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c: In function 'amdgpu_amdkfd_device_init':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:170:13: warning: unused variable 'i' [-Wunused-variable]
     170 |         int i;
         |             ^


vim +/i +170 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c

c0125b848abecf Le Ma             2024-01-25  167  
dc102c436f1238 Andres Rodriguez  2017-02-01  168  void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
130e0371b7d454 Oded Gabbay       2015-06-12  169  {
234441dd49bcd9 Yong Zhao         2019-01-09 @170  	int i;
d0b63bb3385c56 Andres Rodriguez  2017-02-03  171  	int last_valid_bit;
611736d8447c0c Felix Kuehling    2018-11-19  172  
27fb73a0e3aa74 Mukul Joshi       2023-04-25  173  	amdgpu_amdkfd_gpuvm_init_mem_limits();
27fb73a0e3aa74 Mukul Joshi       2023-04-25  174  
611736d8447c0c Felix Kuehling    2018-11-19  175  	if (adev->kfd.dev) {
130e0371b7d454 Oded Gabbay       2015-06-12  176  		struct kgd2kfd_shared_resources gpu_resources = {
40111ec2298f44 Felix Kuehling    2020-06-24  177  			.compute_vmid_bitmap =
40111ec2298f44 Felix Kuehling    2020-06-24  178  				((1 << AMDGPU_NUM_VMID) - 1) -
40111ec2298f44 Felix Kuehling    2020-06-24  179  				((1 << adev->vm_manager.first_kfd_vmid) - 1),
d0b63bb3385c56 Andres Rodriguez  2017-02-03  180  			.num_pipe_per_mec = adev->gfx.mec.num_pipe_per_mec,
155494dbbbf4d6 Felix Kuehling    2018-02-06  181  			.num_queue_per_pipe = adev->gfx.mec.num_queue_per_pipe,
155494dbbbf4d6 Felix Kuehling    2018-02-06  182  			.gpuvm_size = min(adev->vm_manager.max_pfn
155494dbbbf4d6 Felix Kuehling    2018-02-06  183  					  << AMDGPU_GPU_PAGE_SHIFT,
ad9a5b78f585e9 Christian König   2018-08-27  184  					  AMDGPU_GMC_HOLE_START),
4a580877bdcb83 Luben Tuikov      2020-08-24  185  			.drm_render_minor = adev_to_drm(adev)->render->index,
234441dd49bcd9 Yong Zhao         2019-01-09  186  			.sdma_doorbell_idx = adev->doorbell_index.sdma_engine,
cc009e613de656 Mukul Joshi       2022-04-26  187  			.enable_mes = adev->enable_mes,
130e0371b7d454 Oded Gabbay       2015-06-12  188  		};
130e0371b7d454 Oded Gabbay       2015-06-12  189  
d0b63bb3385c56 Andres Rodriguez  2017-02-03  190  		/* this is going to have a few of the MSBs set that we need to
0d87c9cfc08e15 Kent Russell      2019-05-01  191  		 * clear
0d87c9cfc08e15 Kent Russell      2019-05-01  192  		 */
e6945304187dea Yong Zhao         2020-01-30  193  		bitmap_complement(gpu_resources.cp_queue_bitmap,
be697aa3a78ef8 Le Ma             2022-07-27  194  				  adev->gfx.mec_bitmap[0].queue_bitmap,
68fa72a437ea3b Mukul Joshi       2023-09-06  195  				  AMDGPU_MAX_QUEUES);
d0b63bb3385c56 Andres Rodriguez  2017-02-03  196  
3447d220155bd9 Jay Cornwall      2017-07-13  197  		last_valid_bit = 1 /* only first MEC can have compute queues */
d0b63bb3385c56 Andres Rodriguez  2017-02-03  198  				* adev->gfx.mec.num_pipe_per_mec
d0b63bb3385c56 Andres Rodriguez  2017-02-03  199  				* adev->gfx.mec.num_queue_per_pipe;
25259687589365 Yury Norov        2026-04-23  200  		bitmap_clear(gpu_resources.cp_queue_bitmap, last_valid_bit,
25259687589365 Yury Norov        2026-04-23  201  					AMDGPU_MAX_QUEUES - last_valid_bit);
d0b63bb3385c56 Andres Rodriguez  2017-02-03  202  
dc102c436f1238 Andres Rodriguez  2017-02-01  203  		amdgpu_doorbell_get_kfd_info(adev,
130e0371b7d454 Oded Gabbay       2015-06-12  204  				&gpu_resources.doorbell_physical_address,
130e0371b7d454 Oded Gabbay       2015-06-12  205  				&gpu_resources.doorbell_aperture_size,
130e0371b7d454 Oded Gabbay       2015-06-12  206  				&gpu_resources.doorbell_start_offset);
c5892230d98b04 Shaoyun Liu       2018-03-23  207  
1f86805adc3432 Yong Zhao         2019-02-13  208  		/* Since SOC15, BIF starts to statically use the
1f86805adc3432 Yong Zhao         2019-02-13  209  		 * lower 12 bits of doorbell addresses for routing
1f86805adc3432 Yong Zhao         2019-02-13  210  		 * based on settings in registers like
1f86805adc3432 Yong Zhao         2019-02-13  211  		 * SDMA0_DOORBELL_RANGE etc..
1f86805adc3432 Yong Zhao         2019-02-13  212  		 * In order to route a doorbell to CP engine, the lower
1f86805adc3432 Yong Zhao         2019-02-13  213  		 * 12 bits of its address has to be outside the range
1f86805adc3432 Yong Zhao         2019-02-13  214  		 * set for SDMA, VCN, and IH blocks.
642a0e80262af8 Felix Kuehling    2018-04-10  215  		 */
234441dd49bcd9 Yong Zhao         2019-01-09  216  		if (adev->asic_type >= CHIP_VEGA10) {
1f86805adc3432 Yong Zhao         2019-02-13  217  			gpu_resources.non_cp_doorbells_start =
1f86805adc3432 Yong Zhao         2019-02-13  218  					adev->doorbell_index.first_non_cp;
1f86805adc3432 Yong Zhao         2019-02-13  219  			gpu_resources.non_cp_doorbells_end =
1f86805adc3432 Yong Zhao         2019-02-13  220  					adev->doorbell_index.last_non_cp;
234441dd49bcd9 Yong Zhao         2019-01-09  221  		}
130e0371b7d454 Oded Gabbay       2015-06-12  222  
8e2712e71bfc97 shaoyunl          2021-02-16  223  		adev->kfd.init_complete = kgd2kfd_device_init(adev->kfd.dev,
d69a3b762dc4c9 Mukul Joshi       2022-05-09  224  							&gpu_resources);
b5fd0cf3ea377a Andrey Grodzovsky 2022-05-17  225  
2302d507149f0a Philip Yang       2022-10-03  226  		amdgpu_amdkfd_total_mem_size += adev->gmc.real_vram_size;
2302d507149f0a Philip Yang       2022-10-03  227  
b5fd0cf3ea377a Andrey Grodzovsky 2022-05-17  228  		INIT_WORK(&adev->kfd.reset_work, amdgpu_amdkfd_reset_work);
130e0371b7d454 Oded Gabbay       2015-06-12  229  	}
130e0371b7d454 Oded Gabbay       2015-06-12  230  }
130e0371b7d454 Oded Gabbay       2015-06-12  231  

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-25 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24  0:52 [PATCH] drm/amdgpu: use bitmap_clear() in amdgpu_amdkfd_device_init() Yury Norov
2026-04-24  1:27 ` Yury Norov
2026-04-25 15:57 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox