From: Oded Gabbay <oded.gabbay@amd.com>
To: David Airlie <airlied@linux.ie>,
Jerome Glisse <j.glisse@gmail.com>,
"Alex Deucher" <alexdeucher@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "John Bridgman" <John.Bridgman@amd.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Andrew Lewycky" <Andrew.Lewycky@amd.com>,
"Christian König" <deathsimple@vodafone.de>,
"Michel Dänzer" <michel.daenzer@amd.com>,
"Ben Goz" <Ben.Goz@amd.com>,
"Alexey Skidanov" <Alexey.Skidanov@amd.com>,
"Evgeny Pinchuk" <Evgeny.Pinchuk@amd.com>,
"Ben Goz" <ben.goz@amd.com>, "Oded Gabbay" <oded.gabbay@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 21/25] amdkfd: Implement the create/destroy/update queue IOCTLs
Date: Thu, 17 Jul 2014 16:29:28 +0300 [thread overview]
Message-ID: <1405603773-32688-22-git-send-email-oded.gabbay@amd.com> (raw)
In-Reply-To: <1405603773-32688-1-git-send-email-oded.gabbay@amd.com>
From: Ben Goz <ben.goz@amd.com>
Signed-off-by: Ben Goz <ben.goz@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
drivers/gpu/drm/radeon/amdkfd/kfd_chardev.c | 133 +++++++++++++++++++++++++++-
drivers/gpu/drm/radeon/amdkfd/kfd_priv.h | 8 ++
2 files changed, 138 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/radeon/amdkfd/kfd_chardev.c b/drivers/gpu/drm/radeon/amdkfd/kfd_chardev.c
index d6580a6..a74693a 100644
--- a/drivers/gpu/drm/radeon/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/radeon/amdkfd/kfd_chardev.c
@@ -119,17 +119,144 @@ static int kfd_open(struct inode *inode, struct file *filep)
static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, void __user *arg)
{
- return -ENODEV;
+ struct kfd_ioctl_create_queue_args args;
+ struct kfd_dev *dev;
+ int err = 0;
+ unsigned int queue_id;
+ struct kfd_process_device *pdd;
+ struct queue_properties q_properties;
+
+ memset(&q_properties, 0, sizeof(struct queue_properties));
+
+ if (copy_from_user(&args, arg, sizeof(args)))
+ return -EFAULT;
+
+ if (!access_ok(VERIFY_WRITE, args.read_pointer_address, sizeof(qptr_t))) {
+ pr_err("kfd: can't access read pointer");
+ return -EFAULT;
+ }
+
+ if (!access_ok(VERIFY_WRITE, args.write_pointer_address, sizeof(qptr_t))) {
+ pr_err("kfd: can't access write pointer");
+ return -EFAULT;
+ }
+
+ q_properties.is_interop = false;
+ q_properties.queue_percent = args.queue_percentage;
+ q_properties.priority = args.queue_priority;
+ q_properties.queue_address = args.ring_base_address;
+ q_properties.queue_size = args.ring_size;
+ q_properties.read_ptr = (qptr_t *) args.read_pointer_address;
+ q_properties.write_ptr = (qptr_t *) args.write_pointer_address;
+
+
+ pr_debug("%s Arguments: Queue Percentage (%d, %d)\n"
+ "Queue Priority (%d, %d)\n"
+ "Queue Address (0x%llX, 0x%llX)\n"
+ "Queue Size (0x%llX, %u)\n"
+ "Queue r/w Pointers (0x%llX, 0x%llX)\n",
+ __func__,
+ q_properties.queue_percent, args.queue_percentage,
+ q_properties.priority, args.queue_priority,
+ q_properties.queue_address, args.ring_base_address,
+ q_properties.queue_size, args.ring_size,
+ (uint64_t) q_properties.read_ptr,
+ (uint64_t) q_properties.write_ptr);
+
+ dev = kfd_device_by_id(args.gpu_id);
+ if (dev == NULL)
+ return -EINVAL;
+
+ mutex_lock(&p->mutex);
+
+ pdd = kfd_bind_process_to_device(dev, p);
+ if (IS_ERR(pdd) < 0) {
+ err = PTR_ERR(pdd);
+ goto err_bind_process;
+ }
+
+ pr_debug("kfd: creating queue for PASID %d on GPU 0x%x\n",
+ p->pasid,
+ dev->id);
+
+ err = pqm_create_queue(&p->pqm, dev, filep, &q_properties, 0, KFD_QUEUE_TYPE_COMPUTE, &queue_id);
+ if (err != 0)
+ goto err_create_queue;
+
+ args.queue_id = queue_id;
+ args.doorbell_address = (uint64_t)q_properties.doorbell_ptr;
+
+ if (copy_to_user(arg, &args, sizeof(args))) {
+ err = -EFAULT;
+ goto err_copy_args_out;
+ }
+
+ mutex_unlock(&p->mutex);
+
+ pr_debug("kfd: queue id %d was created successfully.\n"
+ " ring buffer address == 0x%016llX\n"
+ " read ptr address == 0x%016llX\n"
+ " write ptr address == 0x%016llX\n"
+ " doorbell address == 0x%016llX\n",
+ args.queue_id,
+ args.ring_base_address,
+ args.read_pointer_address,
+ args.write_pointer_address,
+ args.doorbell_address);
+
+ return 0;
+
+err_copy_args_out:
+ pqm_destroy_queue(&p->pqm, queue_id);
+err_create_queue:
+err_bind_process:
+ mutex_unlock(&p->mutex);
+ return err;
}
static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p, void __user *arg)
{
- return -ENODEV;
+ int retval;
+ struct kfd_ioctl_destroy_queue_args args;
+
+ if (copy_from_user(&args, arg, sizeof(args)))
+ return -EFAULT;
+
+ pr_debug("kfd: destroying queue id %d for PASID %d\n",
+ args.queue_id,
+ p->pasid);
+
+ mutex_lock(&p->mutex);
+
+ retval = pqm_destroy_queue(&p->pqm, args.queue_id);
+
+ mutex_unlock(&p->mutex);
+ return retval;
}
static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p, void __user *arg)
{
- return -ENODEV;
+ int retval;
+ struct kfd_ioctl_update_queue_args args;
+ struct queue_properties properties;
+
+ if (copy_from_user(&args, arg, sizeof(args)))
+ return -EFAULT;
+
+ properties.queue_address = args.ring_base_address;
+ properties.queue_size = args.ring_size;
+ properties.queue_percent = args.queue_percentage;
+ properties.priority = args.queue_priority;
+
+ pr_debug("kfd: updating queue id %d for PASID %d\n", args.queue_id, p->pasid);
+
+ mutex_lock(&p->mutex);
+
+ retval = pqm_update_queue(&p->pqm, args.queue_id, &properties);
+
+ mutex_unlock(&p->mutex);
+
+ return retval;
}
static long kfd_ioctl_set_memory_policy(struct file *filep, struct kfd_process *p, void __user *arg)
diff --git a/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h b/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h
index 8a1de68..7ea0e81 100644
--- a/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h
@@ -418,7 +418,15 @@ struct process_queue_node {
int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p);
void pqm_uninit(struct process_queue_manager *pqm);
+int pqm_create_queue(struct process_queue_manager *pqm,
+ struct kfd_dev *dev,
+ struct file *f,
+ struct queue_properties *properties,
+ unsigned int flags,
+ enum kfd_queue_type type,
+ unsigned int *qid);
int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid);
+int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid, struct queue_properties *p);
/* Packet Manager */
--
1.9.1
next prev parent reply other threads:[~2014-07-17 13:49 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1405603773-32688-1-git-send-email-oded.gabbay@amd.com>
2014-07-17 13:29 ` [PATCH v2 01/25] mm: Add kfd_process pointer to mm_struct Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 02/25] drm/radeon: reduce number of free VMIDs and pipes in KV Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 03/25] drm/radeon/cik: Don't touch int of pipes 1-7 Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 04/25] drm/radeon: Report doorbell configuration to amdkfd Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 05/25] drm/radeon: adding synchronization for GRBM GFX Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 06/25] drm/radeon: Add radeon <--> amdkfd interface Oded Gabbay
2014-07-20 17:35 ` Jerome Glisse
2014-08-02 20:07 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 07/25] Update MAINTAINERS and CREDITS files with amdkfd info Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 08/25] amdkfd: Add IOCTL set definitions of amdkfd Oded Gabbay
2014-07-20 16:54 ` Jerome Glisse
2014-08-02 20:00 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 09/25] amdkfd: Add amdkfd skeleton driver Oded Gabbay
2014-07-20 17:09 ` Jerome Glisse
2014-08-02 19:55 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 10/25] amdkfd: Add topology module to amdkfd Oded Gabbay
2014-07-20 22:37 ` Jerome Glisse
2014-07-27 11:15 ` Oded Gabbay
2014-07-30 12:10 ` Oded Gabbay
2014-07-27 11:26 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 11/25] amdkfd: Add basic modules " Oded Gabbay
2014-07-20 23:02 ` Jerome Glisse
2014-08-02 19:25 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 12/25] amdkfd: Add binding/unbinding calls to amd_iommu driver Oded Gabbay
2014-07-20 23:04 ` Jerome Glisse
2014-07-27 11:11 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 13/25] amdkfd: Add queue module Oded Gabbay
2014-07-20 23:06 ` Jerome Glisse
2014-07-27 11:09 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 14/25] amdkfd: Add mqd_manager module Oded Gabbay
2014-07-21 2:33 ` Jerome Glisse
2014-08-02 19:18 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 15/25] amdkfd: Add kernel queue module Oded Gabbay
2014-07-21 2:42 ` Jerome Glisse
2014-07-27 11:05 ` Oded Gabbay
2014-07-27 12:40 ` Christian König
2014-07-17 13:29 ` [PATCH v2 16/25] amdkfd: Add module parameter of scheduling policy Oded Gabbay
2014-07-21 2:45 ` Jerome Glisse
2014-07-27 10:21 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 17/25] amdkfd: Add packet manager module Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 18/25] amdkfd: Add process queue " Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 19/25] amdkfd: Add device " Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 20/25] amdkfd: Add interrupt handling module Oded Gabbay
2014-07-17 13:29 ` Oded Gabbay [this message]
2014-07-20 23:09 ` [PATCH v2 21/25] amdkfd: Implement the create/destroy/update queue IOCTLs Jerome Glisse
2014-07-27 10:15 ` Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 22/25] amdkfd: Implement the Set Memory Policy IOCTL Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 23/25] amdkfd: Implement the Get Clock Counters IOCTL Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 24/25] amdkfd: Implement the Get Process Aperture IOCTL Oded Gabbay
2014-07-17 13:29 ` [PATCH v2 25/25] amdkfd: Implement the PMC Acquire/Release IOCTLs Oded Gabbay
2014-07-17 13:57 ` [PATCH v2 01/25] mm: Add kfd_process pointer to mm_struct Oded Gabbay
2014-07-17 14:12 ` Jerome Glisse
2014-07-17 14:15 ` Oded Gabbay
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=1405603773-32688-22-git-send-email-oded.gabbay@amd.com \
--to=oded.gabbay@amd.com \
--cc=Alexey.Skidanov@amd.com \
--cc=Andrew.Lewycky@amd.com \
--cc=Ben.Goz@amd.com \
--cc=Evgeny.Pinchuk@amd.com \
--cc=John.Bridgman@amd.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=christian.koenig@amd.com \
--cc=deathsimple@vodafone.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=j.glisse@gmail.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michel.daenzer@amd.com \
/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
Powered by JetHome