aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3319-drm-amdkfd-Remove-GPU-ID-in-GWS-queue-creation.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3319-drm-amdkfd-Remove-GPU-ID-in-GWS-queue-creation.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3319-drm-amdkfd-Remove-GPU-ID-in-GWS-queue-creation.patch144
1 files changed, 144 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3319-drm-amdkfd-Remove-GPU-ID-in-GWS-queue-creation.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3319-drm-amdkfd-Remove-GPU-ID-in-GWS-queue-creation.patch
new file mode 100644
index 00000000..d083c98e
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3319-drm-amdkfd-Remove-GPU-ID-in-GWS-queue-creation.patch
@@ -0,0 +1,144 @@
+From 35cb67e0d12a865676f588010923a6a305b41bfe Mon Sep 17 00:00:00 2001
+From: Joseph Greathouse <Joseph.Greathouse@amd.com>
+Date: Fri, 26 Jul 2019 19:28:31 -0500
+Subject: [PATCH 3319/4256] drm/amdkfd: Remove GPU ID in GWS queue creation
+
+The gpu_id argument is not needed when enabling GWS on a queue.
+The queue can only be associated with one device, so the only
+possible situations for the call as previously defined were:
+1) the gpu_id was for the device associated with the target queue
+and things worked as expected, or 2) the gpu_id was for a device
+not associated with the target queue and the request was undefined.
+
+In particular, the previous result of the undefined operation is
+that you would allocate the number of GWS entries available on the
+gpu_id device, even if the queue was on a device with a different
+number available. For example: a queue on a device without GWS
+capability, but the user passes in a gpu_id for a device with GWS.
+We would end up trying to allocate GWS on the device that does not
+support it.
+
+Rather than leaving this footgun around and making life more
+difficult for user space, we can instead grab the gpu_id from the
+target queue. The gpu_id argument being passed in is thus not
+needed.
+
+v2: Fixed styling, removed gpu_id since it never hit main release
+
+Change-Id: Ic11a781c98d1dad490f2eb237b5c703eb4be56b8
+Signed-off-by: Joseph Greathouse <Joseph.Greathouse@amd.com>
+Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
+---
+ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 25 +++++++++++++------
+ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++
+ .../amd/amdkfd/kfd_process_queue_manager.c | 9 +++++++
+ include/uapi/linux/kfd_ioctl.h | 3 +--
+ 4 files changed, 30 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+index 33381ae358fb..e96aa4eaaa66 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+@@ -1611,25 +1611,36 @@ static int kfd_ioctl_alloc_queue_gws(struct file *filep,
+ {
+ int retval;
+ struct kfd_ioctl_alloc_queue_gws_args *args = data;
++ struct queue *q;
+ struct kfd_dev *dev;
+
+ if (!hws_gws_support)
+ return -ENODEV;
+
+- dev = kfd_device_by_id(args->gpu_id);
+- if (!dev) {
+- pr_debug("Could not find gpu id 0x%x\n", args->gpu_id);
+- return -ENODEV;
++ mutex_lock(&p->mutex);
++ q = pqm_get_user_queue(&p->pqm, args->queue_id);
++
++ if (q) {
++ dev = q->device;
++ } else {
++ retval = -EINVAL;
++ goto out_unlock;
++ }
++
++ if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) {
++ retval = -ENODEV;
++ goto out_unlock;
+ }
+- if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS)
+- return -ENODEV;
+
+- mutex_lock(&p->mutex);
+ retval = pqm_set_gws(&p->pqm, args->queue_id, args->num_gws ? dev->gws : NULL);
+ mutex_unlock(&p->mutex);
+
+ args->first_gws = 0;
+ return retval;
++
++out_unlock:
++ mutex_unlock(&p->mutex);
++ return retval;
+ }
+
+ static int kfd_ioctl_get_dmabuf_info(struct file *filep,
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+index 267c2e4d69a0..40c2b0d5a954 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+@@ -1035,6 +1035,8 @@ int pqm_set_gws(struct process_queue_manager *pqm, unsigned int qid,
+ void *gws);
+ struct kernel_queue *pqm_get_kernel_queue(struct process_queue_manager *pqm,
+ unsigned int qid);
++struct queue *pqm_get_user_queue(struct process_queue_manager *pqm,
++ unsigned int qid);
+ int pqm_get_wave_state(struct process_queue_manager *pqm,
+ unsigned int qid,
+ void __user *ctl_stack,
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+index 7e6c3ee82f5b..7a61a5b09ed8 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+@@ -473,6 +473,15 @@ struct kernel_queue *pqm_get_kernel_queue(
+ return NULL;
+ }
+
++struct queue *pqm_get_user_queue(struct process_queue_manager *pqm,
++ unsigned int qid)
++{
++ struct process_queue_node *pqn;
++
++ pqn = get_queue_by_qid(pqm, qid);
++ return pqn ? pqn->q : NULL;
++}
++
+ int pqm_get_wave_state(struct process_queue_manager *pqm,
+ unsigned int qid,
+ void __user *ctl_stack,
+diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
+index 082f28493e14..8c2862565444 100644
+--- a/include/uapi/linux/kfd_ioctl.h
++++ b/include/uapi/linux/kfd_ioctl.h
+@@ -477,17 +477,16 @@ enum kfd_mmio_remap {
+
+ /* Allocate GWS for specific queue
+ *
+- * @gpu_id: device identifier
+ * @queue_id: queue's id that GWS is allocated for
+ * @num_gws: how many GWS to allocate
+ * @first_gws: index of the first GWS allocated.
+ * only support contiguous GWS allocation
+ */
+ struct kfd_ioctl_alloc_queue_gws_args {
+- __u32 gpu_id; /* to KFD */
+ __u32 queue_id; /* to KFD */
+ __u32 num_gws; /* to KFD */
+ __u32 first_gws; /* from KFD */
++ __u32 pad;
+ };
+
+ struct kfd_ioctl_get_dmabuf_info_args {
+--
+2.17.1
+