aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOak Zeng <Oak.Zeng@amd.com>2019-05-06 23:11:14 -0400
committerAlex Deucher <alexander.deucher@amd.com>2019-05-28 15:44:31 -0400
commit1a058c3376765ee31d65e28cbbb9d4ff15120056 (patch)
treecbb619dc524ae65c831aaab75d351f4f04788a0b
parenteb82da1dc4429c026a165f419f8c76d7bbdcf26f (diff)
drm/amdkfd: New IOCTL to allocate queue GWS
Add a new kfd ioctl to allocate queue GWS. Queue GWS is released on queue destroy. Signed-off-by: Oak Zeng <Oak.Zeng@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_chardev.c27
-rw-r--r--include/uapi/linux/kfd_ioctl.h20
2 files changed, 46 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index c92e931ceb27..aab2aa6c1dee 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1567,6 +1567,31 @@ copy_from_user_failed:
1567 return err; 1567 return err;
1568} 1568}
1569 1569
1570static int kfd_ioctl_alloc_queue_gws(struct file *filep,
1571 struct kfd_process *p, void *data)
1572{
1573 int retval;
1574 struct kfd_ioctl_alloc_queue_gws_args *args = data;
1575 struct kfd_dev *dev = NULL;
1576
1577 if (!hws_gws_support ||
1578 dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS)
1579 return -EINVAL;
1580
1581 dev = kfd_device_by_id(args->gpu_id);
1582 if (!dev) {
1583 pr_debug("Could not find gpu id 0x%x\n", args->gpu_id);
1584 return -EINVAL;
1585 }
1586
1587 mutex_lock(&p->mutex);
1588 retval = pqm_set_gws(&p->pqm, args->queue_id, args->num_gws ? dev->gws : NULL);
1589 mutex_unlock(&p->mutex);
1590
1591 args->first_gws = 0;
1592 return retval;
1593}
1594
1570static int kfd_ioctl_get_dmabuf_info(struct file *filep, 1595static int kfd_ioctl_get_dmabuf_info(struct file *filep,
1571 struct kfd_process *p, void *data) 1596 struct kfd_process *p, void *data)
1572{ 1597{
@@ -1769,6 +1794,8 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
1769 AMDKFD_IOCTL_DEF(AMDKFD_IOC_IMPORT_DMABUF, 1794 AMDKFD_IOCTL_DEF(AMDKFD_IOC_IMPORT_DMABUF,
1770 kfd_ioctl_import_dmabuf, 0), 1795 kfd_ioctl_import_dmabuf, 0),
1771 1796
1797 AMDKFD_IOCTL_DEF(AMDKFD_IOC_ALLOC_QUEUE_GWS,
1798 kfd_ioctl_alloc_queue_gws, 0),
1772}; 1799};
1773 1800
1774#define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls) 1801#define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls)
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 20917c59f39c..070d1bc7e725 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -410,6 +410,21 @@ struct kfd_ioctl_unmap_memory_from_gpu_args {
410 __u32 n_success; /* to/from KFD */ 410 __u32 n_success; /* to/from KFD */
411}; 411};
412 412
413/* Allocate GWS for specific queue
414 *
415 * @gpu_id: device identifier
416 * @queue_id: queue's id that GWS is allocated for
417 * @num_gws: how many GWS to allocate
418 * @first_gws: index of the first GWS allocated.
419 * only support contiguous GWS allocation
420 */
421struct kfd_ioctl_alloc_queue_gws_args {
422 __u32 gpu_id; /* to KFD */
423 __u32 queue_id; /* to KFD */
424 __u32 num_gws; /* to KFD */
425 __u32 first_gws; /* from KFD */
426};
427
413struct kfd_ioctl_get_dmabuf_info_args { 428struct kfd_ioctl_get_dmabuf_info_args {
414 __u64 size; /* from KFD */ 429 __u64 size; /* from KFD */
415 __u64 metadata_ptr; /* to KFD */ 430 __u64 metadata_ptr; /* to KFD */
@@ -529,7 +544,10 @@ enum kfd_mmio_remap {
529#define AMDKFD_IOC_IMPORT_DMABUF \ 544#define AMDKFD_IOC_IMPORT_DMABUF \
530 AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args) 545 AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args)
531 546
547#define AMDKFD_IOC_ALLOC_QUEUE_GWS \
548 AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args)
549
532#define AMDKFD_COMMAND_START 0x01 550#define AMDKFD_COMMAND_START 0x01
533#define AMDKFD_COMMAND_END 0x1E 551#define AMDKFD_COMMAND_END 0x1F
534 552
535#endif 553#endif