drm/amdgpu: Fix module unload hang by KIQ IRQ set
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fix module unload hang by KIQ IRQ set
In some cases, manually insmod/rmmod amdgpu is necessary. When unloading amdgpu, the KIQ IRQ enable/disable function will case system hang. The root cause is, in the sequence of function amdgpu_fini, the sw_fini of IP block AMD_IP_BLOCK_TYPE_GFX will be invoked earlier than that of AMD_IP_BLOCK_TYPE_IH. So continue to use the variable freed by AMD_IP_BLOCK_TYPE_GFX will cause system hang.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -793,6 +793,8 @@ struct amdgpu_kiq {struct amdgpu_bo *eop_obj;struct amdgpu_ring ring;struct amdgpu_irq_src irq; +u32 me; +u32 pipe; };/*
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +8 -9
@@ -1390,12 +1390,15 @@ static int gfx_v8_0_kiq_init_ring(struct amdgpu_device *adev,if (adev->gfx.mec2_fw) { ring->me =2 ; ring->pipe =0 ; + adev->gfx.kiq.me =2 ; + adev->gfx.kiq.pipe =0 ; }else { ring->me =1 ; ring->pipe =1 ; + adev->gfx.kiq.me =1 ; + adev->gfx.kiq.pipe =1 ; } - irq->data = ring; ring->queue =0 ;sprintf (ring->name,"kiq %d.%d.%d" , ring->me, ring->pipe, ring->queue); r = amdgpu_ring_init(adev, ring, 1024,
@@ -1410,7 +1413,6 @@ static void gfx_v8_0_kiq_free_ring(struct amdgpu_ring *ring, {amdgpu_wb_free (ring->adev, ring->adev->virt.reg_val_offs);amdgpu_ring_fini (ring); - irq->data =NULL ; }#define MEC_HPD_SIZE 2048
@@ -6927,15 +6929,12 @@ static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, enum amdgpu_interrupt_state state) {uint32_t tmp, target; -struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; -BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); - -if (ring->me ==1 ) +if (adev->gfx.kiq.me ==1 ) target = mmCP_ME1_PIPE0_INT_CNTL;else target = mmCP_ME2_PIPE0_INT_CNTL; - target += ring->pipe; + target += adev->gfx.kiq.pipe;switch (type) {case AMDGPU_CP_KIQ_IRQ_DRIVER0 :
@@ -6973,7 +6972,7 @@ static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry) {u8 me_id, pipe_id, queue_id; -struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; +struct amdgpu_ring *ring = &(adev->gfx.kiq.ring);BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ ));
@@ -7380,4 +7379,4 @@ static void gfx_v8_0_compute_mqd_soft_fini(struct amdgpu_device *adev) ring = &adev->gfx.kiq.ring;amdgpu_bo_free_kernel (&ring->mqd_obj, &ring->mqd_gpu_addr, (void **)&ring->mqd_ptr); -} +}
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): 1487242099-16380-1-git-send-email-trigger.huang-5C7GfCeVMHo@public.gmane.org
Liu, Monk
Reviewed-by Monk Liu________________________________
发件人: Trigger Huang <[email protected]>
发送时间: 2017年2月16日 18:48:19
收件人: [email protected]
抄送: Liu, Monk; Yu, Xiangliang; Huang, Trigger
主题: [PATCH] drm/amdgpu: Fix module unload hang by KIQ IRQ set
In some cases, manually insmod/rmmod amdgpu is necessary. When unloading amdgpu, the KIQ IRQ enable/disable function will case system hang. The root cause is, in the sequence of function amdgpu_fini, the sw_fini of IP block AMD_IP_BLOCK_TYPE_GFX will be invoked earlier than that of AMD_IP_BLOCK_TYPE_IH. So continue to use the variable freed by AMD_IP_BLOCK_TYPE_GFX will cause system hang.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -793,6 +793,8 @@ struct amdgpu_kiq {struct amdgpu_bo *eop_obj;struct amdgpu_ring ring;struct amdgpu_irq_src irq; +u32 me; +u32 pipe; };/*
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +8 -9
@@ -1390,12 +1390,15 @@ static int gfx_v8_0_kiq_init_ring(struct amdgpu_device *adev,if (adev->gfx.mec2_fw) { ring->me =2 ; ring->pipe =0 ; + adev->gfx.kiq.me =2 ; + adev->gfx.kiq.pipe =0 ; }else { ring->me =1 ; ring->pipe =1 ; + adev->gfx.kiq.me =1 ; + adev->gfx.kiq.pipe =1 ; } - irq->data = ring; ring->queue =0 ;sprintf (ring->name,"kiq %d.%d.%d" , ring->me, ring->pipe, ring->queue); r = amdgpu_ring_init(adev, ring, 1024,
@@ -1410,7 +1413,6 @@ static void gfx_v8_0_kiq_free_ring(struct amdgpu_ring *ring, {amdgpu_wb_free (ring->adev, ring->adev->virt.reg_val_offs);amdgpu_ring_fini (ring); - irq->data =NULL ; }#define MEC_HPD_SIZE 2048
@@ -6927,15 +6929,12 @@ static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, enum amdgpu_interrupt_state state) {uint32_t tmp, target; -struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; -BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); - -if (ring->me ==1 ) +if (adev->gfx.kiq.me ==1 ) target = mmCP_ME1_PIPE0_INT_CNTL;else target = mmCP_ME2_PIPE0_INT_CNTL; - target += ring->pipe; + target += adev->gfx.kiq.pipe;switch (type) {case AMDGPU_CP_KIQ_IRQ_DRIVER0 :
@@ -6973,7 +6972,7 @@ static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry) {u8 me_id, pipe_id, queue_id; -struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; +struct amdgpu_ring *ring = &(adev->gfx.kiq.ring);BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ ));
@@ -7380,4 +7379,4 @@ static void gfx_v8_0_compute_mqd_soft_fini(struct amdgpu_device *adev) ring = &adev->gfx.kiq.ring;amdgpu_bo_free_kernel (&ring->mqd_obj, &ring->mqd_gpu_addr, (void **)&ring->mqd_ptr); -} +}
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Trigger,
Can you try to move src->data= NULL into gfx_v8_0_kiq_set_interrupt_state function? I think it is more simple and clear.
Thanks!
Xiangliang Yu
Quoted 100 lines
-----Original Message-----
From: Trigger Huang [mailto:[email protected]]
Sent: Thursday, February 16, 2017 6:48 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>; Yu, Xiangliang <[email protected]>; Huang, Trigger <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix module unload hang by KIQ IRQ setIn some cases, manually insmod/rmmod amdgpu is necessary. When unloading amdgpu, the KIQ IRQ enable/disable function will case system hang. The root cause is, in the sequence of function
amdgpu_fini, thesw_finiof IP blockAMD_IP_BLOCK_TYPE_GFXwill be invoked earlier than that ofAMD_IP_BLOCK_TYPE_IH. So continue to use the variable freed byAMD_IP_BLOCK_TYPE_GFXwill cause system hang.Signed-off-by Trigger Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0@@ -793,6 +793,8 @@ struct amdgpu_kiq {struct amdgpu_bo *eop_obj;struct amdgpu_ring ring;struct amdgpu_irq_src irq; +u32 me; +u32 pipe; };/* drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4
-1@@ -1390,12 +1390,15 @@ static int gfx_v8_0_kiq_init_ring(struct amdgpu_device *adev, if (adev->gfx.mec2_fw) { ring->me =2 ; ring->pipe =0 ; + adev->gfx.kiq.me =2 ; + adev->gfx.kiq.pipe =0 ; } else { ring->me =1 ; ring->pipe =1 ; + adev->gfx.kiq.me =1 ; + adev->gfx.kiq.pipe =1 ; } - irq->data = ring; ring->queue =0 ; sprintf(ring->name, "kiq %d.%d.%d", ring->me, ring->pipe, ring-Quoted 1 line
queue);
r = amdgpu_ring_init(adev, ring, 1024, @@ -1410,7 +1413,6 @@ static
void gfx_v8_0_kiq_free_ring(structamdgpu_ring*ring, {drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2
-6amdgpu_wb_free (ring->adev, ring->adev->virt.reg_val_offs);amdgpu_ring_fini (ring); - irq->data =NULL ; }#define MEC_HPD_SIZE 2048@@ -6927,15 +6929,12 @@ static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, enum amdgpu_interrupt_state state) { uint32_t tmp, target; -struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; -BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); - -if (ring->me ==1 ) +if (adev->gfx.kiq.me ==1 ) target = mmCP_ME1_PIPE0_INT_CNTL;else target = mmCP_ME2_PIPE0_INT_CNTL; - target += ring->pipe; + target += adev->gfx.kiq.pipe;switch (type) {drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1
-1case AMDGPU_CP_KIQ_IRQ_DRIVER0 :@@ -6973,7 +6972,7 @@ static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry) {u8 me_id, pipe_id, queue_id; -struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; +struct amdgpu_ring *ring = &(adev->gfx.kiq.ring);BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ ));@@ -7380,4 +7379,4 @@ static void gfx_v8_0_compute_mqd_soft_fini(struct amdgpu_device *adev) ring = &adev->gfx.kiq.ring; amdgpu_bo_free_kernel(&ring->mqd_obj, &ring->mqd_gpu_addr,
Quoted 4 lines
(void **)&ring->mqd_ptr); -} \ No newline at end of file +}
--
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): DM5PR12MB1705C5254EB2867EF39417B8EB5D0-2J9CzHegvk9755J/[email protected]
Hi Xiangliang,
Thanks for your suggestions, I will make a new patch according to the discussion
Thanks & Best Wishes,
Trigger Huang
-----Original Message-----
From: Yu, Xiangliang
Sent: Friday, February 17, 2017 2:15 PM
To: Huang, Trigger <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>; Huang, Trigger <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: Fix module unload hang by KIQ IRQ set
Hi Trigger,
Can you try to move src->data= NULL into gfx_v8_0_kiq_set_interrupt_state function? I think it is more simple and clear.
Thanks!
Xiangliang Yu
Quoted 99 lines
-----Original Message-----
From: Trigger Huang [mailto:[email protected]]
Sent: Thursday, February 16, 2017 6:48 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>; Yu, Xiangliang <[email protected]>; Huang, Trigger <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix module unload hang by KIQ IRQ setIn some cases, manually insmod/rmmod amdgpu is necessary. When unloading amdgpu, the KIQ IRQ enable/disable function will case system hang. The root cause is, in the sequence of function
amdgpu_fini, thesw_finiof IP blockAMD_IP_BLOCK_TYPE_GFXwill be invoked earlier than that ofAMD_IP_BLOCK_TYPE_IH. So continue to use the variable freed byAMD_IP_BLOCK_TYPE_GFXwill cause system hang.Signed-off-by Trigger Huang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0@@ -793,6 +793,8 @@ struct amdgpu_kiq {struct amdgpu_bo *eop_obj;struct amdgpu_ring ring;struct amdgpu_irq_src irq; +u32 me; +u32 pipe; };/* drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4
-1@@ -1390,12 +1390,15 @@ static int gfx_v8_0_kiq_init_ring(struct amdgpu_device *adev, if (adev->gfx.mec2_fw) { ring->me =2 ; ring->pipe =0 ; + adev->gfx.kiq.me =2 ; + adev->gfx.kiq.pipe =0 ; } else { ring->me =1 ; ring->pipe =1 ; + adev->gfx.kiq.me =1 ; + adev->gfx.kiq.pipe =1 ; } - irq->data = ring; ring->queue =0 ; sprintf(ring->name, "kiq %d.%d.%d", ring->me, ring->pipe, ring-Quoted 1 line
queue);
r = amdgpu_ring_init(adev, ring, 1024, @@ -1410,7 +1413,6 @@ static
void gfx_v8_0_kiq_free_ring(structamdgpu_ring*ring, {drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +2
-6amdgpu_wb_free (ring->adev, ring->adev->virt.reg_val_offs);amdgpu_ring_fini (ring); - irq->data =NULL ; }#define MEC_HPD_SIZE 2048@@ -6927,15 +6929,12 @@ static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, enum amdgpu_interrupt_state state) { uint32_t tmp, target; -struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; -BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ )); - -if (ring->me ==1 ) +if (adev->gfx.kiq.me ==1 ) target = mmCP_ME1_PIPE0_INT_CNTL;else target = mmCP_ME2_PIPE0_INT_CNTL; - target += ring->pipe; + target += adev->gfx.kiq.pipe;switch (type) {drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1
-1case AMDGPU_CP_KIQ_IRQ_DRIVER0 :@@ -6973,7 +6972,7 @@ static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry) {u8 me_id, pipe_id, queue_id; -struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; +struct amdgpu_ring *ring = &(adev->gfx.kiq.ring);BUG_ON (!ring || (ring->funcs->type !=AMDGPU_RING_TYPE_KIQ ));@@ -7380,4 +7379,4 @@ static void gfx_v8_0_compute_mqd_soft_fini(struct amdgpu_device *adev) ring = &adev->gfx.kiq.ring; amdgpu_bo_free_kernel(&ring->mqd_obj, &ring->mqd_gpu_addr, (void
Quoted 4 lines
**)&ring->mqd_ptr); -} \ No newline at end of file +}
--
2.7.4
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx