All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/amdkfd: Implement queue priority controls for gfx10
@ 2019-11-11 23:25 ` Yong Zhao
  0 siblings, 0 replies; 12+ messages in thread
From: Yong Zhao @ 2019-11-11 23:25 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Jay.Cornwall-5C7GfCeVMHo
  Cc: Yong Zhao

Ported from gfx9.

Change-Id: I388dc7c609ed724a6d600840f8e7317d9c2c877d
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
index 4a236b2c2354..4884cd6c65ce 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
@@ -66,6 +66,12 @@ static void update_cu_mask(struct mqd_manager *mm, void *mqd,
 		m->compute_static_thread_mgmt_se3);
 }
 
+static void set_priority(struct v10_compute_mqd *m, struct queue_properties *q)
+{
+	m->cp_hqd_pipe_priority = pipe_priority_map[q->priority];
+	m->cp_hqd_queue_priority = q->priority;
+}
+
 static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
 		struct queue_properties *q)
 {
@@ -109,9 +115,6 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
 			1 << CP_HQD_QUANTUM__QUANTUM_SCALE__SHIFT |
 			10 << CP_HQD_QUANTUM__QUANTUM_DURATION__SHIFT;
 
-	m->cp_hqd_pipe_priority = 1;
-	m->cp_hqd_queue_priority = 15;
-
 	if (q->format == KFD_QUEUE_FORMAT_AQL) {
 		m->cp_hqd_aql_control =
 			1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT;
@@ -208,6 +211,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
 		m->cp_hqd_ctx_save_control = 0;
 
 	update_cu_mask(mm, mqd, q);
+	set_priority(m, q);
 
 	q->is_active = (q->queue_size > 0 &&
 			q->queue_address != 0 &&
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 1/3] drm/amdkfd: Implement queue priority controls for gfx10
@ 2019-11-11 23:25 ` Yong Zhao
  0 siblings, 0 replies; 12+ messages in thread
From: Yong Zhao @ 2019-11-11 23:25 UTC (permalink / raw)
  To: amd-gfx, Jay.Cornwall; +Cc: Yong Zhao

Ported from gfx9.

Change-Id: I388dc7c609ed724a6d600840f8e7317d9c2c877d
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
index 4a236b2c2354..4884cd6c65ce 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
@@ -66,6 +66,12 @@ static void update_cu_mask(struct mqd_manager *mm, void *mqd,
 		m->compute_static_thread_mgmt_se3);
 }
 
+static void set_priority(struct v10_compute_mqd *m, struct queue_properties *q)
+{
+	m->cp_hqd_pipe_priority = pipe_priority_map[q->priority];
+	m->cp_hqd_queue_priority = q->priority;
+}
+
 static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd,
 		struct queue_properties *q)
 {
@@ -109,9 +115,6 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
 			1 << CP_HQD_QUANTUM__QUANTUM_SCALE__SHIFT |
 			10 << CP_HQD_QUANTUM__QUANTUM_DURATION__SHIFT;
 
-	m->cp_hqd_pipe_priority = 1;
-	m->cp_hqd_queue_priority = 15;
-
 	if (q->format == KFD_QUEUE_FORMAT_AQL) {
 		m->cp_hqd_aql_control =
 			1 << CP_HQD_AQL_CONTROL__CONTROL0__SHIFT;
@@ -208,6 +211,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
 		m->cp_hqd_ctx_save_control = 0;
 
 	update_cu_mask(mm, mqd, q);
+	set_priority(m, q);
 
 	q->is_active = (q->queue_size > 0 &&
 			q->queue_address != 0 &&
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] drm/amdkfd: Update get_wave_state() for GFX10
@ 2019-11-11 23:25     ` Yong Zhao
  0 siblings, 0 replies; 12+ messages in thread
From: Yong Zhao @ 2019-11-11 23:25 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Jay.Cornwall-5C7GfCeVMHo
  Cc: Yong Zhao

Given control stack is now in the userspace context save restore area
on GFX10, the same as GFX8, it is not needed to copy it back to userspace.

Change-Id: I063ddc3026eefa57713ec47b466a90f9bf9d49b8
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
index 4884cd6c65ce..954dc8ac4ff1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
@@ -251,18 +251,22 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
 {
 	struct v10_compute_mqd *m;
 
-	/* Control stack is located one page after MQD. */
-	void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE);
-
 	m = get_mqd(mqd);
 
+	/* Control stack is written backwards, while workgroup context data
+	 * is written forwards. Both starts from m->cp_hqd_cntl_stack_size.
+	 * Current position is at m->cp_hqd_cntl_stack_offset and
+	 * m->cp_hqd_wg_state_offset, respectively.
+	 */
 	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
 		m->cp_hqd_cntl_stack_offset;
 	*save_area_used_size = m->cp_hqd_wg_state_offset -
 		m->cp_hqd_cntl_stack_size;
 
-	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
-		return -EFAULT;
+	/* Control stack is not copied to user mode for GFXv10 because
+	 * it's part of the context save area that is already
+	 * accessible to user mode
+	 */
 
 	return 0;
 }
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] drm/amdkfd: Update get_wave_state() for GFX10
@ 2019-11-11 23:25     ` Yong Zhao
  0 siblings, 0 replies; 12+ messages in thread
From: Yong Zhao @ 2019-11-11 23:25 UTC (permalink / raw)
  To: amd-gfx, Jay.Cornwall; +Cc: Yong Zhao

Given control stack is now in the userspace context save restore area
on GFX10, the same as GFX8, it is not needed to copy it back to userspace.

Change-Id: I063ddc3026eefa57713ec47b466a90f9bf9d49b8
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
index 4884cd6c65ce..954dc8ac4ff1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
@@ -251,18 +251,22 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
 {
 	struct v10_compute_mqd *m;
 
-	/* Control stack is located one page after MQD. */
-	void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE);
-
 	m = get_mqd(mqd);
 
+	/* Control stack is written backwards, while workgroup context data
+	 * is written forwards. Both starts from m->cp_hqd_cntl_stack_size.
+	 * Current position is at m->cp_hqd_cntl_stack_offset and
+	 * m->cp_hqd_wg_state_offset, respectively.
+	 */
 	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
 		m->cp_hqd_cntl_stack_offset;
 	*save_area_used_size = m->cp_hqd_wg_state_offset -
 		m->cp_hqd_cntl_stack_size;
 
-	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
-		return -EFAULT;
+	/* Control stack is not copied to user mode for GFXv10 because
+	 * it's part of the context save area that is already
+	 * accessible to user mode
+	 */
 
 	return 0;
 }
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size
@ 2019-11-11 23:25     ` Yong Zhao
  0 siblings, 0 replies; 12+ messages in thread
From: Yong Zhao @ 2019-11-11 23:25 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Jay.Cornwall-5C7GfCeVMHo
  Cc: Yong Zhao

workgroup context data writes from m->cp_hqd_cntl_stack_size, so we
should deduct it when calculating the used size.

Change-Id: I5252e25662c3b8221f451c39115bf084d1911eae
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
index d3380c5bdbde..3a2ee1f01aae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
@@ -302,7 +302,8 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
 
 	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
 		m->cp_hqd_cntl_stack_offset;
-	*save_area_used_size = m->cp_hqd_wg_state_offset;
+	*save_area_used_size = m->cp_hqd_wg_state_offset -
+		m->cp_hqd_cntl_stack_size;;
 
 	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
 		return -EFAULT;
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size
@ 2019-11-11 23:25     ` Yong Zhao
  0 siblings, 0 replies; 12+ messages in thread
From: Yong Zhao @ 2019-11-11 23:25 UTC (permalink / raw)
  To: amd-gfx, Jay.Cornwall; +Cc: Yong Zhao

workgroup context data writes from m->cp_hqd_cntl_stack_size, so we
should deduct it when calculating the used size.

Change-Id: I5252e25662c3b8221f451c39115bf084d1911eae
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
index d3380c5bdbde..3a2ee1f01aae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
@@ -302,7 +302,8 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
 
 	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
 		m->cp_hqd_cntl_stack_offset;
-	*save_area_used_size = m->cp_hqd_wg_state_offset;
+	*save_area_used_size = m->cp_hqd_wg_state_offset -
+		m->cp_hqd_cntl_stack_size;;
 
 	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
 		return -EFAULT;
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size
@ 2019-11-12 21:14         ` Zhao, Yong
  0 siblings, 0 replies; 12+ messages in thread
From: Zhao, Yong @ 2019-11-12 21:14 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Cornwall, Jay,
	Morichetti, Laurent


[-- Attachment #1.1: Type: text/plain, Size: 1573 bytes --]

+ Laurent
________________________________
From: Zhao, Yong <Yong.Zhao-5C7GfCeVMHo@public.gmane.org>
Sent: Monday, November 11, 2019 6:25 PM
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org <amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>; Cornwall, Jay <Jay.Cornwall-5C7GfCeVMHo@public.gmane.org>
Cc: Zhao, Yong <Yong.Zhao-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size

workgroup context data writes from m->cp_hqd_cntl_stack_size, so we
should deduct it when calculating the used size.

Change-Id: I5252e25662c3b8221f451c39115bf084d1911eae
Signed-off-by: Yong Zhao <Yong.Zhao-5C7GfCeVMHo@public.gmane.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
index d3380c5bdbde..3a2ee1f01aae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
@@ -302,7 +302,8 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,

         *ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
                 m->cp_hqd_cntl_stack_offset;
-       *save_area_used_size = m->cp_hqd_wg_state_offset;
+       *save_area_used_size = m->cp_hqd_wg_state_offset -
+               m->cp_hqd_cntl_stack_size;;

         if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
                 return -EFAULT;
--
2.17.1


[-- Attachment #1.2: Type: text/html, Size: 2866 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size
@ 2019-11-12 21:14         ` Zhao, Yong
  0 siblings, 0 replies; 12+ messages in thread
From: Zhao, Yong @ 2019-11-12 21:14 UTC (permalink / raw)
  To: amd-gfx, Cornwall, Jay, Morichetti, Laurent


[-- Attachment #1.1: Type: text/plain, Size: 1433 bytes --]

+ Laurent
________________________________
From: Zhao, Yong <Yong.Zhao@amd.com>
Sent: Monday, November 11, 2019 6:25 PM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Cornwall, Jay <Jay.Cornwall@amd.com>
Cc: Zhao, Yong <Yong.Zhao@amd.com>
Subject: [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size

workgroup context data writes from m->cp_hqd_cntl_stack_size, so we
should deduct it when calculating the used size.

Change-Id: I5252e25662c3b8221f451c39115bf084d1911eae
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
index d3380c5bdbde..3a2ee1f01aae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
@@ -302,7 +302,8 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,

         *ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
                 m->cp_hqd_cntl_stack_offset;
-       *save_area_used_size = m->cp_hqd_wg_state_offset;
+       *save_area_used_size = m->cp_hqd_wg_state_offset -
+               m->cp_hqd_cntl_stack_size;;

         if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
                 return -EFAULT;
--
2.17.1


[-- Attachment #1.2: Type: text/html, Size: 2726 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size
@ 2019-11-12 21:43         ` Felix Kuehling
  0 siblings, 0 replies; 12+ messages in thread
From: Felix Kuehling @ 2019-11-12 21:43 UTC (permalink / raw)
  To: Yong Zhao, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Jay.Cornwall-5C7GfCeVMHo, Morichetti, Laurent

On 2019-11-11 6:25 p.m., Yong Zhao wrote:
> workgroup context data writes from m->cp_hqd_cntl_stack_size, so we
> should deduct it when calculating the used size.
Looks like something I missed in upstreaming. As far as I can tell this 
was originally part of a commit by Jay on amd-kfd-staging. Another part 
of his commit seems to be upstream. Not sure how this got lost.

See one comment inline.


>
> Change-Id: I5252e25662c3b8221f451c39115bf084d1911eae
> Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
> index d3380c5bdbde..3a2ee1f01aae 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
> @@ -302,7 +302,8 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
>   
>   	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
>   		m->cp_hqd_cntl_stack_offset;
> -	*save_area_used_size = m->cp_hqd_wg_state_offset;
> +	*save_area_used_size = m->cp_hqd_wg_state_offset -
> +		m->cp_hqd_cntl_stack_size;;

Please fix the double-semicolon. With that fixed this change is

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>


>   
>   	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
>   		return -EFAULT;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size
@ 2019-11-12 21:43         ` Felix Kuehling
  0 siblings, 0 replies; 12+ messages in thread
From: Felix Kuehling @ 2019-11-12 21:43 UTC (permalink / raw)
  To: Yong Zhao, amd-gfx, Jay.Cornwall, Morichetti, Laurent

On 2019-11-11 6:25 p.m., Yong Zhao wrote:
> workgroup context data writes from m->cp_hqd_cntl_stack_size, so we
> should deduct it when calculating the used size.
Looks like something I missed in upstreaming. As far as I can tell this 
was originally part of a commit by Jay on amd-kfd-staging. Another part 
of his commit seems to be upstream. Not sure how this got lost.

See one comment inline.


>
> Change-Id: I5252e25662c3b8221f451c39115bf084d1911eae
> Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
> index d3380c5bdbde..3a2ee1f01aae 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
> @@ -302,7 +302,8 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
>   
>   	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
>   		m->cp_hqd_cntl_stack_offset;
> -	*save_area_used_size = m->cp_hqd_wg_state_offset;
> +	*save_area_used_size = m->cp_hqd_wg_state_offset -
> +		m->cp_hqd_cntl_stack_size;;

Please fix the double-semicolon. With that fixed this change is

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>


>   
>   	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
>   		return -EFAULT;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] drm/amdkfd: Update get_wave_state() for GFX10
@ 2019-11-12 21:52         ` Felix Kuehling
  0 siblings, 0 replies; 12+ messages in thread
From: Felix Kuehling @ 2019-11-12 21:52 UTC (permalink / raw)
  To: Yong Zhao, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Jay.Cornwall-5C7GfCeVMHo

On 2019-11-11 6:25 p.m., Yong Zhao wrote:
> Given control stack is now in the userspace context save restore area
> on GFX10, the same as GFX8, it is not needed to copy it back to userspace.
>
> Change-Id: I063ddc3026eefa57713ec47b466a90f9bf9d49b8
> Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
Patches 1 and 2 are

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>


Patch 3 should arguably not be part of this series, because it does not 
affect GFXv10.

Regards,
   Felix



> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
> index 4884cd6c65ce..954dc8ac4ff1 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
> @@ -251,18 +251,22 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
>   {
>   	struct v10_compute_mqd *m;
>   
> -	/* Control stack is located one page after MQD. */
> -	void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE);
> -
>   	m = get_mqd(mqd);
>   
> +	/* Control stack is written backwards, while workgroup context data
> +	 * is written forwards. Both starts from m->cp_hqd_cntl_stack_size.
> +	 * Current position is at m->cp_hqd_cntl_stack_offset and
> +	 * m->cp_hqd_wg_state_offset, respectively.
> +	 */
>   	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
>   		m->cp_hqd_cntl_stack_offset;
>   	*save_area_used_size = m->cp_hqd_wg_state_offset -
>   		m->cp_hqd_cntl_stack_size;
>   
> -	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
> -		return -EFAULT;
> +	/* Control stack is not copied to user mode for GFXv10 because
> +	 * it's part of the context save area that is already
> +	 * accessible to user mode
> +	 */
>   
>   	return 0;
>   }
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] drm/amdkfd: Update get_wave_state() for GFX10
@ 2019-11-12 21:52         ` Felix Kuehling
  0 siblings, 0 replies; 12+ messages in thread
From: Felix Kuehling @ 2019-11-12 21:52 UTC (permalink / raw)
  To: Yong Zhao, amd-gfx, Jay.Cornwall

On 2019-11-11 6:25 p.m., Yong Zhao wrote:
> Given control stack is now in the userspace context save restore area
> on GFX10, the same as GFX8, it is not needed to copy it back to userspace.
>
> Change-Id: I063ddc3026eefa57713ec47b466a90f9bf9d49b8
> Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
Patches 1 and 2 are

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>


Patch 3 should arguably not be part of this series, because it does not 
affect GFXv10.

Regards,
   Felix



> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
> index 4884cd6c65ce..954dc8ac4ff1 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
> @@ -251,18 +251,22 @@ static int get_wave_state(struct mqd_manager *mm, void *mqd,
>   {
>   	struct v10_compute_mqd *m;
>   
> -	/* Control stack is located one page after MQD. */
> -	void *mqd_ctl_stack = (void *)((uintptr_t)mqd + PAGE_SIZE);
> -
>   	m = get_mqd(mqd);
>   
> +	/* Control stack is written backwards, while workgroup context data
> +	 * is written forwards. Both starts from m->cp_hqd_cntl_stack_size.
> +	 * Current position is at m->cp_hqd_cntl_stack_offset and
> +	 * m->cp_hqd_wg_state_offset, respectively.
> +	 */
>   	*ctl_stack_used_size = m->cp_hqd_cntl_stack_size -
>   		m->cp_hqd_cntl_stack_offset;
>   	*save_area_used_size = m->cp_hqd_wg_state_offset -
>   		m->cp_hqd_cntl_stack_size;
>   
> -	if (copy_to_user(ctl_stack, mqd_ctl_stack, m->cp_hqd_cntl_stack_size))
> -		return -EFAULT;
> +	/* Control stack is not copied to user mode for GFXv10 because
> +	 * it's part of the context save area that is already
> +	 * accessible to user mode
> +	 */
>   
>   	return 0;
>   }
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-11-12 21:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 23:25 [PATCH 1/3] drm/amdkfd: Implement queue priority controls for gfx10 Yong Zhao
2019-11-11 23:25 ` Yong Zhao
     [not found] ` <20191111232521.10528-1-Yong.Zhao-5C7GfCeVMHo@public.gmane.org>
2019-11-11 23:25   ` [PATCH 2/3] drm/amdkfd: Update get_wave_state() for GFX10 Yong Zhao
2019-11-11 23:25     ` Yong Zhao
     [not found]     ` <20191111232521.10528-2-Yong.Zhao-5C7GfCeVMHo@public.gmane.org>
2019-11-12 21:52       ` Felix Kuehling
2019-11-12 21:52         ` Felix Kuehling
2019-11-11 23:25   ` [PATCH 3/3] drm/amdkfd: Fix a bug when calculating save_area_used_size Yong Zhao
2019-11-11 23:25     ` Yong Zhao
     [not found]     ` <20191111232521.10528-3-Yong.Zhao-5C7GfCeVMHo@public.gmane.org>
2019-11-12 21:14       ` Zhao, Yong
2019-11-12 21:14         ` Zhao, Yong
2019-11-12 21:43       ` Felix Kuehling
2019-11-12 21:43         ` Felix Kuehling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.