summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdkfd/kfd_process.c
diff options
context:
space:
mode:
authorOded Gabbay <oded.gabbay@amd.com>2014-07-17 00:06:27 +0300
committerOded Gabbay <oded.gabbay@amd.com>2014-07-17 00:06:27 +0300
commitb17f068a09fbe9b193a18080ff8ad5114a900124 (patch)
treeb9f98a743a12fce638f780c60242cd9f69529627 /drivers/gpu/drm/amd/amdkfd/kfd_process.c
parent19f6d2a660340d01bcdb7a09557efeeee28d1517 (diff)
downloadop-kernel-dev-b17f068a09fbe9b193a18080ff8ad5114a900124.zip
op-kernel-dev-b17f068a09fbe9b193a18080ff8ad5114a900124.tar.gz
amdkfd: Add binding/unbinding calls to amd_iommu driver
This patch adds the functions to bind and unbind pasid from a device through the amd_iommu driver. The unbind function is called when the mm_struct of the process is released. The bind function is not called here because it is called only in the IOCTLs which are not yet implemented at this stage of the patchset. Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdkfd/kfd_process.c')
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_process.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 5596f69..5084794 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -24,6 +24,7 @@
#include <linux/log2.h>
#include <linux/sched.h>
#include <linux/slab.h>
+#include <linux/amd-iommu.h>
#include <linux/notifier.h>
struct mm_struct;
@@ -163,6 +164,7 @@ static void kfd_process_wq_release(struct work_struct *work)
list_for_each_entry_safe(pdd, temp, &p->per_device_data,
per_device_list) {
+ amd_iommu_unbind_pasid(pdd->dev->pdev, p->pasid);
list_del(&pdd->per_device_list);
kfree(pdd);
@@ -316,6 +318,7 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
struct kfd_process *p)
{
struct kfd_process_device *pdd = kfd_get_process_device_data(dev, p, 1);
+ int err;
if (pdd == NULL)
return ERR_PTR(-ENOMEM);
@@ -323,6 +326,15 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
if (pdd->bound)
return pdd;
+ err = amd_iommu_bind_pasid(dev->pdev, p->pasid, p->lead_thread);
+ if (err < 0)
+ return ERR_PTR(err);
+
+ if (err < 0) {
+ amd_iommu_unbind_pasid(dev->pdev, p->pasid);
+ return ERR_PTR(err);
+ }
+
pdd->bound = true;
return pdd;
OpenPOWER on IntegriCloud