drm/amdgpu/sriov:unmap KCQ in gfx hw_fini
Subsystems (2)
PATCH 1/4 drm/amdgpu/sriov:unmap KCQ in gfx hw_fini
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 57 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +57 -0
@@ -5034,6 +5034,57 @@ static int gfx_v8_0_hw_init(void *handle)return r; } +static int gfx_v8_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = kiq_ring->adev; +uint32_t scratch, tmp =0 ; +int r, i; + + r =amdgpu_gfx_scratch_get (adev, &scratch); +if (r) { +DRM_ERROR ("Failed to get scratch reg (%d).\n" , r); +return r; + } +WREG32 (scratch,0xCAFEDEAD ); + + r =amdgpu_ring_alloc (kiq_ring,10 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + } + +/* unmap queues */ +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); +amdgpu_ring_write (kiq_ring,/* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ +PACKET3_UNMAP_QUEUES_ACTION (1 ) |/* RESET_QUEUES */ +PACKET3_UNMAP_QUEUES_QUEUE_SEL (0 ) | +PACKET3_UNMAP_QUEUES_ENGINE_SEL (0 ) | +PACKET3_UNMAP_QUEUES_NUM_QUEUES (1 )); +amdgpu_ring_write (kiq_ring,PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0 (ring->doorbell_index)); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +/* write to scratch for completion */ +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_SET_UCONFIG_REG ,1 )); +amdgpu_ring_write (kiq_ring, (scratch -PACKET3_SET_UCONFIG_REG_START )); +amdgpu_ring_write (kiq_ring,0xDEADBEEF ); +amdgpu_ring_commit (kiq_ring); + +for (i =0 ; i < adev->usec_timeout; i++) { + tmp =RREG32 (scratch); +if (tmp ==0xDEADBEEF ) +break ; +DRM_UDELAY (1 ); + } +if (i >= adev->usec_timeout) { +DRM_ERROR ("KCQ disabled failed (scratch(0x%04X)=0x%08X)\n" , scratch, tmp); + r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); +return r; +} +static int gfx_v8_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -5041,6 +5092,12 @@ static int gfx_v8_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );if (amdgpu_sriov_vf (adev)) { +int i; + +/* disable KCQ to avoid CPC touch memory not valid anymore */ +for (i =0 ; i < adev->gfx.num_compute_rings; i++) +gfx_v8_0_kcq_disable (&adev->gfx.kiq.ring, &adev->gfx.compute_ring[i]); +pr_debug ("For SRIOV client, shouldn't do anything.\n" );return 0 ; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +58 -0
70 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
A message that is not in the archive (sent off-list or not yet received): 1505977944-9466-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
PATCH 2/4 drm/amdgpu/sriov:alloc KIQ MQD in VRAM
this way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV SAVE_VF will not fail
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(struct amdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r =amdgpu_bo_create_kernel (adev, mqd_size,PAGE_SIZE , -AMDGPU_GEM_DOMAIN_GTT , &ring->mqd_obj, + (amdgpu_sriov_vf (adev) ?AMDGPU_GEM_DOMAIN_VRAM :AMDGPU_GEM_DOMAIN_GTT ), &ring->mqd_obj, &ring->mqd_gpu_addr, &ring->mqd_ptr);if (r) {dev_warn (adev->dev,"failed to create ring mqd ob (%d)" , r);
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): 1505977944-9466-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
Am 21.09.2017 um 09:12 schrieb Monk Liu:
Quoted 15 lines
this way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV
SAVE_VFwill not failChange-Id Iccef37a70c193c83af80961dae2c67ed859f1a13Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_compute_mqd_sw_init(struct amdgpu_device *adev, · line 264
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(struct amdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, + (amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT), &ring->mqd_obj,
Looks like that line is getting to long, please wrap it a bit.
Apart from that the series looks good to me, but I don't have the slightest idea if that is really correct what you do with the KCQ.
Patch #3 is Reviewed-by: Christian König <[email protected]>, the rest is Acked-by: Christian König <[email protected]>
Maybe wait for Alex/Felix to have another look as well.
Regards,
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_compute_mqd_sw_init(struct amdgpu_device *adev, · line 267
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0&ring->mqd_gpu_addr, &ring->mqd_ptr);if (r) {dev_warn (adev->dev,"failed to create ring mqd ob (%d)" , r);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
In reply to a message not in the archiveQuoted 31 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMthis way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV
SAVE_VFwill not failChange-Id Iccef37a70c193c83af80961dae2c67ed859f1a13Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(structamdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, + (amdgpu_sriov_vf(adev) ?
Quoted 1 line
AMDGPU_GEM_DOMAIN_VRAM:AMDGPU_GEM_DOMAIN_GTT), &ring-
Here as well. Might as well vram for both VF and bare metal for consistency.
Alex
Quoted 9 lines
Quoted 1 line
mqd_obj,
&ring->mqd_gpu_addr, &ring-Quoted 1 line
mqd_ptr);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0if (r) { dev_warn(adev->dev, "failed to create ring mqd ob(%d)", r);
--
2.7.4
Quoted 4 lines
_______________________________________________
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): BN6PR12MB1652DC23F6ED8F72C6124103F7660-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
Alex
Since CPU visible VRAM resource is very limited, I'm not sure BM like it or not,
Besides, after we unify the code we'll forget why we do this on SRIOV and in future someone will change it back to GTT domain (some guy care bare-metal only) and lead to SRIOV issues and that time it's hard to recall what's going on
I prefer keep things different that's good to maintain the stability
BR Monk
-----Original Message-----
From: Deucher, Alexander
Sent: 2017年9月21日 23:00
To: Liu, Monk <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
Quoted 30 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMthis way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV
SAVE_VFwill not failChange-Id Iccef37a70c193c83af80961dae2c67ed859f1a13Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(structamdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, + (amdgpu_sriov_vf(adev) ?
Quoted 1 line
AMDGPU_GEM_DOMAIN_VRAM:AMDGPU_GEM_DOMAIN_GTT), &ring-
Here as well. Might as well vram for both VF and bare metal for consistency.
Alex
Quoted 8 lines
Quoted 1 line
mqd_obj,
&ring->mqd_gpu_addr, &ring-Quoted 1 line
mqd_ptr);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-1if (r) {dev_warn (adev->dev,"failed to create ring mqd ob (%d)" , r); --2.7.4
Quoted 4 lines
_______________________________________________
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): BLUPR12MB0449F001D5A50897C277AB5284670-7LeqcoF/[email protected]
Deucher, Alexander
Acked-by Alex DeucherRE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
Quoted 6 lines
-----Original Message-----
From: Liu, Monk
Sent: Thursday, September 21, 2017 11:37 PM
To: Deucher, Alexander; [email protected]
Subject: RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
Quoted 8 lines
Alex
Since CPU visible VRAM resource is very limited, I'm not sure BM like it or not,
Besides, after we unify the code we'll forget why we do this on SRIOV and in future someone will change it back to GTT domain (some guy care bare- metal only) and lead to SRIOV issues and that time it's hard to recall what's going on
You could add a comment. I'm ok either way for this one.
Alex
Quoted 46 lines
I prefer keep things different that's good to maintain the stability
BR Monk
-----Original Message-----
From: Deucher, Alexander
Sent: 2017年9月21日 23:00
To: Liu, Monk <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMQuoted 30 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMthis way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV
SAVE_VFwill not failChange-Id Iccef37a70c193c83af80961dae2c67ed859f1a13Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(structamdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, + (amdgpu_sriov_vf(adev) ?Quoted 1 line
AMDGPU_GEM_DOMAIN_VRAM:AMDGPU_GEM_DOMAIN_GTT), &ring-Here as well. Might as well vram for both VF and bare metal for consistency.
Quoted 15 lines
Alex
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
Quoted 5 lines
Quoted 1 line
mqd_obj,
&ring->mqd_gpu_addr, &ring-Quoted 1 line
mqd_ptr);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0if (r) { dev_warn(adev->dev, "failed to create ring mqd ob(%d)", r);
Quoted 7 lines
--
2.7.4_______________________________________________
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
Re: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
In reply to a message not in the archiveHi Monk,
I agree with Alex here. We should keep the SRIOV specialized handling to a minimum.
Please add a code comment if you think somebody could accidentally change the code back.
Regards,
Christian.
Am 22.09.2017 um 05:37 schrieb Liu, Monk:
Quoted 59 lines
Alex
Since CPU visible VRAM resource is very limited, I'm not sure BM like it or not,
Besides, after we unify the code we'll forget why we do this on SRIOV and in future someone will change it back to GTT domain (some guy care bare-metal only) and lead to SRIOV issues and that time it's hard to recall what's going onI prefer keep things different that's good to maintain the stability
BR Monk
-----Original Message-----
From: Deucher, Alexander
Sent: 2017年9月21日 23:00
To: Liu, Monk <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMQuoted 30 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMthis way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV
SAVE_VFwill not failChange-Id Iccef37a70c193c83af80961dae2c67ed859f1a13Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(structamdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, + (amdgpu_sriov_vf(adev) ?Quoted 1 line
AMDGPU_GEM_DOMAIN_VRAM:AMDGPU_GEM_DOMAIN_GTT), &ring-Here as well. Might as well vram for both VF and bare metal for consistency.
Alex
Quoted 8 lines
Quoted 1 line
mqd_obj,
&ring->mqd_gpu_addr, &ring-Quoted 1 line
mqd_ptr);if (r) {
dev_warn(adev->dev, "failed to create ring mqd ob (%d)", r);
--
2.7.4
Quoted 8 lines
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): 706a40c1-ecb8-258c-5249-ce87bbca0b18-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
alright
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: 2017年9月22日 15:15
To: Liu, Monk <[email protected]>; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM
Hi Monk,
I agree with Alex here. We should keep the SRIOV specialized handling to a minimum.
Please add a code comment if you think somebody could accidentally change the code back.
Regards,
Christian.
Am 22.09.2017 um 05:37 schrieb Liu, Monk:
Quoted 62 lines
Alex
Since CPU visible VRAM resource is very limited, I'm not sure BM like it or not, Besides, after we unify the code we'll forget why we do this on SRIOV and in future someone will change it back to GTT domain (some guy care bare-metal only) and lead to SRIOV issues and that time it's hard to recall what's going on
I prefer keep things different that's good to maintain the stability
BR Monk
-----Original Message-----
From: Deucher, Alexander
Sent: 2017年9月21日 23:00
To: Liu, Monk <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMQuoted 30 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAMthis way after KIQ MQD released in drv unloading, CPC can still let KIQ access this MQD thus RLCV
SAVE_VFwill not failChange-Id Iccef37a70c193c83af80961dae2c67ed859f1a13Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -261,7 +261,7 @@ int amdgpu_gfx_compute_mqd_sw_init(structamdgpu_device *adev, ring = &adev->gfx.kiq.ring;if (!ring->mqd_obj) { r = amdgpu_bo_create_kernel(adev, mqd_size, PAGE_SIZE, - AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, + (amdgpu_sriov_vf(adev) ?Quoted 1 line
AMDGPU_GEM_DOMAIN_VRAM:AMDGPU_GEM_DOMAIN_GTT), &ring-Here as well. Might as well vram for both VF and bare metal for consistency.
Alex
Quoted 8 lines
Quoted 1 line
mqd_obj,
&ring->mqd_gpu_addr, &ring-Quoted 1 line
mqd_ptr);if (r) {
dev_warn(adev->dev, "failed to create ring mqd ob (%d)", r);
--
2.7.4
Quoted 8 lines
Quoted 4 lines
_______________________________________________
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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu:fix uvd ring fini routine(v2)
In reply to a message not in the archivefix missing finish uvd enc_ring.
v2:
since the adev pointer check in already in ring_fini so drop the check outsider
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4 -0
@@ -269,6 +269,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)int amdgpu_uvd_sw_fini (struct amdgpu_device *adev) { +int i;kfree (adev->uvd.saved_bo);amd_sched_entity_fini (&adev->uvd.ring.sched, &adev->uvd.entity);
@@ -279,6 +280,9 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)amdgpu_ring_fini (&adev->uvd.ring); +for (i =0 ; i <AMDGPU_MAX_UVD_ENC_RINGS ; ++i) +amdgpu_ring_fini (&adev->uvd.ring_enc[i]); +release_firmware (adev->uvd.fw);return 0 ;
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): 1505977944-9466-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH 3/4] drm/amdgpu:fix uvd ring fini routine(v2)
Quoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 3/4] drm/amdgpu:fix uvd ring fini routine(v2)
Quoted 7 lines
fix missing finish uvd
enc_ring.
v2:
since the adev pointer check in already inring_finiso drop the check outsiderChange-Id Ib74237ca5adcb3b128c9b751fced0b7db7b09e86Signed-off-by Monk Liu <[email protected]>
Quoted 32 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1
-0@@ -269,6 +269,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)int amdgpu_uvd_sw_fini (struct amdgpu_device *adev) { +int i;kfree (adev->uvd.saved_bo);drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3
-0amd_sched_entity_fini (&adev->uvd.ring.sched, &adev->uvd.entity);@@ -279,6 +280,9 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)amdgpu_ring_fini (&adev->uvd.ring); +for (i =0 ; i <AMDGPU_MAX_UVD_ENC_RINGS ; ++i) +amdgpu_ring_fini (&adev->uvd.ring_enc[i]); +release_firmware (adev->uvd.fw);return 0;
--
2.7.4
Quoted 4 lines
_______________________________________________
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
PATCH 4/4 drm/amdgpu:fix firmware memoryleak
In reply to a message not in the archivethis fix memory leak due to request_firmware after driver unloaded
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 +++++ 3 files changed, 31 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
@@ -92,6 +92,12 @@ static int psp_sw_init(void *handle)static int psp_sw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +release_firmware (adev->psp.sos_fw); + adev->psp.sos_fw =NULL ; +release_firmware (adev->psp.asd_fw); + adev->psp.asd_fw =NULL ;return 0 ; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +20 -0
@@ -384,6 +384,25 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)return r; } + +static void gfx_v9_0_free_microcode (struct amdgpu_device *adev) +{ +release_firmware (adev->gfx.pfp_fw); + adev->gfx.pfp_fw =NULL ; +release_firmware (adev->gfx.me_fw); + adev->gfx.me_fw =NULL ; +release_firmware (adev->gfx.ce_fw); + adev->gfx.ce_fw =NULL ; +release_firmware (adev->gfx.rlc_fw); + adev->gfx.rlc_fw =NULL ; +release_firmware (adev->gfx.mec_fw); + adev->gfx.mec_fw =NULL ; +release_firmware (adev->gfx.mec2_fw); + adev->gfx.mec2_fw =NULL ; + +kfree (adev->gfx.rlc.register_list_format); +} +static int gfx_v9_0_init_microcode (struct amdgpu_device *adev) {const char *chip_name;
@@ -1429,6 +1448,7 @@ static int gfx_v9_0_sw_fini(void *handle)gfx_v9_0_mec_fini (adev);gfx_v9_0_ngg_fini (adev); +gfx_v9_0_free_microcode (adev);return 0 ; }
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +5 -0
@@ -1264,6 +1264,11 @@ static int sdma_v4_0_sw_fini(void *handle)for (i =0 ; i < adev->sdma.num_instances; i++)amdgpu_ring_fini (&adev->sdma.instance[i].ring); +for (i =0 ; i < adev->sdma.num_instances; i++) { +release_firmware (adev->sdma.instance[i].fw); + adev->sdma.instance[i].fw =NULL ; + } +return 0 ; }
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): 1505977944-9466-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH 4/4] drm/amdgpu:fix firmware memoryleak
Quoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 4/4] drm/amdgpu:fix firmware memoryleak
Quoted 5 lines
this fix memory leak due to
request_firmwareafter driver unloadedChange-Id I7b4724deea0a095189c344eea3801e456e9cced0Signed-off-by Monk Liu <[email protected]>
Bonus points if you send out a patch to fix gmc for mc firmware as well.
Alex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 +++++ 3 files changed, 31 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6
-0@@ -92,6 +92,12 @@ static int psp_sw_init(void *handle)static int psp_sw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +release_firmware (adev->psp.sos_fw); + adev->psp.sos_fw =NULL ; +release_firmware (adev->psp.asd_fw); + adev->psp.asd_fw =NULL ;return 0 ; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +19
-0@@ -384,6 +384,25 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)return r; } + +static void gfx_v9_0_free_microcode (struct amdgpu_device *adev) +{ +release_firmware (adev->gfx.pfp_fw); + adev->gfx.pfp_fw =NULL ; +release_firmware (adev->gfx.me_fw); + adev->gfx.me_fw =NULL ; +release_firmware (adev->gfx.ce_fw); + adev->gfx.ce_fw =NULL ; +release_firmware (adev->gfx.rlc_fw); + adev->gfx.rlc_fw =NULL ; +release_firmware (adev->gfx.mec_fw); + adev->gfx.mec_fw =NULL ; +release_firmware (adev->gfx.mec2_fw); + adev->gfx.mec2_fw =NULL ; + +kfree (adev->gfx.rlc.register_list_format); +} +static int gfx_v9_0_init_microcode (struct amdgpu_device *adev) {drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-0const char *chip_name;@@ -1429,6 +1448,7 @@ static int gfx_v9_0_sw_fini(void *handle)gfx_v9_0_mec_fini (adev);gfx_v9_0_ngg_fini (adev); +gfx_v9_0_free_microcode (adev);return 0 ; }drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +5
-1@@ -1264,6 +1264,11 @@ static int sdma_v4_0_sw_fini(void *handle)for (i =0 ; i < adev->sdma.num_instances; i++)amdgpu_ring_fini (&adev->sdma.instance[i].ring); +for (i =0 ; i < adev->sdma.num_instances; i++) { +release_firmware (adev->sdma.instance[i].fw); + adev->sdma.instance[i].fw =NULL ; + } +return 0 ; } --2.7.4
Quoted 4 lines
_______________________________________________
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
Quoted 92 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Thursday, September 21, 2017 3:12 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 1/4] drm/amdgpu/sriov:unmap KCQ in gfxhw_finiChange-Id Ieee45a0127701ba946b5f8014ff0ac0a8a94a200Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 57 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +23
-0@@ -5034,6 +5034,57 @@ static int gfx_v8_0_hw_init(void *handle)return r; } +static int gfx_v8_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = kiq_ring->adev; +uint32_t scratch, tmp =0 ; +int r, i; + + r =amdgpu_gfx_scratch_get (adev, &scratch); +if (r) { +DRM_ERROR ("Failed to get scratch reg (%d).\n" , r); +return r; + } +WREG32 (scratch,0xCAFEDEAD ); + + r =amdgpu_ring_alloc (kiq_ring,10 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + } + +/* unmap queues */ +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); + amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q:1 */
+PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */ + PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) | + PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) | + PACKET3_UNMAP_QUEUES_NUM_QUEUES(1));drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1
-0+ amdgpu_ring_write(kiq_ring,
PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index));drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +5
-0+amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +/* write to scratch for completion */ + amdgpu_ring_write(kiq_ring,
PACKET3(PACKET3_SET_UCONFIG_REG, 1));drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1
-0+ amdgpu_ring_write(kiq_ring, (scratch -
PACKET3_SET_UCONFIG_REG_START));drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +11
-0+amdgpu_ring_write (kiq_ring,0xDEADBEEF ); +amdgpu_ring_commit (kiq_ring); + +for (i =0 ; i < adev->usec_timeout; i++) { + tmp =RREG32 (scratch); +if (tmp ==0xDEADBEEF ) +break ; +DRM_UDELAY (1 ); + } +if (i >= adev->usec_timeout) { + DRM_ERROR("KCQ disabled failed(scratch(0x%04X)=0x%08X)\n", scratch, tmp);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +6
-0+ r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); +return r; +} +static int gfx_v8_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static int gfx_v8_0_hw_fini(void *handle) · line 5094
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0
-0@@ -5041,6 +5092,12 @@ static int gfx_v8_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );if (amdgpu_sriov_vf (adev)) {
Might as well do this for bare metal as well to keep things consistent.
Alex
Quoted 104 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +6
-0+int i; + +/* disable KCQ to avoid CPC touch memory not valid anymore */ +for (i =0 ; i < adev->gfx.num_compute_rings; i++) +gfx_v8_0_kcq_disable (&adev->gfx.kiq.ring, &adev- >gfx.compute_ring[i]); +pr_debug ("For SRIOV client, shouldn't do anything.\n" );drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0
-0return 0 ; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +23
-0@@ -2895,6 +2895,58 @@ static int gfx_v9_0_hw_init(void *handle)return r; } +static int gfx_v9_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = kiq_ring->adev; +uint32_t scratch, tmp =0 ; +int r, i; + + r =amdgpu_gfx_scratch_get (adev, &scratch); +if (r) { +DRM_ERROR ("Failed to get scratch reg (%d).\n" , r); +return r; + } +WREG32 (scratch,0xCAFEDEAD ); + + r =amdgpu_ring_alloc (kiq_ring,10 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + } + +/* unmap queues */ +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); + amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q:1 */
+PACKET3_UNMAP_QUEUES_ACTION(1) | /* RESET_QUEUES */ + PACKET3_UNMAP_QUEUES_QUEUE_SEL(0) | + PACKET3_UNMAP_QUEUES_ENGINE_SEL(0) | + PACKET3_UNMAP_QUEUES_NUM_QUEUES(1));drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-0+ amdgpu_ring_write(kiq_ring,
PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index));drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5
-0+amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +/* write to scratch for completion */ + amdgpu_ring_write(kiq_ring,
PACKET3(PACKET3_SET_UCONFIG_REG, 1));drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-0+ amdgpu_ring_write(kiq_ring, (scratch -
PACKET3_SET_UCONFIG_REG_START));drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +11
-0+amdgpu_ring_write (kiq_ring,0xDEADBEEF ); +amdgpu_ring_commit (kiq_ring); + +for (i =0 ; i < adev->usec_timeout; i++) { + tmp =RREG32 (scratch); +if (tmp ==0xDEADBEEF ) +break ; +DRM_UDELAY (1 ); + } +if (i >= adev->usec_timeout) { + DRM_ERROR("KCQ disabled failed(scratch(0x%04X)=0x%08X)\n", scratch, tmp);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13
-0+ r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); +return r; +} + +static int gfx_v9_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;@@ -2902,6 +2954,12 @@ static int gfx_v9_0_hw_fini(void *handle)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );if (amdgpu_sriov_vf (adev)) { +int i; + +/* disable KCQ to avoid CPC touch memory not valid anymore */ +for (i =0 ; i < adev->gfx.num_compute_rings; i++) +gfx_v9_0_kcq_disable (&adev->gfx.kiq.ring, &adev- >gfx.compute_ring[i]); +pr_debug ("For SRIOV client, shouldn't do anything.\n" );drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-1return 0 ; } --2.7.4
Quoted 4 lines
_______________________________________________
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