[PATCH 14/23] drm/amdgpu: export two mailbox interface to amdgpu

Xiangliang Yu Xiangliang.Yu at amd.com
Sat Dec 17 16:16:36 UTC 2016


KFD also will access GPU registers when loading/unloading drivers,
so can't hide the mailbox in mxgpu. Right now, can't find any way
to put it into kfd interface, export it into amdgpu.

Signed-off-by: Xiangliang Yu <Xiangliang.Yu at amd.com>
Signed-off-by: shaoyunl <Shaoyun.Liu at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c  |  4 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  4 ++++
 drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c     | 28 ++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 3273d8c..1f152f2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -60,6 +60,8 @@ int amdgpu_driver_unload_kms(struct drm_device *dev)
 	if (adev->rmmio == NULL)
 		goto done_free;
 
+	amdgpu_get_gpu(adev);
+
 	if (amdgpu_device_is_px(dev)) {
 		pm_runtime_get_sync(dev->dev);
 		pm_runtime_forbid(dev->dev);
@@ -139,6 +141,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
 		pm_runtime_put_autosuspend(dev->dev);
 	}
 
+	amdgpu_put_gpu(adev);
+
 out:
 	if (r) {
 		/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index d6f57a2..97aae31 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
@@ -71,4 +71,8 @@ int amdgpu_vm_map_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm);
 void amdgpu_vm_unmap_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm);
 void amdgpu_gfx_ring_emit_meta_data(struct amdgpu_ring *ring,
 				    struct amdgpu_vm *vm);
+
+/* get full gpu access */
+int amdgpu_get_gpu(struct amdgpu_device *adev);
+int amdgpu_put_gpu(struct amdgpu_device *adev);
 #endif
diff --git a/drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c b/drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c
index b74b501..387246c 100644
--- a/drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c
+++ b/drivers/gpu/drm/amd/mxgpu/mxgpu_mb.c
@@ -126,3 +126,31 @@ int xgpu_release_full_gpu_access(struct amdgpu_device *adev, bool init)
 
 	return r;
 }
+
+int amdgpu_get_gpu(struct amdgpu_device *adev)
+{
+	int r = 0;
+
+	if (!adev->priv_data)
+		return 0;
+
+	r = xgpu_request_full_gpu_access(adev, false);
+	if (r)
+		return r;
+
+	return 0;
+}
+
+int amdgpu_put_gpu(struct amdgpu_device *adev)
+{
+	int r = 0;
+
+	if (!adev->priv_data)
+		return 0;
+
+	r = xgpu_release_full_gpu_access(adev, true);
+	if (r)
+		return r;
+
+	return 0;
+}
-- 
2.7.4



More information about the amd-gfx mailing list