Skip to contentSkip to conversation

drm/amdgpu: fix bug when amdkfd destroys hqd

PATCH Superseded Oded Gabbay 3 participants 5 messages Jul 29, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: fix bug when amdkfd destroys hqd

The wrong define was used to check if the hqd is still active

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +2 -1
index 2daad33..6a45330 100644
@@ -450,7 +450,8 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
 
 	while (true) {
 		temp = RREG32(mmCP_HQD_ACTIVE);
-		if (temp & CP_HQD_ACTIVE__ACTIVE__SHIFT)
+		if (temp & (CP_HQD_ACTIVE__ACTIVE_MASK <<
+				CP_HQD_ACTIVE__ACTIVE__SHIFT))
 			break;
 		if (timeout == 0) {
 			pr_err("kfd: cp queue preemption time out (%dms)\n",
Signature · 6 lines
2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/2 drm/amdkfd: fix bug when initializing sdma vm

A logical AND operation was used during mask and shift, instead of a bitwise AND operation. This patch fixes this bug by changing the operation to bitwise AND.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c | 2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +1 -1
index 23ce774..c6f435a 100644
@@ -143,7 +143,7 @@ static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
 				get_sh_mem_bases_32(qpd_to_pdd(qpd));
 	else
 		value |= ((get_sh_mem_bases_nybble_64(qpd_to_pdd(qpd))) <<
-				SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &&
+				SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &
 				SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE_MASK;
 
 	q->properties.sdma_vm_addr = value;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +1 -1
index 44c38e8..7e9cae9 100644
@@ -155,7 +155,7 @@ static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
 				get_sh_mem_bases_32(qpd_to_pdd(qpd));
 	else
 		value |= ((get_sh_mem_bases_nybble_64(qpd_to_pdd(qpd))) <<
-				SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &&
+				SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &
 				SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE_MASK;
 
 	q->properties.sdma_vm_addr = value;
Signature · 6 lines
2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Oded Gabbay
Quoted 12 lines · Oded Gabbay

The wrong define was used to check if the hqd is still active

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +0 -0
index 2daad33..6a45330 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, · line 454

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +2 -1
@@ -450,7 +450,8 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
 
        while (true) {
                temp = RREG32(mmCP_HQD_ACTIVE);
-               if (temp & CP_HQD_ACTIVE__ACTIVE__SHIFT)
+               if (temp & (CP_HQD_ACTIVE__ACTIVE_MASK <<
+                               CP_HQD_ACTIVE__ACTIVE__SHIFT))

It's a bit moot here since the shift is 0, but I thought the mask normally included the shift already...

#define CP_MQD_BASE_ADDR__BASE_ADDR_MASK 0xfffffffc #define CP_MQD_BASE_ADDR__BASE_ADDR__SHIFT 0x2

#define CP_HPD_EOP_CONTROL__PEND_SIG_SEM_MASK 0x80000000 #define CP_HPD_EOP_CONTROL__PEND_SIG_SEM__SHIFT 0x1f

etc.

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +0 -1
                        break;
                if (timeout == 0) {
                        pr_err("kfd: cp queue preemption time out (%dms)\n",
--

2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 23 lines · Ilia Mirkin
Quoted 12 lines · Oded Gabbay

The wrong define was used to check if the hqd is still active

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +0 -0
index 2daad33..6a45330 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, · line 454

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +2 -1
@@ -450,7 +450,8 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
 
        while (true) {
                temp = RREG32(mmCP_HQD_ACTIVE);
-               if (temp & CP_HQD_ACTIVE__ACTIVE__SHIFT)
+               if (temp & (CP_HQD_ACTIVE__ACTIVE_MASK <<
+                               CP_HQD_ACTIVE__ACTIVE__SHIFT))

It's a bit moot here since the shift is 0, but I thought the mask normally included the shift already...

Quoted 8 lines

#define CP_MQD_BASE_ADDR__BASE_ADDR_MASK 0xfffffffc #define CP_MQD_BASE_ADDR__BASE_ADDR__SHIFT 0x2

#define CP_HPD_EOP_CONTROL__PEND_SIG_SEM_MASK 0x80000000 #define CP_HPD_EOP_CONTROL__PEND_SIG_SEM__SHIFT 0x1f

etc.

Absolutely correct and although it is muted here, still best practice is to fix that.
Thanks!

Oded

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +0 -1
                        break;
                if (timeout == 0) {
                        pr_err("kfd: cp queue preemption time out (%dms)\n",
--

2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdkfd: fix bug when initializing sdma vm

In reply to Oded Gabbay
Quoted 5 lines · Oded Gabbay

A logical AND operation was used during mask and shift, instead of a bitwise AND operation. This patch fixes this bug by changing the operation to bitwise AND.

Quoted 32 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c | 2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c +1 -1
index 23ce774..c6f435a 100644
@@ -143,7 +143,7 @@ static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
                                get_sh_mem_bases_32(qpd_to_pdd(qpd));
        else
                value |= ((get_sh_mem_bases_nybble_64(qpd_to_pdd(qpd))) <<
-                               SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &&
+                               SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &
                                SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE_MASK;
 
        q->properties.sdma_vm_addr = value;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_vi.c +1 -2
index 44c38e8..7e9cae9 100644
@@ -155,7 +155,7 @@ static void init_sdma_vm(struct device_queue_manager *dqm, struct queue *q,
                                get_sh_mem_bases_32(qpd_to_pdd(qpd));
        else
                value |= ((get_sh_mem_bases_nybble_64(qpd_to_pdd(qpd))) <<
-                               SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &&
+                               SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE__SHIFT) &
                                SDMA0_RLC0_VIRTUAL_ADDR__SHARED_BASE_MASK;
 
        q->properties.sdma_vm_addr = value;
--
Quoted 2 lines

2.4.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel