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>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH v2 13/25] amdkfd: Add queue module
Date: Thu, 17 Jul 2014 16:29:20 +0300 [thread overview]
Message-ID: <1405603773-32688-14-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>
The queue module enables allocating and initializing queues uniformly.
Signed-off-by: Ben Goz <ben.goz@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
drivers/gpu/drm/radeon/amdkfd/Makefile | 2 +-
drivers/gpu/drm/radeon/amdkfd/kfd_priv.h | 48 +++++++++++++
drivers/gpu/drm/radeon/amdkfd/kfd_queue.c | 109 ++++++++++++++++++++++++++++++
3 files changed, 158 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpu/drm/radeon/amdkfd/kfd_queue.c
diff --git a/drivers/gpu/drm/radeon/amdkfd/Makefile b/drivers/gpu/drm/radeon/amdkfd/Makefile
index daf75a8..dbff147 100644
--- a/drivers/gpu/drm/radeon/amdkfd/Makefile
+++ b/drivers/gpu/drm/radeon/amdkfd/Makefile
@@ -6,6 +6,6 @@ ccflags-y := -Iinclude/drm
amdkfd-y := kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \
kfd_pasid.o kfd_doorbell.o kfd_vidmem.o kfd_aperture.o \
- kfd_process.o
+ kfd_process.o kfd_queue.o
obj-$(CONFIG_HSA_RADEON) += amdkfd.o
diff --git a/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h b/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h
index 604c317..94ff1c3 100644
--- a/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/radeon/amdkfd/kfd_priv.h
@@ -65,6 +65,9 @@ typedef unsigned int pasid_t;
/* Type that represents a HW doorbell slot. */
typedef u32 doorbell_t;
+/* Type that represents queue pointer */
+typedef u32 qptr_t;
+
struct kfd_device_info {
const struct kfd_scheduler_class *scheduler_class;
unsigned int max_pasid_bits;
@@ -125,12 +128,57 @@ void kfd_vidmem_unkmap(struct kfd_dev *kfd, kfd_mem_obj mem_obj);
int kfd_vidmem_alloc_map(struct kfd_dev *kfd, kfd_mem_obj *mem_obj, void **ptr,
uint64_t *vmid0_address, size_t size);
void kfd_vidmem_free_unmap(struct kfd_dev *kfd, kfd_mem_obj mem_obj);
+
/* Character device interface */
int kfd_chardev_init(void);
void kfd_chardev_exit(void);
struct device *kfd_chardev(void);
+enum kfd_queue_type {
+ KFD_QUEUE_TYPE_COMPUTE,
+ KFD_QUEUE_TYPE_SDMA,
+ KFD_QUEUE_TYPE_HIQ,
+ KFD_QUEUE_TYPE_DIQ
+};
+
+struct queue_properties {
+ enum kfd_queue_type type;
+ unsigned int queue_id;
+ uint64_t queue_address;
+ uint64_t queue_size;
+ uint32_t priority;
+ uint32_t queue_percent;
+ qptr_t *read_ptr;
+ qptr_t *write_ptr;
+ qptr_t *doorbell_ptr;
+ qptr_t doorbell_off;
+ bool is_interop;
+ bool is_active;
+ /* Not relevant for user mode queues in cp scheduling */
+ unsigned int vmid;
+};
+
+struct queue {
+ struct list_head list;
+ void *mqd;
+ /* kfd_mem_obj contains the mqd */
+ kfd_mem_obj mqd_mem_obj;
+ uint64_t gart_mqd_addr; /* needed for cp scheduling */
+ struct queue_properties properties;
+
+ /*
+ * Used by the queue device manager to track the hqd slot per queue
+ * when using no cp scheduling
+ */
+ uint32_t mec;
+ uint32_t pipe;
+ uint32_t queue;
+
+ struct kfd_process *process;
+ struct kfd_dev *device;
+};
+
/* Data that is per-process-per device. */
struct kfd_process_device {
/*
diff --git a/drivers/gpu/drm/radeon/amdkfd/kfd_queue.c b/drivers/gpu/drm/radeon/amdkfd/kfd_queue.c
new file mode 100644
index 0000000..646b6d1
--- /dev/null
+++ b/drivers/gpu/drm/radeon/amdkfd/kfd_queue.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <linux/slab.h>
+#include "kfd_priv.h"
+
+void print_queue_properties(struct queue_properties *q)
+{
+ if (!q)
+ return;
+
+ pr_debug("Printing queue properties\n"
+ "Queue Type: %u\n"
+ "Queue Size: %llu\n"
+ "Queue percent: %u\n"
+ "Queue Address: 0x%llX\n"
+ "Queue Id: %u\n"
+ "Queue Process Vmid: %u\n"
+ "Queue Read Pointer: 0x%p\n"
+ "Queue Write Pointer: 0x%p\n"
+ "Queue Doorbell Pointer: 0x%p\n"
+ "Queue Doorbell Offset: %u\n", q->type,
+ q->queue_size,
+ q->queue_percent,
+ q->queue_address,
+ q->queue_id,
+ q->vmid,
+ q->read_ptr,
+ q->write_ptr,
+ q->doorbell_ptr,
+ q->doorbell_off);
+}
+
+void print_queue(struct queue *q)
+{
+ if (!q)
+ return;
+ pr_debug("Printing queue\n"
+ "Queue Type: %u\n"
+ "Queue Size: %llu\n"
+ "Queue percent: %u\n"
+ "Queue Address: 0x%llX\n"
+ "Queue Id: %u\n"
+ "Queue Process Vmid: %u\n"
+ "Queue Read Pointer: 0x%p\n"
+ "Queue Write Pointer: 0x%p\n"
+ "Queue Doorbell Pointer: 0x%p\n"
+ "Queue Doorbell Offset: %u\n"
+ "Queue MQD Address: 0x%p\n"
+ "Queue MQD Gart: 0x%llX\n"
+ "Queue Process Address: 0x%p\n"
+ "Queue Device Address: 0x%p\n",
+ q->properties.type,
+ q->properties.queue_size,
+ q->properties.queue_percent,
+ q->properties.queue_address,
+ q->properties.queue_id,
+ q->properties.vmid,
+ q->properties.read_ptr,
+ q->properties.write_ptr,
+ q->properties.doorbell_ptr,
+ q->properties.doorbell_off,
+ q->mqd,
+ q->gart_mqd_addr,
+ q->process,
+ q->device);
+}
+
+int init_queue(struct queue **q, struct queue_properties properties)
+{
+ struct queue *tmp;
+
+ BUG_ON(!q);
+
+ tmp = kzalloc(sizeof(struct queue), GFP_KERNEL);
+ if (!tmp)
+ return -ENOMEM;
+
+ memset(&tmp->properties, 0, sizeof(struct queue_properties));
+ memcpy(&tmp->properties, &properties, sizeof(struct queue_properties));
+
+ *q = tmp;
+ return 0;
+}
+
+void uninit_queue(struct queue *q)
+{
+ kfree(q);
+}
--
1.9.1
next prev parent reply other threads:[~2014-07-17 13:32 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 ` Oded Gabbay [this message]
2014-07-20 23:06 ` [PATCH v2 13/25] amdkfd: Add queue module 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 ` [PATCH v2 21/25] amdkfd: Implement the create/destroy/update queue IOCTLs Oded Gabbay
2014-07-20 23:09 ` 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-14-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