转发: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Forward to amd-gfx.

å??件人: Yu, Xiangliang
å??é??æ?¶é?´: Monday, December 19, 2016 1:49 PM
�件人: Liu, Monk; dl.SRDC_SW_GPUVirtualization
主�: RE: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization

Make sense.


Thanks!
Xiangliang Yu

From: Liu, Monk
Sent: Monday, December 19, 2016 1:28 PM
To: Yu, Xiangliang <Xiangliang.Yu at amd.com<mailto:Xiangliang.Yu at amd.com>>; dl.SRDC_SW_GPUVirtualization <dl.SRDC_SW_GPUVirtualization at amd.com<mailto:dl.SRDC_SW_GPUVirtualization at amd.com>>
Subject: ��: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization


NAK, there is not need to do that





         spinlock_t                      gtt_list_lock;
         struct list_head                gtt_list;

+       /* GPU virtualization */
+       void                            *priv_data;
 };



just do like this:



         spinlock_t                      gtt_list_lock;
         struct list_head                gtt_list;

+       /* GPU virtualization */
+       struct amdgpu_virtualization virtualization;
 };



don't use needless pointer in amdgpu_device structures, which brings more kmalloc/kfree cost on,



you can just put "struct amdgpu_virtualization" structure definition in amdgpu_virt.h





________________________________
å??件人: Yu, Xiangliang
å??é??æ?¶é?´: 2016å¹´12æ??18æ?¥ 9:48:30
�件人: dl.SRDC_SW_GPUVirtualization
主�: FW: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization



-----Original Message-----
From: Xiangliang Yu [mailto:Xiangliang.Yu@xxxxxxx]
Sent: Sunday, December 18, 2016 12:16 AM
To: amd-gfx at lists.freedesktop.org<mailto:amd-gfx at lists.freedesktop.org>; dl.SRDC_SW_GPUVirtualization <dl.SRDC_SW_GPUVirtualization at amd.com<mailto:dl.SRDC_SW_GPUVirtualization at amd.com>>
Cc: Yu, Xiangliang <Xiangliang.Yu at amd.com<mailto:Xiangliang.Yu at amd.com>>
Subject: [PATCH 07/23] drm/amdgpu: create new directory for GPU virtualization

Create new directory for GPU virtualization and name it with marketing name, so it will easy to mantainer all realted virtual code and make it independent so that will not affect other parts.

And create new pointer and interface to connect virtualization code with amdgpu core code.

Signed-off-by: Xiangliang Yu <Xiangliang.Yu at amd.com<mailto:Xiangliang.Yu at amd.com>>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |   2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |   3 +-
 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c    | 104 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h    |  37 +++++++++++
 4 files changed, 145 insertions(+), 1 deletion(-)  create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c
 create mode 100644 drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 25a3a2a..b0a8d8f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1511,6 +1511,8 @@ struct amdgpu_device {
         spinlock_t                      gtt_list_lock;
         struct list_head                gtt_list;

+       /* GPU virtualization */
+       void                            *priv_data;
 };

 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index 2c37a37..8ee70f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
@@ -54,4 +54,5 @@ static inline bool is_virtual_machine(void)  #endif  }

-#endif
\ No newline at end of file
+int amd_xgpu_set_ip_blocks(struct amdgpu_device *adev); #endif
diff --git a/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c b/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c
new file mode 100644
index 0000000..72469e2
--- /dev/null
+++ b/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+obtaining a
+ * copy of this software and associated documentation files (the
+"Software"),
+ * to deal in the Software without restriction, including without
+limitation
+ * the rights to use, copy, modify, merge, publish, distribute,
+sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
+the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
+SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
+DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Xiangliang.Yu at amd.com<mailto:Xiangliang.Yu at amd.com>
+ *
+ */
+#include "amd_mxgpu.h"
+
+int amd_xgpu_alloc(struct amdgpu_device *adev) {
+       struct amd_xgpu *xgpu = NULL;
+
+       if (!adev->priv_data) {
+               xgpu = kzalloc(sizeof(struct amd_xgpu), GFP_KERNEL);
+               if (!xgpu)
+                       goto error;
+
+               adev->priv_data = xgpu;
+       }
+
+       xgpu->adev = adev;
+       mutex_init(&xgpu->lock);
+
+       return 0;
+
+error:
+       DRM_ERROR("xgpu: failed to allocate xgpu data.\n");
+       return -ENOMEM;
+}
+
+void amd_xgpu_free(struct amd_xgpu *xgpu) {
+       struct amdgpu_device *adev = xgpu->adev;
+
+       kfree(xgpu);
+       adev->priv_data = NULL;
+}
+
+static int amd_xgpu_init_ip_blocks(struct amdgpu_device *adev) {
+       int r = 0;
+
+       switch (adev->asic_type) {
+       case CHIP_TONGA:
+       case CHIP_FIJI:
+               /* add IP blocks*/
+               break;
+       default:
+               DRM_ERROR("Does not support this chip.\n");
+               r = -ENODEV;
+               break;
+       }
+
+       return r;
+}
+
+static void amd_xgpu_init_default_setting(struct amdgpu_device *adev) {
+       /* virtual display setting */
+       adev->mode_info.num_crtc = 1;
+       /* don't need dc */
+       amdgpu_dc = 0;
+       /* disable dpm */
+       amdgpu_dpm = 0;
+}
+
+/*
+ * tell amdgpu IP block info of VF
+ */
+int amd_xgpu_set_ip_blocks(struct amdgpu_device *adev) {
+       int r = 0;
+
+       if (!is_virtual_machine()) {
+               DRM_ERROR("Host OS can't support VF device.\n");
+               return -EPERM;
+       }
+
+       r = amd_xgpu_init_ip_blocks(adev);
+       if (r)
+               return r;
+
+       amd_xgpu_init_default_setting(adev);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h b/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h
new file mode 100644
index 0000000..6ab13bc
--- /dev/null
+++ b/drivers/gpu/drm/amd/mxgpu/amd_mxgpu.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+obtaining a
+ * copy of this software and associated documentation files (the
+"Software"),
+ * to deal in the Software without restriction, including without
+limitation
+ * the rights to use, copy, modify, merge, publish, distribute,
+sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom
+the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
+SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
+DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Xiangliang.Yu at amd.com<mailto:Xiangliang.Yu at amd.com>
+ */
+#ifndef __AMDGPU_XGPU_H__
+#define __AMDGPU_XGPU_H__
+
+#include "amdgpu.h"
+
+struct amd_xgpu {
+       struct amdgpu_device    *adev;
+       struct mutex            lock;
+       u32                     reg_val_offs;
+};
+
+extern int amd_xgpu_alloc(struct amdgpu_device *adev); extern void
+amd_xgpu_free(struct amd_xgpu *xgpu); #endif
--
2.7.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20161219/d7fe2b89/attachment-0001.html>


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux