From: Oak Zeng <ozeng-5C7GfCeVMHo@public.gmane.org>
To: "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Cc: "Zeng, Oak" <Oak.Zeng-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 3/4] drm/amdkfd: Allocate SDMA queue on specif engine
Date: Tue, 13 Nov 2018 19:11:20 +0000 [thread overview]
Message-ID: <1542136254-5561-3-git-send-email-ozeng@amd.com> (raw)
In-Reply-To: <1542136254-5561-1-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org>
From: Oak Zeng <Oak.Zeng@amd.com>
Change-Id: I32e0304cdf6ceeed12ea8d0af62f44e1ab20bffb
Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Reviewd-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 26 +++++++++++++------
.../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 30 +++++++++++++++++++---
2 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 5f4062b..37b02ea 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -143,7 +143,8 @@ static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
return 0;
}
-static int set_queue_properties_from_user(struct queue_properties *q_properties,
+static int set_queue_properties_from_user(struct kfd_dev *dev,
+ struct queue_properties *q_properties,
struct kfd_ioctl_create_queue_args *args)
{
if (args->queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) {
@@ -213,12 +214,21 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
q_properties->ctx_save_restore_area_size = args->ctx_save_restore_size;
q_properties->ctl_stack_size = args->ctl_stack_size;
if (args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE ||
- args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE_AQL)
+ args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE_AQL) {
q_properties->type = KFD_QUEUE_TYPE_COMPUTE;
- else if (args->queue_type == KFD_IOC_QUEUE_TYPE_SDMA)
+ } else if (args->queue_type == KFD_IOC_QUEUE_TYPE_SDMA) {
+ q_properties->sdma_engine_id =
+ dev->device_info->num_sdma_engines;
q_properties->type = KFD_QUEUE_TYPE_SDMA;
- else
+ } else if (args->queue_type >= KFD_IOC_QUEUE_TYPE_SDMA_ENGINE(0) &&
+ args->queue_type < KFD_IOC_QUEUE_TYPE_SDMA_ENGINE(
+ dev->device_info->num_sdma_engines)) {
+ q_properties->sdma_engine_id =
+ args->queue_type - KFD_IOC_QUEUE_TYPE_SDMA_ENGINE(0);
+ q_properties->type = KFD_QUEUE_TYPE_SDMA;
+ } else {
return -ENOTSUPP;
+ }
if (args->queue_type == KFD_IOC_QUEUE_TYPE_COMPUTE_AQL)
q_properties->format = KFD_QUEUE_FORMAT_AQL;
@@ -265,10 +275,6 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
pr_debug("Creating queue ioctl\n");
- err = set_queue_properties_from_user(&q_properties, args);
- if (err)
- return err;
-
pr_debug("Looking for gpu id 0x%x\n", args->gpu_id);
dev = kfd_device_by_id(args->gpu_id);
if (!dev) {
@@ -276,6 +282,10 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
return -EINVAL;
}
+ err = set_queue_properties_from_user(dev, &q_properties, args);
+ if (err)
+ return err;
+
mutex_lock(&p->mutex);
pdd = kfd_bind_process_to_device(dev, p);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 7bf4bca..bc8f955 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -916,14 +916,34 @@ static int stop_nocpsch(struct device_queue_manager *dqm)
}
static int allocate_sdma_queue(struct device_queue_manager *dqm,
+ unsigned int sdma_engine_id,
unsigned int *sdma_queue_id)
{
- int bit;
+ int bit = -1;
if (dqm->sdma_bitmap == 0)
return -ENOMEM;
- bit = __ffs64(dqm->sdma_bitmap);
+ /* If sdma_engine_id is valid,
+ * allocate queue on specific engine
+ */
+ if (sdma_engine_id < get_num_sdma_engines(dqm)) {
+ unsigned int i;
+
+ for (i = sdma_engine_id; i < get_num_sdma_queues(dqm);
+ i += get_num_sdma_engines(dqm)) {
+ if (dqm->sdma_bitmap & (1<<i)) {
+ bit = i;
+ break;
+ }
+ }
+ if (bit == -1)
+ return -EBUSY;
+ /* Otherwise allocate from any engine */
+ } else {
+ bit = __ffs64(dqm->sdma_bitmap);
+ }
+
dqm->sdma_bitmap &= ~(1ULL << bit);
*sdma_queue_id = bit;
@@ -949,7 +969,8 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
if (!mqd_mgr)
return -ENOMEM;
- retval = allocate_sdma_queue(dqm, &q->sdma_id);
+ retval = allocate_sdma_queue(dqm, q->properties.sdma_engine_id,
+ &q->sdma_id);
if (retval)
return retval;
@@ -1168,7 +1189,8 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
}
if (q->properties.type == KFD_QUEUE_TYPE_SDMA) {
- retval = allocate_sdma_queue(dqm, &q->sdma_id);
+ retval = allocate_sdma_queue(dqm, q->properties.sdma_engine_id,
+ &q->sdma_id);
if (retval)
goto out_unlock;
q->properties.sdma_queue_id =
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-11-13 19:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 19:11 [PATCH 1/4] drm/amdkfd: Use 64 bit sdma_bitmap Oak Zeng
[not found] ` <1542136254-5561-1-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org>
2018-11-13 19:11 ` [PATCH 2/4] drm/amdkfd: Added more SDMA queue type Oak Zeng
[not found] ` <1542136254-5561-2-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org>
2018-11-13 19:57 ` Alex Deucher
2018-11-13 19:11 ` Oak Zeng [this message]
[not found] ` <1542136254-5561-3-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org>
2018-11-13 19:59 ` [PATCH 3/4] drm/amdkfd: Allocate SDMA queue on specif engine Alex Deucher
2018-11-13 19:11 ` [PATCH 4/4] drm/amdkfd: Add sdma allocation debug message Oak Zeng
[not found] ` <1542136254-5561-4-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org>
2018-11-13 19:13 ` ozeng
2018-11-13 20:00 ` Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1542136254-5561-3-git-send-email-ozeng@amd.com \
--to=ozeng-5c7gfcevmho@public.gmane.org \
--cc=Oak.Zeng-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox