Skip to contentSkip to conversation

drm/amdgpu/sriov:unmap KCQ in gfx hw_fini

PATCH In review Monk Liu 3 participants 13 messages Sep 21, 2017 – Sep 22, 2017 7 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/4 drm/amdgpu/sriov:unmap KCQ in gfx hw_fini

Change-Id Ieee45a0127701ba946b5f8014ff0ac0a8a94a200
---
 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
index 0c4a3b8..a027bda 100644
@@ -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

author
#2 lore raw

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

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
 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
index 4f6c68f..d85962b 100644
@@ -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

#4 lore raw

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_VF will not fail

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
  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
index 4f6c68f..d85962b 100644

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

#5 lore raw

RE: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM

In reply to a message not in the archive
Quoted 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 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

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
 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
index 4f6c68f..d85962b 100644
@@ -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) ?
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 -0
 		if (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

author
#7 lore raw

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 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

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
 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
index 4f6c68f..d85962b 100644
@@ -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) ?
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 -1
 		if (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]

Acked-by Alex Deucher
#9 lore raw

RE: [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 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 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

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
 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
index 4f6c68f..d85962b 100644
@@ -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) ?
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 -0
 		if (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

#10 lore raw

Re: [PATCH 2/4] drm/amdgpu/sriov:alloc KIQ MQD in VRAM

In reply to a message not in the archive

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 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 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 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

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
  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
index 4f6c68f..d85962b 100644
@@ -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) ?
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

author
#12 lore raw

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 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 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

Change-Id Iccef37a70c193c83af80961dae2c67ed859f1a13
---
  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
index 4f6c68f..d85962b 100644
@@ -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) ?
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

author
#13 lore raw

PATCH 3/4 drm/amdgpu:fix uvd ring fini routine(v2)

In reply to a message not in the archive

fix missing finish uvd enc_ring.
v2:
since the adev pointer check in already in ring_fini so drop the check outsider

Change-Id Ib74237ca5adcb3b128c9b751fced0b7db7b09e86
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4 -0
index 331e34a..e8bd50c 100644
@@ -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

Reviewed-by Alex Deucher
#15 lore raw

RE: [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 in ring_fini so drop the check outsider

Change-Id Ib74237ca5adcb3b128c9b751fced0b7db7b09e86
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
index 331e34a..e8bd50c 100644
@@ -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 -0
 	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;
--
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

author
#16 lore raw

PATCH 4/4 drm/amdgpu:fix firmware memoryleak

In reply to a message not in the archive

this fix memory leak due to request_firmware after driver unloaded

Change-Id I7b4724deea0a095189c344eea3801e456e9cced0
---
 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
index e028286..447d446 100644
@@ -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
index bbae00a..f768f1f 100644
@@ -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
index d5f3848..d052922 100644
@@ -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

Reviewed-by Alex Deucher
#18 lore raw

RE: [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_firmware after driver unloaded

Change-Id I7b4724deea0a095189c344eea3801e456e9cced0

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
index e028286..447d446 100644
@@ -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
index bbae00a..f768f1f 100644
@@ -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 -0
 	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 -1
index d5f3848..d052922 100644
@@ -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

#19 lore raw
In reply to a message not in the archive
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 gfx hw_fini

Change-Id Ieee45a0127701ba946b5f8014ff0ac0a8a94a200
---
 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
index 0c4a3b8..a027bda 100644
@@ -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 -0
 		return 0;
 	}
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +23 -0
index e2ae00d..bbae00a 100644
@@ -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 -1
 		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