From 28b40611d0f485545854a1544ec0462d430307d0 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Tue, 21 Mar 2017 11:47:11 -0400 Subject: [PATCH 1251/4131] drm/amdkfd: Enable quiesce/resume_mm of multiple kfd_devs If kfd_dev* passed to the quiesce_mm/resume_mm functions is NULL, quiesce or resume all devices. This capability will be used by a rewritten MMU-notifier. Change-Id: Ifffd7083d6c4ebe1646bc4cd215b11d41dd0736d Signed-off-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 108 ++++++++++++++++---------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index 1d10eed..0e95fb2 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -721,60 +721,6 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry) spin_unlock(&kfd->interrupt_lock); } -int kgd2kfd_quiesce_mm(struct kfd_dev *kfd, struct mm_struct *mm) -{ - struct kfd_process *p; - struct kfd_process_device *pdd; - int r; - - BUG_ON(kfd == NULL); - if (!kfd->init_complete) - return 0; - - /* Because we are called from arbitrary context (workqueue) as opposed - * to process context, kfd_process could attempt to exit while we are - * running so the lookup function increments the process ref count. - */ - p = kfd_lookup_process_by_mm(mm); - if (!p) - return -ENODEV; - - r = -ENODEV; - pdd = kfd_get_process_device_data(kfd, p); - if (pdd) - r = process_evict_queues(kfd->dqm, &pdd->qpd); - - kfd_unref_process(p); - return r; -} - -int kgd2kfd_resume_mm(struct kfd_dev *kfd, struct mm_struct *mm) -{ - struct kfd_process *p; - struct kfd_process_device *pdd; - int r; - - BUG_ON(kfd == NULL); - if (!kfd->init_complete) - return 0; - - /* Because we are called from arbitrary context (workqueue) as opposed - * to process context, kfd_process could attempt to exit while we are - * running so the lookup function increments the process ref count. - */ - p = kfd_lookup_process_by_mm(mm); - if (!p) - return -ENODEV; - - r = -ENODEV; - pdd = kfd_get_process_device_data(kfd, p); - if (pdd) - r = process_restore_queues(kfd->dqm, &pdd->qpd); - - kfd_unref_process(p); - return r; -} - /* quiesce_process_mm - * Quiesce all user queues that belongs to given process p */ @@ -839,6 +785,60 @@ static int resume_process_mm(struct kfd_process *p) return ret; } +int kgd2kfd_quiesce_mm(struct kfd_dev *kfd, struct mm_struct *mm) +{ + struct kfd_process *p; + struct kfd_process_device *pdd; + int r; + + /* Because we are called from arbitrary context (workqueue) as opposed + * to process context, kfd_process could attempt to exit while we are + * running so the lookup function increments the process ref count. + */ + p = kfd_lookup_process_by_mm(mm); + if (!p) + return -ENODEV; + + if (kfd) { + r = -ENODEV; + pdd = kfd_get_process_device_data(kfd, p); + if (pdd) + r = process_evict_queues(kfd->dqm, &pdd->qpd); + } else { + r = quiesce_process_mm(p); + } + + kfd_unref_process(p); + return r; +} + +int kgd2kfd_resume_mm(struct kfd_dev *kfd, struct mm_struct *mm) +{ + struct kfd_process *p; + struct kfd_process_device *pdd; + int r; + + /* Because we are called from arbitrary context (workqueue) as opposed + * to process context, kfd_process could attempt to exit while we are + * running so the lookup function increments the process ref count. + */ + p = kfd_lookup_process_by_mm(mm); + if (!p) + return -ENODEV; + + if (kfd) { + r = -ENODEV; + pdd = kfd_get_process_device_data(kfd, p); + if (pdd) + r = process_restore_queues(kfd->dqm, &pdd->qpd); + } else { + r = resume_process_mm(p); + } + + kfd_unref_process(p); + return r; +} + void kfd_restore_bo_worker(struct work_struct *work) { -- 2.7.4