Skip to contentSkip to conversation

KFD fixes, cleanups, features to make the runtime happy

PATCH In review Felix Kuehling 4 participants 45 messages Aug 16, 2017 – Sep 9, 2017 16 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover KFD fixes, cleanups, features to make the runtime happy

I merged the last two patch series and made a number of updates as discussed. I also rebased it on Alex's drm-next-4.14-wip branch. All patches applied cleanly without having to resolve any conflicts.

I'm also publishing my branch with this patch series on GitHub to make it easier to test and apply the changes. This KFD branch requires the corresponding Thunk branch from GitHub, which uses a different ioctl ABI from the last ROCm release. The rest of the user mode stack should be OK on top of that Thunk.

https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/tree/fkxamd/drm-next-wip
https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/tree/fxkamd/drm-next-wip

On CZ, hsaconformance passes. OpenCL tests can be run with the current ROCm OpenCL stack. I ran the SHOC benchmark as an example.

On KV, the current ROCm OpenCL driver doesn't work. This is a limitation of the OpenCL driver. I'm trying to find out how hard it would be to change that. In the mean time, some hsaconformance tests can be run on KV. It passes most tests up to 162:code_recursive_kernel_function, where it hangs.

For testing KV with current user mode stack, please use amdgpu. I don't expect this to work with radeon and I'm not planning to spend any effort on making radeon work with a current user mode stack.

Dropped patches:
* drm/amdkfd: Fix double Mutex lock order

Added patches:
* drm/radeon: Return dword offsets of address watch registers
* drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Reordered patch sequence:
I moved "drm/amdgpu: Remove hard-coded assumptions about compute pipes" just after "drm/amdkfd: Fix allocated_queues bitmap initialization" because these two patches fix related problems (how queues are shared between KFD and KGD).

Updated patches:
* drm/amdkfd: Clean up KFD style errors and warnings v2
* drm/amdkfd: Fix goto usage v2
* drm/amdkfd: Handle remaining BUG_ONs more gracefully v2
* drm/amdkfd: Add more error printing to help bringup v2
* drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
* drm/amdkfd: Adding new IOCTL for scratch memory v2
* drm/amdgpu: Add kgd kfd interface get_tile_config() v2
* drm/amdkfd: Implement image tiling mode support v2

Patches that still need a Reviewed-by or Acked-by:
* drm/radeon: Return dword offsets of address watch registers
* drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t)
* drm/amdkfd: Clean up KFD style errors and warnings v2
* drm/amdkfd: Handle remaining BUG_ONs more gracefully v2
* drm/amdkfd: Add more error printing to help bringup v2
* drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID
* drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
* drm/amdkfd: Adding new IOCTL for scratch memory v2

***

Felix Kuehling (13):
drm/amdkfd: Fix typo in dbgdev_wave_reset_wavefronts drm/radeon: Return dword offsets of address watch registers drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t) drm/amdkfd: Fix allocated_queues bitmap initialization drm/amdgpu: Remove hard-coded assumptions about compute pipes drm/amdkfd: Remove BUG_ONs for NULL pointer arguments drm/amdkfd: Fix doorbell initialization and finalization drm/amdkfd: Allocate gtt_sa_bitmap in long units drm/amdkfd: Handle remaining BUG_ONs more gracefully v2 drm/amdkfd: Update PM4 packet headers
drm/amdgpu: Disable GFX PG on CZ
drm/amd: Update MEC HQD loading code for KFD drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Jay Cornwall (1):
drm/amdkfd: Clamp EOP queue size correctly on Gfx8

Kent Russell (5):
drm/amdkfd: Clean up KFD style errors and warnings v2 drm/amdkfd: Consolidate and clean up log commands drm/amdkfd: Change x==NULL/false references to !x drm/amdkfd: Fix goto usage v2
drm/amdkfd: Remove usage of alloc(sizeof(struct...

Moses Reuben (2):
drm/amdgpu: Add kgd/kfd interface to support scratch memory v2 drm/amdkfd: Adding new IOCTL for scratch memory v2

Yong Zhao (3):
drm/amdkfd: Add more error printing to help bringup v2 drm/amdgpu: Add kgd kfd interface get_tile_config() v2 drm/amdkfd: Implement image tiling mode support v2

 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h         |  16 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 189 ++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 227 ++++++++++++--
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c              |   2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              |   3 +-
 drivers/gpu/drm/amd/amdgpu/vi.c                    |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 183 ++++++++----
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            | 102 +++----
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  21 +-
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h            |  27 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 123 ++++----
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 316 ++++++++------------
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |   8 +-
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |   8 +-
 drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c          |  40 +--
 drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  33 +--
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c       |   2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c         |   2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      |  63 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_module.c            |  10 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h       |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  62 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  46 +--
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 294 ++++++------------
 drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |   7 +-
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h       | 330 +++------------------
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h    | 140 ++++++++-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  32 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  25 +-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  71 ++---
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c             |  12 +-
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  46 +--
 drivers/gpu/drm/amd/include/kgd_kfd_interface.h    |  30 +-
 drivers/gpu/drm/radeon/radeon_kfd.c                |  15 +-
 include/uapi/linux/kfd_ioctl.h                     |  37 ++-
 36 files changed, 1280 insertions(+), 1252 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/24 drm/amdkfd: Fix typo in dbgdev_wave_reset_wavefronts

---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +1 -1
index d5e19b5..8b14a4e 100644
@@ -823,7 +823,7 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
 	for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) {
 		if (dev->kfd2kgd->get_atc_vmid_pasid_mapping_valid
 				(dev->kgd, vmid)) {
-			if (dev->kfd2kgd->get_atc_vmid_pasid_mapping_valid
+			if (dev->kfd2kgd->get_atc_vmid_pasid_mapping_pasid
 					(dev->kgd, vmid) == p->pasid) {
 				pr_debug("Killing wave fronts of vmid %d and pasid %d\n",
 						vmid, p->pasid);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 2/24 drm/radeon: Return dword offsets of address watch registers

In reply to a message not in the archive

Dword offsets are what KFD really needs and what amdgpu already returns.

---
 drivers/gpu/drm/radeon/radeon_kfd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_kfd.c +2 -1
index a2ab6dc..cab6c03 100644
@@ -785,7 +785,8 @@ static uint32_t kgd_address_watch_get_offset(struct kgd_dev *kgd,
 					unsigned int watch_point_id,
 					unsigned int reg_offset)
 {
-	return watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX + reg_offset];
+	return watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX + reg_offset]
+		/ 4;
 }
 
 static bool get_atc_vmid_pasid_mapping_valid(struct kgd_dev *kgd, uint8_t vmid)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-3-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#5 lore raw

Re: [PATCH 02/24] drm/radeon: Return dword offsets of address watch registers

Quoted 22 lines · Felix Kuehling

Dword offsets are what KFD really needs and what amdgpu already returns.

---
 drivers/gpu/drm/radeon/radeon_kfd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_kfd.c +2 -2
index a2ab6dc..cab6c03 100644
@@ -785,7 +785,8 @@ static uint32_t kgd_address_watch_get_offset(struct kgd_dev *kgd,
                                        unsigned int watch_point_id,
                                        unsigned int reg_offset)
 {
-       return watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX + reg_offset];
+       return watchRegs[watch_point_id * ADDRESS_WATCH_REG_MAX + reg_offset]
+               / 4;
 }
 
 static bool get_atc_vmid_pasid_mapping_valid(struct kgd_dev *kgd, uint8_t vmid)
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw

PATCH 3/24 drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t)

In reply to a message not in the archive

kfd2kgd->address_watch_get_offset returns dword register offsets.

---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +0 -8
index 8b14a4e..faa0790 100644
@@ -442,8 +442,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 					i,
 					ADDRESS_WATCH_REG_CNTL);
 
-		aw_reg_add_dword /= sizeof(uint32_t);
-
 		packets_vec[0].bitfields2.reg_offset =
 					aw_reg_add_dword - AMD_CONFIG_REG_BASE;
 
@@ -455,8 +453,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 					i,
 					ADDRESS_WATCH_REG_ADDR_HI);
 
-		aw_reg_add_dword /= sizeof(uint32_t);
-
 		packets_vec[1].bitfields2.reg_offset =
 					aw_reg_add_dword - AMD_CONFIG_REG_BASE;
 		packets_vec[1].reg_data[0] = addrHi.u32All;
@@ -467,8 +463,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 					i,
 					ADDRESS_WATCH_REG_ADDR_LO);
 
-		aw_reg_add_dword /= sizeof(uint32_t);
-
 		packets_vec[2].bitfields2.reg_offset =
 				aw_reg_add_dword - AMD_CONFIG_REG_BASE;
 		packets_vec[2].reg_data[0] = addrLo.u32All;
@@ -485,8 +479,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 					i,
 					ADDRESS_WATCH_REG_CNTL);
 
-		aw_reg_add_dword /= sizeof(uint32_t);
-
 		packets_vec[3].bitfields2.reg_offset =
 					aw_reg_add_dword - AMD_CONFIG_REG_BASE;
 		packets_vec[3].reg_data[0] = cntl.u32All;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-4-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#8 lore raw

Re: [PATCH 03/24] drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t)

Quoted 48 lines · Felix Kuehling

kfd2kgd->address_watch_get_offset returns dword register offsets.

---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +0 -9
index 8b14a4e..faa0790 100644
@@ -442,8 +442,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
                                        i,
                                        ADDRESS_WATCH_REG_CNTL);
 
-               aw_reg_add_dword /= sizeof(uint32_t);
-
                packets_vec[0].bitfields2.reg_offset =
                                        aw_reg_add_dword - AMD_CONFIG_REG_BASE;
 
@@ -455,8 +453,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
                                        i,
                                        ADDRESS_WATCH_REG_ADDR_HI);
 
-               aw_reg_add_dword /= sizeof(uint32_t);
-
                packets_vec[1].bitfields2.reg_offset =
                                        aw_reg_add_dword - AMD_CONFIG_REG_BASE;
                packets_vec[1].reg_data[0] = addrHi.u32All;
@@ -467,8 +463,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
                                        i,
                                        ADDRESS_WATCH_REG_ADDR_LO);
 
-               aw_reg_add_dword /= sizeof(uint32_t);
-
                packets_vec[2].bitfields2.reg_offset =
                                aw_reg_add_dword - AMD_CONFIG_REG_BASE;
                packets_vec[2].reg_data[0] = addrLo.u32All;
@@ -485,8 +479,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
                                        i,
                                        ADDRESS_WATCH_REG_CNTL);
 
-               aw_reg_add_dword /= sizeof(uint32_t);
-
                packets_vec[3].bitfields2.reg_offset =
                                        aw_reg_add_dword - AMD_CONFIG_REG_BASE;
                packets_vec[3].reg_data[0] = cntl.u32All;
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#9 lore raw

PATCH 4/24 drm/amdkfd: Fix allocated_queues bitmap initialization

In reply to a message not in the archive

Use shared_resources.queue_bitmap to determine the queues available for KFD in each pipe.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +9 -3
index 42de22b..9d2796b 100644
@@ -513,7 +513,7 @@ static int init_scheduler(struct device_queue_manager *dqm)
 
 static int initialize_nocpsch(struct device_queue_manager *dqm)
 {
-	int i;
+	int pipe, queue;
 
 	BUG_ON(!dqm);
 
@@ -531,8 +531,14 @@ static int initialize_nocpsch(struct device_queue_manager *dqm)
 		return -ENOMEM;
 	}
 
-	for (i = 0; i < get_pipes_per_mec(dqm); i++)
-		dqm->allocated_queues[i] = (1 << get_queues_per_pipe(dqm)) - 1;
+	for (pipe = 0; pipe < get_pipes_per_mec(dqm); pipe++) {
+		int pipe_offset = pipe * get_queues_per_pipe(dqm);
+
+		for (queue = 0; queue < get_queues_per_pipe(dqm); queue++)
+			if (test_bit(pipe_offset + queue,
+				     dqm->dev->shared_resources.queue_bitmap))
+				dqm->allocated_queues[pipe] |= 1 << queue;
+	}
 
 	dqm->vmid_bitmap = (1 << VMID_PER_DEVICE) - 1;
 	dqm->sdma_bitmap = (1 << CIK_SDMA_QUEUES) - 1;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#10 lore raw

PATCH 5/24 drm/amdgpu: Remove hard-coded assumptions about compute pipes

In reply to a message not in the archive

Remove hard-coded assumption that the first compute pipe is reserved for amdgpu. Pipe 0 actually means pipe 0 now.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +1 -1
index 5254562..31c4fbd 100644
@@ -186,7 +186,7 @@ static void acquire_queue(struct kgd_dev *kgd, uint32_t pipe_id,
 {
 	struct amdgpu_device *adev = get_amdgpu_device(kgd);
 
-	uint32_t mec = (++pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
+	uint32_t mec = (pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
 	uint32_t pipe = (pipe_id % adev->gfx.mec.num_pipe_per_mec);
 
 	lock_srbm(kgd, mec, pipe, queue_id, 0);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +2 -2
index 133d066..c8ac402 100644
@@ -147,7 +147,7 @@ static void acquire_queue(struct kgd_dev *kgd, uint32_t pipe_id,
 {
 	struct amdgpu_device *adev = get_amdgpu_device(kgd);
 
-	uint32_t mec = (++pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
+	uint32_t mec = (pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
 	uint32_t pipe = (pipe_id % adev->gfx.mec.num_pipe_per_mec);
 
 	lock_srbm(kgd, mec, pipe, queue_id, 0);
@@ -216,7 +216,7 @@ static int kgd_init_interrupts(struct kgd_dev *kgd, uint32_t pipe_id)
 	uint32_t mec;
 	uint32_t pipe;
 
-	mec = (++pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
+	mec = (pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
 	pipe = (pipe_id % adev->gfx.mec.num_pipe_per_mec);
 
 	lock_srbm(kgd, mec, pipe, 0, 0);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#11 lore raw

PATCH 6/24 drm/amdkfd: Clean up KFD style errors and warnings v2

In reply to a message not in the archive

From: Kent Russell <[email protected]>

Using checkpatch.pl -f <file> showed a number of style issues. This patch addresses as many of them as possible. Some long lines have been left for readability, but attempts to minimize them have been made.

v2: Broke long lines in gfx_v7 get_fw_version

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 16 ++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 16 ++++++-------
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           |  6 +++--
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            |  7 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h            | 27 +++++++++++-----------
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            |  5 ++--
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  8 ++++---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  5 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c         |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_module.c            |  3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  3 +--
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    |  5 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |  3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h       | 16 ++++++-------
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h    | 10 ++++----
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              | 23 ++++++++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  6 +++--
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  4 ++--
 19 files changed, 91 insertions(+), 78 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index c7bcf52..5432af3 100644
@@ -28,14 +28,14 @@
 #include <linux/module.h>
 
 const struct kgd2kfd_calls *kgd2kfd;
-bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
+bool (*kgd2kfd_init_p)(unsigned int, const struct kgd2kfd_calls**);
 
 int amdgpu_amdkfd_init(void)
 {
 	int ret;
 
 #if defined(CONFIG_HSA_AMD_MODULE)
-	int (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
+	int (*kgd2kfd_init_p)(unsigned int, const struct kgd2kfd_calls**);
 
 	kgd2kfd_init_p = symbol_request(kgd2kfd_init);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +8 -8
index 31c4fbd..dcd90e8 100644
@@ -566,42 +566,42 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 	switch (type) {
 	case KGD_ENGINE_PFP:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.pfp_fw->data;
+						adev->gfx.pfp_fw->data;
 		break;
 
 	case KGD_ENGINE_ME:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.me_fw->data;
+						adev->gfx.me_fw->data;
 		break;
 
 	case KGD_ENGINE_CE:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.ce_fw->data;
+						adev->gfx.ce_fw->data;
 		break;
 
 	case KGD_ENGINE_MEC1:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.mec_fw->data;
+						adev->gfx.mec_fw->data;
 		break;
 
 	case KGD_ENGINE_MEC2:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.mec2_fw->data;
+						adev->gfx.mec2_fw->data;
 		break;
 
 	case KGD_ENGINE_RLC:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.rlc_fw->data;
+						adev->gfx.rlc_fw->data;
 		break;
 
 	case KGD_ENGINE_SDMA1:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->sdma.instance[0].fw->data;
+						adev->sdma.instance[0].fw->data;
 		break;
 
 	case KGD_ENGINE_SDMA2:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->sdma.instance[1].fw->data;
+						adev->sdma.instance[1].fw->data;
 		break;
 
 	default:
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +8 -8
index c8ac402..0fccd30 100644
@@ -454,42 +454,42 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 	switch (type) {
 	case KGD_ENGINE_PFP:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.pfp_fw->data;
+						adev->gfx.pfp_fw->data;
 		break;
 
 	case KGD_ENGINE_ME:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.me_fw->data;
+						adev->gfx.me_fw->data;
 		break;
 
 	case KGD_ENGINE_CE:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.ce_fw->data;
+						adev->gfx.ce_fw->data;
 		break;
 
 	case KGD_ENGINE_MEC1:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.mec_fw->data;
+						adev->gfx.mec_fw->data;
 		break;
 
 	case KGD_ENGINE_MEC2:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.mec2_fw->data;
+						adev->gfx.mec2_fw->data;
 		break;
 
 	case KGD_ENGINE_RLC:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->gfx.rlc_fw->data;
+						adev->gfx.rlc_fw->data;
 		break;
 
 	case KGD_ENGINE_SDMA1:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->sdma.instance[0].fw->data;
+						adev->sdma.instance[0].fw->data;
 		break;
 
 	case KGD_ENGINE_SDMA2:
 		hdr = (const union amdgpu_firmware_header *)
-							adev->sdma.instance[1].fw->data;
+						adev->sdma.instance[1].fw->data;
 		break;
 
 	default:
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +4 -2
index 6316aad..2603b7c 100644
@@ -782,7 +782,8 @@ static int kfd_ioctl_get_process_apertures(struct file *filp,
 				"scratch_limit %llX\n", pdd->scratch_limit);
 
 			args->num_of_nodes++;
-		} while ((pdd = kfd_get_next_process_device_data(p, pdd)) != NULL &&
+		} while ((pdd = kfd_get_next_process_device_data(p, pdd)) !=
+				NULL &&
 				(args->num_of_nodes < NUM_OF_SUPPORTED_GPUS));
 	}
 
@@ -848,7 +849,8 @@ static int kfd_ioctl_wait_events(struct file *filp, struct kfd_process *p,
 }
 
 #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
-	[_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0, .name = #ioctl}
+	[_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \
+			    .cmd_drv = 0, .name = #ioctl}
 
 /** Ioctl table */
 static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +4 -3
index faa0790..a7548a5 100644
@@ -313,7 +313,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 		return -EINVAL;
 	}
 
-	for (i = 0 ; i < adw_info->num_watch_points ; i++) {
+	for (i = 0; i < adw_info->num_watch_points; i++) {
 		dbgdev_address_watch_set_registers(adw_info, &addrHi, &addrLo,
 						&cntl, i, pdd->qpd.vmid);
 
@@ -623,7 +623,7 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
 		return status;
 	}
 
-	/* we do not control the VMID in DIQ,so reset it to a known value */
+	/* we do not control the VMID in DIQ, so reset it to a known value */
 	reg_sq_cmd.bits.vm_id = 0;
 
 	pr_debug("\t\t %30s\n", "* * * * * * * * * * * * * * * * * *");
@@ -810,7 +810,8 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
 
 	/* Scan all registers in the range ATC_VMID8_PASID_MAPPING ..
 	 * ATC_VMID15_PASID_MAPPING
-	 * to check which VMID the current process is mapped to. */
+	 * to check which VMID the current process is mapped to.
+	 */
 
 	for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) {
 		if (dev->kfd2kgd->get_atc_vmid_pasid_mapping_valid
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h +13 -14
index 257a745..a04a1fe 100644
@@ -30,13 +30,11 @@
 #pragma pack(push, 4)
 
 enum HSA_DBG_WAVEOP {
-	HSA_DBG_WAVEOP_HALT = 1,	/* Halts a wavefront		*/
-	HSA_DBG_WAVEOP_RESUME = 2,	/* Resumes a wavefront		*/
-	HSA_DBG_WAVEOP_KILL = 3,	/* Kills a wavefront		*/
-	HSA_DBG_WAVEOP_DEBUG = 4,	/* Causes wavefront to enter
-						debug mode		*/
-	HSA_DBG_WAVEOP_TRAP = 5,	/* Causes wavefront to take
-						a trap			*/
+	HSA_DBG_WAVEOP_HALT = 1,   /* Halts a wavefront */
+	HSA_DBG_WAVEOP_RESUME = 2, /* Resumes a wavefront */
+	HSA_DBG_WAVEOP_KILL = 3,   /* Kills a wavefront */
+	HSA_DBG_WAVEOP_DEBUG = 4,  /* Causes wavefront to enter dbg mode */
+	HSA_DBG_WAVEOP_TRAP = 5,   /* Causes wavefront to take a trap */
 	HSA_DBG_NUM_WAVEOP = 5,
 	HSA_DBG_MAX_WAVEOP = 0xFFFFFFFF
 };
@@ -81,15 +79,13 @@ struct HsaDbgWaveMsgAMDGen2 {
 			uint32_t UserData:8;	/* user data */
 			uint32_t ShaderArray:1;	/* Shader array */
 			uint32_t Priv:1;	/* Privileged */
-			uint32_t Reserved0:4;	/* This field is reserved,
-						   should be 0 */
+			uint32_t Reserved0:4;	/* Reserved, should be 0 */
 			uint32_t WaveId:4;	/* wave id */
 			uint32_t SIMD:2;	/* SIMD id */
 			uint32_t HSACU:4;	/* Compute unit */
 			uint32_t ShaderEngine:2;/* Shader engine */
 			uint32_t MessageType:2;	/* see HSA_DBG_WAVEMSG_TYPE */
-			uint32_t Reserved1:4;	/* This field is reserved,
-						   should be 0 */
+			uint32_t Reserved1:4;	/* Reserved, should be 0 */
 		} ui32;
 		uint32_t Value;
 	};
@@ -121,20 +117,23 @@ struct HsaDbgWaveMessage {
  * in the user mode instruction stream. The OS scheduler event is typically
  * associated and signaled by an interrupt issued by the GPU, but other HSA
  * system interrupt conditions from other HW (e.g. IOMMUv2) may be surfaced
- * by the KFD by this mechanism, too. */
+ * by the KFD by this mechanism, too.
+ */
 
 /* these are the new definitions for events */
 enum HSA_EVENTTYPE {
 	HSA_EVENTTYPE_SIGNAL = 0,	/* user-mode generated GPU signal */
 	HSA_EVENTTYPE_NODECHANGE = 1,	/* HSA node change (attach/detach) */
 	HSA_EVENTTYPE_DEVICESTATECHANGE = 2,	/* HSA device state change
-						   (start/stop) */
+						 * (start/stop)
+						 */
 	HSA_EVENTTYPE_HW_EXCEPTION = 3,	/* GPU shader exception event */
 	HSA_EVENTTYPE_SYSTEM_EVENT = 4,	/* GPU SYSCALL with parameter info */
 	HSA_EVENTTYPE_DEBUG_EVENT = 5,	/* GPU signal for debugging */
 	HSA_EVENTTYPE_PROFILE_EVENT = 6,/* GPU signal for profiling */
 	HSA_EVENTTYPE_QUEUE_EVENT = 7,	/* GPU signal queue idle state
-					   (EOP pm4) */
+					 * (EOP pm4)
+					 */
 	/* ...  */
 	HSA_EVENTTYPE_MAXID,
 	HSA_EVENTTYPE_TYPE_SIZE = 0xFFFFFFFF
drivers/gpu/drm/amd/amdkfd/kfd_device.c +3 -2
index 3f95f7c..1f50325 100644
@@ -155,12 +155,13 @@ static bool device_iommu_pasid_init(struct kfd_dev *kfd)
 		dev_err(kfd_device, "error required iommu flags ats(%i), pri(%i), pasid(%i)\n",
 		       (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_ATS_SUP) != 0,
 		       (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_PRI_SUP) != 0,
-		       (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_PASID_SUP) != 0);
+		       (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_PASID_SUP)
+									!= 0);
 		return false;
 	}
 
 	pasid_limit = min_t(unsigned int,
-			(unsigned int)1 << kfd->device_info->max_pasid_bits,
+			(unsigned int)(1 << kfd->device_info->max_pasid_bits),
 			iommu_info.max_pasids);
 	/*
 	 * last pasid is used for kernel queues doorbells
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -3
index 9d2796b..3b850da 100644
@@ -216,7 +216,8 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
 
 	set = false;
 
-	for (pipe = dqm->next_pipe_to_allocate, i = 0; i < get_pipes_per_mec(dqm);
+	for (pipe = dqm->next_pipe_to_allocate, i = 0;
+			i < get_pipes_per_mec(dqm);
 			pipe = ((pipe + 1) % get_pipes_per_mec(dqm)), ++i) {
 
 		if (!is_pipe_enabled(dqm, 0, pipe))
@@ -669,7 +670,8 @@ static int set_sched_resources(struct device_queue_manager *dqm)
 
 		/* This situation may be hit in the future if a new HW
 		 * generation exposes more than 64 queues. If so, the
-		 * definition of res.queue_mask needs updating */
+		 * definition of res.queue_mask needs updating
+		 */
 		if (WARN_ON(i >= (sizeof(res.queue_mask)*8))) {
 			pr_err("Invalid queue enabled by amdgpu: %d\n", i);
 			break;
@@ -890,7 +892,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
 	}
 
 	if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
-			dqm->sdma_queue_count++;
+		dqm->sdma_queue_count++;
 	/*
 	 * Unconditionally increment this counter, regardless of the queue's
 	 * type or whether the queue is active.
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -2
index d1ce83d..d8b9b3c 100644
@@ -194,7 +194,8 @@ static void release_event_notification_slot(struct signal_page *page,
 	page->free_slots++;
 
 	/* We don't free signal pages, they are retained by the process
-	 * and reused until it exits. */
+	 * and reused until it exits.
+	 */
 }
 
 static struct signal_page *lookup_signal_page_by_index(struct kfd_process *p,
@@ -584,7 +585,7 @@ void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
 		 * search faster.
 		 */
 		struct signal_page *page;
-		unsigned i;
+		unsigned int i;
 
 		list_for_each_entry(page, &p->signal_event_pages, event_pages)
 			for (i = 0; i < SLOTS_PER_PAGE; i++)
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +1 -1
index 7f134aa..70b3a99c 100644
@@ -179,7 +179,7 @@ static void interrupt_wq(struct work_struct *work)
 bool interrupt_is_wanted(struct kfd_dev *dev, const uint32_t *ih_ring_entry)
 {
 	/* integer and bitwise OR so there is no boolean short-circuiting */
-	unsigned wanted = 0;
+	unsigned int wanted = 0;
 
 	wanted |= dev->device_info->event_interrupt_class->interrupt_isr(dev,
 								ih_ring_entry);
drivers/gpu/drm/amd/amdkfd/kfd_module.c +2 -1
index 850a562..af5bfc1 100644
@@ -61,7 +61,8 @@ MODULE_PARM_DESC(send_sigterm,
 
 static int amdkfd_init_completed;
 
-int kgd2kfd_init(unsigned interface_version, const struct kgd2kfd_calls **g2f)
+int kgd2kfd_init(unsigned int interface_version,
+		const struct kgd2kfd_calls **g2f)
 {
 	if (!amdkfd_init_completed)
 		return -EPROBE_DEFER;
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +1 -2
index 6acc431..ac59229 100644
@@ -193,9 +193,8 @@ static int update_mqd(struct mqd_manager *mm, void *mqd,
 
 	m->cp_hqd_vmid = q->vmid;
 
-	if (q->format == KFD_QUEUE_FORMAT_AQL) {
+	if (q->format == KFD_QUEUE_FORMAT_AQL)
 		m->cp_hqd_pq_control |= NO_UPDATE_RPTR;
-	}
 
 	m->cp_hqd_active = 0;
 	q->is_active = false;
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +2 -3
index 7131998..99c11a4 100644
@@ -458,7 +458,7 @@ int pm_send_set_resources(struct packet_manager *pm,
 	mutex_lock(&pm->lock);
 	pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
 					sizeof(*packet) / sizeof(uint32_t),
-			(unsigned int **)&packet);
+					(unsigned int **)&packet);
 	if (packet == NULL) {
 		mutex_unlock(&pm->lock);
 		pr_err("kfd: failed to allocate buffer on kernel queue\n");
@@ -530,8 +530,7 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
 fail_acquire_packet_buffer:
 	mutex_unlock(&pm->lock);
 fail_create_runlist_ib:
-	if (pm->allocated)
-		pm_release_ib(pm);
+	pm_release_ib(pm);
 	return retval;
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_pasid.c +2 -1
index 6cfe7f1..b3f7d43 100644
@@ -32,7 +32,8 @@ int kfd_pasid_init(void)
 {
 	pasid_limit = KFD_MAX_NUM_OF_PROCESSES;
 
-	pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long), GFP_KERNEL);
+	pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long),
+				GFP_KERNEL);
 	if (!pasid_bitmap)
 		return -ENOMEM;
 
drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h +8 -8
index 5b393f3..97e5442 100644
@@ -28,14 +28,14 @@
 #define PM4_MES_HEADER_DEFINED
 union PM4_MES_TYPE_3_HEADER {
 	struct {
-		uint32_t reserved1:8;	/* < reserved */
-		uint32_t opcode:8;	/* < IT opcode */
-		uint32_t count:14;	/* < number of DWORDs - 1
-					 * in the information body.
-					 */
-		uint32_t type:2;	/* < packet identifier.
-					 * It should be 3 for type 3 packets
-					 */
+		/* reserved */
+		uint32_t reserved1:8;
+		/* IT opcode */
+		uint32_t opcode:8;
+		/* number of DWORDs - 1 in the information body */
+		uint32_t count:14;
+		/* packet identifier. It should be 3 for type 3 packets */
+		uint32_t type:2;
 	};
 	uint32_t u32all;
 };
drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h +6 -4
index 08c72192..c4eda6f 100644
@@ -30,10 +30,12 @@ union PM4_MES_TYPE_3_HEADER {
 	struct {
 		uint32_t reserved1 : 8; /* < reserved */
 		uint32_t opcode    : 8; /* < IT opcode */
-		uint32_t count     : 14;/* < number of DWORDs - 1 in the
-		information body. */
-		uint32_t type      : 2; /* < packet identifier.
-					It should be 3 for type 3 packets */
+		uint32_t count     : 14;/* < Number of DWORDS - 1 in the
+					 *   information body
+					 */
+		uint32_t type      : 2; /* < packet identifier
+					 *   It should be 3 for type 3 packets
+					 */
 	};
 	uint32_t u32All;
 };
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +13 -10
index 4750cab..469b7ea 100644
@@ -294,13 +294,13 @@ enum kfd_queue_format {
  * @write_ptr: Defines the number of dwords written to the ring buffer.
  *
  * @doorbell_ptr: This field aim is to notify the H/W of new packet written to
- * the queue ring buffer. This field should be similar to write_ptr and the user
- * should update this field after he updated the write_ptr.
+ * the queue ring buffer. This field should be similar to write_ptr and the
+ * user should update this field after he updated the write_ptr.
  *
  * @doorbell_off: The doorbell offset in the doorbell pci-bar.
  *
- * @is_interop: Defines if this is a interop queue. Interop queue means that the
- * queue can access both graphics and compute resources.
+ * @is_interop: Defines if this is a interop queue. Interop queue means that
+ * the queue can access both graphics and compute resources.
  *
  * @is_active: Defines if the queue is active or not.
  *
@@ -352,9 +352,10 @@ struct queue_properties {
  * @properties: The queue properties.
  *
  * @mec: Used only in no cp scheduling mode and identifies to micro engine id
- * that the queue should be execute on.
+ *	 that the queue should be execute on.
  *
- * @pipe: Used only in no cp scheduling mode and identifies the queue's pipe id.
+ * @pipe: Used only in no cp scheduling mode and identifies the queue's pipe
+ *	  id.
  *
  * @queue: Used only in no cp scheduliong mode and identifies the queue's slot.
  *
@@ -520,8 +521,8 @@ struct kfd_process {
 	struct mutex event_mutex;
 	/* All events in process hashed by ID, linked on kfd_event.events. */
 	DECLARE_HASHTABLE(events, 4);
-	struct list_head signal_event_pages;	/* struct slot_page_header.
-								event_pages */
+	/* struct slot_page_header.event_pages */
+	struct list_head signal_event_pages;
 	u32 next_nonsignal_event_id;
 	size_t signal_event_count;
 };
@@ -559,8 +560,10 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
 							struct kfd_process *p);
 
 /* Process device data iterator */
-struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p);
-struct kfd_process_device *kfd_get_next_process_device_data(struct kfd_process *p,
+struct kfd_process_device *kfd_get_first_process_device_data(
+							struct kfd_process *p);
+struct kfd_process_device *kfd_get_next_process_device_data(
+						struct kfd_process *p,
 						struct kfd_process_device *pdd);
 bool kfd_has_process_device_data(struct kfd_process *p);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +4 -2
index 035bbc9..a4e4a2d 100644
@@ -449,14 +449,16 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
 	mutex_unlock(&p->mutex);
 }
 
-struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p)
+struct kfd_process_device *kfd_get_first_process_device_data(
+						struct kfd_process *p)
 {
 	return list_first_entry(&p->per_device_data,
 				struct kfd_process_device,
 				per_device_list);
 }
 
-struct kfd_process_device *kfd_get_next_process_device_data(struct kfd_process *p,
+struct kfd_process_device *kfd_get_next_process_device_data(
+						struct kfd_process *p,
 						struct kfd_process_device *pdd)
 {
 	if (list_is_last(&pdd->per_device_list, &p->per_device_data))
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -2
index 1e50647..0200dae 100644
@@ -1170,8 +1170,8 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 		 * GPU vBIOS
 		 */
 
-		/*
-		 * Update the SYSFS tree, since we added another topology device
+		/* Update the SYSFS tree, since we added another topology
+		 * device
 		 */
 		if (kfd_topology_update_sysfs() < 0)
 			kfd_topology_release_sysfs();
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-7-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#13 lore raw

Re: [PATCH 06/24] drm/amdkfd: Clean up KFD style errors and warnings v2

Quoted 588 lines · Felix Kuehling

From: Kent Russell <[email protected]>

Using checkpatch.pl -f <file> showed a number of style issues. This patch addresses as many of them as possible. Some long lines have been left for readability, but attempts to minimize them have been made.

v2: Broke long lines in gfx_v7 get_fw_version

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 16 ++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 16 ++++++-------
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           |  6 +++--
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            |  7 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h            | 27 +++++++++++-----------
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            |  5 ++--
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  8 ++++---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  5 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c         |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_module.c            |  3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  3 +--
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    |  5 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |  3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h       | 16 ++++++-------
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h    | 10 ++++----
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              | 23 ++++++++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  6 +++--
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  4 ++--
 19 files changed, 91 insertions(+), 78 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -2
index c7bcf52..5432af3 100644
@@ -28,14 +28,14 @@
 #include <linux/module.h>
 
 const struct kgd2kfd_calls *kgd2kfd;
-bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
+bool (*kgd2kfd_init_p)(unsigned int, const struct kgd2kfd_calls**);
 
 int amdgpu_amdkfd_init(void)
 {
        int ret;
 
 #if defined(CONFIG_HSA_AMD_MODULE)
-       int (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
+       int (*kgd2kfd_init_p)(unsigned int, const struct kgd2kfd_calls**);
 
        kgd2kfd_init_p = symbol_request(kgd2kfd_init);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +8 -8
index 31c4fbd..dcd90e8 100644
@@ -566,42 +566,42 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
        switch (type) {
        case KGD_ENGINE_PFP:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.pfp_fw->data;
+                                               adev->gfx.pfp_fw->data;
                break;
 
        case KGD_ENGINE_ME:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.me_fw->data;
+                                               adev->gfx.me_fw->data;
                break;
 
        case KGD_ENGINE_CE:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.ce_fw->data;
+                                               adev->gfx.ce_fw->data;
                break;
 
        case KGD_ENGINE_MEC1:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.mec_fw->data;
+                                               adev->gfx.mec_fw->data;
                break;
 
        case KGD_ENGINE_MEC2:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.mec2_fw->data;
+                                               adev->gfx.mec2_fw->data;
                break;
 
        case KGD_ENGINE_RLC:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.rlc_fw->data;
+                                               adev->gfx.rlc_fw->data;
                break;
 
        case KGD_ENGINE_SDMA1:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->sdma.instance[0].fw->data;
+                                               adev->sdma.instance[0].fw->data;
                break;
 
        case KGD_ENGINE_SDMA2:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->sdma.instance[1].fw->data;
+                                               adev->sdma.instance[1].fw->data;
                break;
 
        default:
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +8 -8
index c8ac402..0fccd30 100644
@@ -454,42 +454,42 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
        switch (type) {
        case KGD_ENGINE_PFP:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.pfp_fw->data;
+                                               adev->gfx.pfp_fw->data;
                break;
 
        case KGD_ENGINE_ME:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.me_fw->data;
+                                               adev->gfx.me_fw->data;
                break;
 
        case KGD_ENGINE_CE:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.ce_fw->data;
+                                               adev->gfx.ce_fw->data;
                break;
 
        case KGD_ENGINE_MEC1:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.mec_fw->data;
+                                               adev->gfx.mec_fw->data;
                break;
 
        case KGD_ENGINE_MEC2:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.mec2_fw->data;
+                                               adev->gfx.mec2_fw->data;
                break;
 
        case KGD_ENGINE_RLC:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->gfx.rlc_fw->data;
+                                               adev->gfx.rlc_fw->data;
                break;
 
        case KGD_ENGINE_SDMA1:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->sdma.instance[0].fw->data;
+                                               adev->sdma.instance[0].fw->data;
                break;
 
        case KGD_ENGINE_SDMA2:
                hdr = (const union amdgpu_firmware_header *)
-                                                       adev->sdma.instance[1].fw->data;
+                                               adev->sdma.instance[1].fw->data;
                break;
 
        default:
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +4 -2
index 6316aad..2603b7c 100644
@@ -782,7 +782,8 @@ static int kfd_ioctl_get_process_apertures(struct file *filp,
                                "scratch_limit %llX\n", pdd->scratch_limit);
 
                        args->num_of_nodes++;
-               } while ((pdd = kfd_get_next_process_device_data(p, pdd)) != NULL &&
+               } while ((pdd = kfd_get_next_process_device_data(p, pdd)) !=
+                               NULL &&
                                (args->num_of_nodes < NUM_OF_SUPPORTED_GPUS));
        }
 
@@ -848,7 +849,8 @@ static int kfd_ioctl_wait_events(struct file *filp, struct kfd_process *p,
 }
 
 #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
-       [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0, .name = #ioctl}
+       [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \
+                           .cmd_drv = 0, .name = #ioctl}
 
 /** Ioctl table */
 static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +4 -3
index faa0790..a7548a5 100644
@@ -313,7 +313,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
                return -EINVAL;
        }
 
-       for (i = 0 ; i < adw_info->num_watch_points ; i++) {
+       for (i = 0; i < adw_info->num_watch_points; i++) {
                dbgdev_address_watch_set_registers(adw_info, &addrHi, &addrLo,
                                                &cntl, i, pdd->qpd.vmid);
 
@@ -623,7 +623,7 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
                return status;
        }
 
-       /* we do not control the VMID in DIQ,so reset it to a known value */
+       /* we do not control the VMID in DIQ, so reset it to a known value */
        reg_sq_cmd.bits.vm_id = 0;
 
        pr_debug("\t\t %30s\n", "* * * * * * * * * * * * * * * * * *");
@@ -810,7 +810,8 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
 
        /* Scan all registers in the range ATC_VMID8_PASID_MAPPING ..
         * ATC_VMID15_PASID_MAPPING
-        * to check which VMID the current process is mapped to. */
+        * to check which VMID the current process is mapped to.
+        */
 
        for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) {
                if (dev->kfd2kgd->get_atc_vmid_pasid_mapping_valid
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h +13 -14
index 257a745..a04a1fe 100644
@@ -30,13 +30,11 @@
 #pragma pack(push, 4)
 
 enum HSA_DBG_WAVEOP {
-       HSA_DBG_WAVEOP_HALT = 1,        /* Halts a wavefront            */
-       HSA_DBG_WAVEOP_RESUME = 2,      /* Resumes a wavefront          */
-       HSA_DBG_WAVEOP_KILL = 3,        /* Kills a wavefront            */
-       HSA_DBG_WAVEOP_DEBUG = 4,       /* Causes wavefront to enter
-                                               debug mode              */
-       HSA_DBG_WAVEOP_TRAP = 5,        /* Causes wavefront to take
-                                               a trap                  */
+       HSA_DBG_WAVEOP_HALT = 1,   /* Halts a wavefront */
+       HSA_DBG_WAVEOP_RESUME = 2, /* Resumes a wavefront */
+       HSA_DBG_WAVEOP_KILL = 3,   /* Kills a wavefront */
+       HSA_DBG_WAVEOP_DEBUG = 4,  /* Causes wavefront to enter dbg mode */
+       HSA_DBG_WAVEOP_TRAP = 5,   /* Causes wavefront to take a trap */
        HSA_DBG_NUM_WAVEOP = 5,
        HSA_DBG_MAX_WAVEOP = 0xFFFFFFFF
 };
@@ -81,15 +79,13 @@ struct HsaDbgWaveMsgAMDGen2 {
                        uint32_t UserData:8;    /* user data */
                        uint32_t ShaderArray:1; /* Shader array */
                        uint32_t Priv:1;        /* Privileged */
-                       uint32_t Reserved0:4;   /* This field is reserved,
-                                                  should be 0 */
+                       uint32_t Reserved0:4;   /* Reserved, should be 0 */
                        uint32_t WaveId:4;      /* wave id */
                        uint32_t SIMD:2;        /* SIMD id */
                        uint32_t HSACU:4;       /* Compute unit */
                        uint32_t ShaderEngine:2;/* Shader engine */
                        uint32_t MessageType:2; /* see HSA_DBG_WAVEMSG_TYPE */
-                       uint32_t Reserved1:4;   /* This field is reserved,
-                                                  should be 0 */
+                       uint32_t Reserved1:4;   /* Reserved, should be 0 */
                } ui32;
                uint32_t Value;
        };
@@ -121,20 +117,23 @@ struct HsaDbgWaveMessage {
  * in the user mode instruction stream. The OS scheduler event is typically
  * associated and signaled by an interrupt issued by the GPU, but other HSA
  * system interrupt conditions from other HW (e.g. IOMMUv2) may be surfaced
- * by the KFD by this mechanism, too. */
+ * by the KFD by this mechanism, too.
+ */
 
 /* these are the new definitions for events */
 enum HSA_EVENTTYPE {
        HSA_EVENTTYPE_SIGNAL = 0,       /* user-mode generated GPU signal */
        HSA_EVENTTYPE_NODECHANGE = 1,   /* HSA node change (attach/detach) */
        HSA_EVENTTYPE_DEVICESTATECHANGE = 2,    /* HSA device state change
-                                                  (start/stop) */
+                                                * (start/stop)
+                                                */
        HSA_EVENTTYPE_HW_EXCEPTION = 3, /* GPU shader exception event */
        HSA_EVENTTYPE_SYSTEM_EVENT = 4, /* GPU SYSCALL with parameter info */
        HSA_EVENTTYPE_DEBUG_EVENT = 5,  /* GPU signal for debugging */
        HSA_EVENTTYPE_PROFILE_EVENT = 6,/* GPU signal for profiling */
        HSA_EVENTTYPE_QUEUE_EVENT = 7,  /* GPU signal queue idle state
-                                          (EOP pm4) */
+                                        * (EOP pm4)
+                                        */
        /* ...  */
        HSA_EVENTTYPE_MAXID,
        HSA_EVENTTYPE_TYPE_SIZE = 0xFFFFFFFF
drivers/gpu/drm/amd/amdkfd/kfd_device.c +3 -2
index 3f95f7c..1f50325 100644
@@ -155,12 +155,13 @@ static bool device_iommu_pasid_init(struct kfd_dev *kfd)
                dev_err(kfd_device, "error required iommu flags ats(%i), pri(%i), pasid(%i)\n",
                       (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_ATS_SUP) != 0,
                       (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_PRI_SUP) != 0,
-                      (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_PASID_SUP) != 0);
+                      (iommu_info.flags & AMD_IOMMU_DEVICE_FLAG_PASID_SUP)
+                                                                       != 0);
                return false;
        }
 
        pasid_limit = min_t(unsigned int,
-                       (unsigned int)1 << kfd->device_info->max_pasid_bits,
+                       (unsigned int)(1 << kfd->device_info->max_pasid_bits),
                        iommu_info.max_pasids);
        /*
         * last pasid is used for kernel queues doorbells
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -3
index 9d2796b..3b850da 100644
@@ -216,7 +216,8 @@ static int allocate_hqd(struct device_queue_manager *dqm, struct queue *q)
 
        set = false;
 
-       for (pipe = dqm->next_pipe_to_allocate, i = 0; i < get_pipes_per_mec(dqm);
+       for (pipe = dqm->next_pipe_to_allocate, i = 0;
+                       i < get_pipes_per_mec(dqm);
                        pipe = ((pipe + 1) % get_pipes_per_mec(dqm)), ++i) {
 
                if (!is_pipe_enabled(dqm, 0, pipe))
@@ -669,7 +670,8 @@ static int set_sched_resources(struct device_queue_manager *dqm)
 
                /* This situation may be hit in the future if a new HW
                 * generation exposes more than 64 queues. If so, the
-                * definition of res.queue_mask needs updating */
+                * definition of res.queue_mask needs updating
+                */
                if (WARN_ON(i >= (sizeof(res.queue_mask)*8))) {
                        pr_err("Invalid queue enabled by amdgpu: %d\n", i);
                        break;
@@ -890,7 +892,7 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
        }
 
        if (q->properties.type == KFD_QUEUE_TYPE_SDMA)
-                       dqm->sdma_queue_count++;
+               dqm->sdma_queue_count++;
        /*
         * Unconditionally increment this counter, regardless of the queue's
         * type or whether the queue is active.
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -2
index d1ce83d..d8b9b3c 100644
@@ -194,7 +194,8 @@ static void release_event_notification_slot(struct signal_page *page,
        page->free_slots++;
 
        /* We don't free signal pages, they are retained by the process
-        * and reused until it exits. */
+        * and reused until it exits.
+        */
 }
 
 static struct signal_page *lookup_signal_page_by_index(struct kfd_process *p,
@@ -584,7 +585,7 @@ void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
                 * search faster.
                 */
                struct signal_page *page;
-               unsigned i;
+               unsigned int i;
 
                list_for_each_entry(page, &p->signal_event_pages, event_pages)
                        for (i = 0; i < SLOTS_PER_PAGE; i++)
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +1 -1
index 7f134aa..70b3a99c 100644
@@ -179,7 +179,7 @@ static void interrupt_wq(struct work_struct *work)
 bool interrupt_is_wanted(struct kfd_dev *dev, const uint32_t *ih_ring_entry)
 {
        /* integer and bitwise OR so there is no boolean short-circuiting */
-       unsigned wanted = 0;
+       unsigned int wanted = 0;
 
        wanted |= dev->device_info->event_interrupt_class->interrupt_isr(dev,
                                                                ih_ring_entry);
drivers/gpu/drm/amd/amdkfd/kfd_module.c +2 -1
index 850a562..af5bfc1 100644
@@ -61,7 +61,8 @@ MODULE_PARM_DESC(send_sigterm,
 
 static int amdkfd_init_completed;
 
-int kgd2kfd_init(unsigned interface_version, const struct kgd2kfd_calls **g2f)
+int kgd2kfd_init(unsigned int interface_version,
+               const struct kgd2kfd_calls **g2f)
 {
        if (!amdkfd_init_completed)
                return -EPROBE_DEFER;
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +1 -2
index 6acc431..ac59229 100644
@@ -193,9 +193,8 @@ static int update_mqd(struct mqd_manager *mm, void *mqd,
 
        m->cp_hqd_vmid = q->vmid;
 
-       if (q->format == KFD_QUEUE_FORMAT_AQL) {
+       if (q->format == KFD_QUEUE_FORMAT_AQL)
                m->cp_hqd_pq_control |= NO_UPDATE_RPTR;
-       }
 
        m->cp_hqd_active = 0;
        q->is_active = false;
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +2 -3
index 7131998..99c11a4 100644
@@ -458,7 +458,7 @@ int pm_send_set_resources(struct packet_manager *pm,
        mutex_lock(&pm->lock);
        pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
                                        sizeof(*packet) / sizeof(uint32_t),
-                       (unsigned int **)&packet);
+                                       (unsigned int **)&packet);
        if (packet == NULL) {
                mutex_unlock(&pm->lock);
                pr_err("kfd: failed to allocate buffer on kernel queue\n");
@@ -530,8 +530,7 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
 fail_acquire_packet_buffer:
        mutex_unlock(&pm->lock);
 fail_create_runlist_ib:
-       if (pm->allocated)
-               pm_release_ib(pm);
+       pm_release_ib(pm);
        return retval;
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_pasid.c +2 -1
index 6cfe7f1..b3f7d43 100644
@@ -32,7 +32,8 @@ int kfd_pasid_init(void)
 {
        pasid_limit = KFD_MAX_NUM_OF_PROCESSES;
 
-       pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long), GFP_KERNEL);
+       pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long),
+                               GFP_KERNEL);
        if (!pasid_bitmap)
                return -ENOMEM;
 
drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h +8 -8
index 5b393f3..97e5442 100644
@@ -28,14 +28,14 @@
 #define PM4_MES_HEADER_DEFINED
 union PM4_MES_TYPE_3_HEADER {
        struct {
-               uint32_t reserved1:8;   /* < reserved */
-               uint32_t opcode:8;      /* < IT opcode */
-               uint32_t count:14;      /* < number of DWORDs - 1
-                                        * in the information body.
-                                        */
-               uint32_t type:2;        /* < packet identifier.
-                                        * It should be 3 for type 3 packets
-                                        */
+               /* reserved */
+               uint32_t reserved1:8;
+               /* IT opcode */
+               uint32_t opcode:8;
+               /* number of DWORDs - 1 in the information body */
+               uint32_t count:14;
+               /* packet identifier. It should be 3 for type 3 packets */
+               uint32_t type:2;
        };
        uint32_t u32all;
 };
drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h +6 -4
index 08c72192..c4eda6f 100644
@@ -30,10 +30,12 @@ union PM4_MES_TYPE_3_HEADER {
        struct {
                uint32_t reserved1 : 8; /* < reserved */
                uint32_t opcode    : 8; /* < IT opcode */
-               uint32_t count     : 14;/* < number of DWORDs - 1 in the
-               information body. */
-               uint32_t type      : 2; /* < packet identifier.
-                                       It should be 3 for type 3 packets */
+               uint32_t count     : 14;/* < Number of DWORDS - 1 in the
+                                        *   information body
+                                        */
+               uint32_t type      : 2; /* < packet identifier
+                                        *   It should be 3 for type 3 packets
+                                        */
        };
        uint32_t u32All;
 };
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +13 -10
index 4750cab..469b7ea 100644
@@ -294,13 +294,13 @@ enum kfd_queue_format {
  * @write_ptr: Defines the number of dwords written to the ring buffer.
  *
  * @doorbell_ptr: This field aim is to notify the H/W of new packet written to
- * the queue ring buffer. This field should be similar to write_ptr and the user
- * should update this field after he updated the write_ptr.
+ * the queue ring buffer. This field should be similar to write_ptr and the
+ * user should update this field after he updated the write_ptr.
  *
  * @doorbell_off: The doorbell offset in the doorbell pci-bar.
  *
- * @is_interop: Defines if this is a interop queue. Interop queue means that the
- * queue can access both graphics and compute resources.
+ * @is_interop: Defines if this is a interop queue. Interop queue means that
+ * the queue can access both graphics and compute resources.
  *
  * @is_active: Defines if the queue is active or not.
  *
@@ -352,9 +352,10 @@ struct queue_properties {
  * @properties: The queue properties.
  *
  * @mec: Used only in no cp scheduling mode and identifies to micro engine id
- * that the queue should be execute on.
+ *      that the queue should be execute on.
  *
- * @pipe: Used only in no cp scheduling mode and identifies the queue's pipe id.
+ * @pipe: Used only in no cp scheduling mode and identifies the queue's pipe
+ *       id.
  *
  * @queue: Used only in no cp scheduliong mode and identifies the queue's slot.
  *
@@ -520,8 +521,8 @@ struct kfd_process {
        struct mutex event_mutex;
        /* All events in process hashed by ID, linked on kfd_event.events. */
        DECLARE_HASHTABLE(events, 4);
-       struct list_head signal_event_pages;    /* struct slot_page_header.
-                                                               event_pages */
+       /* struct slot_page_header.event_pages */
+       struct list_head signal_event_pages;
        u32 next_nonsignal_event_id;
        size_t signal_event_count;
 };
@@ -559,8 +560,10 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
                                                        struct kfd_process *p);
 
 /* Process device data iterator */
-struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p);
-struct kfd_process_device *kfd_get_next_process_device_data(struct kfd_process *p,
+struct kfd_process_device *kfd_get_first_process_device_data(
+                                                       struct kfd_process *p);
+struct kfd_process_device *kfd_get_next_process_device_data(
+                                               struct kfd_process *p,
                                                struct kfd_process_device *pdd);
 bool kfd_has_process_device_data(struct kfd_process *p);
 
drivers/gpu/drm/amd/amdkfd/kfd_process.c +4 -2
index 035bbc9..a4e4a2d 100644
@@ -449,14 +449,16 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
        mutex_unlock(&p->mutex);
 }
 
-struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p)
+struct kfd_process_device *kfd_get_first_process_device_data(
+                                               struct kfd_process *p)
 {
        return list_first_entry(&p->per_device_data,
                                struct kfd_process_device,
                                per_device_list);
 }
 
-struct kfd_process_device *kfd_get_next_process_device_data(struct kfd_process *p,
+struct kfd_process_device *kfd_get_next_process_device_data(
+                                               struct kfd_process *p,
                                                struct kfd_process_device *pdd)
 {
        if (list_is_last(&pdd->per_device_list, &p->per_device_data))
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -3
index 1e50647..0200dae 100644
@@ -1170,8 +1170,8 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
                 * GPU vBIOS
                 */
 
-               /*
-                * Update the SYSFS tree, since we added another topology device
+               /* Update the SYSFS tree, since we added another topology
+                * device
                 */
                if (kfd_topology_update_sysfs() < 0)
                        kfd_topology_release_sysfs();
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#14 lore raw

PATCH 7/24 drm/amdkfd: Consolidate and clean up log commands

In reply to a message not in the archive

From: Kent Russell <[email protected]>

Consolidate log commands so that dev_info(NULL, "Error...") uses the more accurate pr_err, remove the module name from the log (can be seen via dynamic debugging with +m), and the function name (can be seen via dynamic debugging with +f). We also don't need debug messages saying what function we're in. Those can be added by devs when needed

Don't print vendor and device ID in error messages. They are typically the same for all GPUs in a multi-GPU system. So this doesn't add any value to the message.

Lastly, remove parentheses around %d, %i and 0x%llX. According to kernel.org:
"Printing numbers in parentheses (%d) adds no value and should be avoided."

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 64 ++++++++---------
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            | 38 +++++-----
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 51 ++++++--------
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 81 +++++++---------------
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |  2 +-
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c          | 21 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c            | 22 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      | 16 ++---
 drivers/gpu/drm/amd/amdkfd/kfd_module.c            |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   | 10 ---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  8 +--
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 34 ++++-----
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  4 +-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 27 +++-----
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  6 +-
 17 files changed, 158 insertions(+), 236 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +32 -32
index 2603b7c..6763972 100644
@@ -142,12 +142,12 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 				struct kfd_ioctl_create_queue_args *args)
 {
 	if (args->queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) {
-		pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n");
+		pr_err("Queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n");
 		return -EINVAL;
 	}
 
 	if (args->queue_priority > KFD_MAX_QUEUE_PRIORITY) {
-		pr_err("kfd: queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n");
+		pr_err("Queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n");
 		return -EINVAL;
 	}
 
@@ -155,26 +155,26 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 		(!access_ok(VERIFY_WRITE,
 			(const void __user *) args->ring_base_address,
 			sizeof(uint64_t)))) {
-		pr_err("kfd: can't access ring base address\n");
+		pr_err("Can't access ring base address\n");
 		return -EFAULT;
 	}
 
 	if (!is_power_of_2(args->ring_size) && (args->ring_size != 0)) {
-		pr_err("kfd: ring size must be a power of 2 or 0\n");
+		pr_err("Ring size must be a power of 2 or 0\n");
 		return -EINVAL;
 	}
 
 	if (!access_ok(VERIFY_WRITE,
 			(const void __user *) args->read_pointer_address,
 			sizeof(uint32_t))) {
-		pr_err("kfd: can't access read pointer\n");
+		pr_err("Can't access read pointer\n");
 		return -EFAULT;
 	}
 
 	if (!access_ok(VERIFY_WRITE,
 			(const void __user *) args->write_pointer_address,
 			sizeof(uint32_t))) {
-		pr_err("kfd: can't access write pointer\n");
+		pr_err("Can't access write pointer\n");
 		return -EFAULT;
 	}
 
@@ -182,7 +182,7 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 		!access_ok(VERIFY_WRITE,
 			(const void __user *) args->eop_buffer_address,
 			sizeof(uint32_t))) {
-		pr_debug("kfd: can't access eop buffer");
+		pr_debug("Can't access eop buffer");
 		return -EFAULT;
 	}
 
@@ -190,7 +190,7 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 		!access_ok(VERIFY_WRITE,
 			(const void __user *) args->ctx_save_restore_address,
 			sizeof(uint32_t))) {
-		pr_debug("kfd: can't access ctx save restore buffer");
+		pr_debug("Can't access ctx save restore buffer");
 		return -EFAULT;
 	}
 
@@ -219,27 +219,27 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 	else
 		q_properties->format = KFD_QUEUE_FORMAT_PM4;
 
-	pr_debug("Queue Percentage (%d, %d)\n",
+	pr_debug("Queue Percentage: %d, %d\n",
 			q_properties->queue_percent, args->queue_percentage);
 
-	pr_debug("Queue Priority (%d, %d)\n",
+	pr_debug("Queue Priority: %d, %d\n",
 			q_properties->priority, args->queue_priority);
 
-	pr_debug("Queue Address (0x%llX, 0x%llX)\n",
+	pr_debug("Queue Address: 0x%llX, 0x%llX\n",
 			q_properties->queue_address, args->ring_base_address);
 
-	pr_debug("Queue Size (0x%llX, %u)\n",
+	pr_debug("Queue Size: 0x%llX, %u\n",
 			q_properties->queue_size, args->ring_size);
 
-	pr_debug("Queue r/w Pointers (0x%llX, 0x%llX)\n",
-			(uint64_t) q_properties->read_ptr,
-			(uint64_t) q_properties->write_ptr);
+	pr_debug("Queue r/w Pointers: %p, %p\n",
+			q_properties->read_ptr,
+			q_properties->write_ptr);
 
-	pr_debug("Queue Format (%d)\n", q_properties->format);
+	pr_debug("Queue Format: %d\n", q_properties->format);
 
-	pr_debug("Queue EOP (0x%llX)\n", q_properties->eop_ring_buffer_address);
+	pr_debug("Queue EOP: 0x%llX\n", q_properties->eop_ring_buffer_address);
 
-	pr_debug("Queue CTX save arex (0x%llX)\n",
+	pr_debug("Queue CTX save area: 0x%llX\n",
 			q_properties->ctx_save_restore_area_address);
 
 	return 0;
@@ -257,16 +257,16 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
 
 	memset(&q_properties, 0, sizeof(struct queue_properties));
 
-	pr_debug("kfd: creating queue ioctl\n");
+	pr_debug("Creating queue ioctl\n");
 
 	err = set_queue_properties_from_user(&q_properties, args);
 	if (err)
 		return err;
 
-	pr_debug("kfd: looking for gpu id 0x%x\n", args->gpu_id);
+	pr_debug("Looking for gpu id 0x%x\n", args->gpu_id);
 	dev = kfd_device_by_id(args->gpu_id);
 	if (dev == NULL) {
-		pr_debug("kfd: gpu id 0x%x was not found\n", args->gpu_id);
+		pr_debug("Could not find gpu id 0x%x\n", args->gpu_id);
 		return -EINVAL;
 	}
 
@@ -278,7 +278,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
 		goto err_bind_process;
 	}
 
-	pr_debug("kfd: creating queue for PASID %d on GPU 0x%x\n",
+	pr_debug("Creating queue for PASID %d on gpu 0x%x\n",
 			p->pasid,
 			dev->id);
 
@@ -296,15 +296,15 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
 
 	mutex_unlock(&p->mutex);
 
-	pr_debug("kfd: queue id %d was created successfully\n", args->queue_id);
+	pr_debug("Queue id %d was created successfully\n", args->queue_id);
 
-	pr_debug("ring buffer address == 0x%016llX\n",
+	pr_debug("Ring buffer address == 0x%016llX\n",
 			args->ring_base_address);
 
-	pr_debug("read ptr address    == 0x%016llX\n",
+	pr_debug("Read ptr address    == 0x%016llX\n",
 			args->read_pointer_address);
 
-	pr_debug("write ptr address   == 0x%016llX\n",
+	pr_debug("Write ptr address   == 0x%016llX\n",
 			args->write_pointer_address);
 
 	return 0;
@@ -321,7 +321,7 @@ static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p,
 	int retval;
 	struct kfd_ioctl_destroy_queue_args *args = data;
 
-	pr_debug("kfd: destroying queue id %d for PASID %d\n",
+	pr_debug("Destroying queue id %d for pasid %d\n",
 				args->queue_id,
 				p->pasid);
 
@@ -341,12 +341,12 @@ static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p,
 	struct queue_properties properties;
 
 	if (args->queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) {
-		pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n");
+		pr_err("Queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n");
 		return -EINVAL;
 	}
 
 	if (args->queue_priority > KFD_MAX_QUEUE_PRIORITY) {
-		pr_err("kfd: queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n");
+		pr_err("Queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n");
 		return -EINVAL;
 	}
 
@@ -354,12 +354,12 @@ static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p,
 		(!access_ok(VERIFY_WRITE,
 			(const void __user *) args->ring_base_address,
 			sizeof(uint64_t)))) {
-		pr_err("kfd: can't access ring base address\n");
+		pr_err("Can't access ring base address\n");
 		return -EFAULT;
 	}
 
 	if (!is_power_of_2(args->ring_size) && (args->ring_size != 0)) {
-		pr_err("kfd: ring size must be a power of 2 or 0\n");
+		pr_err("Ring size must be a power of 2 or 0\n");
 		return -EINVAL;
 	}
 
@@ -368,7 +368,7 @@ static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p,
 	properties.queue_percent = args->queue_percentage;
 	properties.priority = args->queue_priority;
 
-	pr_debug("kfd: updating queue id %d for PASID %d\n",
+	pr_debug("Updating queue id %d for pasid %d\n",
 			args->queue_id, p->pasid);
 
 	mutex_lock(&p->mutex);
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +19 -19
index a7548a5..bf8ee19 100644
@@ -78,7 +78,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 				pq_packets_size_in_bytes / sizeof(uint32_t),
 				&ib_packet_buff);
 	if (status != 0) {
-		pr_err("amdkfd: acquire_packet_buffer failed\n");
+		pr_err("acquire_packet_buffer failed\n");
 		return status;
 	}
 
@@ -116,7 +116,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 					&mem_obj);
 
 	if (status != 0) {
-		pr_err("amdkfd: Failed to allocate GART memory\n");
+		pr_err("Failed to allocate GART memory\n");
 		kq->ops.rollback_packet(kq);
 		return status;
 	}
@@ -194,7 +194,7 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
 				&qid);
 
 	if (status) {
-		pr_err("amdkfd: Failed to create DIQ\n");
+		pr_err("Failed to create DIQ\n");
 		return status;
 	}
 
@@ -203,7 +203,7 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
 	kq = pqm_get_kernel_queue(dbgdev->pqm, qid);
 
 	if (kq == NULL) {
-		pr_err("amdkfd: Error getting DIQ\n");
+		pr_err("Error getting DIQ\n");
 		pqm_destroy_queue(dbgdev->pqm, qid);
 		return -EFAULT;
 	}
@@ -279,7 +279,7 @@ static void dbgdev_address_watch_set_registers(
 }
 
 static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
-					struct dbg_address_watch_info *adw_info)
+				      struct dbg_address_watch_info *adw_info)
 {
 	union TCP_WATCH_ADDR_H_BITS addrHi;
 	union TCP_WATCH_ADDR_L_BITS addrLo;
@@ -293,7 +293,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 	pdd = kfd_get_process_device_data(dbgdev->dev,
 					adw_info->process);
 	if (!pdd) {
-		pr_err("amdkfd: Failed to get pdd for wave control no DIQ\n");
+		pr_err("Failed to get pdd for wave control no DIQ\n");
 		return -EFAULT;
 	}
 
@@ -303,13 +303,13 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 
 	if ((adw_info->num_watch_points > MAX_WATCH_ADDRESSES) ||
 			(adw_info->num_watch_points == 0)) {
-		pr_err("amdkfd: num_watch_points is invalid\n");
+		pr_err("num_watch_points is invalid\n");
 		return -EINVAL;
 	}
 
 	if ((adw_info->watch_mode == NULL) ||
 		(adw_info->watch_address == NULL)) {
-		pr_err("amdkfd: adw_info fields are not valid\n");
+		pr_err("adw_info fields are not valid\n");
 		return -EINVAL;
 	}
 
@@ -348,7 +348,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 }
 
 static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
-					struct dbg_address_watch_info *adw_info)
+				    struct dbg_address_watch_info *adw_info)
 {
 	struct pm4__set_config_reg *packets_vec;
 	union TCP_WATCH_ADDR_H_BITS addrHi;
@@ -371,20 +371,20 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 
 	if ((adw_info->num_watch_points > MAX_WATCH_ADDRESSES) ||
 			(adw_info->num_watch_points == 0)) {
-		pr_err("amdkfd: num_watch_points is invalid\n");
+		pr_err("num_watch_points is invalid\n");
 		return -EINVAL;
 	}
 
 	if ((NULL == adw_info->watch_mode) ||
 			(NULL == adw_info->watch_address)) {
-		pr_err("amdkfd: adw_info fields are not valid\n");
+		pr_err("adw_info fields are not valid\n");
 		return -EINVAL;
 	}
 
 	status = kfd_gtt_sa_allocate(dbgdev->dev, ib_size, &mem_obj);
 
 	if (status != 0) {
-		pr_err("amdkfd: Failed to allocate GART memory\n");
+		pr_err("Failed to allocate GART memory\n");
 		return status;
 	}
 
@@ -491,7 +491,7 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 					ib_size);
 
 		if (status != 0) {
-			pr_err("amdkfd: Failed to submit IB to DIQ\n");
+			pr_err("Failed to submit IB to DIQ\n");
 			break;
 		}
 	}
@@ -619,7 +619,7 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
 	status = dbgdev_wave_control_set_registers(wac_info, &reg_sq_cmd,
 							&reg_gfx_index);
 	if (status) {
-		pr_err("amdkfd: Failed to set wave control registers\n");
+		pr_err("Failed to set wave control registers\n");
 		return status;
 	}
 
@@ -659,7 +659,7 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
 	status = kfd_gtt_sa_allocate(dbgdev->dev, ib_size, &mem_obj);
 
 	if (status != 0) {
-		pr_err("amdkfd: Failed to allocate GART memory\n");
+		pr_err("Failed to allocate GART memory\n");
 		return status;
 	}
 
@@ -712,7 +712,7 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
 			ib_size);
 
 	if (status != 0)
-		pr_err("amdkfd: Failed to submit IB to DIQ\n");
+		pr_err("Failed to submit IB to DIQ\n");
 
 	kfd_gtt_sa_free(dbgdev->dev, mem_obj);
 
@@ -735,13 +735,13 @@ static int dbgdev_wave_control_nodiq(struct kfd_dbgdev *dbgdev,
 	pdd = kfd_get_process_device_data(dbgdev->dev, wac_info->process);
 
 	if (!pdd) {
-		pr_err("amdkfd: Failed to get pdd for wave control no DIQ\n");
+		pr_err("Failed to get pdd for wave control no DIQ\n");
 		return -EFAULT;
 	}
 	status = dbgdev_wave_control_set_registers(wac_info, &reg_sq_cmd,
 							&reg_gfx_index);
 	if (status) {
-		pr_err("amdkfd: Failed to set wave control registers\n");
+		pr_err("Failed to set wave control registers\n");
 		return status;
 	}
 
@@ -826,7 +826,7 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
 	}
 
 	if (vmid > last_vmid_to_scan) {
-		pr_err("amdkfd: didn't found vmid for pasid (%d)\n", p->pasid);
+		pr_err("Didn't find vmid for pasid %d\n", p->pasid);
 		return -EFAULT;
 	}
 
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c +2 -2
index 56d6763..7225789 100644
@@ -71,7 +71,7 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
 
 	new_buff = kfd_alloc_struct(new_buff);
 	if (!new_buff) {
-		pr_err("amdkfd: Failed to allocate dbgmgr instance\n");
+		pr_err("Failed to allocate dbgmgr instance\n");
 		return false;
 	}
 
@@ -79,7 +79,7 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
 	new_buff->dev = pdev;
 	new_buff->dbgdev = kfd_alloc_struct(new_buff->dbgdev);
 	if (!new_buff->dbgdev) {
-		pr_err("amdkfd: Failed to allocate dbgdev instance\n");
+		pr_err("Failed to allocate dbgdev instance\n");
 		kfree(new_buff);
 		return false;
 	}
drivers/gpu/drm/amd/amdkfd/kfd_device.c +20 -31

155 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +25 -56

255 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +1 -1
index 48dc056..a263e2a 100644
@@ -127,7 +127,7 @@ static int register_process_cik(struct device_queue_manager *dqm,
 		qpd->sh_mem_bases = compute_sh_mem_bases_64bit(temp);
 	}
 
-	pr_debug("kfd: is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
+	pr_debug("is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
 		qpd->pqm->process->is_32bit_user_mode, temp, qpd->sh_mem_bases);
 
 	return 0;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +1 -1
index 7e9cae9..8c45c86 100644
@@ -139,7 +139,7 @@ static int register_process_vi(struct device_queue_manager *dqm,
 			SH_MEM_CONFIG__ADDRESS_MODE__SHIFT;
 	}
 
-	pr_debug("kfd: is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
+	pr_debug("is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
 		qpd->pqm->process->is_32bit_user_mode, temp, qpd->sh_mem_bases);
 
 	return 0;
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c +10 -11
index 453c5d6..ca21538 100644
@@ -97,23 +97,23 @@ void kfd_doorbell_init(struct kfd_dev *kfd)
 
 	BUG_ON(!kfd->doorbell_kernel_ptr);
 
-	pr_debug("kfd: doorbell initialization:\n");
-	pr_debug("kfd: doorbell base           == 0x%08lX\n",
+	pr_debug("Doorbell initialization:\n");
+	pr_debug("doorbell base           == 0x%08lX\n",
 			(uintptr_t)kfd->doorbell_base);
 
-	pr_debug("kfd: doorbell_id_offset      == 0x%08lX\n",
+	pr_debug("doorbell_id_offset      == 0x%08lX\n",
 			kfd->doorbell_id_offset);
 
-	pr_debug("kfd: doorbell_process_limit  == 0x%08lX\n",
+	pr_debug("doorbell_process_limit  == 0x%08lX\n",
 			doorbell_process_limit);
 
-	pr_debug("kfd: doorbell_kernel_offset  == 0x%08lX\n",
+	pr_debug("doorbell_kernel_offset  == 0x%08lX\n",
 			(uintptr_t)kfd->doorbell_base);
 
-	pr_debug("kfd: doorbell aperture size  == 0x%08lX\n",
+	pr_debug("doorbell aperture size  == 0x%08lX\n",
 			kfd->shared_resources.doorbell_aperture_size);
 
-	pr_debug("kfd: doorbell kernel address == 0x%08lX\n",
+	pr_debug("doorbell kernel address == 0x%08lX\n",
 			(uintptr_t)kfd->doorbell_kernel_ptr);
 }
 
@@ -142,12 +142,11 @@ int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma)
 
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-	pr_debug("kfd: mapping doorbell page in %s\n"
+	pr_debug("Mapping doorbell page\n"
 		 "     target user address == 0x%08llX\n"
 		 "     physical address    == 0x%08llX\n"
 		 "     vm_flags            == 0x%04lX\n"
 		 "     size                == 0x%04lX\n",
-		 __func__,
 		 (unsigned long long) vma->vm_start, address, vma->vm_flags,
 		 doorbell_process_allocation());
 
@@ -185,7 +184,7 @@ u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
 	*doorbell_off = KERNEL_DOORBELL_PASID * (doorbell_process_allocation() /
 							sizeof(u32)) + inx;
 
-	pr_debug("kfd: get kernel queue doorbell\n"
+	pr_debug("Get kernel queue doorbell\n"
 			 "     doorbell offset   == 0x%08X\n"
 			 "     kernel address    == 0x%08lX\n",
 		*doorbell_off, (uintptr_t)(kfd->doorbell_kernel_ptr + inx));
@@ -210,7 +209,7 @@ inline void write_kernel_doorbell(u32 __iomem *db, u32 value)
 {
 	if (db) {
 		writel(value, db);
-		pr_debug("writing %d to doorbell address 0x%p\n", value, db);
+		pr_debug("Writing %d to doorbell address 0x%p\n", value, db);
 	}
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_events.c +9 -13
index d8b9b3c..abdaf95 100644
@@ -110,7 +110,7 @@ static bool allocate_free_slot(struct kfd_process *process,
 			*out_page = page;
 			*out_slot_index = slot;
 
-			pr_debug("allocated event signal slot in page %p, slot %d\n",
+			pr_debug("Allocated event signal slot in page %p, slot %d\n",
 					page, slot);
 
 			return true;
@@ -155,9 +155,9 @@ static bool allocate_signal_page(struct file *devkfd, struct kfd_process *p)
 						   struct signal_page,
 						   event_pages)->page_index + 1;
 
-	pr_debug("allocated new event signal page at %p, for process %p\n",
+	pr_debug("Allocated new event signal page at %p, for process %p\n",
 			page, p);
-	pr_debug("page index is %d\n", page->page_index);
+	pr_debug("Page index is %d\n", page->page_index);
 
 	list_add(&page->event_pages, &p->signal_event_pages);
 
@@ -292,13 +292,13 @@ static int create_signal_event(struct file *devkfd,
 				struct kfd_event *ev)
 {
 	if (p->signal_event_count == KFD_SIGNAL_EVENT_LIMIT) {
-		pr_warn("amdkfd: Signal event wasn't created because limit was reached\n");
+		pr_warn("Signal event wasn't created because limit was reached\n");
 		return -ENOMEM;
 	}
 
 	if (!allocate_event_notification_slot(devkfd, p, &ev->signal_page,
 						&ev->signal_slot_index)) {
-		pr_warn("amdkfd: Signal event wasn't created because out of kernel memory\n");
+		pr_warn("Signal event wasn't created because out of kernel memory\n");
 		return -ENOMEM;
 	}
 
@@ -310,11 +310,7 @@ static int create_signal_event(struct file *devkfd,
 	ev->event_id = make_signal_event_id(ev->signal_page,
 						ev->signal_slot_index);
 
-	pr_debug("signal event number %zu created with id %d, address %p\n",
-			p->signal_event_count, ev->event_id,
-			ev->user_signal_address);
-
-	pr_debug("signal event number %zu created with id %d, address %p\n",
+	pr_debug("Signal event number %zu created with id %d, address %p\n",
 			p->signal_event_count, ev->event_id,
 			ev->user_signal_address);
 
@@ -817,7 +813,7 @@ int kfd_event_mmap(struct kfd_process *p, struct vm_area_struct *vma)
 	/* check required size is logical */
 	if (get_order(KFD_SIGNAL_EVENT_LIMIT * 8) !=
 			get_order(vma->vm_end - vma->vm_start)) {
-		pr_err("amdkfd: event page mmap requested illegal size\n");
+		pr_err("Event page mmap requested illegal size\n");
 		return -EINVAL;
 	}
 
@@ -826,7 +822,7 @@ int kfd_event_mmap(struct kfd_process *p, struct vm_area_struct *vma)
 	page = lookup_signal_page_by_index(p, page_index);
 	if (!page) {
 		/* Probably KFD bug, but mmap is user-accessible. */
-		pr_debug("signal page could not be found for page_index %u\n",
+		pr_debug("Signal page could not be found for page_index %u\n",
 				page_index);
 		return -EINVAL;
 	}
@@ -837,7 +833,7 @@ int kfd_event_mmap(struct kfd_process *p, struct vm_area_struct *vma)
 	vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_NORESERVE
 		       | VM_DONTDUMP | VM_PFNMAP;
 
-	pr_debug("mapping signal page\n");
+	pr_debug("Mapping signal page\n");
 	pr_debug("     start user address  == 0x%08lx\n", vma->vm_start);
 	pr_debug("     end user address    == 0x%08lx\n", vma->vm_end);
 	pr_debug("     pfn                 == 0x%016lX\n", pfn);
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +8 -8
index d135cd0..f89d366 100644
@@ -44,8 +44,8 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 	BUG_ON(!kq || !dev);
 	BUG_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ);
 
-	pr_debug("amdkfd: In func %s initializing queue type %d size %d\n",
-			__func__, KFD_QUEUE_TYPE_HIQ, queue_size);
+	pr_debug("Initializing queue type %d size %d\n", KFD_QUEUE_TYPE_HIQ,
+			queue_size);
 
 	memset(&prop, 0, sizeof(prop));
 	memset(&nop, 0, sizeof(nop));
@@ -73,13 +73,13 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 	prop.doorbell_ptr = kfd_get_kernel_doorbell(dev, &prop.doorbell_off);
 
 	if (prop.doorbell_ptr == NULL) {
-		pr_err("amdkfd: error init doorbell");
+		pr_err("Failed to initialize doorbell");
 		goto err_get_kernel_doorbell;
 	}
 
 	retval = kfd_gtt_sa_allocate(dev, queue_size, &kq->pq);
 	if (retval != 0) {
-		pr_err("amdkfd: error init pq queues size (%d)\n", queue_size);
+		pr_err("Failed to init pq queues size %d\n", queue_size);
 		goto err_pq_allocate_vidmem;
 	}
 
@@ -139,7 +139,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 
 	/* assign HIQ to HQD */
 	if (type == KFD_QUEUE_TYPE_HIQ) {
-		pr_debug("assigning hiq to hqd\n");
+		pr_debug("Assigning hiq to hqd\n");
 		kq->queue->pipe = KFD_CIK_HIQ_PIPE;
 		kq->queue->queue = KFD_CIK_HIQ_QUEUE;
 		kq->mqd->load_mqd(kq->mqd, kq->queue->mqd, kq->queue->pipe,
@@ -304,7 +304,7 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
 	}
 
 	if (!kq->ops.initialize(kq, dev, type, KFD_KERNEL_QUEUE_SIZE)) {
-		pr_err("amdkfd: failed to init kernel queue\n");
+		pr_err("Failed to init kernel queue\n");
 		kfree(kq);
 		return NULL;
 	}
@@ -327,7 +327,7 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 
 	BUG_ON(!dev);
 
-	pr_err("amdkfd: starting kernel queue test\n");
+	pr_err("Starting kernel queue test\n");
 
 	kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_HIQ);
 	BUG_ON(!kq);
@@ -338,7 +338,7 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 		buffer[i] = kq->nop_packet;
 	kq->ops.submit_packet(kq);
 
-	pr_err("amdkfd: ending kernel queue test\n");
+	pr_err("Ending kernel queue test\n");
 }
 
 
drivers/gpu/drm/amd/amdkfd/kfd_module.c +2 -2
index af5bfc1..819a442 100644
@@ -91,7 +91,7 @@ static int __init kfd_module_init(void)
 	/* Verify module parameters */
 	if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
 		(sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
-		pr_err("kfd: sched_policy has invalid value\n");
+		pr_err("sched_policy has invalid value\n");
 		return -1;
 	}
 
@@ -99,7 +99,7 @@ static int __init kfd_module_init(void)
 	if ((max_num_of_queues_per_device < 1) ||
 		(max_num_of_queues_per_device >
 			KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
-		pr_err("kfd: max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
+		pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
 		return -1;
 	}
 
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0 -10
index ac59229..27fd930 100644
@@ -46,8 +46,6 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
 
 	BUG_ON(!mm || !q || !mqd);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd),
 					mqd_mem_obj);
 
@@ -172,8 +170,6 @@ static int update_mqd(struct mqd_manager *mm, void *mqd,
 
 	BUG_ON(!mm || !q || !mqd);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	m = get_mqd(mqd);
 	m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE |
 				DEFAULT_MIN_AVAIL_SIZE | PQ_ATC_EN;
@@ -302,8 +298,6 @@ static int init_mqd_hiq(struct mqd_manager *mm, void **mqd,
 
 	BUG_ON(!mm || !q || !mqd || !mqd_mem_obj);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd),
 					mqd_mem_obj);
 
@@ -360,8 +354,6 @@ static int update_mqd_hiq(struct mqd_manager *mm, void *mqd,
 
 	BUG_ON(!mm || !q || !mqd);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	m = get_mqd(mqd);
 	m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE |
 				DEFAULT_MIN_AVAIL_SIZE |
@@ -414,8 +406,6 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
 	BUG_ON(!dev);
 	BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	mqd = kzalloc(sizeof(struct mqd_manager), GFP_KERNEL);
 	if (!mqd)
 		return NULL;
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +2 -6
index a9b9882..5dc30f5 100644
@@ -108,8 +108,6 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 
 	BUG_ON(!mm || !q || !mqd);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	m = get_mqd(mqd);
 
 	m->cp_hqd_pq_control = 5 << CP_HQD_PQ_CONTROL__RPTR_BLOCK_SIZE__SHIFT |
@@ -117,7 +115,7 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 			mtype << CP_HQD_PQ_CONTROL__MTYPE__SHIFT;
 	m->cp_hqd_pq_control |=
 			ffs(q->queue_size / sizeof(unsigned int)) - 1 - 1;
-	pr_debug("kfd: cp_hqd_pq_control 0x%x\n", m->cp_hqd_pq_control);
+	pr_debug("cp_hqd_pq_control 0x%x\n", m->cp_hqd_pq_control);
 
 	m->cp_hqd_pq_base_lo = lower_32_bits((uint64_t)q->queue_address >> 8);
 	m->cp_hqd_pq_base_hi = upper_32_bits((uint64_t)q->queue_address >> 8);
@@ -129,7 +127,7 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 		1 << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_EN__SHIFT |
 		q->doorbell_off <<
 			CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT;
-	pr_debug("kfd: cp_hqd_pq_doorbell_control 0x%x\n",
+	pr_debug("cp_hqd_pq_doorbell_control 0x%x\n",
 			m->cp_hqd_pq_doorbell_control);
 
 	m->cp_hqd_eop_control = atc_bit << CP_HQD_EOP_CONTROL__EOP_ATC__SHIFT |
@@ -241,8 +239,6 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
 	BUG_ON(!dev);
 	BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	mqd = kzalloc(sizeof(struct mqd_manager), GFP_KERNEL);
 	if (!mqd)
 		return NULL;
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +12 -22
index 99c11a4..31d7d46 100644
@@ -67,7 +67,7 @@ static void pm_calc_rlib_size(struct packet_manager *pm,
 	*over_subscription = false;
 	if ((process_count > 1) || queue_count > get_queues_num(pm->dqm)) {
 		*over_subscription = true;
-		pr_debug("kfd: over subscribed runlist\n");
+		pr_debug("Over subscribed runlist\n");
 	}
 
 	map_queue_size =
@@ -85,7 +85,7 @@ static void pm_calc_rlib_size(struct packet_manager *pm,
 	if (*over_subscription)
 		*rlib_size += sizeof(struct pm4_runlist);
 
-	pr_debug("kfd: runlist ib size %d\n", *rlib_size);
+	pr_debug("runlist ib size %d\n", *rlib_size);
 }
 
 static int pm_allocate_runlist_ib(struct packet_manager *pm,
@@ -106,7 +106,7 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm,
 					&pm->ib_buffer_obj);
 
 	if (retval != 0) {
-		pr_err("kfd: failed to allocate runlist IB\n");
+		pr_err("Failed to allocate runlist IB\n");
 		return retval;
 	}
 
@@ -152,8 +152,6 @@ static int pm_create_map_process(struct packet_manager *pm, uint32_t *buffer,
 
 	packet = (struct pm4_map_process *)buffer;
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	memset(buffer, 0, sizeof(struct pm4_map_process));
 
 	packet->header.u32all = build_pm4_header(IT_MAP_PROCESS,
@@ -189,8 +187,6 @@ static int pm_create_map_queue_vi(struct packet_manager *pm, uint32_t *buffer,
 
 	BUG_ON(!pm || !buffer || !q);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	packet = (struct pm4_mes_map_queues *)buffer;
 	memset(buffer, 0, sizeof(struct pm4_map_queues));
 
@@ -223,8 +219,7 @@ static int pm_create_map_queue_vi(struct packet_manager *pm, uint32_t *buffer,
 		use_static = false; /* no static queues under SDMA */
 		break;
 	default:
-		pr_err("kfd: in %s queue type %d\n", __func__,
-				q->properties.type);
+		pr_err("queue type %d\n", q->properties.type);
 		BUG();
 		break;
 	}
@@ -254,8 +249,6 @@ static int pm_create_map_queue(struct packet_manager *pm, uint32_t *buffer,
 
 	BUG_ON(!pm || !buffer || !q);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	packet = (struct pm4_map_queues *)buffer;
 	memset(buffer, 0, sizeof(struct pm4_map_queues));
 
@@ -333,8 +326,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 
 	*rl_size_bytes = alloc_size_bytes;
 
-	pr_debug("kfd: In func %s\n", __func__);
-	pr_debug("kfd: building runlist ib process count: %d queues count %d\n",
+	pr_debug("Building runlist ib process count: %d queues count %d\n",
 		pm->dqm->processes_count, pm->dqm->queue_count);
 
 	/* build the run list ib packet */
@@ -342,7 +334,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 		qpd = cur->qpd;
 		/* build map process packet */
 		if (proccesses_mapped >= pm->dqm->processes_count) {
-			pr_debug("kfd: not enough space left in runlist IB\n");
+			pr_debug("Not enough space left in runlist IB\n");
 			pm_release_ib(pm);
 			return -ENOMEM;
 		}
@@ -359,7 +351,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 			if (!kq->queue->properties.is_active)
 				continue;
 
-			pr_debug("kfd: static_queue, mapping kernel q %d, is debug status %d\n",
+			pr_debug("static_queue, mapping kernel q %d, is debug status %d\n",
 				kq->queue->queue, qpd->is_debug);
 
 			if (pm->dqm->dev->device_info->asic_family ==
@@ -385,7 +377,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 			if (!q->properties.is_active)
 				continue;
 
-			pr_debug("kfd: static_queue, mapping user queue %d, is debug status %d\n",
+			pr_debug("static_queue, mapping user queue %d, is debug status %d\n",
 				q->queue, qpd->is_debug);
 
 			if (pm->dqm->dev->device_info->asic_family ==
@@ -409,7 +401,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 		}
 	}
 
-	pr_debug("kfd: finished map process and queues to runlist\n");
+	pr_debug("Finished map process and queues to runlist\n");
 
 	if (is_over_subscription)
 		pm_create_runlist(pm, &rl_buffer[rl_wptr], *rl_gpu_addr,
@@ -453,15 +445,13 @@ int pm_send_set_resources(struct packet_manager *pm,
 
 	BUG_ON(!pm || !res);
 
-	pr_debug("kfd: In func %s\n", __func__);
-
 	mutex_lock(&pm->lock);
 	pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
 					sizeof(*packet) / sizeof(uint32_t),
 					(unsigned int **)&packet);
 	if (packet == NULL) {
 		mutex_unlock(&pm->lock);
-		pr_err("kfd: failed to allocate buffer on kernel queue\n");
+		pr_err("Failed to allocate buffer on kernel queue\n");
 		return -ENOMEM;
 	}
 
@@ -504,7 +494,7 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
 	if (retval != 0)
 		goto fail_create_runlist_ib;
 
-	pr_debug("kfd: runlist IB address: 0x%llX\n", rl_gpu_ib_addr);
+	pr_debug("runlist IB address: 0x%llX\n", rl_gpu_ib_addr);
 
 	packet_size_dwords = sizeof(struct pm4_runlist) / sizeof(uint32_t);
 	mutex_lock(&pm->lock);
@@ -595,7 +585,7 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
 
 	packet = (struct pm4_unmap_queues *)buffer;
 	memset(buffer, 0, sizeof(struct pm4_unmap_queues));
-	pr_debug("kfd: static_queue: unmapping queues: mode is %d , reset is %d , type is %d\n",
+	pr_debug("static_queue: unmapping queues: mode is %d , reset is %d , type is %d\n",
 		mode, reset, type);
 	packet->header.u32all = build_pm4_header(IT_UNMAP_QUEUES,
 					sizeof(struct pm4_unmap_queues));
drivers/gpu/drm/amd/amdkfd/kfd_process.c +2 -2
index a4e4a2d..86032bd 100644
@@ -101,7 +101,7 @@ struct kfd_process *kfd_create_process(const struct task_struct *thread)
 	/* A prior open of /dev/kfd could have already created the process. */
 	process = find_process(thread);
 	if (process)
-		pr_debug("kfd: process already found\n");
+		pr_debug("Process already found\n");
 
 	if (!process)
 		process = create_process(thread);
@@ -250,7 +250,7 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
 			kfd_dbgmgr_destroy(pdd->dev->dbgmgr);
 
 		if (pdd->reset_wavefronts) {
-			pr_warn("amdkfd: Resetting all wave fronts\n");
+			pr_warn("Resetting all wave fronts\n");
 			dbgdev_wave_reset_wavefronts(pdd->dev, p);
 			pdd->reset_wavefronts = false;
 		}
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +10 -17
index 32cdf2b..9482a5a 100644
@@ -51,15 +51,13 @@ static int find_available_queue_slot(struct process_queue_manager *pqm,
 
 	BUG_ON(!pqm || !qid);
 
-	pr_debug("kfd: in %s\n", __func__);
-
 	found = find_first_zero_bit(pqm->queue_slot_bitmap,
 			KFD_MAX_NUM_OF_QUEUES_PER_PROCESS);
 
-	pr_debug("kfd: the new slot id %lu\n", found);
+	pr_debug("The new slot id %lu\n", found);
 
 	if (found >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) {
-		pr_info("amdkfd: Can not open more queues for process with pasid %d\n",
+		pr_info("Cannot open more queues for process with pasid %d\n",
 				pqm->process->pasid);
 		return -ENOMEM;
 	}
@@ -92,8 +90,6 @@ void pqm_uninit(struct process_queue_manager *pqm)
 
 	BUG_ON(!pqm);
 
-	pr_debug("In func %s\n", __func__);
-
 	list_for_each_entry_safe(pqn, next, &pqm->queues, process_queue_list) {
 		retval = pqm_destroy_queue(
 				pqm,
@@ -102,7 +98,7 @@ void pqm_uninit(struct process_queue_manager *pqm)
 					pqn->kq->queue->properties.queue_id);
 
 		if (retval != 0) {
-			pr_err("kfd: failed to destroy queue\n");
+			pr_err("failed to destroy queue\n");
 			return;
 		}
 	}
@@ -136,7 +132,7 @@ static int create_cp_queue(struct process_queue_manager *pqm,
 	(*q)->device = dev;
 	(*q)->process = pqm->process;
 
-	pr_debug("kfd: PQM After init queue");
+	pr_debug("PQM After init queue");
 
 	return retval;
 
@@ -210,7 +206,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 		if ((sched_policy == KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION) &&
 		((dev->dqm->processes_count >= VMID_PER_DEVICE) ||
 		(dev->dqm->queue_count >= get_queues_num(dev->dqm)))) {
-			pr_err("kfd: over-subscription is not allowed in radeon_kfd.sched_policy == 1\n");
+			pr_err("Over-subscription is not allowed in radeon_kfd.sched_policy == 1\n");
 			retval = -EPERM;
 			goto err_create_queue;
 		}
@@ -243,17 +239,17 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 	}
 
 	if (retval != 0) {
-		pr_debug("Error dqm create queue\n");
+		pr_err("DQM create queue failed\n");
 		goto err_create_queue;
 	}
 
-	pr_debug("kfd: PQM After DQM create queue\n");
+	pr_debug("PQM After DQM create queue\n");
 
 	list_add(&pqn->process_queue_list, &pqm->queues);
 
 	if (q) {
 		*properties = q->properties;
-		pr_debug("kfd: PQM done creating queue\n");
+		pr_debug("PQM done creating queue\n");
 		print_queue_properties(properties);
 	}
 
@@ -282,11 +278,9 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
 	BUG_ON(!pqm);
 	retval = 0;
 
-	pr_debug("kfd: In Func %s\n", __func__);
-
 	pqn = get_queue_by_qid(pqm, qid);
 	if (pqn == NULL) {
-		pr_err("kfd: queue id does not match any known queue\n");
+		pr_err("Queue id does not match any known queue\n");
 		return -EINVAL;
 	}
 
@@ -339,8 +333,7 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
 
 	pqn = get_queue_by_qid(pqm, qid);
 	if (!pqn) {
-		pr_debug("amdkfd: No queue %d exists for update operation\n",
-				qid);
+		pr_debug("No queue %d exists for update operation\n", qid);
 		return -EFAULT;
 	}
 
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -3
index 0200dae..72d566a 100644
@@ -666,7 +666,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
 			dev->node_props.simd_count);
 
 	if (dev->mem_bank_count < dev->node_props.mem_banks_count) {
-		pr_info_once("kfd: mem_banks_count truncated from %d to %d\n",
+		pr_info_once("mem_banks_count truncated from %d to %d\n",
 				dev->node_props.mem_banks_count,
 				dev->mem_bank_count);
 		sysfs_show_32bit_prop(buffer, "mem_banks_count",
@@ -1147,7 +1147,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 
 	gpu_id = kfd_generate_gpu_id(gpu);
 
-	pr_debug("kfd: Adding new GPU (ID: 0x%x) to topology\n", gpu_id);
+	pr_debug("Adding new GPU (ID: 0x%x) to topology\n", gpu_id);
 
 	down_write(&topology_lock);
 	/*
@@ -1190,7 +1190,7 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 
 	if (dev->gpu->device_info->asic_family == CHIP_CARRIZO) {
 		dev->node_props.capability |= HSA_CAP_DOORBELL_PACKET_TYPE;
-		pr_info("amdkfd: adding doorbell packet type capability\n");
+		pr_info("Adding doorbell packet type capability\n");
 	}
 
 	res = 0;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#15 lore raw

PATCH 8/24 drm/amdkfd: Change x==NULL/false references to !x

In reply to a message not in the archive

From: Kent Russell <[email protected]>

Upstream prefers the !x notation to x==NULL or x==false. Along those lines change the ==true or !=NULL references as well. Also make the references to !x the same, excluding () for readability.

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 22 +++++-----
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            | 20 ++++-----
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 10 ++---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 50 +++++++++++-----------
 drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c          |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  6 +--
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c       |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      |  6 +--
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 26 +++++------
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  6 +--
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  6 +--
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  6 +--
 15 files changed, 85 insertions(+), 87 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +11 -11
index 6763972..44c6bfe 100644
@@ -265,7 +265,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
 
 	pr_debug("Looking for gpu id 0x%x\n", args->gpu_id);
 	dev = kfd_device_by_id(args->gpu_id);
-	if (dev == NULL) {
+	if (!dev) {
 		pr_debug("Could not find gpu id 0x%x\n", args->gpu_id);
 		return -EINVAL;
 	}
@@ -400,7 +400,7 @@ static int kfd_ioctl_set_memory_policy(struct file *filep,
 	}
 
 	dev = kfd_device_by_id(args->gpu_id);
-	if (dev == NULL)
+	if (!dev)
 		return -EINVAL;
 
 	mutex_lock(&p->mutex);
@@ -443,7 +443,7 @@ static int kfd_ioctl_dbg_register(struct file *filep,
 	long status = 0;
 
 	dev = kfd_device_by_id(args->gpu_id);
-	if (dev == NULL)
+	if (!dev)
 		return -EINVAL;
 
 	if (dev->device_info->asic_family == CHIP_CARRIZO) {
@@ -465,7 +465,7 @@ static int kfd_ioctl_dbg_register(struct file *filep,
 		return PTR_ERR(pdd);
 	}
 
-	if (dev->dbgmgr == NULL) {
+	if (!dev->dbgmgr) {
 		/* In case of a legal call, we have no dbgmgr yet */
 		create_ok = kfd_dbgmgr_create(&dbgmgr_ptr, dev);
 		if (create_ok) {
@@ -494,7 +494,7 @@ static int kfd_ioctl_dbg_unregister(struct file *filep,
 	long status;
 
 	dev = kfd_device_by_id(args->gpu_id);
-	if (dev == NULL)
+	if (!dev)
 		return -EINVAL;
 
 	if (dev->device_info->asic_family == CHIP_CARRIZO) {
@@ -505,7 +505,7 @@ static int kfd_ioctl_dbg_unregister(struct file *filep,
 	mutex_lock(kfd_get_dbgmgr_mutex());
 
 	status = kfd_dbgmgr_unregister(dev->dbgmgr, p);
-	if (status == 0) {
+	if (!status) {
 		kfd_dbgmgr_destroy(dev->dbgmgr);
 		dev->dbgmgr = NULL;
 	}
@@ -539,7 +539,7 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep,
 	memset((void *) &aw_info, 0, sizeof(struct dbg_address_watch_info));
 
 	dev = kfd_device_by_id(args->gpu_id);
-	if (dev == NULL)
+	if (!dev)
 		return -EINVAL;
 
 	if (dev->device_info->asic_family == CHIP_CARRIZO) {
@@ -646,7 +646,7 @@ static int kfd_ioctl_dbg_wave_control(struct file *filep,
 				sizeof(wac_info.trapId);
 
 	dev = kfd_device_by_id(args->gpu_id);
-	if (dev == NULL)
+	if (!dev)
 		return -EINVAL;
 
 	if (dev->device_info->asic_family == CHIP_CARRIZO) {
@@ -782,9 +782,9 @@ static int kfd_ioctl_get_process_apertures(struct file *filp,
 				"scratch_limit %llX\n", pdd->scratch_limit);
 
 			args->num_of_nodes++;
-		} while ((pdd = kfd_get_next_process_device_data(p, pdd)) !=
-				NULL &&
-				(args->num_of_nodes < NUM_OF_SUPPORTED_GPUS));
+
+			pdd = kfd_get_next_process_device_data(p, pdd);
+		} while (pdd && (args->num_of_nodes < NUM_OF_SUPPORTED_GPUS));
 	}
 
 	mutex_unlock(&p->mutex);
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +9 -11
index bf8ee19..0ef9136 100644
@@ -77,7 +77,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 	status = kq->ops.acquire_packet_buffer(kq,
 				pq_packets_size_in_bytes / sizeof(uint32_t),
 				&ib_packet_buff);
-	if (status != 0) {
+	if (status) {
 		pr_err("acquire_packet_buffer failed\n");
 		return status;
 	}
@@ -115,7 +115,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 	status = kfd_gtt_sa_allocate(dbgdev->dev, sizeof(uint64_t),
 					&mem_obj);
 
-	if (status != 0) {
+	if (status) {
 		pr_err("Failed to allocate GART memory\n");
 		kq->ops.rollback_packet(kq);
 		return status;
@@ -202,7 +202,7 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
 
 	kq = pqm_get_kernel_queue(dbgdev->pqm, qid);
 
-	if (kq == NULL) {
+	if (!kq) {
 		pr_err("Error getting DIQ\n");
 		pqm_destroy_queue(dbgdev->pqm, qid);
 		return -EFAULT;
@@ -252,7 +252,7 @@ static void dbgdev_address_watch_set_registers(
 	addrLo->u32All = 0;
 	cntl->u32All = 0;
 
-	if (adw_info->watch_mask != NULL)
+	if (adw_info->watch_mask)
 		cntl->bitfields.mask =
 			(uint32_t) (adw_info->watch_mask[index] &
 					ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK);
@@ -307,8 +307,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 		return -EINVAL;
 	}
 
-	if ((adw_info->watch_mode == NULL) ||
-		(adw_info->watch_address == NULL)) {
+	if (!adw_info->watch_mode || !adw_info->watch_address) {
 		pr_err("adw_info fields are not valid\n");
 		return -EINVAL;
 	}
@@ -375,15 +374,14 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 		return -EINVAL;
 	}
 
-	if ((NULL == adw_info->watch_mode) ||
-			(NULL == adw_info->watch_address)) {
+	if (!adw_info->watch_mode || !adw_info->watch_address) {
 		pr_err("adw_info fields are not valid\n");
 		return -EINVAL;
 	}
 
 	status = kfd_gtt_sa_allocate(dbgdev->dev, ib_size, &mem_obj);
 
-	if (status != 0) {
+	if (status) {
 		pr_err("Failed to allocate GART memory\n");
 		return status;
 	}
@@ -490,7 +488,7 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 					packet_buff_uint,
 					ib_size);
 
-		if (status != 0) {
+		if (status) {
 			pr_err("Failed to submit IB to DIQ\n");
 			break;
 		}
@@ -711,7 +709,7 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
 			packet_buff_uint,
 			ib_size);
 
-	if (status != 0)
+	if (status)
 		pr_err("Failed to submit IB to DIQ\n");
 
 	kfd_gtt_sa_free(dbgdev->dev, mem_obj);
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c +2 -2
index 7225789..210bdc1 100644
@@ -55,7 +55,7 @@ static void kfd_dbgmgr_uninitialize(struct kfd_dbgmgr *pmgr)
 
 void kfd_dbgmgr_destroy(struct kfd_dbgmgr *pmgr)
 {
-	if (pmgr != NULL) {
+	if (pmgr) {
 		kfd_dbgmgr_uninitialize(pmgr);
 		kfree(pmgr);
 	}
@@ -66,7 +66,7 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
 	enum DBGDEV_TYPE type = DBGDEV_TYPE_DIQ;
 	struct kfd_dbgmgr *new_buff;
 
-	BUG_ON(pdev == NULL);
+	BUG_ON(!pdev);
 	BUG_ON(!pdev->init_complete);
 
 	new_buff = kfd_alloc_struct(new_buff);
drivers/gpu/drm/amd/amdkfd/kfd_device.c +5 -5
index 87df8bf..d962342 100644
@@ -98,7 +98,7 @@ static const struct kfd_device_info *lookup_device_info(unsigned short did)
 
 	for (i = 0; i < ARRAY_SIZE(supported_devices); i++) {
 		if (supported_devices[i].did == did) {
-			BUG_ON(supported_devices[i].device_info == NULL);
+			BUG_ON(!supported_devices[i].device_info);
 			return supported_devices[i].device_info;
 		}
 	}
@@ -212,7 +212,7 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, int pasid,
 			flags);
 
 	dev = kfd_device_by_pci_dev(pdev);
-	BUG_ON(dev == NULL);
+	BUG_ON(!dev);
 
 	kfd_signal_iommu_event(dev, pasid, address,
 			flags & PPR_FAULT_WRITE, flags & PPR_FAULT_EXEC);
@@ -262,7 +262,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 
 	kfd_doorbell_init(kfd);
 
-	if (kfd_topology_add_device(kfd) != 0) {
+	if (kfd_topology_add_device(kfd)) {
 		dev_err(kfd_device, "Error adding device to topology\n");
 		goto kfd_topology_add_device_error;
 	}
@@ -288,7 +288,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 		goto device_queue_manager_error;
 	}
 
-	if (kfd->dqm->ops.start(kfd->dqm) != 0) {
+	if (kfd->dqm->ops.start(kfd->dqm)) {
 		dev_err(kfd_device,
 			"Error starting queue manager for device %x:%x\n",
 			kfd->pdev->vendor, kfd->pdev->device);
@@ -341,7 +341,7 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)
 
 void kgd2kfd_suspend(struct kfd_dev *kfd)
 {
-	BUG_ON(kfd == NULL);
+	BUG_ON(!kfd);
 
 	if (kfd->init_complete) {
 		kfd->dqm->ops.stop(kfd->dqm);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +25 -25

192 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c +1 -1
index ca21538..48018a3 100644
@@ -131,7 +131,7 @@ int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma)
 
 	/* Find kfd device according to gpu id */
 	dev = kfd_device_by_id(vma->vm_pgoff);
-	if (dev == NULL)
+	if (!dev)
 		return -EINVAL;
 
 	/* Calculate physical address of doorbell */
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -3
index abdaf95..5979158 100644
@@ -247,7 +247,7 @@ static u32 make_nonsignal_event_id(struct kfd_process *p)
 
 	for (id = p->next_nonsignal_event_id;
 		id < KFD_LAST_NONSIGNAL_EVENT_ID &&
-		lookup_event_by_id(p, id) != NULL;
+		lookup_event_by_id(p, id);
 		id++)
 		;
 
@@ -266,7 +266,7 @@ static u32 make_nonsignal_event_id(struct kfd_process *p)
 
 	for (id = KFD_FIRST_NONSIGNAL_EVENT_ID;
 		id < KFD_LAST_NONSIGNAL_EVENT_ID &&
-		lookup_event_by_id(p, id) != NULL;
+		lookup_event_by_id(p, id);
 		id++)
 		;
 
@@ -342,7 +342,7 @@ void kfd_event_init_process(struct kfd_process *p)
 
 static void destroy_event(struct kfd_process *p, struct kfd_event *ev)
 {
-	if (ev->signal_page != NULL) {
+	if (ev->signal_page) {
 		release_event_notification_slot(ev->signal_page,
 						ev->signal_slot_index);
 		p->signal_event_count--;
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +1 -1
index 2b65510..c59384b 100644
@@ -304,7 +304,7 @@ int kfd_init_apertures(struct kfd_process *process)
 		id < NUM_OF_SUPPORTED_GPUS) {
 
 		pdd = kfd_create_process_device_data(dev, process);
-		if (pdd == NULL) {
+		if (!pdd) {
 			pr_err("Failed to create process device data\n");
 			return -1;
 		}
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +3 -3
index f89d366..8844798 100644
@@ -67,12 +67,12 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 		break;
 	}
 
-	if (kq->mqd == NULL)
+	if (!kq->mqd)
 		return false;
 
 	prop.doorbell_ptr = kfd_get_kernel_doorbell(dev, &prop.doorbell_off);
 
-	if (prop.doorbell_ptr == NULL) {
+	if (!prop.doorbell_ptr) {
 		pr_err("Failed to initialize doorbell");
 		goto err_get_kernel_doorbell;
 	}
@@ -87,7 +87,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 	kq->pq_gpu_addr = kq->pq->gpu_addr;
 
 	retval = kq->ops_asic_specific.initialize(kq, dev, type, queue_size);
-	if (retval == false)
+	if (!retval)
 		goto err_eop_allocate_vidmem;
 
 	retval = kfd_gtt_sa_allocate(dev, sizeof(*kq->rptr_kernel),
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +2 -2
index 27fd930..9908227 100644
@@ -99,7 +99,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
 		m->cp_hqd_iq_rptr = AQL_ENABLE;
 
 	*mqd = m;
-	if (gart_addr != NULL)
+	if (gart_addr)
 		*gart_addr = addr;
 	retval = mm->update_mqd(mm, m, q);
 
@@ -127,7 +127,7 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd,
 	memset(m, 0, sizeof(struct cik_sdma_rlc_registers));
 
 	*mqd = m;
-	if (gart_addr != NULL)
+	if (gart_addr)
 		*gart_addr = (*mqd_mem_obj)->gpu_addr;
 
 	retval = mm->update_mqd(mm, m, q);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +1 -1
index 5dc30f5..5ba3b40 100644
@@ -85,7 +85,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
 		m->cp_hqd_iq_rptr = 1;
 
 	*mqd = m;
-	if (gart_addr != NULL)
+	if (gart_addr)
 		*gart_addr = addr;
 	retval = mm->update_mqd(mm, m, q);
 
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +13 -13
index 31d7d46..f3b8cc8 100644
@@ -98,14 +98,14 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm,
 
 	BUG_ON(!pm);
 	BUG_ON(pm->allocated);
-	BUG_ON(is_over_subscription == NULL);
+	BUG_ON(!is_over_subscription);
 
 	pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription);
 
 	retval = kfd_gtt_sa_allocate(pm->dqm->dev, *rl_buffer_size,
 					&pm->ib_buffer_obj);
 
-	if (retval != 0) {
+	if (retval) {
 		pr_err("Failed to allocate runlist IB\n");
 		return retval;
 	}
@@ -321,7 +321,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 
 	retval = pm_allocate_runlist_ib(pm, &rl_buffer, rl_gpu_addr,
 				&alloc_size_bytes, &is_over_subscription);
-	if (retval != 0)
+	if (retval)
 		return retval;
 
 	*rl_size_bytes = alloc_size_bytes;
@@ -340,7 +340,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 		}
 
 		retval = pm_create_map_process(pm, &rl_buffer[rl_wptr], qpd);
-		if (retval != 0)
+		if (retval)
 			return retval;
 
 		proccesses_mapped++;
@@ -365,7 +365,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 						&rl_buffer[rl_wptr],
 						kq->queue,
 						qpd->is_debug);
-			if (retval != 0)
+			if (retval)
 				return retval;
 
 			inc_wptr(&rl_wptr,
@@ -392,7 +392,7 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 						q,
 						qpd->is_debug);
 
-			if (retval != 0)
+			if (retval)
 				return retval;
 
 			inc_wptr(&rl_wptr,
@@ -421,7 +421,7 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm)
 	pm->dqm = dqm;
 	mutex_init(&pm->lock);
 	pm->priv_queue = kernel_queue_init(dqm->dev, KFD_QUEUE_TYPE_HIQ);
-	if (pm->priv_queue == NULL) {
+	if (!pm->priv_queue) {
 		mutex_destroy(&pm->lock);
 		return -ENOMEM;
 	}
@@ -449,7 +449,7 @@ int pm_send_set_resources(struct packet_manager *pm,
 	pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
 					sizeof(*packet) / sizeof(uint32_t),
 					(unsigned int **)&packet);
-	if (packet == NULL) {
+	if (!packet) {
 		mutex_unlock(&pm->lock);
 		pr_err("Failed to allocate buffer on kernel queue\n");
 		return -ENOMEM;
@@ -491,7 +491,7 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
 
 	retval = pm_create_runlist_ib(pm, dqm_queues, &rl_gpu_ib_addr,
 					&rl_ib_size);
-	if (retval != 0)
+	if (retval)
 		goto fail_create_runlist_ib;
 
 	pr_debug("runlist IB address: 0x%llX\n", rl_gpu_ib_addr);
@@ -501,12 +501,12 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
 
 	retval = pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
 					packet_size_dwords, &rl_buffer);
-	if (retval != 0)
+	if (retval)
 		goto fail_acquire_packet_buffer;
 
 	retval = pm_create_runlist(pm, rl_buffer, rl_gpu_ib_addr,
 					rl_ib_size / sizeof(uint32_t), false);
-	if (retval != 0)
+	if (retval)
 		goto fail_create_runlist;
 
 	pm->priv_queue->ops.submit_packet(pm->priv_queue);
@@ -537,7 +537,7 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
 			pm->priv_queue,
 			sizeof(struct pm4_query_status) / sizeof(uint32_t),
 			(unsigned int **)&packet);
-	if (retval != 0)
+	if (retval)
 		goto fail_acquire_packet_buffer;
 
 	packet->header.u32all = build_pm4_header(IT_QUERY_STATUS,
@@ -580,7 +580,7 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
 			pm->priv_queue,
 			sizeof(struct pm4_unmap_queues) / sizeof(uint32_t),
 			&buffer);
-	if (retval != 0)
+	if (retval)
 		goto err_acquire_packet_buffer;
 
 	packet = (struct pm4_unmap_queues *)buffer;
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -3
index 86032bd..d877cda 100644
@@ -81,7 +81,7 @@ struct kfd_process *kfd_create_process(const struct task_struct *thread)
 
 	BUG_ON(!kfd_process_wq);
 
-	if (thread->mm == NULL)
+	if (!thread->mm)
 		return ERR_PTR(-EINVAL);
 
 	/* Only the pthreads threading model is supported. */
@@ -117,7 +117,7 @@ struct kfd_process *kfd_get_process(const struct task_struct *thread)
 {
 	struct kfd_process *process;
 
-	if (thread->mm == NULL)
+	if (!thread->mm)
 		return ERR_PTR(-EINVAL);
 
 	/* Only the pthreads threading model is supported. */
@@ -407,7 +407,7 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
 	struct kfd_process *p;
 	struct kfd_process_device *pdd;
 
-	BUG_ON(dev == NULL);
+	BUG_ON(!dev);
 
 	/*
 	 * Look for the process that matches the pasid. If there is no such
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +3 -3
index 9482a5a..d4f8bae 100644
@@ -76,7 +76,7 @@ int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p)
 	pqm->queue_slot_bitmap =
 			kzalloc(DIV_ROUND_UP(KFD_MAX_NUM_OF_QUEUES_PER_PROCESS,
 					BITS_PER_BYTE), GFP_KERNEL);
-	if (pqm->queue_slot_bitmap == NULL)
+	if (!pqm->queue_slot_bitmap)
 		return -ENOMEM;
 	pqm->process = p;
 
@@ -223,7 +223,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 		break;
 	case KFD_QUEUE_TYPE_DIQ:
 		kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_DIQ);
-		if (kq == NULL) {
+		if (!kq) {
 			retval = -ENOMEM;
 			goto err_create_queue;
 		}
@@ -279,7 +279,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
 	retval = 0;
 
 	pqn = get_queue_by_qid(pqm, qid);
-	if (pqn == NULL) {
+	if (!pqn) {
 		pr_err("Queue id does not match any known queue\n");
 		return -EINVAL;
 	}
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -3
index 72d566a..113c1ce 100644
@@ -416,7 +416,7 @@ static struct kfd_topology_device *kfd_create_topology_device(void)
 	struct kfd_topology_device *dev;
 
 	dev = kfd_alloc_struct(dev);
-	if (dev == NULL) {
+	if (!dev) {
 		pr_err("No memory to allocate a topology device");
 		return NULL;
 	}
@@ -957,7 +957,7 @@ static int kfd_topology_update_sysfs(void)
 	int ret;
 
 	pr_info("Creating topology SYSFS entries\n");
-	if (sys_props.kobj_topology == NULL) {
+	if (!sys_props.kobj_topology) {
 		sys_props.kobj_topology =
 				kfd_alloc_struct(sys_props.kobj_topology);
 		if (!sys_props.kobj_topology)
@@ -1120,7 +1120,7 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
 	BUG_ON(!gpu);
 
 	list_for_each_entry(dev, &topology_device_list, list)
-		if (dev->gpu == NULL && dev->node_props.simd_count > 0) {
+		if (!dev->gpu && (dev->node_props.simd_count > 0)) {
 			dev->gpu = gpu;
 			out_dev = dev;
 			break;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#16 lore raw

PATCH 9/24 drm/amdkfd: Fix goto usage v2

In reply to a message not in the archive

From: Kent Russell <[email protected]>

Remove gotos that do not feature any common cleanup, and use gotos instead of repeating cleanup commands.

According to kernel.org: "The goto statement comes in handy when a function exits from multiple locations and some common work such as cleanup has to be done. If there is no cleanup needed then just return directly."

v2: Applied review suggestions in create_queue_nocpsch

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           |  15 +--
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 102 ++++++++++-----------
 drivers/gpu/drm/amd/amdkfd/kfd_module.c            |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    |  14 +--
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  14 +--
 5 files changed, 66 insertions(+), 82 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +8 -7
index 44c6bfe..65b506f1 100644
@@ -460,9 +460,8 @@ static int kfd_ioctl_dbg_register(struct file *filep,
 	 */
 	pdd = kfd_bind_process_to_device(dev, p);
 	if (IS_ERR(pdd)) {
-		mutex_unlock(&p->mutex);
-		mutex_unlock(kfd_get_dbgmgr_mutex());
-		return PTR_ERR(pdd);
+		status = PTR_ERR(pdd);
+		goto out;
 	}
 
 	if (!dev->dbgmgr) {
@@ -480,6 +479,7 @@ static int kfd_ioctl_dbg_register(struct file *filep,
 		status = -EINVAL;
 	}
 
+out:
 	mutex_unlock(&p->mutex);
 	mutex_unlock(kfd_get_dbgmgr_mutex());
 
@@ -580,8 +580,8 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep,
 	args_idx += sizeof(aw_info.watch_address) * aw_info.num_watch_points;
 
 	if (args_idx >= args->buf_size_in_bytes - sizeof(*args)) {
-		kfree(args_buff);
-		return -EINVAL;
+		status = -EINVAL;
+		goto out;
 	}
 
 	watch_mask_value = (uint64_t) args_buff[args_idx];
@@ -604,8 +604,8 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep,
 	}
 
 	if (args_idx >= args->buf_size_in_bytes - sizeof(args)) {
-		kfree(args_buff);
-		return -EINVAL;
+		status = -EINVAL;
+		goto out;
 	}
 
 	/* Currently HSA Event is not supported for DBG */
@@ -617,6 +617,7 @@ static int kfd_ioctl_dbg_address_watch(struct file *filep,
 
 	mutex_unlock(kfd_get_dbgmgr_mutex());
 
+out:
 	kfree(args_buff);
 
 	return status;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +48 -54

207 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_module.c +1 -2
index 819a442..0d73bea 100644
@@ -105,7 +105,7 @@ static int __init kfd_module_init(void)
 
 	err = kfd_pasid_init();
 	if (err < 0)
-		goto err_pasid;
+		return err;
 
 	err = kfd_chardev_init();
 	if (err < 0)
@@ -127,7 +127,6 @@ static int __init kfd_module_init(void)
 	kfd_chardev_exit();
 err_ioctl:
 	kfd_pasid_exit();
-err_pasid:
 	return err;
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +5 -9
index f3b8cc8..c4030b3 100644
@@ -442,6 +442,7 @@ int pm_send_set_resources(struct packet_manager *pm,
 				struct scheduling_resources *res)
 {
 	struct pm4_set_resources *packet;
+	int retval = 0;
 
 	BUG_ON(!pm || !res);
 
@@ -450,9 +451,9 @@ int pm_send_set_resources(struct packet_manager *pm,
 					sizeof(*packet) / sizeof(uint32_t),
 					(unsigned int **)&packet);
 	if (!packet) {
-		mutex_unlock(&pm->lock);
 		pr_err("Failed to allocate buffer on kernel queue\n");
-		return -ENOMEM;
+		retval = -ENOMEM;
+		goto out;
 	}
 
 	memset(packet, 0, sizeof(struct pm4_set_resources));
@@ -475,9 +476,10 @@ int pm_send_set_resources(struct packet_manager *pm,
 
 	pm->priv_queue->ops.submit_packet(pm->priv_queue);
 
+out:
 	mutex_unlock(&pm->lock);
 
-	return 0;
+	return retval;
 }
 
 int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
@@ -555,9 +557,6 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
 	packet->data_lo = lower_32_bits((uint64_t)fence_value);
 
 	pm->priv_queue->ops.submit_packet(pm->priv_queue);
-	mutex_unlock(&pm->lock);
-
-	return 0;
 
 fail_acquire_packet_buffer:
 	mutex_unlock(&pm->lock);
@@ -639,9 +638,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
 
 	pm->priv_queue->ops.submit_packet(pm->priv_queue);
 
-	mutex_unlock(&pm->lock);
-	return 0;
-
 err_acquire_packet_buffer:
 	mutex_unlock(&pm->lock);
 	return retval;
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +4 -10
index d4f8bae..8432f5f 100644
@@ -35,9 +35,8 @@ static inline struct process_queue_node *get_queue_by_qid(
 	BUG_ON(!pqm);
 
 	list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
-		if (pqn->q && pqn->q->properties.queue_id == qid)
-			return pqn;
-		if (pqn->kq && pqn->kq->queue->properties.queue_id == qid)
+		if ((pqn->q && pqn->q->properties.queue_id == qid) ||
+		    (pqn->kq && pqn->kq->queue->properties.queue_id == qid))
 			return pqn;
 	}
 
@@ -113,8 +112,6 @@ static int create_cp_queue(struct process_queue_manager *pqm,
 {
 	int retval;
 
-	retval = 0;
-
 	/* Doorbell initialized in user space*/
 	q_properties->doorbell_ptr = NULL;
 
@@ -127,7 +124,7 @@ static int create_cp_queue(struct process_queue_manager *pqm,
 
 	retval = init_queue(q, q_properties);
 	if (retval != 0)
-		goto err_init_queue;
+		return retval;
 
 	(*q)->device = dev;
 	(*q)->process = pqm->process;
@@ -135,9 +132,6 @@ static int create_cp_queue(struct process_queue_manager *pqm,
 	pr_debug("PQM After init queue");
 
 	return retval;
-
-err_init_queue:
-	return retval;
 }
 
 int pqm_create_queue(struct process_queue_manager *pqm,
@@ -181,7 +175,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 		list_for_each_entry(cur, &pdd->qpd.queues_list, list)
 			num_queues++;
 		if (num_queues >= dev->device_info->max_no_of_hqd/2)
-			return (-ENOSPC);
+			return -ENOSPC;
 	}
 
 	retval = find_available_queue_slot(pqm, qid);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#17 lore raw

PATCH 10/24 drm/amdkfd: Remove usage of alloc(sizeof(struct...

In reply to a message not in the archive

From: Kent Russell <[email protected]>

See https://kernel.org/doc/html/latest/process/coding-style.html
under "14) Allocating Memory" for rationale behind removing the x=alloc(sizeof(struct) style and using x=alloc(sizeof(*x) instead

---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  4 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c          |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c       |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c        |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c                 | 10 +++++-----
 6 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +2 -2
index 2e03379..22a47b9 100644
@@ -422,7 +422,7 @@ static int register_process_nocpsch(struct device_queue_manager *dqm,
 
 	BUG_ON(!dqm || !qpd);
 
-	n = kzalloc(sizeof(struct device_process_node), GFP_KERNEL);
+	n = kzalloc(sizeof(*n), GFP_KERNEL);
 	if (!n)
 		return -ENOMEM;
 
@@ -1135,7 +1135,7 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
 
 	pr_debug("Loading device queue manager\n");
 
-	dqm = kzalloc(sizeof(struct device_queue_manager), GFP_KERNEL);
+	dqm = kzalloc(sizeof(*dqm), GFP_KERNEL);
 	if (!dqm)
 		return NULL;
 
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +1 -1
index 8844798..47e2e8a 100644
@@ -283,7 +283,7 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
 
 	BUG_ON(!dev);
 
-	kq = kzalloc(sizeof(struct kernel_queue), GFP_KERNEL);
+	kq = kzalloc(sizeof(*kq), GFP_KERNEL);
 	if (!kq)
 		return NULL;
 
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +1 -1
index 9908227..dca4fc7 100644
@@ -406,7 +406,7 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
 	BUG_ON(!dev);
 	BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
-	mqd = kzalloc(sizeof(struct mqd_manager), GFP_KERNEL);
+	mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
 	if (!mqd)
 		return NULL;
 
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +1 -1
index 5ba3b40..aaaa87a 100644
@@ -239,7 +239,7 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
 	BUG_ON(!dev);
 	BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
-	mqd = kzalloc(sizeof(struct mqd_manager), GFP_KERNEL);
+	mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
 	if (!mqd)
 		return NULL;
 
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -1
index 8432f5f..1d056a6 100644
@@ -187,7 +187,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 		dev->dqm->ops.register_process(dev->dqm, &pdd->qpd);
 	}
 
-	pqn = kzalloc(sizeof(struct process_queue_node), GFP_KERNEL);
+	pqn = kzalloc(sizeof(*pqn), GFP_KERNEL);
 	if (!pqn) {
 		retval = -ENOMEM;
 		goto err_allocate_pqn;
drivers/gpu/drm/amd/amdkfd/kfd_queue.c +5 -5
index 0ab1970..5ad9f6f 100644
@@ -65,17 +65,17 @@ void print_queue(struct queue *q)
 
 int init_queue(struct queue **q, const struct queue_properties *properties)
 {
-	struct queue *tmp;
+	struct queue *tmp_q;
 
 	BUG_ON(!q);
 
-	tmp = kzalloc(sizeof(struct queue), GFP_KERNEL);
-	if (!tmp)
+	tmp_q = kzalloc(sizeof(*tmp_q), GFP_KERNEL);
+	if (!tmp_q)
 		return -ENOMEM;
 
-	memcpy(&tmp->properties, properties, sizeof(struct queue_properties));
+	memcpy(&tmp_q->properties, properties, sizeof(*properties));
 
-	*q = tmp;
+	*q = tmp_q;
 	return 0;
 }
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#18 lore raw

PATCH 11/24 drm/amdkfd: Remove BUG_ONs for NULL pointer arguments

In reply to a message not in the archive

Remove BUG_ONs that check for NULL pointer arguments that are dereferenced in the same function. Dereferencing the NULL pointer will generate a BUG anyway, so the explicit check is redundant and unnecessary overhead.

---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            | 26 +-----------
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            | 12 ------
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 10 -----
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 48 +---------------------
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |  2 -
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |  2 -
 drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c          |  4 --
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      | 16 --------
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   | 17 --------
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  4 --
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 28 +------------
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  2 -
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 15 -------
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c             |  2 -
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          | 28 -------------
 15 files changed, 4 insertions(+), 212 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +1 -25
index 0ef9136..3841cad 100644
@@ -42,8 +42,6 @@
 
 static void dbgdev_address_watch_disable_nodiq(struct kfd_dev *dev)
 {
-	BUG_ON(!dev || !dev->kfd2kgd);
-
 	dev->kfd2kgd->address_watch_disable(dev->kgd);
 }
 
@@ -62,7 +60,7 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 	unsigned int *ib_packet_buff;
 	int status;
 
-	BUG_ON(!dbgdev || !dbgdev->kq || !packet_buff || !size_in_bytes);
+	BUG_ON(!size_in_bytes);
 
 	kq = dbgdev->kq;
 
@@ -168,8 +166,6 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 
 static int dbgdev_register_nodiq(struct kfd_dbgdev *dbgdev)
 {
-	BUG_ON(!dbgdev);
-
 	/*
 	 * no action is needed in this case,
 	 * just make sure diq will not be used
@@ -187,8 +183,6 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
 	struct kernel_queue *kq = NULL;
 	int status;
 
-	BUG_ON(!dbgdev || !dbgdev->pqm || !dbgdev->dev);
-
 	status = pqm_create_queue(dbgdev->pqm, dbgdev->dev, NULL,
 				&properties, 0, KFD_QUEUE_TYPE_DIQ,
 				&qid);
@@ -215,8 +209,6 @@ static int dbgdev_register_diq(struct kfd_dbgdev *dbgdev)
 
 static int dbgdev_unregister_nodiq(struct kfd_dbgdev *dbgdev)
 {
-	BUG_ON(!dbgdev || !dbgdev->dev);
-
 	/* disable watch address */
 	dbgdev_address_watch_disable_nodiq(dbgdev->dev);
 	return 0;
@@ -227,8 +219,6 @@ static int dbgdev_unregister_diq(struct kfd_dbgdev *dbgdev)
 	/* todo - disable address watch */
 	int status;
 
-	BUG_ON(!dbgdev || !dbgdev->pqm || !dbgdev->kq);
-
 	status = pqm_destroy_queue(dbgdev->pqm,
 			dbgdev->kq->queue->properties.queue_id);
 	dbgdev->kq = NULL;
@@ -245,8 +235,6 @@ static void dbgdev_address_watch_set_registers(
 {
 	union ULARGE_INTEGER addr;
 
-	BUG_ON(!adw_info || !addrHi || !addrLo || !cntl);
-
 	addr.quad_part = 0;
 	addrHi->u32All = 0;
 	addrLo->u32All = 0;
@@ -287,8 +275,6 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 	struct kfd_process_device *pdd;
 	unsigned int i;
 
-	BUG_ON(!dbgdev || !dbgdev->dev || !adw_info);
-
 	/* taking the vmid for that process on the safe way using pdd */
 	pdd = kfd_get_process_device_data(dbgdev->dev,
 					adw_info->process);
@@ -362,8 +348,6 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 	/* we do not control the vmid in DIQ mode, just a place holder */
 	unsigned int vmid = 0;
 
-	BUG_ON(!dbgdev || !dbgdev->dev || !adw_info);
-
 	addrHi.u32All = 0;
 	addrLo.u32All = 0;
 	cntl.u32All = 0;
@@ -508,8 +492,6 @@ static int dbgdev_wave_control_set_registers(
 	union GRBM_GFX_INDEX_BITS reg_gfx_index;
 	struct HsaDbgWaveMsgAMDGen2 *pMsg;
 
-	BUG_ON(!wac_info || !in_reg_sq_cmd || !in_reg_gfx_index);
-
 	reg_sq_cmd.u32All = 0;
 	reg_gfx_index.u32All = 0;
 	pMsg = &wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2;
@@ -610,8 +592,6 @@ static int dbgdev_wave_control_diq(struct kfd_dbgdev *dbgdev,
 	struct pm4__set_config_reg *packets_vec;
 	size_t ib_size = sizeof(struct pm4__set_config_reg) * 3;
 
-	BUG_ON(!dbgdev || !wac_info);
-
 	reg_sq_cmd.u32All = 0;
 
 	status = dbgdev_wave_control_set_registers(wac_info, &reg_sq_cmd,
@@ -725,8 +705,6 @@ static int dbgdev_wave_control_nodiq(struct kfd_dbgdev *dbgdev,
 	union GRBM_GFX_INDEX_BITS reg_gfx_index;
 	struct kfd_process_device *pdd;
 
-	BUG_ON(!dbgdev || !dbgdev->dev || !wac_info);
-
 	reg_sq_cmd.u32All = 0;
 
 	/* taking the VMID for that process on the safe way using PDD */
@@ -851,8 +829,6 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p)
 void kfd_dbgdev_init(struct kfd_dbgdev *pdbgdev, struct kfd_dev *pdev,
 			enum DBGDEV_TYPE type)
 {
-	BUG_ON(!pdbgdev || !pdev);
-
 	pdbgdev->dev = pdev;
 	pdbgdev->kq = NULL;
 	pdbgdev->type = type;
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c +0 -12
index 210bdc1..2d5555c 100644
@@ -44,8 +44,6 @@ struct mutex *kfd_get_dbgmgr_mutex(void)
 
 static void kfd_dbgmgr_uninitialize(struct kfd_dbgmgr *pmgr)
 {
-	BUG_ON(!pmgr);
-
 	kfree(pmgr->dbgdev);
 
 	pmgr->dbgdev = NULL;
@@ -66,7 +64,6 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
 	enum DBGDEV_TYPE type = DBGDEV_TYPE_DIQ;
 	struct kfd_dbgmgr *new_buff;
 
-	BUG_ON(!pdev);
 	BUG_ON(!pdev->init_complete);
 
 	new_buff = kfd_alloc_struct(new_buff);
@@ -96,8 +93,6 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
 
 long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
 {
-	BUG_ON(!p || !pmgr || !pmgr->dbgdev);
-
 	if (pmgr->pasid != 0) {
 		pr_debug("H/W debugger is already active using pasid %d\n",
 				pmgr->pasid);
@@ -118,8 +113,6 @@ long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
 
 long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
 {
-	BUG_ON(!p || !pmgr || !pmgr->dbgdev);
-
 	/* Is the requests coming from the already registered process? */
 	if (pmgr->pasid != p->pasid) {
 		pr_debug("H/W debugger is not registered by calling pasid %d\n",
@@ -137,8 +130,6 @@ long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p)
 long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr,
 				struct dbg_wave_control_info *wac_info)
 {
-	BUG_ON(!pmgr || !pmgr->dbgdev || !wac_info);
-
 	/* Is the requests coming from the already registered process? */
 	if (pmgr->pasid != wac_info->process->pasid) {
 		pr_debug("H/W debugger support was not registered for requester pasid %d\n",
@@ -152,9 +143,6 @@ long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr,
 long kfd_dbgmgr_address_watch(struct kfd_dbgmgr *pmgr,
 				struct dbg_address_watch_info *adw_info)
 {
-	BUG_ON(!pmgr || !pmgr->dbgdev || !adw_info);
-
-
 	/* Is the requests coming from the already registered process? */
 	if (pmgr->pasid != adw_info->process->pasid) {
 		pr_debug("H/W debugger support was not registered for requester pasid %d\n",
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -10
index d962342..e28e818 100644
@@ -341,8 +341,6 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)
 
 void kgd2kfd_suspend(struct kfd_dev *kfd)
 {
-	BUG_ON(!kfd);
-
 	if (kfd->init_complete) {
 		kfd->dqm->ops.stop(kfd->dqm);
 		amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL);
@@ -356,8 +354,6 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
 	unsigned int pasid_limit;
 	int err;
 
-	BUG_ON(kfd == NULL);
-
 	pasid_limit = kfd_get_pasid_limit();
 
 	if (kfd->init_complete) {
@@ -394,8 +390,6 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
 {
 	unsigned int num_of_bits;
 
-	BUG_ON(!kfd);
-	BUG_ON(!kfd->gtt_mem);
 	BUG_ON(buf_size < chunk_size);
 	BUG_ON(buf_size == 0);
 	BUG_ON(chunk_size == 0);
@@ -445,8 +439,6 @@ int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
 {
 	unsigned int found, start_search, cur_size;
 
-	BUG_ON(!kfd);
-
 	if (size == 0)
 		return -EINVAL;
 
@@ -551,8 +543,6 @@ int kfd_gtt_sa_free(struct kfd_dev *kfd, struct kfd_mem_obj *mem_obj)
 {
 	unsigned int bit;
 
-	BUG_ON(!kfd);
-
 	/* Act like kfree when trying to free a NULL object */
 	if (!mem_obj)
 		return 0;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -47

203 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +0 -2
index a263e2a..43194b4 100644
@@ -104,8 +104,6 @@ static int register_process_cik(struct device_queue_manager *dqm,
 	struct kfd_process_device *pdd;
 	unsigned int temp;
 
-	BUG_ON(!dqm || !qpd);
-
 	pdd = qpd_to_pdd(qpd);
 
 	/* check if sh_mem_config register already configured */
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +0 -2
index 8c45c86..47ef910 100644
@@ -110,8 +110,6 @@ static int register_process_vi(struct device_queue_manager *dqm,
 	struct kfd_process_device *pdd;
 	unsigned int temp;
 
-	BUG_ON(!dqm || !qpd);
-
 	pdd = qpd_to_pdd(qpd);
 
 	/* check if sh_mem_config register already configured */
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c +0 -4
index 48018a3..0055270 100644
@@ -165,8 +165,6 @@ u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
 {
 	u32 inx;
 
-	BUG_ON(!kfd || !doorbell_off);
-
 	mutex_lock(&kfd->doorbell_mutex);
 	inx = find_first_zero_bit(kfd->doorbell_available_index,
 					KFD_MAX_NUM_OF_QUEUES_PER_PROCESS);
@@ -196,8 +194,6 @@ void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr)
 {
 	unsigned int inx;
 
-	BUG_ON(!kfd || !db_addr);
-
 	inx = (unsigned int)(db_addr - kfd->doorbell_kernel_ptr);
 
 	mutex_lock(&kfd->doorbell_mutex);
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +0 -16
index 47e2e8a..970bc07 100644
@@ -41,7 +41,6 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 	int retval;
 	union PM4_MES_TYPE_3_HEADER nop;
 
-	BUG_ON(!kq || !dev);
 	BUG_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ);
 
 	pr_debug("Initializing queue type %d size %d\n", KFD_QUEUE_TYPE_HIQ,
@@ -180,8 +179,6 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 
 static void uninitialize(struct kernel_queue *kq)
 {
-	BUG_ON(!kq);
-
 	if (kq->queue->properties.type == KFD_QUEUE_TYPE_HIQ)
 		kq->mqd->destroy_mqd(kq->mqd,
 					NULL,
@@ -211,8 +208,6 @@ static int acquire_packet_buffer(struct kernel_queue *kq,
 	uint32_t wptr, rptr;
 	unsigned int *queue_address;
 
-	BUG_ON(!kq || !buffer_ptr);
-
 	rptr = *kq->rptr_kernel;
 	wptr = *kq->wptr_kernel;
 	queue_address = (unsigned int *)kq->pq_kernel_addr;
@@ -252,11 +247,7 @@ static void submit_packet(struct kernel_queue *kq)
 {
 #ifdef DEBUG
 	int i;
-#endif
-
-	BUG_ON(!kq);
 
-#ifdef DEBUG
 	for (i = *kq->wptr_kernel; i < kq->pending_wptr; i++) {
 		pr_debug("0x%2X ", kq->pq_kernel_addr[i]);
 		if (i % 15 == 0)
@@ -272,7 +263,6 @@ static void submit_packet(struct kernel_queue *kq)
 
 static void rollback_packet(struct kernel_queue *kq)
 {
-	BUG_ON(!kq);
 	kq->pending_wptr = *kq->queue->properties.write_ptr;
 }
 
@@ -281,8 +271,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
 {
 	struct kernel_queue *kq;
 
-	BUG_ON(!dev);
-
 	kq = kzalloc(sizeof(*kq), GFP_KERNEL);
 	if (!kq)
 		return NULL;
@@ -313,8 +301,6 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
 
 void kernel_queue_uninit(struct kernel_queue *kq)
 {
-	BUG_ON(!kq);
-
 	kq->ops.uninitialize(kq);
 	kfree(kq);
 }
@@ -325,8 +311,6 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 	uint32_t *buffer, i;
 	int retval;
 
-	BUG_ON(!dev);
-
 	pr_err("Starting kernel queue test\n");
 
 	kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_HIQ);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0 -17
index dca4fc7..a11477d 100644
@@ -44,8 +44,6 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
 	struct cik_mqd *m;
 	int retval;
 
-	BUG_ON(!mm || !q || !mqd);
-
 	retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd),
 					mqd_mem_obj);
 
@@ -113,8 +111,6 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd,
 	int retval;
 	struct cik_sdma_rlc_registers *m;
 
-	BUG_ON(!mm || !mqd || !mqd_mem_obj);
-
 	retval = kfd_gtt_sa_allocate(mm->dev,
 					sizeof(struct cik_sdma_rlc_registers),
 					mqd_mem_obj);
@@ -138,14 +134,12 @@ static int init_mqd_sdma(struct mqd_manager *mm, void **mqd,
 static void uninit_mqd(struct mqd_manager *mm, void *mqd,
 			struct kfd_mem_obj *mqd_mem_obj)
 {
-	BUG_ON(!mm || !mqd);
 	kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
 }
 
 static void uninit_mqd_sdma(struct mqd_manager *mm, void *mqd,
 				struct kfd_mem_obj *mqd_mem_obj)
 {
-	BUG_ON(!mm || !mqd);
 	kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
 }
 
@@ -168,8 +162,6 @@ static int update_mqd(struct mqd_manager *mm, void *mqd,
 {
 	struct cik_mqd *m;
 
-	BUG_ON(!mm || !q || !mqd);
-
 	m = get_mqd(mqd);
 	m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE |
 				DEFAULT_MIN_AVAIL_SIZE | PQ_ATC_EN;
@@ -209,8 +201,6 @@ static int update_mqd_sdma(struct mqd_manager *mm, void *mqd,
 {
 	struct cik_sdma_rlc_registers *m;
 
-	BUG_ON(!mm || !mqd || !q);
-
 	m = get_sdma_mqd(mqd);
 	m->sdma_rlc_rb_cntl = ffs(q->queue_size / sizeof(unsigned int)) <<
 			SDMA0_RLC0_RB_CNTL__RB_SIZE__SHIFT |
@@ -296,8 +286,6 @@ static int init_mqd_hiq(struct mqd_manager *mm, void **mqd,
 	struct cik_mqd *m;
 	int retval;
 
-	BUG_ON(!mm || !q || !mqd || !mqd_mem_obj);
-
 	retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd),
 					mqd_mem_obj);
 
@@ -352,8 +340,6 @@ static int update_mqd_hiq(struct mqd_manager *mm, void *mqd,
 {
 	struct cik_mqd *m;
 
-	BUG_ON(!mm || !q || !mqd);
-
 	m = get_mqd(mqd);
 	m->cp_hqd_pq_control = DEFAULT_RPTR_BLOCK_SIZE |
 				DEFAULT_MIN_AVAIL_SIZE |
@@ -391,8 +377,6 @@ struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd)
 {
 	struct cik_sdma_rlc_registers *m;
 
-	BUG_ON(!mqd);
-
 	m = (struct cik_sdma_rlc_registers *)mqd;
 
 	return m;
@@ -403,7 +387,6 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
 {
 	struct mqd_manager *mqd;
 
-	BUG_ON(!dev);
 	BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
 	mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0 -4
index aaaa87a..d638c2c 100644
@@ -106,8 +106,6 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 {
 	struct vi_mqd *m;
 
-	BUG_ON(!mm || !q || !mqd);
-
 	m = get_mqd(mqd);
 
 	m->cp_hqd_pq_control = 5 << CP_HQD_PQ_CONTROL__RPTR_BLOCK_SIZE__SHIFT |
@@ -186,7 +184,6 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd,
 static void uninit_mqd(struct mqd_manager *mm, void *mqd,
 			struct kfd_mem_obj *mqd_mem_obj)
 {
-	BUG_ON(!mm || !mqd);
 	kfd_gtt_sa_free(mm->dev, mqd_mem_obj);
 }
 
@@ -236,7 +233,6 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
 {
 	struct mqd_manager *mqd;
 
-	BUG_ON(!dev);
 	BUG_ON(type >= KFD_MQD_TYPE_MAX);
 
 	mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +2 -26
index c4030b3..aacd5a3 100644
@@ -58,8 +58,6 @@ static void pm_calc_rlib_size(struct packet_manager *pm,
 	unsigned int process_count, queue_count;
 	unsigned int map_queue_size;
 
-	BUG_ON(!pm || !rlib_size || !over_subscription);
-
 	process_count = pm->dqm->processes_count;
 	queue_count = pm->dqm->queue_count;
 
@@ -96,9 +94,7 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm,
 {
 	int retval;
 
-	BUG_ON(!pm);
 	BUG_ON(pm->allocated);
-	BUG_ON(!is_over_subscription);
 
 	pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription);
 
@@ -123,7 +119,7 @@ static int pm_create_runlist(struct packet_manager *pm, uint32_t *buffer,
 {
 	struct pm4_runlist *packet;
 
-	BUG_ON(!pm || !buffer || !ib);
+	BUG_ON(!ib);
 
 	packet = (struct pm4_runlist *)buffer;
 
@@ -148,8 +144,6 @@ static int pm_create_map_process(struct packet_manager *pm, uint32_t *buffer,
 	struct queue *cur;
 	uint32_t num_queues;
 
-	BUG_ON(!pm || !buffer || !qpd);
-
 	packet = (struct pm4_map_process *)buffer;
 
 	memset(buffer, 0, sizeof(struct pm4_map_process));
@@ -185,8 +179,6 @@ static int pm_create_map_queue_vi(struct packet_manager *pm, uint32_t *buffer,
 	struct pm4_mes_map_queues *packet;
 	bool use_static = is_static;
 
-	BUG_ON(!pm || !buffer || !q);
-
 	packet = (struct pm4_mes_map_queues *)buffer;
 	memset(buffer, 0, sizeof(struct pm4_map_queues));
 
@@ -247,8 +239,6 @@ static int pm_create_map_queue(struct packet_manager *pm, uint32_t *buffer,
 	struct pm4_map_queues *packet;
 	bool use_static = is_static;
 
-	BUG_ON(!pm || !buffer || !q);
-
 	packet = (struct pm4_map_queues *)buffer;
 	memset(buffer, 0, sizeof(struct pm4_map_queues));
 
@@ -315,8 +305,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 	struct kernel_queue *kq;
 	bool is_over_subscription;
 
-	BUG_ON(!pm || !queues || !rl_size_bytes || !rl_gpu_addr);
-
 	rl_wptr = retval = proccesses_mapped = 0;
 
 	retval = pm_allocate_runlist_ib(pm, &rl_buffer, rl_gpu_addr,
@@ -416,8 +404,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
 
 int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm)
 {
-	BUG_ON(!dqm);
-
 	pm->dqm = dqm;
 	mutex_init(&pm->lock);
 	pm->priv_queue = kernel_queue_init(dqm->dev, KFD_QUEUE_TYPE_HIQ);
@@ -432,8 +418,6 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm)
 
 void pm_uninit(struct packet_manager *pm)
 {
-	BUG_ON(!pm);
-
 	mutex_destroy(&pm->lock);
 	kernel_queue_uninit(pm->priv_queue);
 }
@@ -444,8 +428,6 @@ int pm_send_set_resources(struct packet_manager *pm,
 	struct pm4_set_resources *packet;
 	int retval = 0;
 
-	BUG_ON(!pm || !res);
-
 	mutex_lock(&pm->lock);
 	pm->priv_queue->ops.acquire_packet_buffer(pm->priv_queue,
 					sizeof(*packet) / sizeof(uint32_t),
@@ -489,8 +471,6 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
 	size_t rl_ib_size, packet_size_dwords;
 	int retval;
 
-	BUG_ON(!pm || !dqm_queues);
-
 	retval = pm_create_runlist_ib(pm, dqm_queues, &rl_gpu_ib_addr,
 					&rl_ib_size);
 	if (retval)
@@ -532,7 +512,7 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
 	int retval;
 	struct pm4_query_status *packet;
 
-	BUG_ON(!pm || !fence_address);
+	BUG_ON(!fence_address);
 
 	mutex_lock(&pm->lock);
 	retval = pm->priv_queue->ops.acquire_packet_buffer(
@@ -572,8 +552,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
 	uint32_t *buffer;
 	struct pm4_unmap_queues *packet;
 
-	BUG_ON(!pm);
-
 	mutex_lock(&pm->lock);
 	retval = pm->priv_queue->ops.acquire_packet_buffer(
 			pm->priv_queue,
@@ -645,8 +623,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
 
 void pm_release_ib(struct packet_manager *pm)
 {
-	BUG_ON(!pm);
-
 	mutex_lock(&pm->lock);
 	if (pm->allocated) {
 		kfd_gtt_sa_free(pm->dqm->dev, pm->ib_buffer_obj);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -2
index d877cda..d030d76 100644
@@ -407,8 +407,6 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
 	struct kfd_process *p;
 	struct kfd_process_device *pdd;
 
-	BUG_ON(!dev);
-
 	/*
 	 * Look for the process that matches the pasid. If there is no such
 	 * process, we either released it in amdkfd's own notifier, or there
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +0 -15
index 1d056a6..f6ecdff 100644
@@ -32,8 +32,6 @@ static inline struct process_queue_node *get_queue_by_qid(
 {
 	struct process_queue_node *pqn;
 
-	BUG_ON(!pqm);
-
 	list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
 		if ((pqn->q && pqn->q->properties.queue_id == qid) ||
 		    (pqn->kq && pqn->kq->queue->properties.queue_id == qid))
@@ -48,8 +46,6 @@ static int find_available_queue_slot(struct process_queue_manager *pqm,
 {
 	unsigned long found;
 
-	BUG_ON(!pqm || !qid);
-
 	found = find_first_zero_bit(pqm->queue_slot_bitmap,
 			KFD_MAX_NUM_OF_QUEUES_PER_PROCESS);
 
@@ -69,8 +65,6 @@ static int find_available_queue_slot(struct process_queue_manager *pqm,
 
 int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p)
 {
-	BUG_ON(!pqm);
-
 	INIT_LIST_HEAD(&pqm->queues);
 	pqm->queue_slot_bitmap =
 			kzalloc(DIV_ROUND_UP(KFD_MAX_NUM_OF_QUEUES_PER_PROCESS,
@@ -87,8 +81,6 @@ void pqm_uninit(struct process_queue_manager *pqm)
 	int retval;
 	struct process_queue_node *pqn, *next;
 
-	BUG_ON(!pqm);
-
 	list_for_each_entry_safe(pqn, next, &pqm->queues, process_queue_list) {
 		retval = pqm_destroy_queue(
 				pqm,
@@ -151,8 +143,6 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 	int num_queues = 0;
 	struct queue *cur;
 
-	BUG_ON(!pqm || !dev || !properties || !qid);
-
 	memset(&q_properties, 0, sizeof(struct queue_properties));
 	memcpy(&q_properties, properties, sizeof(struct queue_properties));
 	q = NULL;
@@ -269,7 +259,6 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
 
 	dqm = NULL;
 
-	BUG_ON(!pqm);
 	retval = 0;
 
 	pqn = get_queue_by_qid(pqm, qid);
@@ -323,8 +312,6 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
 	int retval;
 	struct process_queue_node *pqn;
 
-	BUG_ON(!pqm);
-
 	pqn = get_queue_by_qid(pqm, qid);
 	if (!pqn) {
 		pr_debug("No queue %d exists for update operation\n", qid);
@@ -350,8 +337,6 @@ struct kernel_queue *pqm_get_kernel_queue(
 {
 	struct process_queue_node *pqn;
 
-	BUG_ON(!pqm);
-
 	pqn = get_queue_by_qid(pqm, qid);
 	if (pqn && pqn->kq)
 		return pqn->kq;
drivers/gpu/drm/amd/amdkfd/kfd_queue.c +0 -2
index 5ad9f6f..a5315d4 100644
@@ -67,8 +67,6 @@ int init_queue(struct queue **q, const struct queue_properties *properties)
 {
 	struct queue *tmp_q;
 
-	BUG_ON(!q);
-
 	tmp_q = kzalloc(sizeof(*tmp_q), GFP_KERNEL);
 	if (!tmp_q)
 		return -ENOMEM;
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0 -28
index 113c1ce..e5486f4 100644
@@ -108,9 +108,6 @@ static int kfd_topology_get_crat_acpi(void *crat_image, size_t *size)
 static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev,
 		struct crat_subtype_computeunit *cu)
 {
-	BUG_ON(!dev);
-	BUG_ON(!cu);
-
 	dev->node_props.cpu_cores_count = cu->num_cpu_cores;
 	dev->node_props.cpu_core_id_base = cu->processor_id_low;
 	if (cu->hsa_capability & CRAT_CU_FLAGS_IOMMU_PRESENT)
@@ -123,9 +120,6 @@ static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev,
 static void kfd_populated_cu_info_gpu(struct kfd_topology_device *dev,
 		struct crat_subtype_computeunit *cu)
 {
-	BUG_ON(!dev);
-	BUG_ON(!cu);
-
 	dev->node_props.simd_id_base = cu->processor_id_low;
 	dev->node_props.simd_count = cu->num_simd_cores;
 	dev->node_props.lds_size_in_kb = cu->lds_size_in_kb;
@@ -148,8 +142,6 @@ static int kfd_parse_subtype_cu(struct crat_subtype_computeunit *cu)
 	struct kfd_topology_device *dev;
 	int i = 0;
 
-	BUG_ON(!cu);
-
 	pr_info("Found CU entry in CRAT table with proximity_domain=%d caps=%x\n",
 			cu->proximity_domain, cu->hsa_capability);
 	list_for_each_entry(dev, &topology_device_list, list) {
@@ -177,8 +169,6 @@ static int kfd_parse_subtype_mem(struct crat_subtype_memory *mem)
 	struct kfd_topology_device *dev;
 	int i = 0;
 
-	BUG_ON(!mem);
-
 	pr_info("Found memory entry in CRAT table with proximity_domain=%d\n",
 			mem->promixity_domain);
 	list_for_each_entry(dev, &topology_device_list, list) {
@@ -223,8 +213,6 @@ static int kfd_parse_subtype_cache(struct crat_subtype_cache *cache)
 	struct kfd_topology_device *dev;
 	uint32_t id;
 
-	BUG_ON(!cache);
-
 	id = cache->processor_id_low;
 
 	pr_info("Found cache entry in CRAT table with processor_id=%d\n", id);
@@ -274,8 +262,6 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink)
 	uint32_t id_from;
 	uint32_t id_to;
 
-	BUG_ON(!iolink);
-
 	id_from = iolink->proximity_domain_from;
 	id_to = iolink->proximity_domain_to;
 
@@ -323,8 +309,6 @@ static int kfd_parse_subtype(struct crat_subtype_generic *sub_type_hdr)
 	struct crat_subtype_iolink *iolink;
 	int ret = 0;
 
-	BUG_ON(!sub_type_hdr);
-
 	switch (sub_type_hdr->type) {
 	case CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY:
 		cu = (struct crat_subtype_computeunit *)sub_type_hdr;
@@ -368,8 +352,6 @@ static void kfd_release_topology_device(struct kfd_topology_device *dev)
 	struct kfd_cache_properties *cache;
 	struct kfd_iolink_properties *iolink;
 
-	BUG_ON(!dev);
-
 	list_del(&dev->list);
 
 	while (dev->mem_props.next != &dev->mem_props) {
@@ -763,8 +745,6 @@ static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev)
 	struct kfd_cache_properties *cache;
 	struct kfd_mem_properties *mem;
 
-	BUG_ON(!dev);
-
 	if (dev->kobj_iolink) {
 		list_for_each_entry(iolink, &dev->io_link_props, list)
 			if (iolink->kobj) {
@@ -819,8 +799,6 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
 	int ret;
 	uint32_t i;
 
-	BUG_ON(!dev);
-
 	/*
 	 * Creating the sysfs folders
 	 */
@@ -1117,8 +1095,6 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
 	struct kfd_topology_device *dev;
 	struct kfd_topology_device *out_dev = NULL;
 
-	BUG_ON(!gpu);
-
 	list_for_each_entry(dev, &topology_device_list, list)
 		if (!dev->gpu && (dev->node_props.simd_count > 0)) {
 			dev->gpu = gpu;
@@ -1143,8 +1119,6 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 	struct kfd_topology_device *dev;
 	int res;
 
-	BUG_ON(!gpu);
-
 	gpu_id = kfd_generate_gpu_id(gpu);
 
 	pr_debug("Adding new GPU (ID: 0x%x) to topology\n", gpu_id);
@@ -1210,8 +1184,6 @@ int kfd_topology_remove_device(struct kfd_dev *gpu)
 	uint32_t gpu_id;
 	int res = -ENODEV;
 
-	BUG_ON(!gpu);
-
 	down_write(&topology_lock);
 
 	list_for_each_entry(dev, &topology_device_list, list)
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#19 lore raw

PATCH 12/24 drm/amdkfd: Fix doorbell initialization and finalization

In reply to a message not in the archive

Handle errors in doorbell aperture initialization instead of BUG_ON. iounmap doorbell aperture during finalization.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c   |  9 ++++++++-
 drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c | 13 +++++++++++--
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h     |  3 ++-
 3 files changed, 21 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +8 -1
index e28e818..cb7ed02 100644
@@ -260,7 +260,11 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 		goto kfd_gtt_sa_init_error;
 	}
 
-	kfd_doorbell_init(kfd);
+	if (kfd_doorbell_init(kfd)) {
+		dev_err(kfd_device,
+			"Error initializing doorbell aperture\n");
+		goto kfd_doorbell_error;
+	}
 
 	if (kfd_topology_add_device(kfd)) {
 		dev_err(kfd_device, "Error adding device to topology\n");
@@ -315,6 +319,8 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 kfd_interrupt_error:
 	kfd_topology_remove_device(kfd);
 kfd_topology_add_device_error:
+	kfd_doorbell_fini(kfd);
+kfd_doorbell_error:
 	kfd_gtt_sa_fini(kfd);
 kfd_gtt_sa_init_error:
 	kfd->kfd2kgd->free_gtt_mem(kfd->kgd, kfd->gtt_mem);
@@ -332,6 +338,7 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)
 		amd_iommu_free_device(kfd->pdev);
 		kfd_interrupt_exit(kfd);
 		kfd_topology_remove_device(kfd);
+		kfd_doorbell_fini(kfd);
 		kfd_gtt_sa_fini(kfd);
 		kfd->kfd2kgd->free_gtt_mem(kfd->kgd, kfd->gtt_mem);
 	}
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c +11 -2
index 0055270..acf4d2a 100644
@@ -59,7 +59,7 @@ static inline size_t doorbell_process_allocation(void)
 }
 
 /* Doorbell calculations for device init. */
-void kfd_doorbell_init(struct kfd_dev *kfd)
+int kfd_doorbell_init(struct kfd_dev *kfd)
 {
 	size_t doorbell_start_offset;
 	size_t doorbell_aperture_size;
@@ -95,7 +95,8 @@ void kfd_doorbell_init(struct kfd_dev *kfd)
 	kfd->doorbell_kernel_ptr = ioremap(kfd->doorbell_base,
 						doorbell_process_allocation());
 
-	BUG_ON(!kfd->doorbell_kernel_ptr);
+	if (!kfd->doorbell_kernel_ptr)
+		return -ENOMEM;
 
 	pr_debug("Doorbell initialization:\n");
 	pr_debug("doorbell base           == 0x%08lX\n",
@@ -115,6 +116,14 @@ void kfd_doorbell_init(struct kfd_dev *kfd)
 
 	pr_debug("doorbell kernel address == 0x%08lX\n",
 			(uintptr_t)kfd->doorbell_kernel_ptr);
+
+	return 0;
+}
+
+void kfd_doorbell_fini(struct kfd_dev *kfd)
+{
+	if (kfd->doorbell_kernel_ptr)
+		iounmap(kfd->doorbell_kernel_ptr);
 }
 
 int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -1
index 469b7ea..f0d55cc0 100644
@@ -576,7 +576,8 @@ unsigned int kfd_pasid_alloc(void);
 void kfd_pasid_free(unsigned int pasid);
 
 /* Doorbells */
-void kfd_doorbell_init(struct kfd_dev *kfd);
+int kfd_doorbell_init(struct kfd_dev *kfd);
+void kfd_doorbell_fini(struct kfd_dev *kfd);
 int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma);
 u32 __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
 					unsigned int *doorbell_off);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#20 lore raw

PATCH 13/24 drm/amdkfd: Allocate gtt_sa_bitmap in long units

In reply to a message not in the archive

gtt_sa_bitmap is accessed by bitmap functions, which operate on longs. Therefore the array should be allocated in long units. Also round up in case the number of bits is not a multiple of BITS_PER_LONG.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +4 -4
index cb7ed02..416955f 100644
@@ -395,7 +395,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry)
 static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
 				unsigned int chunk_size)
 {
-	unsigned int num_of_bits;
+	unsigned int num_of_longs;
 
 	BUG_ON(buf_size < chunk_size);
 	BUG_ON(buf_size == 0);
@@ -404,10 +404,10 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
 	kfd->gtt_sa_chunk_size = chunk_size;
 	kfd->gtt_sa_num_of_chunks = buf_size / chunk_size;
 
-	num_of_bits = kfd->gtt_sa_num_of_chunks / BITS_PER_BYTE;
-	BUG_ON(num_of_bits == 0);
+	num_of_longs = (kfd->gtt_sa_num_of_chunks + BITS_PER_LONG - 1) /
+		BITS_PER_LONG;
 
-	kfd->gtt_sa_bitmap = kzalloc(num_of_bits, GFP_KERNEL);
+	kfd->gtt_sa_bitmap = kcalloc(num_of_longs, sizeof(long), GFP_KERNEL);
 
 	if (!kfd->gtt_sa_bitmap)
 		return -ENOMEM;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#21 lore raw

PATCH 14/24 drm/amdkfd: Handle remaining BUG_ONs more gracefully v2

In reply to a message not in the archive

In most cases, BUG_ONs can be replaced with WARN_ON with an error return. In some void functions just turn them into a WARN_ON and possibly an early exit.

v2:
* Cleaned up error handling in pm_send_unmap_queue
* Removed redundant WARN_ON in kfd_process_destroy_delayed

---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 16 ++++----
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 19 +++++-----
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |  2 +-
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      | 20 +++++++---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 44 ++++++++++++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  9 ++---
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  7 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  4 +-
 14 files changed, 84 insertions(+), 55 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +2 -1
index 3841cad..0aa021a 100644
@@ -60,7 +60,8 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
 	unsigned int *ib_packet_buff;
 	int status;
 
-	BUG_ON(!size_in_bytes);
+	if (WARN_ON(!size_in_bytes))
+		return -EINVAL;
 
 	kq = dbgdev->kq;
 
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c +2 -1
index 2d5555c..3da25f7 100644
@@ -64,7 +64,8 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
 	enum DBGDEV_TYPE type = DBGDEV_TYPE_DIQ;
 	struct kfd_dbgmgr *new_buff;
 
-	BUG_ON(!pdev->init_complete);
+	if (WARN_ON(!pdev->init_complete))
+		return false;
 
 	new_buff = kfd_alloc_struct(new_buff);
 	if (!new_buff) {
drivers/gpu/drm/amd/amdkfd/kfd_device.c +9 -7
index 416955f..f628ac3 100644
@@ -98,7 +98,7 @@ static const struct kfd_device_info *lookup_device_info(unsigned short did)
 
 	for (i = 0; i < ARRAY_SIZE(supported_devices); i++) {
 		if (supported_devices[i].did == did) {
-			BUG_ON(!supported_devices[i].device_info);
+			WARN_ON(!supported_devices[i].device_info);
 			return supported_devices[i].device_info;
 		}
 	}
@@ -212,9 +212,8 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, int pasid,
 			flags);
 
 	dev = kfd_device_by_pci_dev(pdev);
-	BUG_ON(!dev);
-
-	kfd_signal_iommu_event(dev, pasid, address,
+	if (!WARN_ON(!dev))
+		kfd_signal_iommu_event(dev, pasid, address,
 			flags & PPR_FAULT_WRITE, flags & PPR_FAULT_EXEC);
 
 	return AMD_IOMMU_INV_PRI_RSP_INVALID;
@@ -397,9 +396,12 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
 {
 	unsigned int num_of_longs;
 
-	BUG_ON(buf_size < chunk_size);
-	BUG_ON(buf_size == 0);
-	BUG_ON(chunk_size == 0);
+	if (WARN_ON(buf_size < chunk_size))
+		return -EINVAL;
+	if (WARN_ON(buf_size == 0))
+		return -EINVAL;
+	if (WARN_ON(chunk_size == 0))
+		return -EINVAL;
 
 	kfd->gtt_sa_chunk_size = chunk_size;
 	kfd->gtt_sa_num_of_chunks = buf_size / chunk_size;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +10 -9
index 2486dfb..e553c5e 100644
@@ -388,7 +388,8 @@ static struct mqd_manager *get_mqd_manager_nocpsch(
 {
 	struct mqd_manager *mqd;
 
-	BUG_ON(type >= KFD_MQD_TYPE_MAX);
+	if (WARN_ON(type >= KFD_MQD_TYPE_MAX))
+		return NULL;
 
 	pr_debug("mqd type %d\n", type);
 
@@ -513,7 +514,7 @@ static void uninitialize_nocpsch(struct device_queue_manager *dqm)
 {
 	int i;
 
-	BUG_ON(dqm->queue_count > 0 || dqm->processes_count > 0);
+	WARN_ON(dqm->queue_count > 0 || dqm->processes_count > 0);
 
 	kfree(dqm->allocated_queues);
 	for (i = 0 ; i < KFD_MQD_TYPE_MAX ; i++)
@@ -1129,8 +1130,8 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
 		dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
 		break;
 	default:
-		BUG();
-		break;
+		pr_err("Invalid scheduling policy %d\n", sched_policy);
+		goto out_free;
 	}
 
 	switch (dev->device_info->asic_family) {
@@ -1143,12 +1144,12 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
 		break;
 	}
 
-	if (dqm->ops.initialize(dqm)) {
-		kfree(dqm);
-		return NULL;
-	}
+	if (!dqm->ops.initialize(dqm))
+		return dqm;
 
-	return dqm;
+out_free:
+	kfree(dqm);
+	return NULL;
 }
 
 void device_queue_manager_uninit(struct device_queue_manager *dqm)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +1 -1
index 43194b4..fadc56a 100644
@@ -65,7 +65,7 @@ static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
 	 * for LDS/Scratch and GPUVM.
 	 */
 
-	BUG_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
+	WARN_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
 		top_address_nybble == 0);
 
 	return PRIVATE_BASE(top_address_nybble << 12) |
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +1 -1
index 47ef910..15e81ae 100644
@@ -67,7 +67,7 @@ static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
 	 * for LDS/Scratch and GPUVM.
 	 */
 
-	BUG_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
+	WARN_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
 		top_address_nybble == 0);
 
 	return top_address_nybble << 12 |
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +15 -5
index 970bc07..0e4d4a9 100644
@@ -41,7 +41,8 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 	int retval;
 	union PM4_MES_TYPE_3_HEADER nop;
 
-	BUG_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ);
+	if (WARN_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ))
+		return false;
 
 	pr_debug("Initializing queue type %d size %d\n", KFD_QUEUE_TYPE_HIQ,
 			queue_size);
@@ -62,8 +63,8 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 						KFD_MQD_TYPE_HIQ);
 		break;
 	default:
-		BUG();
-		break;
+		pr_err("Invalid queue type %d\n", type);
+		return false;
 	}
 
 	if (!kq->mqd)
@@ -305,6 +306,7 @@ void kernel_queue_uninit(struct kernel_queue *kq)
 	kfree(kq);
 }
 
+/* FIXME: Can this test be removed? */
 static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 {
 	struct kernel_queue *kq;
@@ -314,10 +316,18 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 	pr_err("Starting kernel queue test\n");
 
 	kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_HIQ);
-	BUG_ON(!kq);
+	if (unlikely(!kq)) {
+		pr_err("  Failed to initialize HIQ\n");
+		pr_err("Kernel queue test failed\n");
+		return;
+	}
 
 	retval = kq->ops.acquire_packet_buffer(kq, 5, &buffer);
-	BUG_ON(retval != 0);
+	if (unlikely(retval != 0)) {
+		pr_err("  Failed to acquire packet buffer\n");
+		pr_err("Kernel queue test failed\n");
+		return;
+	}
 	for (i = 0; i < 5; i++)
 		buffer[i] = kq->nop_packet;
 	kq->ops.submit_packet(kq);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +2 -1
index a11477d..7e0ec6b 100644
@@ -387,7 +387,8 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
 {
 	struct mqd_manager *mqd;
 
-	BUG_ON(type >= KFD_MQD_TYPE_MAX);
+	if (WARN_ON(type >= KFD_MQD_TYPE_MAX))
+		return NULL;
 
 	mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
 	if (!mqd)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +2 -1
index d638c2c..f4c8c23 100644
@@ -233,7 +233,8 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
 {
 	struct mqd_manager *mqd;
 
-	BUG_ON(type >= KFD_MQD_TYPE_MAX);
+	if (WARN_ON(type >= KFD_MQD_TYPE_MAX))
+		return NULL;
 
 	mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
 	if (!mqd)
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +28 -16

107 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_pasid.c +2 -2
index b3f7d43..1e06de0 100644
@@ -92,6 +92,6 @@ unsigned int kfd_pasid_alloc(void)
 
 void kfd_pasid_free(unsigned int pasid)
 {
-	BUG_ON(pasid == 0 || pasid >= pasid_limit);
-	clear_bit(pasid, pasid_bitmap);
+	if (!WARN_ON(pasid == 0 || pasid >= pasid_limit))
+		clear_bit(pasid, pasid_bitmap);
 }
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -6
index d030d76..c74cf22 100644
@@ -79,8 +79,6 @@ struct kfd_process *kfd_create_process(const struct task_struct *thread)
 {
 	struct kfd_process *process;
 
-	BUG_ON(!kfd_process_wq);
-
 	if (!thread->mm)
 		return ERR_PTR(-EINVAL);
 
@@ -202,10 +200,8 @@ static void kfd_process_destroy_delayed(struct rcu_head *rcu)
 	struct kfd_process_release_work *work;
 	struct kfd_process *p;
 
-	BUG_ON(!kfd_process_wq);
-
 	p = container_of(rcu, struct kfd_process, rcu);
-	BUG_ON(atomic_read(&p->mm->mm_count) <= 0);
+	WARN_ON(atomic_read(&p->mm->mm_count) <= 0);
 
 	mmdrop(p->mm);
 
@@ -229,7 +225,8 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
 	 * mmu_notifier srcu is read locked
 	 */
 	p = container_of(mn, struct kfd_process, mmu_notifier);
-	BUG_ON(p->mm != mm);
+	if (WARN_ON(p->mm != mm))
+		return;
 
 	mutex_lock(&kfd_processes_mutex);
 	hash_del_rcu(&p->kfd_processes);
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +4 -3
index f6ecdff..1cae95e 100644
@@ -218,8 +218,8 @@ int pqm_create_queue(struct process_queue_manager *pqm,
 							kq, &pdd->qpd);
 		break;
 	default:
-		BUG();
-		break;
+		WARN(1, "Invalid queue type %d", type);
+		retval = -EINVAL;
 	}
 
 	if (retval != 0) {
@@ -272,7 +272,8 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
 		dev = pqn->kq->dev;
 	if (pqn->q)
 		dev = pqn->q->device;
-	BUG_ON(!dev);
+	if (WARN_ON(!dev))
+		return -ENODEV;
 
 	pdd = kfd_get_process_device_data(dev, pqm->process);
 	if (!pdd) {
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -1
index e5486f4..19ce590 100644
@@ -799,10 +799,12 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
 	int ret;
 	uint32_t i;
 
+	if (WARN_ON(dev->kobj_node))
+		return -EEXIST;
+
 	/*
 	 * Creating the sysfs folders
 	 */
-	BUG_ON(dev->kobj_node);
 	dev->kobj_node = kfd_alloc_struct(dev->kobj_node);
 	if (!dev->kobj_node)
 		return -ENOMEM;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-15-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#23 lore raw

Re: [PATCH 14/24] drm/amdkfd: Handle remaining BUG_ONs more gracefully v2

Quoted 467 lines · Felix Kuehling

In most cases, BUG_ONs can be replaced with WARN_ON with an error return. In some void functions just turn them into a WARN_ON and possibly an early exit.

v2:
* Cleaned up error handling in pm_send_unmap_queue
* Removed redundant WARN_ON in kfd_process_destroy_delayed

---
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 16 ++++----
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 19 +++++-----
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |  2 +-
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      | 20 +++++++---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 44 ++++++++++++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |  4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  9 ++---
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  7 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  4 +-
 14 files changed, 84 insertions(+), 55 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c +2 -1
index 3841cad..0aa021a 100644
@@ -60,7 +60,8 @@ static int dbgdev_diq_submit_ib(struct kfd_dbgdev *dbgdev,
        unsigned int *ib_packet_buff;
        int status;
 
-       BUG_ON(!size_in_bytes);
+       if (WARN_ON(!size_in_bytes))
+               return -EINVAL;
 
        kq = dbgdev->kq;
 
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c +2 -1
index 2d5555c..3da25f7 100644
@@ -64,7 +64,8 @@ bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev)
        enum DBGDEV_TYPE type = DBGDEV_TYPE_DIQ;
        struct kfd_dbgmgr *new_buff;
 
-       BUG_ON(!pdev->init_complete);
+       if (WARN_ON(!pdev->init_complete))
+               return false;
 
        new_buff = kfd_alloc_struct(new_buff);
        if (!new_buff) {
drivers/gpu/drm/amd/amdkfd/kfd_device.c +9 -7
index 416955f..f628ac3 100644
@@ -98,7 +98,7 @@ static const struct kfd_device_info *lookup_device_info(unsigned short did)
 
        for (i = 0; i < ARRAY_SIZE(supported_devices); i++) {
                if (supported_devices[i].did == did) {
-                       BUG_ON(!supported_devices[i].device_info);
+                       WARN_ON(!supported_devices[i].device_info);
                        return supported_devices[i].device_info;
                }
        }
@@ -212,9 +212,8 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, int pasid,
                        flags);
 
        dev = kfd_device_by_pci_dev(pdev);
-       BUG_ON(!dev);
-
-       kfd_signal_iommu_event(dev, pasid, address,
+       if (!WARN_ON(!dev))
+               kfd_signal_iommu_event(dev, pasid, address,
                        flags & PPR_FAULT_WRITE, flags & PPR_FAULT_EXEC);
 
        return AMD_IOMMU_INV_PRI_RSP_INVALID;
@@ -397,9 +396,12 @@ static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size,
 {
        unsigned int num_of_longs;
 
-       BUG_ON(buf_size < chunk_size);
-       BUG_ON(buf_size == 0);
-       BUG_ON(chunk_size == 0);
+       if (WARN_ON(buf_size < chunk_size))
+               return -EINVAL;
+       if (WARN_ON(buf_size == 0))
+               return -EINVAL;
+       if (WARN_ON(chunk_size == 0))
+               return -EINVAL;
 
        kfd->gtt_sa_chunk_size = chunk_size;
        kfd->gtt_sa_num_of_chunks = buf_size / chunk_size;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +10 -9
index 2486dfb..e553c5e 100644
@@ -388,7 +388,8 @@ static struct mqd_manager *get_mqd_manager_nocpsch(
 {
        struct mqd_manager *mqd;
 
-       BUG_ON(type >= KFD_MQD_TYPE_MAX);
+       if (WARN_ON(type >= KFD_MQD_TYPE_MAX))
+               return NULL;
 
        pr_debug("mqd type %d\n", type);
 
@@ -513,7 +514,7 @@ static void uninitialize_nocpsch(struct device_queue_manager *dqm)
 {
        int i;
 
-       BUG_ON(dqm->queue_count > 0 || dqm->processes_count > 0);
+       WARN_ON(dqm->queue_count > 0 || dqm->processes_count > 0);
 
        kfree(dqm->allocated_queues);
        for (i = 0 ; i < KFD_MQD_TYPE_MAX ; i++)
@@ -1129,8 +1130,8 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
                dqm->ops.set_cache_memory_policy = set_cache_memory_policy;
                break;
        default:
-               BUG();
-               break;
+               pr_err("Invalid scheduling policy %d\n", sched_policy);
+               goto out_free;
        }
 
        switch (dev->device_info->asic_family) {
@@ -1143,12 +1144,12 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
                break;
        }
 
-       if (dqm->ops.initialize(dqm)) {
-               kfree(dqm);
-               return NULL;
-       }
+       if (!dqm->ops.initialize(dqm))
+               return dqm;
 
-       return dqm;
+out_free:
+       kfree(dqm);
+       return NULL;
 }
 
 void device_queue_manager_uninit(struct device_queue_manager *dqm)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +1 -1
index 43194b4..fadc56a 100644
@@ -65,7 +65,7 @@ static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
         * for LDS/Scratch and GPUVM.
         */
 
-       BUG_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
+       WARN_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
                top_address_nybble == 0);
 
        return PRIVATE_BASE(top_address_nybble << 12) |
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +1 -1
index 47ef910..15e81ae 100644
@@ -67,7 +67,7 @@ static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble)
         * for LDS/Scratch and GPUVM.
         */
 
-       BUG_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
+       WARN_ON((top_address_nybble & 1) || top_address_nybble > 0xE ||
                top_address_nybble == 0);
 
        return top_address_nybble << 12 |
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +15 -5
index 970bc07..0e4d4a9 100644
@@ -41,7 +41,8 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
        int retval;
        union PM4_MES_TYPE_3_HEADER nop;
 
-       BUG_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ);
+       if (WARN_ON(type != KFD_QUEUE_TYPE_DIQ && type != KFD_QUEUE_TYPE_HIQ))
+               return false;
 
        pr_debug("Initializing queue type %d size %d\n", KFD_QUEUE_TYPE_HIQ,
                        queue_size);
@@ -62,8 +63,8 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
                                                KFD_MQD_TYPE_HIQ);
                break;
        default:
-               BUG();
-               break;
+               pr_err("Invalid queue type %d\n", type);
+               return false;
        }
 
        if (!kq->mqd)
@@ -305,6 +306,7 @@ void kernel_queue_uninit(struct kernel_queue *kq)
        kfree(kq);
 }
 
+/* FIXME: Can this test be removed? */
 static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 {
        struct kernel_queue *kq;
@@ -314,10 +316,18 @@ static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
        pr_err("Starting kernel queue test\n");
 
        kq = kernel_queue_init(dev, KFD_QUEUE_TYPE_HIQ);
-       BUG_ON(!kq);
+       if (unlikely(!kq)) {
+               pr_err("  Failed to initialize HIQ\n");
+               pr_err("Kernel queue test failed\n");
+               return;
+       }
 
        retval = kq->ops.acquire_packet_buffer(kq, 5, &buffer);
-       BUG_ON(retval != 0);
+       if (unlikely(retval != 0)) {
+               pr_err("  Failed to acquire packet buffer\n");
+               pr_err("Kernel queue test failed\n");
+               return;
+       }
        for (i = 0; i < 5; i++)
                buffer[i] = kq->nop_packet;
        kq->ops.submit_packet(kq);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +2 -1
index a11477d..7e0ec6b 100644
@@ -387,7 +387,8 @@ struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
 {
        struct mqd_manager *mqd;
 
-       BUG_ON(type >= KFD_MQD_TYPE_MAX);
+       if (WARN_ON(type >= KFD_MQD_TYPE_MAX))
+               return NULL;
 
        mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
        if (!mqd)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +2 -1
index d638c2c..f4c8c23 100644
@@ -233,7 +233,8 @@ struct mqd_manager *mqd_manager_init_vi(enum KFD_MQD_TYPE type,
 {
        struct mqd_manager *mqd;
 
-       BUG_ON(type >= KFD_MQD_TYPE_MAX);
+       if (WARN_ON(type >= KFD_MQD_TYPE_MAX))
+               return NULL;
 
        mqd = kzalloc(sizeof(*mqd), GFP_KERNEL);
        if (!mqd)
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +28 -16
index aacd5a3..0816d11 100644
@@ -35,7 +35,8 @@ static inline void inc_wptr(unsigned int *wptr, unsigned int increment_bytes,
 {
        unsigned int temp = *wptr + increment_bytes / sizeof(uint32_t);
 
-       BUG_ON((temp * sizeof(uint32_t)) > buffer_size_bytes);
+       WARN((temp * sizeof(uint32_t)) > buffer_size_bytes,
+            "Runlist IB overflow");
        *wptr = temp;
 }
 
@@ -94,7 +95,8 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm,
 {
        int retval;
 
-       BUG_ON(pm->allocated);
+       if (WARN_ON(pm->allocated))
+               return -EINVAL;
 
        pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription);
 
@@ -119,7 +121,8 @@ static int pm_create_runlist(struct packet_manager *pm, uint32_t *buffer,
 {
        struct pm4_runlist *packet;
 
-       BUG_ON(!ib);
+       if (WARN_ON(!ib))
+               return -EFAULT;
 
        packet = (struct pm4_runlist *)buffer;
 
@@ -211,9 +214,8 @@ static int pm_create_map_queue_vi(struct packet_manager *pm, uint32_t *buffer,
                use_static = false; /* no static queues under SDMA */
                break;
        default:
-               pr_err("queue type %d\n", q->properties.type);
-               BUG();
-               break;
+               WARN(1, "queue type %d", q->properties.type);
+               return -EINVAL;
        }
        packet->bitfields3.doorbell_offset =
                        q->properties.doorbell_off;
@@ -266,8 +268,8 @@ static int pm_create_map_queue(struct packet_manager *pm, uint32_t *buffer,
                use_static = false; /* no static queues under SDMA */
                break;
        default:
-               BUG();
-               break;
+               WARN(1, "queue type %d", q->properties.type);
+               return -EINVAL;
        }
 
        packet->mes_map_queues_ordinals[0].bitfields3.doorbell_offset =
@@ -392,14 +394,16 @@ static int pm_create_runlist_ib(struct packet_manager *pm,
        pr_debug("Finished map process and queues to runlist\n");
 
        if (is_over_subscription)
-               pm_create_runlist(pm, &rl_buffer[rl_wptr], *rl_gpu_addr,
-                               alloc_size_bytes / sizeof(uint32_t), true);
+               retval = pm_create_runlist(pm, &rl_buffer[rl_wptr],
+                                       *rl_gpu_addr,
+                                       alloc_size_bytes / sizeof(uint32_t),
+                                       true);
 
        for (i = 0; i < alloc_size_bytes / sizeof(uint32_t); i++)
                pr_debug("0x%2X ", rl_buffer[i]);
        pr_debug("\n");
 
-       return 0;
+       return retval;
 }
 
 int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm)
@@ -512,7 +516,8 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
        int retval;
        struct pm4_query_status *packet;
 
-       BUG_ON(!fence_address);
+       if (WARN_ON(!fence_address))
+               return -EFAULT;
 
        mutex_lock(&pm->lock);
        retval = pm->priv_queue->ops.acquire_packet_buffer(
@@ -577,8 +582,9 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
                        engine_sel__mes_unmap_queues__sdma0 + sdma_engine;
                break;
        default:
-               BUG();
-               break;
+               WARN(1, "queue type %d", type);
+               retval = -EINVAL;
+               goto err_invalid;
        }
 
        if (reset)
@@ -610,12 +616,18 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
                                queue_sel__mes_unmap_queues__perform_request_on_dynamic_queues_only;
                break;
        default:
-               BUG();
-               break;
+               WARN(1, "filter %d", mode);
+               retval = -EINVAL;
+               goto err_invalid;
        }
 
        pm->priv_queue->ops.submit_packet(pm->priv_queue);
 
+       mutex_unlock(&pm->lock);
+       return 0;
+
+err_invalid:
+       pm->priv_queue->ops.rollback_packet(pm->priv_queue);
 err_acquire_packet_buffer:
        mutex_unlock(&pm->lock);
        return retval;
drivers/gpu/drm/amd/amdkfd/kfd_pasid.c +2 -2
index b3f7d43..1e06de0 100644
@@ -92,6 +92,6 @@ unsigned int kfd_pasid_alloc(void)
 
 void kfd_pasid_free(unsigned int pasid)
 {
-       BUG_ON(pasid == 0 || pasid >= pasid_limit);
-       clear_bit(pasid, pasid_bitmap);
+       if (!WARN_ON(pasid == 0 || pasid >= pasid_limit))
+               clear_bit(pasid, pasid_bitmap);
 }
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -6
index d030d76..c74cf22 100644
@@ -79,8 +79,6 @@ struct kfd_process *kfd_create_process(const struct task_struct *thread)
 {
        struct kfd_process *process;
 
-       BUG_ON(!kfd_process_wq);
-
        if (!thread->mm)
                return ERR_PTR(-EINVAL);
 
@@ -202,10 +200,8 @@ static void kfd_process_destroy_delayed(struct rcu_head *rcu)
        struct kfd_process_release_work *work;
        struct kfd_process *p;
 
-       BUG_ON(!kfd_process_wq);
-
        p = container_of(rcu, struct kfd_process, rcu);
-       BUG_ON(atomic_read(&p->mm->mm_count) <= 0);
+       WARN_ON(atomic_read(&p->mm->mm_count) <= 0);
 
        mmdrop(p->mm);
 
@@ -229,7 +225,8 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
         * mmu_notifier srcu is read locked
         */
        p = container_of(mn, struct kfd_process, mmu_notifier);
-       BUG_ON(p->mm != mm);
+       if (WARN_ON(p->mm != mm))
+               return;
 
        mutex_lock(&kfd_processes_mutex);
        hash_del_rcu(&p->kfd_processes);
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +4 -3
index f6ecdff..1cae95e 100644
@@ -218,8 +218,8 @@ int pqm_create_queue(struct process_queue_manager *pqm,
                                                        kq, &pdd->qpd);
                break;
        default:
-               BUG();
-               break;
+               WARN(1, "Invalid queue type %d", type);
+               retval = -EINVAL;
        }
 
        if (retval != 0) {
@@ -272,7 +272,8 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)
                dev = pqn->kq->dev;
        if (pqn->q)
                dev = pqn->q->device;
-       BUG_ON(!dev);
+       if (WARN_ON(!dev))
+               return -ENODEV;
 
        pdd = kfd_get_process_device_data(dev, pqm->process);
        if (!pdd) {
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +3 -2
index e5486f4..19ce590 100644
@@ -799,10 +799,12 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
        int ret;
        uint32_t i;
 
+       if (WARN_ON(dev->kobj_node))
+               return -EEXIST;
+
        /*
         * Creating the sysfs folders
         */
-       BUG_ON(dev->kobj_node);
        dev->kobj_node = kfd_alloc_struct(dev->kobj_node);
        if (!dev->kobj_node)
                return -ENOMEM;
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#24 lore raw

PATCH 15/24 drm/amdkfd: Add more error printing to help bringup v2

In reply to a message not in the archive

From: Yong Zhao <[email protected]>

v2: Turned WARN into dev_warn and made the message more helpful

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +10 -2
index f628ac3..fd26d7b 100644
@@ -103,6 +103,9 @@ static const struct kfd_device_info *lookup_device_info(unsigned short did)
 		}
 	}
 
+	dev_warn(kfd_device, "DID %04x is missing in supported_devices\n",
+		 did);
+
 	return NULL;
 }
 
@@ -114,8 +117,10 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
 	const struct kfd_device_info *device_info =
 					lookup_device_info(pdev->device);
 
-	if (!device_info)
+	if (!device_info) {
+		dev_err(kfd_device, "kgd2kfd_probe failed\n");
 		return NULL;
+	}
 
 	kfd = kzalloc(sizeof(*kfd), GFP_KERNEL);
 	if (!kfd)
@@ -364,8 +369,11 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
 
 	if (kfd->init_complete) {
 		err = amd_iommu_init_device(kfd->pdev, pasid_limit);
-		if (err < 0)
+		if (err < 0) {
+			dev_err(kfd_device, "failed to initialize iommu\n");
 			return -ENXIO;
+		}
+
 		amd_iommu_set_invalidate_ctx_cb(kfd->pdev,
 						iommu_pasid_shutdown_callback);
 		amd_iommu_set_invalid_ppr_cb(kfd->pdev, iommu_invalid_ppr_cb);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-16-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#26 lore raw

Re: [PATCH 15/24] drm/amdkfd: Add more error printing to help bringup v2

Quoted 50 lines · Felix Kuehling

From: Yong Zhao <[email protected]>

v2: Turned WARN into dev_warn and made the message more helpful

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +10 -3
index f628ac3..fd26d7b 100644
@@ -103,6 +103,9 @@ static const struct kfd_device_info *lookup_device_info(unsigned short did)
                }
        }
 
+       dev_warn(kfd_device, "DID %04x is missing in supported_devices\n",
+                did);
+
        return NULL;
 }
 
@@ -114,8 +117,10 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
        const struct kfd_device_info *device_info =
                                        lookup_device_info(pdev->device);
 
-       if (!device_info)
+       if (!device_info) {
+               dev_err(kfd_device, "kgd2kfd_probe failed\n");
                return NULL;
+       }
 
        kfd = kzalloc(sizeof(*kfd), GFP_KERNEL);
        if (!kfd)
@@ -364,8 +369,11 @@ int kgd2kfd_resume(struct kfd_dev *kfd)
 
        if (kfd->init_complete) {
                err = amd_iommu_init_device(kfd->pdev, pasid_limit);
-               if (err < 0)
+               if (err < 0) {
+                       dev_err(kfd_device, "failed to initialize iommu\n");
                        return -ENXIO;
+               }
+
                amd_iommu_set_invalidate_ctx_cb(kfd->pdev,
                                                iommu_pasid_shutdown_callback);
                amd_iommu_set_invalid_ppr_cb(kfd->pdev, iommu_invalid_ppr_cb);
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#27 lore raw

PATCH 16/24 drm/amdkfd: Clamp EOP queue size correctly on Gfx8

In reply to a message not in the archive

From: Jay Cornwall <[email protected]>

Gfx8 HW incorrectly clamps CP_HQD_EOP_CONTROL.EOP_SIZE, which can lead to scheduling deadlock due to SE EOP done counter overflow.

Enforce a EOP queue size limit which prevents the CP from sending more than 0xFF events at a time.

---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +9 -2
index f4c8c23..98a930e 100644
@@ -135,8 +135,15 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 			3 << CP_HQD_IB_CONTROL__MIN_IB_AVAIL_SIZE__SHIFT |
 			mtype << CP_HQD_IB_CONTROL__MTYPE__SHIFT;
 
-	m->cp_hqd_eop_control |=
-		ffs(q->eop_ring_buffer_size / sizeof(unsigned int)) - 1 - 1;
+	/*
+	 * HW does not clamp this field correctly. Maximum EOP queue size
+	 * is constrained by per-SE EOP done signal count, which is 8-bit.
+	 * Limit is 0xFF EOP entries (= 0x7F8 dwords). CP will not submit
+	 * more than (EOP entry count - 1) so a queue size of 0x800 dwords
+	 * is safe, giving a maximum field value of 0xA.
+	 */
+	m->cp_hqd_eop_control |= min(0xA,
+		ffs(q->eop_ring_buffer_size / sizeof(unsigned int)) - 1 - 1);
 	m->cp_hqd_eop_base_addr_lo =
 			lower_32_bits(q->eop_ring_buffer_address >> 8);
 	m->cp_hqd_eop_base_addr_hi =
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#28 lore raw

PATCH 17/24 drm/amdkfd: Update PM4 packet headers

In reply to a message not in the archive

To match current firmware. The map process packet has been extended to support scratch. This is a non-backwards compatible change and it's about two years old. So no point keeping the old version around conditionally.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c         |   8 +-
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c | 161 ++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h    | 314 +++---------------------
 drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h | 130 +++++++++-
 4 files changed, 199 insertions(+), 414 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +4 -4
index fd26d7b..61fff25 100644
@@ -26,7 +26,7 @@
 #include <linux/slab.h>
 #include "kfd_priv.h"
 #include "kfd_device_queue_manager.h"
-#include "kfd_pm4_headers.h"
+#include "kfd_pm4_headers_vi.h"
 
 #define MQD_SIZE_ALIGNED 768
 
@@ -239,9 +239,9 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 	 * calculate max size of runlist packet.
 	 * There can be only 2 packets at once
 	 */
-	size += (KFD_MAX_NUM_OF_PROCESSES * sizeof(struct pm4_map_process) +
-		max_num_of_queues_per_device *
-		sizeof(struct pm4_map_queues) + sizeof(struct pm4_runlist)) * 2;
+	size += (KFD_MAX_NUM_OF_PROCESSES * sizeof(struct pm4_mes_map_process) +
+		max_num_of_queues_per_device * sizeof(struct pm4_mes_map_queues)
+		+ sizeof(struct pm4_mes_runlist)) * 2;
 
 	/* Add size of HIQ & DIQ */
 	size += KFD_KERNEL_QUEUE_SIZE * 2;
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +44 -117

327 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h +31 -283

347 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h +120 -10

184 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#29 lore raw

PATCH 18/24 drm/amdgpu: Disable GFX PG on CZ

In reply to a message not in the archive

It's causing problems with user mode queues and the HIQ, and can lead to hard hangs during boot after programming RLC_CP_SCHEDULERS.

---
 drivers/gpu/drm/amd/amdgpu/vi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/vi.c +1 -2
index 6cac291..9ff69b9 100644
@@ -1028,8 +1028,7 @@ static int vi_common_early_init(void *handle)
 		/* rev0 hardware requires workarounds to support PG */
 		adev->pg_flags = 0;
 		if (adev->rev_id != 0x00 || CZ_REV_BRISTOL(adev->pdev->revision)) {
-			adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG |
-				AMD_PG_SUPPORT_GFX_SMG |
+			adev->pg_flags |= AMD_PG_SUPPORT_GFX_SMG |
 				AMD_PG_SUPPORT_GFX_PIPELINE |
 				AMD_PG_SUPPORT_CP |
 				AMD_PG_SUPPORT_UVD |
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#30 lore raw

PATCH 19/24 drm/amd: Update MEC HQD loading code for KFD

In reply to a message not in the archive

Various bug fixes and improvements that accumulated over the last two years.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h         |  16 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 130 +++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 165 ++++++++++++++++++---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |   7 +-
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h       |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  23 +--
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  16 +-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |   5 -
 drivers/gpu/drm/amd/include/kgd_kfd_interface.h    |  11 +-
 drivers/gpu/drm/radeon/radeon_kfd.c                |  12 +-
 11 files changed, 322 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +16 -0
index b8802a5..8d689ab 100644
@@ -26,6 +26,7 @@
 #define AMDGPU_AMDKFD_H_INCLUDED
 
 #include <linux/types.h>
+#include <linux/mmu_context.h>
 #include <kgd_kfd_interface.h>
 
 struct amdgpu_device;
@@ -60,4 +61,19 @@ uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);
 
 uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd);
 
+#define read_user_wptr(mmptr, wptr, dst)				\
+	({								\
+		bool valid = false;					\
+		if ((mmptr) && (wptr)) {				\
+			if ((mmptr) == current->mm) {			\
+				valid = !get_user((dst), (wptr));	\
+			} else if (current->mm == NULL) {		\
+				use_mm(mmptr);				\
+				valid = !get_user((dst), (wptr));	\
+				unuse_mm(mmptr);			\
+			}						\
+		}							\
+		valid;							\
+	})
+
 #endif /* AMDGPU_AMDKFD_H_INCLUDED */
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +113 -17

181 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +147 -18

214 lines not on this page · raw message

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -4
index e553c5e..618ac65 100644
@@ -270,8 +270,8 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
 	pr_debug("Loading mqd to hqd on pipe %d, queue %d\n",
 			q->pipe, q->queue);
 
-	retval = mqd->load_mqd(mqd, q->mqd, q->pipe,
-			q->queue, (uint32_t __user *) q->properties.write_ptr);
+	retval = mqd->load_mqd(mqd, q->mqd, q->pipe, q->queue, &q->properties,
+			       q->process->mm);
 	if (retval)
 		goto out_uninit_mqd;
 
@@ -587,8 +587,7 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
 	if (retval)
 		goto out_deallocate_sdma_queue;
 
-	retval = mqd->load_mqd(mqd, q->mqd, 0,
-				0, NULL);
+	retval = mqd->load_mqd(mqd, q->mqd, 0, 0, &q->properties, NULL);
 	if (retval)
 		goto out_uninit_mqd;
 
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +2 -1
index 0e4d4a9..681b639 100644
@@ -143,7 +143,8 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 		kq->queue->pipe = KFD_CIK_HIQ_PIPE;
 		kq->queue->queue = KFD_CIK_HIQ_QUEUE;
 		kq->mqd->load_mqd(kq->mqd, kq->queue->mqd, kq->queue->pipe,
-					kq->queue->queue, NULL);
+				  kq->queue->queue, &kq->queue->properties,
+				  NULL);
 	} else {
 		/* allocate fence for DIQ */
 
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +2 -1
index 213a71e..1f3a6ba 100644
@@ -67,7 +67,8 @@ struct mqd_manager {
 
 	int	(*load_mqd)(struct mqd_manager *mm, void *mqd,
 				uint32_t pipe_id, uint32_t queue_id,
-				uint32_t __user *wptr);
+				struct queue_properties *p,
+				struct mm_struct *mms);
 
 	int	(*update_mqd)(struct mqd_manager *mm, void *mqd,
 				struct queue_properties *q);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +13 -10
index 7e0ec6b..44ffd23 100644
@@ -144,15 +144,21 @@ static void uninit_mqd_sdma(struct mqd_manager *mm, void *mqd,
 }
 
 static int load_mqd(struct mqd_manager *mm, void *mqd, uint32_t pipe_id,
-			uint32_t queue_id, uint32_t __user *wptr)
+		    uint32_t queue_id, struct queue_properties *p,
+		    struct mm_struct *mms)
 {
-	return mm->dev->kfd2kgd->hqd_load
-		(mm->dev->kgd, mqd, pipe_id, queue_id, wptr);
+	/* AQL write pointer counts in 64B packets, PM4/CP counts in dwords. */
+	uint32_t wptr_shift = (p->format == KFD_QUEUE_FORMAT_AQL ? 4 : 0);
+	uint32_t wptr_mask = (uint32_t)((p->queue_size / sizeof(uint32_t)) - 1);
+
+	return mm->dev->kfd2kgd->hqd_load(mm->dev->kgd, mqd, pipe_id, queue_id,
+					  (uint32_t __user *)p->write_ptr,
+					  wptr_shift, wptr_mask, mms);
 }
 
 static int load_mqd_sdma(struct mqd_manager *mm, void *mqd,
-			uint32_t pipe_id, uint32_t queue_id,
-			uint32_t __user *wptr)
+			 uint32_t pipe_id, uint32_t queue_id,
+			 struct queue_properties *p, struct mm_struct *mms)
 {
 	return mm->dev->kfd2kgd->hqd_sdma_load(mm->dev->kgd, mqd);
 }
@@ -176,20 +182,17 @@ static int update_mqd(struct mqd_manager *mm, void *mqd,
 	m->cp_hqd_pq_base_hi = upper_32_bits((uint64_t)q->queue_address >> 8);
 	m->cp_hqd_pq_rptr_report_addr_lo = lower_32_bits((uint64_t)q->read_ptr);
 	m->cp_hqd_pq_rptr_report_addr_hi = upper_32_bits((uint64_t)q->read_ptr);
-	m->cp_hqd_pq_doorbell_control = DOORBELL_EN |
-					DOORBELL_OFFSET(q->doorbell_off);
+	m->cp_hqd_pq_doorbell_control = DOORBELL_OFFSET(q->doorbell_off);
 
 	m->cp_hqd_vmid = q->vmid;
 
 	if (q->format == KFD_QUEUE_FORMAT_AQL)
 		m->cp_hqd_pq_control |= NO_UPDATE_RPTR;
 
-	m->cp_hqd_active = 0;
 	q->is_active = false;
 	if (q->queue_size > 0 &&
 			q->queue_address != 0 &&
 			q->queue_percent > 0) {
-		m->cp_hqd_active = 1;
 		q->is_active = true;
 	}
 
@@ -239,7 +242,7 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd,
 			unsigned int timeout, uint32_t pipe_id,
 			uint32_t queue_id)
 {
-	return mm->dev->kfd2kgd->hqd_destroy(mm->dev->kgd, type, timeout,
+	return mm->dev->kfd2kgd->hqd_destroy(mm->dev->kgd, mqd, type, timeout,
 					pipe_id, queue_id);
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +9 -7
index 98a930e..73cbfe1 100644
@@ -94,10 +94,15 @@ static int init_mqd(struct mqd_manager *mm, void **mqd,
 
 static int load_mqd(struct mqd_manager *mm, void *mqd,
 			uint32_t pipe_id, uint32_t queue_id,
-			uint32_t __user *wptr)
+			struct queue_properties *p, struct mm_struct *mms)
 {
-	return mm->dev->kfd2kgd->hqd_load
-		(mm->dev->kgd, mqd, pipe_id, queue_id, wptr);
+	/* AQL write pointer counts in 64B packets, PM4/CP counts in dwords. */
+	uint32_t wptr_shift = (p->format == KFD_QUEUE_FORMAT_AQL ? 4 : 0);
+	uint32_t wptr_mask = (uint32_t)((p->queue_size / sizeof(uint32_t)) - 1);
+
+	return mm->dev->kfd2kgd->hqd_load(mm->dev->kgd, mqd, pipe_id, queue_id,
+					  (uint32_t __user *)p->write_ptr,
+					  wptr_shift, wptr_mask, mms);
 }
 
 static int __update_mqd(struct mqd_manager *mm, void *mqd,
@@ -122,7 +127,6 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 	m->cp_hqd_pq_rptr_report_addr_hi = upper_32_bits((uint64_t)q->read_ptr);
 
 	m->cp_hqd_pq_doorbell_control =
-		1 << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_EN__SHIFT |
 		q->doorbell_off <<
 			CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT;
 	pr_debug("cp_hqd_pq_doorbell_control 0x%x\n",
@@ -159,12 +163,10 @@ static int __update_mqd(struct mqd_manager *mm, void *mqd,
 				2 << CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT;
 	}
 
-	m->cp_hqd_active = 0;
 	q->is_active = false;
 	if (q->queue_size > 0 &&
 			q->queue_address != 0 &&
 			q->queue_percent > 0) {
-		m->cp_hqd_active = 1;
 		q->is_active = true;
 	}
 
@@ -184,7 +186,7 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd,
 			uint32_t queue_id)
 {
 	return mm->dev->kfd2kgd->hqd_destroy
-		(mm->dev->kgd, type, timeout,
+		(mm->dev->kgd, mqd, type, timeout,
 		pipe_id, queue_id);
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0 -5
index f0d55cc0..30ce92c 100644
@@ -239,11 +239,6 @@ enum kfd_preempt_type_filter {
 	KFD_PREEMPT_TYPE_FILTER_BY_PASID
 };
 
-enum kfd_preempt_type {
-	KFD_PREEMPT_TYPE_WAVEFRONT,
-	KFD_PREEMPT_TYPE_WAVEFRONT_RESET
-};
-
 /**
  * enum kfd_queue_type
  *
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +9 -2
index 36f3766..ffafda0 100644
@@ -41,6 +41,11 @@ struct kgd_dev;
 
 struct kgd_mem;
 
+enum kfd_preempt_type {
+	KFD_PREEMPT_TYPE_WAVEFRONT_DRAIN = 0,
+	KFD_PREEMPT_TYPE_WAVEFRONT_RESET,
+};
+
 enum kgd_memory_pool {
 	KGD_POOL_SYSTEM_CACHEABLE = 1,
 	KGD_POOL_SYSTEM_WRITECOMBINE = 2,
@@ -153,14 +158,16 @@ struct kfd2kgd_calls {
 	int (*init_interrupts)(struct kgd_dev *kgd, uint32_t pipe_id);
 
 	int (*hqd_load)(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
-			uint32_t queue_id, uint32_t __user *wptr);
+			uint32_t queue_id, uint32_t __user *wptr,
+			uint32_t wptr_shift, uint32_t wptr_mask,
+			struct mm_struct *mm);
 
 	int (*hqd_sdma_load)(struct kgd_dev *kgd, void *mqd);
 
 	bool (*hqd_is_occupied)(struct kgd_dev *kgd, uint64_t queue_address,
 				uint32_t pipe_id, uint32_t queue_id);
 
-	int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type,
+	int (*hqd_destroy)(struct kgd_dev *kgd, void *mqd, uint32_t reset_type,
 				unsigned int timeout, uint32_t pipe_id,
 				uint32_t queue_id);
 
drivers/gpu/drm/radeon/radeon_kfd.c +8 -4
index cab6c03..f6578c9 100644
@@ -75,12 +75,14 @@ static int kgd_init_pipeline(struct kgd_dev *kgd, uint32_t pipe_id,
 				uint32_t hpd_size, uint64_t hpd_gpu_addr);
 static int kgd_init_interrupts(struct kgd_dev *kgd, uint32_t pipe_id);
 static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
-			uint32_t queue_id, uint32_t __user *wptr);
+			uint32_t queue_id, uint32_t __user *wptr,
+			uint32_t wptr_shift, uint32_t wptr_mask,
+			struct mm_struct *mm);
 static int kgd_hqd_sdma_load(struct kgd_dev *kgd, void *mqd);
 static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address,
 				uint32_t pipe_id, uint32_t queue_id);
 
-static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
+static int kgd_hqd_destroy(struct kgd_dev *kgd, void *mqd, uint32_t reset_type,
 				unsigned int timeout, uint32_t pipe_id,
 				uint32_t queue_id);
 static bool kgd_hqd_sdma_is_occupied(struct kgd_dev *kgd, void *mqd);
@@ -482,7 +484,9 @@ static inline struct cik_sdma_rlc_registers *get_sdma_mqd(void *mqd)
 }
 
 static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
-			uint32_t queue_id, uint32_t __user *wptr)
+			uint32_t queue_id, uint32_t __user *wptr,
+			uint32_t wptr_shift, uint32_t wptr_mask,
+			struct mm_struct *mm)
 {
 	uint32_t wptr_shadow, is_wptr_shadow_valid;
 	struct cik_mqd *m;
@@ -636,7 +640,7 @@ static bool kgd_hqd_sdma_is_occupied(struct kgd_dev *kgd, void *mqd)
 	return false;
 }
 
-static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
+static int kgd_hqd_destroy(struct kgd_dev *kgd, void *mqd, uint32_t reset_type,
 				unsigned int timeout, uint32_t pipe_id,
 				uint32_t queue_id)
 {
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#31 lore raw

PATCH 20/24 drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

In reply to a message not in the archive

This register only has a single instance in the hardware. Its value applies to all VMIDS.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 53a4af7..0086876 100644
@@ -1921,6 +1921,7 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
 				   ELEMENT_SIZE, 1);
 	sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
 				   INDEX_STRIDE, 3);
+	WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
 
 	mutex_lock(&adev->srbm_mutex);
 	for (i = 0; i < adev->vm_manager.id_mgr[0].num_ids; i++) {
@@ -1934,7 +1935,6 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
 		WREG32(mmSH_MEM_APE1_BASE, 1);
 		WREG32(mmSH_MEM_APE1_LIMIT, 0);
 		WREG32(mmSH_MEM_BASES, sh_mem_base);
-		WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
 	}
 	cik_srbm_select(adev, 0, 0, 0, 0);
 	mutex_unlock(&adev->srbm_mutex);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -1
index 0710b0b..832e592 100644
@@ -3707,6 +3707,8 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
 				   ELEMENT_SIZE, 1);
 	sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
 				   INDEX_STRIDE, 3);
+	WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
+
 	mutex_lock(&adev->srbm_mutex);
 	for (i = 0; i < adev->vm_manager.id_mgr[0].num_ids; i++) {
 		vi_srbm_select(adev, 0, 0, 0, i);
@@ -3730,7 +3732,6 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
 
 		WREG32(mmSH_MEM_APE1_BASE, 1);
 		WREG32(mmSH_MEM_APE1_LIMIT, 0);
-		WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
 	}
 	vi_srbm_select(adev, 0, 0, 0, 0);
 	mutex_unlock(&adev->srbm_mutex);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-21-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Acked-by
#33 lore raw

Re: [PATCH 20/24] drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Quoted 51 lines · Felix Kuehling

This register only has a single instance in the hardware. Its value applies to all VMIDS.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 53a4af7..0086876 100644
@@ -1921,6 +1921,7 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
                                   ELEMENT_SIZE, 1);
        sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
                                   INDEX_STRIDE, 3);
+       WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
 
        mutex_lock(&adev->srbm_mutex);
        for (i = 0; i < adev->vm_manager.id_mgr[0].num_ids; i++) {
@@ -1934,7 +1935,6 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
                WREG32(mmSH_MEM_APE1_BASE, 1);
                WREG32(mmSH_MEM_APE1_LIMIT, 0);
                WREG32(mmSH_MEM_BASES, sh_mem_base);
-               WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
        }
        cik_srbm_select(adev, 0, 0, 0, 0);
        mutex_unlock(&adev->srbm_mutex);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2 -2
index 0710b0b..832e592 100644
@@ -3707,6 +3707,8 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
                                   ELEMENT_SIZE, 1);
        sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
                                   INDEX_STRIDE, 3);
+       WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
+
        mutex_lock(&adev->srbm_mutex);
        for (i = 0; i < adev->vm_manager.id_mgr[0].num_ids; i++) {
                vi_srbm_select(adev, 0, 0, 0, i);
@@ -3730,7 +3732,6 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
 
                WREG32(mmSH_MEM_APE1_BASE, 1);
                WREG32(mmSH_MEM_APE1_LIMIT, 0);
-               WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
        }
        vi_srbm_select(adev, 0, 0, 0, 0);
        mutex_unlock(&adev->srbm_mutex);
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#34 lore raw

PATCH 21/24 drm/amdgpu: Add kgd/kfd interface to support scratch memory v2

In reply to a message not in the archive

From: Moses Reuben <[email protected]>

v2:
* Shortened headline
* Removed write_config_static_mem, it gets initialized by gfx_v?_0_gpu_init
* Renamed alloc_memory_of_scratch to set_scratch_backing_va
* Made set_scratch_backing_va a void function
* Documented set_scratch_backing in kgd_kfd_interface.h

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 15 ++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 16 +++++++++++++++-
 drivers/gpu/drm/amd/include/kgd_kfd_interface.h   |  5 +++++
 3 files changed, 34 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +14 -1
index d1719be..3793d7b 100644
@@ -135,6 +135,8 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
 
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+					uint64_t va, uint32_t vmid);
 
 static const struct kfd2kgd_calls kfd2kgd = {
 	.init_gtt_mem_allocation = alloc_gtt_mem,
@@ -159,7 +161,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
 	.get_atc_vmid_pasid_mapping_pasid = get_atc_vmid_pasid_mapping_pasid,
 	.get_atc_vmid_pasid_mapping_valid = get_atc_vmid_pasid_mapping_valid,
 	.write_vmid_invalidate_request = write_vmid_invalidate_request,
-	.get_fw_version = get_fw_version
+	.get_fw_version = get_fw_version,
+	.set_scratch_backing_va = set_scratch_backing_va,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
@@ -652,6 +655,16 @@ static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid)
 	WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid);
 }
 
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+					uint64_t va, uint32_t vmid)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
+
+	lock_srbm(kgd, 0, 0, 0, vmid);
+	WREG32(mmSH_HIDDEN_PRIVATE_BASE_VMID, va);
+	unlock_srbm(kgd);
+}
+
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +15 -1
index 29a6f5d..61f6457 100644
@@ -94,6 +94,8 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
 		uint8_t vmid);
 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+					uint64_t va, uint32_t vmid);
 
 static const struct kfd2kgd_calls kfd2kgd = {
 	.init_gtt_mem_allocation = alloc_gtt_mem,
@@ -120,12 +122,14 @@ static const struct kfd2kgd_calls kfd2kgd = {
 	.get_atc_vmid_pasid_mapping_valid =
 			get_atc_vmid_pasid_mapping_valid,
 	.write_vmid_invalidate_request = write_vmid_invalidate_request,
-	.get_fw_version = get_fw_version
+	.get_fw_version = get_fw_version,
+	.set_scratch_backing_va = set_scratch_backing_va,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
 {
 	return (struct kfd2kgd_calls *)&kfd2kgd;
+	return (struct kfd2kgd_calls *)&kfd2kgd;
 }
 
 static inline struct amdgpu_device *get_amdgpu_device(struct kgd_dev *kgd)
@@ -573,6 +577,16 @@ static uint32_t kgd_address_watch_get_offset(struct kgd_dev *kgd,
 	return 0;
 }
 
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+					uint64_t va, uint32_t vmid)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
+
+	lock_srbm(kgd, 0, 0, 0, vmid);
+	WREG32(mmSH_HIDDEN_PRIVATE_BASE_VMID, va);
+	unlock_srbm(kgd);
+}
+
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +5 -0
index ffafda0..2a9cc5e 100644
@@ -128,6 +128,9 @@ struct kgd2kfd_shared_resources {
  *
  * @get_fw_version: Returns FW versions from the header
  *
+ * @set_scratch_backing_va: Sets VA for scratch backing memory of a VMID.
+ * Only used for no cp scheduling mode
+ *
  * This structure contains function pointers to services that the kgd driver
  * provides to amdkfd driver.
  *
@@ -199,6 +202,8 @@ struct kfd2kgd_calls {
 
 	uint16_t (*get_fw_version)(struct kgd_dev *kgd,
 				enum kgd_engine_type type);
+	void (*set_scratch_backing_va)(struct kgd_dev *kgd,
+				uint64_t va, uint32_t vmid);
 };
 
 /**
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-22-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#36 lore raw

Re: [PATCH 21/24] drm/amdgpu: Add kgd/kfd interface to support scratch memory v2

Quoted 128 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Shortened headline
* Removed write_config_static_mem, it gets initialized by gfx_v?_0_gpu_init
* Renamed alloc_memory_of_scratch to set_scratch_backing_va
* Made set_scratch_backing_va a void function
* Documented set_scratch_backing in kgd_kfd_interface.h

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 15 ++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 16 +++++++++++++++-
 drivers/gpu/drm/amd/include/kgd_kfd_interface.h   |  5 +++++
 3 files changed, 34 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +14 -1
index d1719be..3793d7b 100644
@@ -135,6 +135,8 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
 
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid);
 
 static const struct kfd2kgd_calls kfd2kgd = {
        .init_gtt_mem_allocation = alloc_gtt_mem,
@@ -159,7 +161,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .get_atc_vmid_pasid_mapping_pasid = get_atc_vmid_pasid_mapping_pasid,
        .get_atc_vmid_pasid_mapping_valid = get_atc_vmid_pasid_mapping_valid,
        .write_vmid_invalidate_request = write_vmid_invalidate_request,
-       .get_fw_version = get_fw_version
+       .get_fw_version = get_fw_version,
+       .set_scratch_backing_va = set_scratch_backing_va,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
@@ -652,6 +655,16 @@ static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid)
        WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid);
 }
 
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
+
+       lock_srbm(kgd, 0, 0, 0, vmid);
+       WREG32(mmSH_HIDDEN_PRIVATE_BASE_VMID, va);
+       unlock_srbm(kgd);
+}
+
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +15 -1
index 29a6f5d..61f6457 100644
@@ -94,6 +94,8 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
                uint8_t vmid);
 static void write_vmid_invalidate_request(struct kgd_dev *kgd, uint8_t vmid);
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid);
 
 static const struct kfd2kgd_calls kfd2kgd = {
        .init_gtt_mem_allocation = alloc_gtt_mem,
@@ -120,12 +122,14 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .get_atc_vmid_pasid_mapping_valid =
                        get_atc_vmid_pasid_mapping_valid,
        .write_vmid_invalidate_request = write_vmid_invalidate_request,
-       .get_fw_version = get_fw_version
+       .get_fw_version = get_fw_version,
+       .set_scratch_backing_va = set_scratch_backing_va,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
 {
        return (struct kfd2kgd_calls *)&kfd2kgd;
+       return (struct kfd2kgd_calls *)&kfd2kgd;
 }
 
 static inline struct amdgpu_device *get_amdgpu_device(struct kgd_dev *kgd)
@@ -573,6 +577,16 @@ static uint32_t kgd_address_watch_get_offset(struct kgd_dev *kgd,
        return 0;
 }
 
+static void set_scratch_backing_va(struct kgd_dev *kgd,
+                                       uint64_t va, uint32_t vmid)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
+
+       lock_srbm(kgd, 0, 0, 0, vmid);
+       WREG32(mmSH_HIDDEN_PRIVATE_BASE_VMID, va);
+       unlock_srbm(kgd);
+}
+
 static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +5 -1
index ffafda0..2a9cc5e 100644
@@ -128,6 +128,9 @@ struct kgd2kfd_shared_resources {
  *
  * @get_fw_version: Returns FW versions from the header
  *
+ * @set_scratch_backing_va: Sets VA for scratch backing memory of a VMID.
+ * Only used for no cp scheduling mode
+ *
  * This structure contains function pointers to services that the kgd driver
  * provides to amdkfd driver.
  *
@@ -199,6 +202,8 @@ struct kfd2kgd_calls {
 
        uint16_t (*get_fw_version)(struct kgd_dev *kgd,
                                enum kgd_engine_type type);
+       void (*set_scratch_backing_va)(struct kgd_dev *kgd,
+                               uint64_t va, uint32_t vmid);
 };
 
 /**
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#37 lore raw

PATCH 22/24 drm/amdkfd: Adding new IOCTL for scratch memory v2

In reply to a message not in the archive

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 37 ++++++++++++++++++++++
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  3 ++
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |  2 ++
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |  2 ++
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  1 +
 include/uapi/linux/kfd_ioctl.h                     | 11 ++++++-
 6 files changed, 55 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +37 -0
index 65b506f1..7436d34 100644
@@ -848,6 +848,40 @@ static int kfd_ioctl_wait_events(struct file *filp, struct kfd_process *p,
 
 	return err;
 }
+static int kfd_ioctl_set_scratch_backing_va(struct file *filep,
+					struct kfd_process *p, void *data)
+{
+	struct kfd_ioctl_set_scratch_backing_va_args *args = data;
+	struct kfd_process_device *pdd;
+	struct kfd_dev *dev;
+	long err;
+
+	dev = kfd_device_by_id(args->gpu_id);
+	if (!dev)
+		return -EINVAL;
+
+	mutex_lock(&p->mutex);
+
+	pdd = kfd_bind_process_to_device(dev, p);
+	if (IS_ERR(pdd)) {
+		err = PTR_ERR(pdd);
+		goto bind_process_to_device_fail;
+	}
+
+	pdd->qpd.sh_hidden_private_base = args->va_addr;
+
+	mutex_unlock(&p->mutex);
+
+	if (sched_policy == KFD_SCHED_POLICY_NO_HWS && pdd->qpd.vmid != 0)
+		dev->kfd2kgd->set_scratch_backing_va(
+			dev->kgd, args->va_addr, pdd->qpd.vmid);
+
+	return 0;
+
+bind_process_to_device_fail:
+	mutex_unlock(&p->mutex);
+	return err;
+}
 
 #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
 	[_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \
@@ -902,6 +936,9 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
 
 	AMDKFD_IOCTL_DEF(AMDKFD_IOC_DBG_WAVE_CONTROL,
 			kfd_ioctl_dbg_wave_control, 0),
+
+	AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_SCRATCH_BACKING_VA,
+			kfd_ioctl_set_scratch_backing_va, 0),
 };
 
 #define AMDKFD_CORE_IOCTL_COUNT	ARRAY_SIZE(amdkfd_ioctls)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -0
index 618ac65..53a66e8 100644
@@ -270,6 +270,9 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
 	pr_debug("Loading mqd to hqd on pipe %d, queue %d\n",
 			q->pipe, q->queue);
 
+	dqm->dev->kfd2kgd->set_scratch_backing_va(
+			dqm->dev->kgd, qpd->sh_hidden_private_base, qpd->vmid);
+
 	retval = mqd->load_mqd(mqd, q->mqd, q->pipe, q->queue, &q->properties,
 			       q->process->mm);
 	if (retval)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +2 -0
index fadc56a..72c3cba 100644
@@ -24,6 +24,7 @@
 #include "kfd_device_queue_manager.h"
 #include "cik_regs.h"
 #include "oss/oss_2_4_sh_mask.h"
+#include "gca/gfx_7_2_sh_mask.h"
 
 static bool set_cache_memory_policy_cik(struct device_queue_manager *dqm,
 				   struct qcm_process_device *qpd,
@@ -123,6 +124,7 @@ static int register_process_cik(struct device_queue_manager *dqm,
 	} else {
 		temp = get_sh_mem_bases_nybble_64(pdd);
 		qpd->sh_mem_bases = compute_sh_mem_bases_64bit(temp);
+		qpd->sh_mem_config |= 1  << SH_MEM_CONFIG__PRIVATE_ATC__SHIFT;
 	}
 
 	pr_debug("is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +2 -0
index 15e81ae..40e9ddd 100644
@@ -135,6 +135,8 @@ static int register_process_vi(struct device_queue_manager *dqm,
 		qpd->sh_mem_bases = compute_sh_mem_bases_64bit(temp);
 		qpd->sh_mem_config |= SH_MEM_ADDRESS_MODE_HSA64 <<
 			SH_MEM_CONFIG__ADDRESS_MODE__SHIFT;
+		qpd->sh_mem_config |= 1  <<
+			SH_MEM_CONFIG__PRIVATE_ATC__SHIFT;
 	}
 
 	pr_debug("is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -0
index 30ce92c..b397ec7 100644
@@ -432,6 +432,7 @@ struct qcm_process_device {
 	uint32_t gds_size;
 	uint32_t num_gws;
 	uint32_t num_oac;
+	uint32_t sh_hidden_private_base;
 };
 
 /* Data that is per-process-per device. */
include/uapi/linux/kfd_ioctl.h +10 -1
index d683342..1b9c560 100644
@@ -232,6 +232,12 @@ struct kfd_ioctl_wait_events_args {
 	uint32_t wait_result;		/* from KFD */
 };
 
+struct kfd_ioctl_set_scratch_backing_va_args {
+	uint64_t va_addr;	/* to KFD */
+	uint32_t gpu_id;	/* to KFD */
+	uint32_t pad;
+};
+
 #define AMDKFD_IOCTL_BASE 'K'
 #define AMDKFD_IO(nr)			_IO(AMDKFD_IOCTL_BASE, nr)
 #define AMDKFD_IOR(nr, type)		_IOR(AMDKFD_IOCTL_BASE, nr, type)
@@ -286,7 +292,10 @@ struct kfd_ioctl_wait_events_args {
 #define AMDKFD_IOC_DBG_WAVE_CONTROL		\
 		AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
 
+#define AMDKFD_IOC_SET_SCRATCH_BACKING_VA	\
+		AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
+
 #define AMDKFD_COMMAND_START		0x01
-#define AMDKFD_COMMAND_END		0x11
+#define AMDKFD_COMMAND_END		0x12
 
 #endif
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1502852422-19620-23-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#39 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Quoted 165 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 37 ++++++++++++++++++++++
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  3 ++
 .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |  2 ++
 .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |  2 ++
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  1 +
 include/uapi/linux/kfd_ioctl.h                     | 11 ++++++-
 6 files changed, 55 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +37 -0
index 65b506f1..7436d34 100644
@@ -848,6 +848,40 @@ static int kfd_ioctl_wait_events(struct file *filp, struct kfd_process *p,
 
        return err;
 }
+static int kfd_ioctl_set_scratch_backing_va(struct file *filep,
+                                       struct kfd_process *p, void *data)
+{
+       struct kfd_ioctl_set_scratch_backing_va_args *args = data;
+       struct kfd_process_device *pdd;
+       struct kfd_dev *dev;
+       long err;
+
+       dev = kfd_device_by_id(args->gpu_id);
+       if (!dev)
+               return -EINVAL;
+
+       mutex_lock(&p->mutex);
+
+       pdd = kfd_bind_process_to_device(dev, p);
+       if (IS_ERR(pdd)) {
+               err = PTR_ERR(pdd);
+               goto bind_process_to_device_fail;
+       }
+
+       pdd->qpd.sh_hidden_private_base = args->va_addr;
+
+       mutex_unlock(&p->mutex);
+
+       if (sched_policy == KFD_SCHED_POLICY_NO_HWS && pdd->qpd.vmid != 0)
+               dev->kfd2kgd->set_scratch_backing_va(
+                       dev->kgd, args->va_addr, pdd->qpd.vmid);
+
+       return 0;
+
+bind_process_to_device_fail:
+       mutex_unlock(&p->mutex);
+       return err;
+}
 
 #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
        [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \
@@ -902,6 +936,9 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
 
        AMDKFD_IOCTL_DEF(AMDKFD_IOC_DBG_WAVE_CONTROL,
                        kfd_ioctl_dbg_wave_control, 0),
+
+       AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_SCRATCH_BACKING_VA,
+                       kfd_ioctl_set_scratch_backing_va, 0),
 };
 
 #define AMDKFD_CORE_IOCTL_COUNT        ARRAY_SIZE(amdkfd_ioctls)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -0
index 618ac65..53a66e8 100644
@@ -270,6 +270,9 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
        pr_debug("Loading mqd to hqd on pipe %d, queue %d\n",
                        q->pipe, q->queue);
 
+       dqm->dev->kfd2kgd->set_scratch_backing_va(
+                       dqm->dev->kgd, qpd->sh_hidden_private_base, qpd->vmid);
+
        retval = mqd->load_mqd(mqd, q->mqd, q->pipe, q->queue, &q->properties,
                               q->process->mm);
        if (retval)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +2 -0
index fadc56a..72c3cba 100644
@@ -24,6 +24,7 @@
 #include "kfd_device_queue_manager.h"
 #include "cik_regs.h"
 #include "oss/oss_2_4_sh_mask.h"
+#include "gca/gfx_7_2_sh_mask.h"
 
 static bool set_cache_memory_policy_cik(struct device_queue_manager *dqm,
                                   struct qcm_process_device *qpd,
@@ -123,6 +124,7 @@ static int register_process_cik(struct device_queue_manager *dqm,
        } else {
                temp = get_sh_mem_bases_nybble_64(pdd);
                qpd->sh_mem_bases = compute_sh_mem_bases_64bit(temp);
+               qpd->sh_mem_config |= 1  << SH_MEM_CONFIG__PRIVATE_ATC__SHIFT;
        }
 
        pr_debug("is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +2 -0
index 15e81ae..40e9ddd 100644
@@ -135,6 +135,8 @@ static int register_process_vi(struct device_queue_manager *dqm,
                qpd->sh_mem_bases = compute_sh_mem_bases_64bit(temp);
                qpd->sh_mem_config |= SH_MEM_ADDRESS_MODE_HSA64 <<
                        SH_MEM_CONFIG__ADDRESS_MODE__SHIFT;
+               qpd->sh_mem_config |= 1  <<
+                       SH_MEM_CONFIG__PRIVATE_ATC__SHIFT;
        }
 
        pr_debug("is32bit process: %d sh_mem_bases nybble: 0x%X and register 0x%X\n",
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -0
index 30ce92c..b397ec7 100644
@@ -432,6 +432,7 @@ struct qcm_process_device {
        uint32_t gds_size;
        uint32_t num_gws;
        uint32_t num_oac;
+       uint32_t sh_hidden_private_base;
 };
 
 /* Data that is per-process-per device. */
include/uapi/linux/kfd_ioctl.h +10 -2
index d683342..1b9c560 100644
@@ -232,6 +232,12 @@ struct kfd_ioctl_wait_events_args {
        uint32_t wait_result;           /* from KFD */
 };
 
+struct kfd_ioctl_set_scratch_backing_va_args {
+       uint64_t va_addr;       /* to KFD */
+       uint32_t gpu_id;        /* to KFD */
+       uint32_t pad;
+};
+
 #define AMDKFD_IOCTL_BASE 'K'
 #define AMDKFD_IO(nr)                  _IO(AMDKFD_IOCTL_BASE, nr)
 #define AMDKFD_IOR(nr, type)           _IOR(AMDKFD_IOCTL_BASE, nr, type)
@@ -286,7 +292,10 @@ struct kfd_ioctl_wait_events_args {
 #define AMDKFD_IOC_DBG_WAVE_CONTROL            \
                AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
 
+#define AMDKFD_IOC_SET_SCRATCH_BACKING_VA      \
+               AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
+
 #define AMDKFD_COMMAND_START           0x01
-#define AMDKFD_COMMAND_END             0x11
+#define AMDKFD_COMMAND_END             0x12
 
 #endif
--
Quoted 2 lines

2.7.4

This patch is:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#40 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

In reply to a message not in the archive
Quoted 8 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

What kind of memory is suppose to back this virtual address range ? How big is the range suppose to be ? Can it be any valid virtual address ?

My worry here is to ascertain that one can not abuse this ioctl say to set the virtual address to some mmaped shared library code/data section and write something malicious there.

I am assuming that if it has to go through ATS/PASID of the IOMMUv2 then the write protection will be asserted and we will see proper COW (copy on write) due to mmap PRIVATE flags.

Idealy this area should be a special vma and the driver should track its lifetime and cancel GPU jobs if it is unmap. But i am unsure on how dynamic is that scratch memory suppose to be (ie do you allocate new scratch memory with every GPU job or is it allocated once and reuse for every jobs).

Bigger commit message would be nice too. Like i had tons of i believe valid questions.

Cheers,
Jérôme
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#42 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Quoted 31 lines · Jerome Glisse
Quoted 8 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

What kind of memory is suppose to back this virtual address range ? How big is the range suppose to be ? Can it be any valid virtual address ?

My worry here is to ascertain that one can not abuse this ioctl say to set the virtual address to some mmaped shared library code/data section and write something malicious there.

I am assuming that if it has to go through ATS/PASID of the IOMMUv2 then the write protection will be asserted and we will see proper COW (copy on write) due to mmap PRIVATE flags.

Idealy this area should be a special vma and the driver should track its lifetime and cancel GPU jobs if it is unmap. But i am unsure on how dynamic is that scratch memory suppose to be (ie do you allocate new scratch memory with every GPU job or is it allocated once and reuse for every jobs).

Quoted 5 lines

Bigger commit message would be nice too. Like i had tons of i believe valid questions.

Cheers,
Jérôme

Hi Jerome,
Great points.

This is the explanation Felix gave a few days ago on this ioctl in a different email thread:

"Scratch memory is private memory per work-item. It's used when a shader program has too few registers available. With HSA we use flat scratch addressing, where shaders can access private memory in a special scratch aperture using normal memory instructions. Using the same virtual address, each work item gets its own private piece of memory. The hardware does the address translation from the VA in the private aperture to a scratch-backing VA. The application is responsible for allocating the memory to back that scratch area, and to map it somewhere in its virtual address space.

This ioctl tells the hardware (or HWS firmware) the VA of the scratch backing memory."

From this explanation, I think that the user's supplied VA should be tested that its a valid writable area of the user.
How do you test for that ? could you point me to such a code in the kernel ? From looking at other drivers that pin host memory, like mellanox nic, they don't do any special testing for the address they receive from the user.

Felix,
Is the scratch memory size fixed ? Because I don't see a size argument in the IOCTL.
If it is fixed, what is the size ?

Thanks,
Oded
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAFCwf10hhjmmoTv+3GP85FeyWYv4AyL1G+xBYmZfr_39N=wiOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#44 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Quoted 57 lines · Oded Gabbay
Quoted 31 lines · Jerome Glisse
Quoted 8 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

What kind of memory is suppose to back this virtual address range ? How big is the range suppose to be ? Can it be any valid virtual address ?

My worry here is to ascertain that one can not abuse this ioctl say to set the virtual address to some mmaped shared library code/data section and write something malicious there.

I am assuming that if it has to go through ATS/PASID of the IOMMUv2 then the write protection will be asserted and we will see proper COW (copy on write) due to mmap PRIVATE flags.

Idealy this area should be a special vma and the driver should track its lifetime and cancel GPU jobs if it is unmap. But i am unsure on how dynamic is that scratch memory suppose to be (ie do you allocate new scratch memory with every GPU job or is it allocated once and reuse for every jobs).

Quoted 5 lines

Bigger commit message would be nice too. Like i had tons of i believe valid questions.

Cheers,
Jérôme

Hi Jerome,
Great points.

This is the explanation Felix gave a few days ago on this ioctl in a different email thread:

"Scratch memory is private memory per work-item. It's used when a shader program has too few registers available. With HSA we use flat scratch addressing, where shaders can access private memory in a special scratch aperture using normal memory instructions. Using the same virtual address, each work item gets its own private piece of memory. The hardware does the address translation from the VA in the private aperture to a scratch-backing VA. The application is responsible for allocating the memory to back that scratch area, and to map it somewhere in its virtual address space.

This ioctl tells the hardware (or HWS firmware) the VA of the scratch backing memory."

Quoted 6 lines

From this explanation, I think that the user's supplied VA should be tested that its a valid writable area of the user.
How do you test for that ? could you point me to such a code in the kernel ? From looking at other drivers that pin host memory, like mellanox nic, they don't do any special testing for the address they receive from the user.

GUP (get_user_page()) will perform proper check on your behalf. I am assuming those driver use GUP.

Jérôme
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#46 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Quoted 8 lines · Jerome Glisse
Quoted 6 lines

From this explanation, I think that the user's supplied VA should be tested that its a valid writable area of the user.
How do you test for that ? could you point me to such a code in the kernel ? From looking at other drivers that pin host memory, like mellanox nic, they don't do any special testing for the address they receive from the user.

GUP (get_user_page()) will perform proper check on your behalf. I am assuming those driver use GUP.

On APUs, the GPU can address memory directly through ATS. So it doesn't use GUP. The GPU uses the same page tables as the CPU, so uses the same access bits to check permissions on the fly.

On dGPU, when we use VRAM for scratch backing, that doesn't use GUP. In theory it should be possible to use GUP (using our userptr mechanism). In that case GUP would check the access permissions of the underlying mapping.

Regards,
Felix

Quoted 2 lines

Jérôme

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 9b600e94-f3d7-d1de-90da-6e578ce8c108-5C7GfCeVMHo@public.gmane.org

#48 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Quoted 10 lines · Felix Kuehling
Quoted 8 lines · Jerome Glisse
Quoted 6 lines

From this explanation, I think that the user's supplied VA should be tested that its a valid writable area of the user.
How do you test for that ? could you point me to such a code in the kernel ? From looking at other drivers that pin host memory, like mellanox nic, they don't do any special testing for the address they receive from the user.

GUP (get_user_page()) will perform proper check on your behalf. I am assuming those driver use GUP.

Ah, ok. I thought you refer to some other check that needs to be done *before* calling get_user_page().
As Felix said, for APU the GPU doesn't need the memory to be pinned and it uses the ATS to access it directly so we don't call get_user_page() or some other function that calls it eventually.

On dGPU I guess it would be similar to what is done in most drivers that need to pin user memory, by calling to get_user_page().

Oded

Quoted 4 lines

On APUs, the GPU can address memory directly through ATS. So it doesn't use GUP. The GPU uses the same page tables as the CPU, so uses the same access bits to check permissions on the fly.

Quoted 11 lines

On dGPU, when we use VRAM for scratch backing, that doesn't use GUP. In theory it should be possible to use GUP (using our userptr mechanism). In that case GUP would check the access permissions of the underlying mapping.

Regards,
Felix

Quoted 2 lines

Jérôme

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#49 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

In reply to a message not in the archive
Quoted 62 lines · Oded Gabbay
Quoted 30 lines · Jerome Glisse
Quoted 8 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

What kind of memory is suppose to back this virtual address range ? How big is the range suppose to be ? Can it be any valid virtual address ?

My worry here is to ascertain that one can not abuse this ioctl say to set the virtual address to some mmaped shared library code/data section and write something malicious there.

I am assuming that if it has to go through ATS/PASID of the IOMMUv2 then the write protection will be asserted and we will see proper COW (copy on write) due to mmap PRIVATE flags.

Idealy this area should be a special vma and the driver should track its lifetime and cancel GPU jobs if it is unmap. But i am unsure on how dynamic is that scratch memory suppose to be (ie do you allocate new scratch memory with every GPU job or is it allocated once and reuse for every jobs).

Quoted 5 lines

Bigger commit message would be nice too. Like i had tons of i believe valid questions.

Cheers,
Jérôme

Hi Jerome,
Great points.

This is the explanation Felix gave a few days ago on this ioctl in a different email thread:

"Scratch memory is private memory per work-item. It's used when a shader program has too few registers available. With HSA we use flat scratch addressing, where shaders can access private memory in a special scratch aperture using normal memory instructions. Using the same virtual address, each work item gets its own private piece of memory. The hardware does the address translation from the VA in the private aperture to a scratch-backing VA. The application is responsible for allocating the memory to back that scratch area, and to map it somewhere in its virtual address space.

This ioctl tells the hardware (or HWS firmware) the VA of the scratch backing memory."

From this explanation, I think that the user's supplied VA should be tested that its a valid writable area of the user.
How do you test for that ? could you point me to such a code in the kernel ? From looking at other drivers that pin host memory, like mellanox nic, they don't do any special testing for the address they receive from the user.

Quoted 3 lines

Felix,
Is the scratch memory size fixed ? Because I don't see a size argument in the IOCTL.

The hardware needs a continuous pieces of virtual address space for scratch backing. The base address of that continuous region is programmed into a per-VMID register (SH_HIDDEN_PRIVATE_BASE_VMID) by the driver or the HWS (hardware scheduler) firmware. So the size is limited by the amount of address space reserved for this purpose by user mode. But the HW doesn't really care what that size is. The HSA runtime manages the sub-allocation or scratch memory per queue. It knows the size that it allocates and will need to make sure it sub-allocates within that size.

In the queue setup data structures it must somewhere contain information about the offset from the start of scratch memory, and some address swizzling parameters to determine per work item or per wavefront addresses. I'm not familiar with the details of those data structures, and the size limits in the hardware. They would determine an upper limit for the size of scratch backing.

BTW, on Vega10 the way scratch works has been changed, and this ioctl becomes basically a no-op. The SH_HIDDEN_PRIVATE_BASE_VMID register no longer exists. Instead the base address is now provided to the shader directly without being programmed ahead of time by KFD or HWS. Setting up scratch memory per queue is entirely up to the Runtime now.

Regards,
Felix

Quoted 4 lines

If it is fixed, what is the size ?

Thanks,
Oded

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 3aaf8348-46b2-bff4-16fb-65f3fbc2fb48-5C7GfCeVMHo@public.gmane.org

#51 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Am 21.08.2017 um 22:06 schrieb Felix Kuehling:

Quoted 83 lines · Oded Gabbay
Quoted 62 lines · Jerome Glisse
Quoted 30 lines · Felix Kuehling
Quoted 8 lines

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

What kind of memory is suppose to back this virtual address range ? How big is the range suppose to be ? Can it be any valid virtual address ?

My worry here is to ascertain that one can not abuse this ioctl say to set the virtual address to some mmaped shared library code/data section and write something malicious there.

I am assuming that if it has to go through ATS/PASID of the IOMMUv2 then the write protection will be asserted and we will see proper COW (copy on write) due to mmap PRIVATE flags.

Idealy this area should be a special vma and the driver should track its lifetime and cancel GPU jobs if it is unmap. But i am unsure on how dynamic is that scratch memory suppose to be (ie do you allocate new scratch memory with every GPU job or is it allocated once and reuse for every jobs).

Quoted 5 lines

Bigger commit message would be nice too. Like i had tons of i believe valid questions.

Cheers,
Jérôme

Hi Jerome,
Great points.

This is the explanation Felix gave a few days ago on this ioctl in a different email thread:

"Scratch memory is private memory per work-item. It's used when a shader program has too few registers available. With HSA we use flat scratch addressing, where shaders can access private memory in a special scratch aperture using normal memory instructions. Using the same virtual address, each work item gets its own private piece of memory. The hardware does the address translation from the VA in the private aperture to a scratch-backing VA. The application is responsible for allocating the memory to back that scratch area, and to map it somewhere in its virtual address space.

This ioctl tells the hardware (or HWS firmware) the VA of the scratch backing memory."

From this explanation, I think that the user's supplied VA should be
tested that its a valid writable area of the user.
How do you test for that ? could you point me to such a code in the kernel ?
From looking at other drivers that pin host memory, like mellanox nic,
they don't do any special testing for the address they receive from the user.

Quoted 3 lines

Felix,
Is the scratch memory size fixed ? Because I don't see a size argument in the IOCTL.

The hardware needs a continuous pieces of virtual address space for scratch backing. The base address of that continuous region is programmed into a per-VMID register (SH_HIDDEN_PRIVATE_BASE_VMID) by the driver or the HWS (hardware scheduler) firmware. So the size is limited by the amount of address space reserved for this purpose by user mode. But the HW doesn't really care what that size is. The HSA runtime manages the sub-allocation or scratch memory per queue. It knows the size that it allocates and will need to make sure it sub-allocates within that size.

In the queue setup data structures it must somewhere contain information about the offset from the start of scratch memory, and some address swizzling parameters to determine per work item or per wavefront addresses. I'm not familiar with the details of those data structures, and the size limits in the hardware. They would determine an upper limit for the size of scratch backing.

Quoted 5 lines

BTW, on Vega10 the way scratch works has been changed, and this ioctl becomes basically a no-op. The SH_HIDDEN_PRIVATE_BASE_VMID register no longer exists. Instead the base address is now provided to the shader directly without being programmed ahead of time by KFD or HWS. Setting up scratch memory per queue is entirely up to the Runtime now.

So essentially this is actually more a workaround to set a privileged register by the hardware scheduler when it switches between tasks.

Do we have more cases like this? In other words would it make sense to generalize this interface to something like "Please HWS when you switch to one of my tasks can you set register X to value Y"?

Regards,
Christian.

Quoted 4 lines

Regards,
Felix

Quoted 8 lines
Quoted 4 lines

If it is fixed, what is the size ?

Thanks,
Oded

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): f87ac8e2-8cf0-0729-87ed-de172af3499f-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#53 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

Quoted 8 lines · Christian König
Quoted 5 lines

BTW, on Vega10 the way scratch works has been changed, and this ioctl becomes basically a no-op. The SH_HIDDEN_PRIVATE_BASE_VMID register no longer exists. Instead the base address is now provided to the shader directly without being programmed ahead of time by KFD or HWS. Setting up scratch memory per queue is entirely up to the Runtime now.

So essentially this is actually more a workaround to set a privileged register by the hardware scheduler when it switches between tasks.

Sort of. In case we run without HWS it's programmed by the driver once (because we assign VMIDs statically in that case).

Quoted 4 lines

Do we have more cases like this? In other words would it make sense to generalize this interface to something like "Please HWS when you switch to one of my tasks can you set register X to value Y"?

In general, if you're looking for process-specific information that's programmed by the HWS, the MAP_PROCESS PM4 packet definition is a good place to look. Beside the sh_hidden_private_base_vmid it includes information about virtual memory address apertures. Part of this is handled by the set_memory_policy ioctl that's already upstream. More will be added by a dGPU-specific ioctl:

struct kfd_ioctl_set_process_dgpu_aperture_args {
        uint64_t dgpu_base;
        uint64_t dgpu_limit;
        uint32_t gpu_id;
        uint32_t pad;
};

The only other similar thing that comes to mind is the secondary trap handler address. But that's not programmed in a register, but in a memory buffer associated with the first level trap handler.

Regards,
Felix

Quoted 3 lines

Regards,
Christian.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#54 lore raw

Re: [PATCH 22/24] drm/amdkfd: Adding new IOCTL for scratch memory v2

In reply to a message not in the archive
Quoted 9 lines · Jerome Glisse
Quoted 8 lines · Felix Kuehling

From: Moses Reuben <[email protected]>

v2:
* Renamed ALLOC_MEMORY_OF_SCRATCH to SET_SCRATCH_BACKING_VA
* Removed size parameter from the ioctl, it was unused
* Removed hole in ioctl number space
* No more call to write_config_static_mem
* Return correct error code from ioctl

Quoted 3 lines

What kind of memory is suppose to back this virtual address range ? How big is the range suppose to be ? Can it be any valid virtual address ?

Yes.

Quoted 5 lines

My worry here is to ascertain that one can not abuse this ioctl say to set the virtual address to some mmaped shared library code/data section and write something malicious there.

The memory is both read and written by the GPU. It's just data used by the compute shaders. You can't really use this to do something malicious, because the code that accesses this memory runs without special privileges. If you point this to some other memory (shared library code or data), it's no more dangerous than a random memcpy or memset to that address.

It's the user mode driver's responsibility to allocate a big enough address range and provide the virtual address to KFD.

Quoted 3 lines

I am assuming that if it has to go through ATS/PASID of the IOMMUv2

It does on APUs. On dGPUs this memory is accessed by the GPU through GPUVM and it can be backed either by system memory or VRAM. In our current implementation we use VRAM for performance reasons.

Quoted 2 lines

then the write protection will be asserted and we
will see proper COW (copy on write) due to mmap PRIVATE flags.

If nothing is mapped there, the access will fail. I think you'd only get COW in very special situations, e.g. after a fork.

Quoted 3 lines

Idealy this area should be a special vma and the driver should track its lifetime and cancel GPU jobs if it is unmap.

There is nothing special about this memory. If it's unmapped, any subsequent accesses by the GPU will cause a segfault (on APU) or a GPUVM fault (on dGPU).

Quoted 4 lines

But i am unsure on how dynamic is that scratch
memory suppose to be (ie do you allocate new scratch memory with every GPU job or is it allocated once and reuse for every jobs).

It's allocated once when the HSA runtime initialized. The runtime suballocates the scratch backing memory per queue. This relies on the fact that the kernel won't commit actual physical pages until the first access.

On dGPUs it only allocates address space at initialization. When the runtime suballocates a region, the actual VRAM for it is allocated. So we can allocate 4GB of scratch backing virtual address space without consuming any VRAM until it actually gets used.

Regards,
Felix

Quoted 5 lines

Bigger commit message would be nice too. Like i had tons of i believe valid questions.

Cheers,
Jérôme

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#55 lore raw

PATCH 23/24 drm/amdgpu: Add kgd kfd interface get_tile_config() v2

In reply to a message not in the archive

From: Yong Zhao <[email protected]>

v2:
* Removed amdgpu_amdkfd prefix from static functions
* Documented get_tile_config in kgd_kfd_interface.h

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 26 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | 26 +++++++++++++++++++++++
 drivers/gpu/drm/amd/include/kgd_kfd_interface.h   | 14 ++++++++++++
 3 files changed, 66 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +26 -0
index 3793d7b..b9dbbf9 100644
@@ -138,6 +138,31 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
 static void set_scratch_backing_va(struct kgd_dev *kgd,
 					uint64_t va, uint32_t vmid);
 
+/* Because of REG_GET_FIELD() being used, we put this function in the
+ * asic specific file.
+ */
+static int get_tile_config(struct kgd_dev *kgd,
+		struct tile_config *config)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
+
+	config->gb_addr_config = adev->gfx.config.gb_addr_config;
+	config->num_banks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
+				MC_ARB_RAMCFG, NOOFBANK);
+	config->num_ranks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
+				MC_ARB_RAMCFG, NOOFRANKS);
+
+	config->tile_config_ptr = adev->gfx.config.tile_mode_array;
+	config->num_tile_configs =
+			ARRAY_SIZE(adev->gfx.config.tile_mode_array);
+	config->macro_tile_config_ptr =
+			adev->gfx.config.macrotile_mode_array;
+	config->num_macro_tile_configs =
+			ARRAY_SIZE(adev->gfx.config.macrotile_mode_array);
+
+	return 0;
+}
+
 static const struct kfd2kgd_calls kfd2kgd = {
 	.init_gtt_mem_allocation = alloc_gtt_mem,
 	.free_gtt_mem = free_gtt_mem,
@@ -163,6 +188,7 @@ static const struct kfd2kgd_calls kfd2kgd = {
 	.write_vmid_invalidate_request = write_vmid_invalidate_request,
 	.get_fw_version = get_fw_version,
 	.set_scratch_backing_va = set_scratch_backing_va,
+	.get_tile_config = get_tile_config,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +26 -0
index 61f6457..fb6e5db 100644
@@ -97,6 +97,31 @@ static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
 static void set_scratch_backing_va(struct kgd_dev *kgd,
 					uint64_t va, uint32_t vmid);
 
+/* Because of REG_GET_FIELD() being used, we put this function in the
+ * asic specific file.
+ */
+static int get_tile_config(struct kgd_dev *kgd,
+		struct tile_config *config)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
+
+	config->gb_addr_config = adev->gfx.config.gb_addr_config;
+	config->num_banks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
+				MC_ARB_RAMCFG, NOOFBANK);
+	config->num_ranks = REG_GET_FIELD(adev->gfx.config.mc_arb_ramcfg,
+				MC_ARB_RAMCFG, NOOFRANKS);
+
+	config->tile_config_ptr = adev->gfx.config.tile_mode_array;
+	config->num_tile_configs =
+			ARRAY_SIZE(adev->gfx.config.tile_mode_array);
+	config->macro_tile_config_ptr =
+			adev->gfx.config.macrotile_mode_array;
+	config->num_macro_tile_configs =
+			ARRAY_SIZE(adev->gfx.config.macrotile_mode_array);
+
+	return 0;
+}
+
 static const struct kfd2kgd_calls kfd2kgd = {
 	.init_gtt_mem_allocation = alloc_gtt_mem,
 	.free_gtt_mem = free_gtt_mem,
@@ -124,6 +149,7 @@ static const struct kfd2kgd_calls kfd2kgd = {
 	.write_vmid_invalidate_request = write_vmid_invalidate_request,
 	.get_fw_version = get_fw_version,
 	.set_scratch_backing_va = set_scratch_backing_va,
+	.get_tile_config = get_tile_config,
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +14 -0
index 2a9cc5e..94277cb 100644
@@ -87,6 +87,17 @@ struct kgd2kfd_shared_resources {
 	size_t doorbell_start_offset;
 };
 
+struct tile_config {
+	uint32_t *tile_config_ptr;
+	uint32_t *macro_tile_config_ptr;
+	uint32_t num_tile_configs;
+	uint32_t num_macro_tile_configs;
+
+	uint32_t gb_addr_config;
+	uint32_t num_banks;
+	uint32_t num_ranks;
+};
+
 /**
  * struct kfd2kgd_calls
  *
@@ -131,6 +142,8 @@ struct kgd2kfd_shared_resources {
  * @set_scratch_backing_va: Sets VA for scratch backing memory of a VMID.
  * Only used for no cp scheduling mode
  *
+ * @get_tile_config: Returns GPU-specific tiling mode information
+ *
  * This structure contains function pointers to services that the kgd driver
  * provides to amdkfd driver.
  *
@@ -204,6 +217,7 @@ struct kfd2kgd_calls {
 				enum kgd_engine_type type);
 	void (*set_scratch_backing_va)(struct kgd_dev *kgd,
 				uint64_t va, uint32_t vmid);
+	int (*get_tile_config)(struct kgd_dev *kgd, struct tile_config *config);
 };
 
 /**
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#56 lore raw

PATCH 24/24 drm/amdkfd: Implement image tiling mode support v2

In reply to a message not in the archive

From: Yong Zhao <[email protected]>

v2: Removed hole in ioctl number space

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 43 ++++++++++++++++++++++++++++++++
 include/uapi/linux/kfd_ioctl.h           | 28 ++++++++++++++++++++-
 2 files changed, 70 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +43 -0
index 7436d34..e4a8c2e 100644
@@ -883,6 +883,46 @@ static int kfd_ioctl_set_scratch_backing_va(struct file *filep,
 	return err;
 }
 
+static int kfd_ioctl_get_tile_config(struct file *filep,
+		struct kfd_process *p, void *data)
+{
+	struct kfd_ioctl_get_tile_config_args *args = data;
+	struct kfd_dev *dev;
+	struct tile_config config;
+	int err = 0;
+
+	dev = kfd_device_by_id(args->gpu_id);
+
+	dev->kfd2kgd->get_tile_config(dev->kgd, &config);
+
+	args->gb_addr_config = config.gb_addr_config;
+	args->num_banks = config.num_banks;
+	args->num_ranks = config.num_ranks;
+
+	if (args->num_tile_configs > config.num_tile_configs)
+		args->num_tile_configs = config.num_tile_configs;
+	err = copy_to_user((void __user *)args->tile_config_ptr,
+			config.tile_config_ptr,
+			args->num_tile_configs * sizeof(uint32_t));
+	if (err) {
+		args->num_tile_configs = 0;
+		return -EFAULT;
+	}
+
+	if (args->num_macro_tile_configs > config.num_macro_tile_configs)
+		args->num_macro_tile_configs =
+				config.num_macro_tile_configs;
+	err = copy_to_user((void __user *)args->macro_tile_config_ptr,
+			config.macro_tile_config_ptr,
+			args->num_macro_tile_configs * sizeof(uint32_t));
+	if (err) {
+		args->num_macro_tile_configs = 0;
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
 #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
 	[_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \
 			    .cmd_drv = 0, .name = #ioctl}
@@ -939,6 +979,9 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
 
 	AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_SCRATCH_BACKING_VA,
 			kfd_ioctl_set_scratch_backing_va, 0),
+
+	AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_TILE_CONFIG,
+			kfd_ioctl_get_tile_config, 0)
 };
 
 #define AMDKFD_CORE_IOCTL_COUNT	ARRAY_SIZE(amdkfd_ioctls)
include/uapi/linux/kfd_ioctl.h +27 -1
index 1b9c560..7b4567b 100644
@@ -238,6 +238,29 @@ struct kfd_ioctl_set_scratch_backing_va_args {
 	uint32_t pad;
 };
 
+struct kfd_ioctl_get_tile_config_args {
+	/* to KFD: pointer to tile array */
+	uint64_t tile_config_ptr;
+	/* to KFD: pointer to macro tile array */
+	uint64_t macro_tile_config_ptr;
+	/* to KFD: array size allocated by user mode
+	 * from KFD: array size filled by kernel
+	 */
+	uint32_t num_tile_configs;
+	/* to KFD: array size allocated by user mode
+	 * from KFD: array size filled by kernel
+	 */
+	uint32_t num_macro_tile_configs;
+
+	uint32_t gpu_id;		/* to KFD */
+	uint32_t gb_addr_config;	/* from KFD */
+	uint32_t num_banks;		/* from KFD */
+	uint32_t num_ranks;		/* from KFD */
+	/* struct size can be extended later if needed
+	 * without breaking ABI compatibility
+	 */
+};
+
 #define AMDKFD_IOCTL_BASE 'K'
 #define AMDKFD_IO(nr)			_IO(AMDKFD_IOCTL_BASE, nr)
 #define AMDKFD_IOR(nr, type)		_IOR(AMDKFD_IOCTL_BASE, nr, type)
@@ -295,7 +318,10 @@ struct kfd_ioctl_set_scratch_backing_va_args {
 #define AMDKFD_IOC_SET_SCRATCH_BACKING_VA	\
 		AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
 
+#define AMDKFD_IOC_GET_TILE_CONFIG                                      \
+		AMDKFD_IOWR(0x12, struct kfd_ioctl_get_tile_config_args)
+
 #define AMDKFD_COMMAND_START		0x01
-#define AMDKFD_COMMAND_END		0x12
+#define AMDKFD_COMMAND_END		0x13
 
 #endif
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#57 lore raw
In reply to a message not in the archive
Quoted 3 lines

For testing KV with current user mode stack, please use amdgpu. I don't expect this to work with radeon and I'm not planning to spend any effort on making radeon work with a current user mode stack.

In this case any objection to just rip out radeon support?

Christian.

Am 16.08.2017 um 04:59 schrieb Felix Kuehling:

Quoted 124 lines

I merged the last two patch series and made a number of updates as discussed. I also rebased it on Alex's drm-next-4.14-wip branch. All patches applied cleanly without having to resolve any conflicts.

I'm also publishing my branch with this patch series on GitHub to make it easier to test and apply the changes. This KFD branch requires the corresponding Thunk branch from GitHub, which uses a different ioctl ABI from the last ROCm release. The rest of the user mode stack should be OK on top of that Thunk.

https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/tree/fkxamd/drm-next-wip
https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/tree/fxkamd/drm-next-wip

On CZ, hsaconformance passes. OpenCL tests can be run with the current ROCm OpenCL stack. I ran the SHOC benchmark as an example.

On KV, the current ROCm OpenCL driver doesn't work. This is a limitation of the OpenCL driver. I'm trying to find out how hard it would be to change that. In the mean time, some hsaconformance tests can be run on KV. It passes most tests up to 162:code_recursive_kernel_function, where it hangs.

For testing KV with current user mode stack, please use amdgpu. I don't expect this to work with radeon and I'm not planning to spend any effort on making radeon work with a current user mode stack.

Dropped patches:
* drm/amdkfd: Fix double Mutex lock order

Added patches:
* drm/radeon: Return dword offsets of address watch registers
* drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Reordered patch sequence:
I moved "drm/amdgpu: Remove hard-coded assumptions about compute pipes" just after "drm/amdkfd: Fix allocated_queues bitmap initialization" because these two patches fix related problems (how queues are shared between KFD and KGD).

Updated patches:
* drm/amdkfd: Clean up KFD style errors and warnings v2
* drm/amdkfd: Fix goto usage v2
* drm/amdkfd: Handle remaining BUG_ONs more gracefully v2
* drm/amdkfd: Add more error printing to help bringup v2
* drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
* drm/amdkfd: Adding new IOCTL for scratch memory v2
* drm/amdgpu: Add kgd kfd interface get_tile_config() v2
* drm/amdkfd: Implement image tiling mode support v2

Patches that still need a Reviewed-by or Acked-by:
* drm/radeon: Return dword offsets of address watch registers
* drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t)
* drm/amdkfd: Clean up KFD style errors and warnings v2
* drm/amdkfd: Handle remaining BUG_ONs more gracefully v2
* drm/amdkfd: Add more error printing to help bringup v2
* drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID
* drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
* drm/amdkfd: Adding new IOCTL for scratch memory v2

***

Felix Kuehling (13):
drm/amdkfd: Fix typo in dbgdev_wave_reset_wavefronts drm/radeon: Return dword offsets of address watch registers drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t) drm/amdkfd: Fix allocated_queues bitmap initialization drm/amdgpu: Remove hard-coded assumptions about compute pipes drm/amdkfd: Remove BUG_ONs for NULL pointer arguments drm/amdkfd: Fix doorbell initialization and finalization drm/amdkfd: Allocate gtt_sa_bitmap in long units drm/amdkfd: Handle remaining BUG_ONs more gracefully v2 drm/amdkfd: Update PM4 packet headers
drm/amdgpu: Disable GFX PG on CZ
drm/amd: Update MEC HQD loading code for KFD drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Jay Cornwall (1):
drm/amdkfd: Clamp EOP queue size correctly on Gfx8

Kent Russell (5):
drm/amdkfd: Clean up KFD style errors and warnings v2 drm/amdkfd: Consolidate and clean up log commands drm/amdkfd: Change x==NULL/false references to !x drm/amdkfd: Fix goto usage v2
drm/amdkfd: Remove usage of alloc(sizeof(struct...

Moses Reuben (2):
drm/amdgpu: Add kgd/kfd interface to support scratch memory v2 drm/amdkfd: Adding new IOCTL for scratch memory v2

Yong Zhao (3):
drm/amdkfd: Add more error printing to help bringup v2 drm/amdgpu: Add kgd kfd interface get_tile_config() v2 drm/amdkfd: Implement image tiling mode support v2

  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |   4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h         |  16 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 189 ++++++++++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 227 ++++++++++++--
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c              |   2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              |   3 +-
  drivers/gpu/drm/amd/amdgpu/vi.c                    |   3 +-
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 183 ++++++++----
  drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            | 102 +++----
  drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  21 +-
  drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h            |  27 +-
  drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 123 ++++----
  .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 316 ++++++++------------
  .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |   8 +-
  .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |   8 +-
  drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c          |  40 +--
  drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  33 +--
  drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c       |   2 +-
  drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c         |   2 +-
  drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      |  63 ++--
  drivers/gpu/drm/amd/amdkfd/kfd_module.c            |  10 +-
  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h       |   3 +-
  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  62 ++--
  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  46 +--
  drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 294 ++++++------------
  drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |   7 +-
  drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h       | 330 +++------------------
  drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h    | 140 ++++++++-
  drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  32 +-
Quoted 9 lines
  drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  25 +-
  .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  71 ++---
  drivers/gpu/drm/amd/amdkfd/kfd_queue.c             |  12 +-
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  46 +--
  drivers/gpu/drm/amd/include/kgd_kfd_interface.h    |  30 +-
  drivers/gpu/drm/radeon/radeon_kfd.c                |  15 +-
  include/uapi/linux/kfd_ioctl.h                     |  37 ++-
  36 files changed, 1280 insertions(+), 1252 deletions(-)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 5c7f2140-0467-ebdb-87ca-0cd9d642ddbf-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#59 lore raw
Quoted 8 lines · Christian König
Quoted 3 lines

For testing KV with current user mode stack, please use amdgpu. I don't expect this to work with radeon and I'm not planning to spend any effort on making radeon work with a current user mode stack.

In this case any objection to just rip out radeon support?

Christian.

No objection from my side.

Oded

Quoted 142 lines

Am 16.08.2017 um 04:59 schrieb Felix Kuehling:

Quoted 139 lines

I merged the last two patch series and made a number of updates as discussed. I also rebased it on Alex's drm-next-4.14-wip branch. All patches applied cleanly without having to resolve any conflicts.

I'm also publishing my branch with this patch series on GitHub to make it easier to test and apply the changes. This KFD branch requires the corresponding Thunk branch from GitHub, which uses a different ioctl ABI from the last ROCm release. The rest of the user mode stack should be OK on top of that Thunk.

https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/tree/fkxamd/drm-next-wip

https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface/tree/fxkamd/drm-next-wip

On CZ, hsaconformance passes. OpenCL tests can be run with the current ROCm OpenCL stack. I ran the SHOC benchmark as an example.

On KV, the current ROCm OpenCL driver doesn't work. This is a limitation of the OpenCL driver. I'm trying to find out how hard it would be to change that. In the mean time, some hsaconformance tests can be run on KV. It passes most tests up to 162:code_recursive_kernel_function, where it hangs.

For testing KV with current user mode stack, please use amdgpu. I don't expect this to work with radeon and I'm not planning to spend any effort on making radeon work with a current user mode stack.

Dropped patches:
* drm/amdkfd: Fix double Mutex lock order

Added patches:
* drm/radeon: Return dword offsets of address watch registers
* drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Reordered patch sequence:
I moved "drm/amdgpu: Remove hard-coded assumptions about compute pipes" just after "drm/amdkfd: Fix allocated_queues bitmap initialization" because these two patches fix related problems (how queues are shared between KFD and KGD).

Updated patches:
* drm/amdkfd: Clean up KFD style errors and warnings v2
* drm/amdkfd: Fix goto usage v2
* drm/amdkfd: Handle remaining BUG_ONs more gracefully v2
* drm/amdkfd: Add more error printing to help bringup v2
* drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
* drm/amdkfd: Adding new IOCTL for scratch memory v2
* drm/amdgpu: Add kgd kfd interface get_tile_config() v2
* drm/amdkfd: Implement image tiling mode support v2

Patches that still need a Reviewed-by or Acked-by:
* drm/radeon: Return dword offsets of address watch registers
* drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t)
* drm/amdkfd: Clean up KFD style errors and warnings v2
* drm/amdkfd: Handle remaining BUG_ONs more gracefully v2
* drm/amdkfd: Add more error printing to help bringup v2
* drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID
* drm/amdgpu: Add kgd/kfd interface to support scratch memory v2
* drm/amdkfd: Adding new IOCTL for scratch memory v2

***

Felix Kuehling (13):
drm/amdkfd: Fix typo in dbgdev_wave_reset_wavefronts drm/radeon: Return dword offsets of address watch registers drm/amdkfd: Remove bogus divide-by-sizeof(uint32_t) drm/amdkfd: Fix allocated_queues bitmap initialization drm/amdgpu: Remove hard-coded assumptions about compute pipes drm/amdkfd: Remove BUG_ONs for NULL pointer arguments drm/amdkfd: Fix doorbell initialization and finalization drm/amdkfd: Allocate gtt_sa_bitmap in long units drm/amdkfd: Handle remaining BUG_ONs more gracefully v2 drm/amdkfd: Update PM4 packet headers
drm/amdgpu: Disable GFX PG on CZ
drm/amd: Update MEC HQD loading code for KFD drm/amdgpu: Program SH_STATIC_MEM_CONFIG globally, not per-VMID

Jay Cornwall (1):
drm/amdkfd: Clamp EOP queue size correctly on Gfx8

Kent Russell (5):
drm/amdkfd: Clean up KFD style errors and warnings v2 drm/amdkfd: Consolidate and clean up log commands drm/amdkfd: Change x==NULL/false references to !x drm/amdkfd: Fix goto usage v2
drm/amdkfd: Remove usage of alloc(sizeof(struct...

Moses Reuben (2):
drm/amdgpu: Add kgd/kfd interface to support scratch memory v2 drm/amdkfd: Adding new IOCTL for scratch memory v2

Yong Zhao (3):
drm/amdkfd: Add more error printing to help bringup v2 drm/amdgpu: Add kgd kfd interface get_tile_config() v2 drm/amdkfd: Implement image tiling mode support v2

  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |   4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h         |  16 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  | 189 ++++++++++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  | 227 ++++++++++++--
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c              |   2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              |   3 +-
  drivers/gpu/drm/amd/amdgpu/vi.c                    |   3 +-
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 183 ++++++++----
  drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c            | 102 +++----
  drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c            |  21 +-
  drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h            |  27 +-
  drivers/gpu/drm/amd/amdkfd/kfd_device.c            | 123 ++++----
  .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 316
++++++++------------
  .../drm/amd/amdkfd/kfd_device_queue_manager_cik.c  |   8 +-
  .../drm/amd/amdkfd/kfd_device_queue_manager_vi.c   |   8 +-
  drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c          |  40 +--
  drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  33 +--
  drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c       |   2 +-
  drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c         |   2 +-
  drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      |  63 ++--
  drivers/gpu/drm/amd/amdkfd/kfd_module.c            |  10 +-
  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h       |   3 +-
  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c   |  62 ++--
  drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c    |  46 +--
  drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c    | 294
++++++------------
  drivers/gpu/drm/amd/amdkfd/kfd_pasid.c             |   7 +-
  drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers.h       | 330
+++------------------
  drivers/gpu/drm/amd/amdkfd/kfd_pm4_headers_vi.h    | 140 ++++++++-
  drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  32 +-
  drivers/gpu/drm/amd/amdkfd/kfd_process.c           |  25 +-
  .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  71 ++---
  drivers/gpu/drm/amd/amdkfd/kfd_queue.c             |  12 +-
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c          |  46 +--
  drivers/gpu/drm/amd/include/kgd_kfd_interface.h    |  30 +-
  drivers/gpu/drm/radeon/radeon_kfd.c                |  15 +-
  include/uapi/linux/kfd_ioctl.h                     |  37 ++-
  36 files changed, 1280 insertions(+), 1252 deletions(-)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#60 lore raw
In reply to a message not in the archive

Update on KV testing with upstream kernel code:

I was able to make OpenCL work with a simple change. I compiled it from the open-source version available on GitHub
(https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime) and applied the change below.

I'm running the SHOC benchmark right now, and it's looking good so far. I can easily get it to hang with OpenCL conformance tests, so it's not entirely stable. But this is progress and I think a reasonable baseline for validating further KFD changes. Most importantly, it's a real open-source user mode GPU compute stack using KFD, now running on an upstream kernel on both CZ and KV.

Regards,
Felix

commit 2761ff8bb444cf93de4d3d182b38d1da140df986

Author: Felix Kuehling <[email protected]>
Date:   Fri Sep 8 16:14:23 2017 -0400

Enable Kaveri

runtime/device/rocm/rocdevice.cpp +2 -0
index 16db78a..edd3cbd 100644
@@ -76,6 +76,8 @@ static HsaDeviceId getHsaDeviceId(hsa_agent_t device, uint32_t& pci_id) {
   }
 
   switch (gfxipVersion) {
+    case 700:
+      return HSA_SPECTRE_ID;
     case 701:
       return HSA_HAWAII_ID;
     case 801:
Quoted 5 lines · Felix Kuehling

On KV, the current ROCm OpenCL driver doesn't work. This is a limitation of the OpenCL driver. I'm trying to find out how hard it would be to change that. In the mean time, some hsaconformance tests can be run on KV. It passes most tests up to 162:code_recursive_kernel_function, where it hangs.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx