Skip to contentSkip to conversation

static CSA patches

PATCH New Monk Liu 1 participant 4 messages Jan 10, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

cover static CSA patches

allocate/deallocate static CSA per device
and map CSA per VM
no need to unmap CSA when VM die.

*** BLURB HERE ***

Monk Liu (3):
drm/amdgpu:new field members for SRIOV
drm/amdgpu:add new file for SRIOV
drm/amdgpu:invoke CSA functions

 drivers/gpu/drm/amd/amdgpu/Makefile        |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     |  14 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  12 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    |   6 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c   | 105 +++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h   |  19 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |   2 +
 drivers/gpu/drm/amd/amdgpu/vi.c            |   3 +
 8 files changed, 162 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1484044422-2898-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 1/3 drm/amdgpu:new field members for SRIOV

and implement CSA functions in this file

Change-Id Ife0eff7b13b8b5946f005a39f6ecb8db1cb72c38
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 14 ++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h   |  2 ++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +14 -0
index 0d821d9..cc36d28 100644
@@ -28,9 +28,23 @@
 #define AMDGPU_SRIOV_CAPS_ENABLE_IOV   (1 << 1) /* sr-iov is enabled on this GPU */
 #define AMDGPU_SRIOV_CAPS_IS_VF        (1 << 2) /* this GPU is a virtual function */
 #define AMDGPU_PASSTHROUGH_MODE        (1 << 3) /* thw whole GPU is pass through for VM */
+
 /* GPU virtualization */
 struct amdgpu_virt {
 	uint32_t caps;
+	uint32_t csa_size;
+	struct amdgpu_bo *csa_obj;
+	uint64_t csa_vmid0_addr;
+	uint64_t gds_vmid0_addr;
+};
+
+struct amdgpu_vm_virt {
+	/* each VM will map on CSA */
+	struct ttm_validate_buffer csa_tv;
+	struct amdgpu_bo_va *csa_bo_va;
+	/* virtual MC address of CSA & GDS for each VM */
+	uint64_t vm_csa_addr;
+	uint64_t vm_gds_addr;
 };
 
 #define amdgpu_sriov_enabled(adev) \
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -0
index 42a629b..27cbcbc 100644
@@ -29,6 +29,7 @@
 #include "gpu_scheduler.h"
 #include "amdgpu_sync.h"
 #include "amdgpu_ring.h"
+#include "amdgpu_virt.h"
 
 struct amdgpu_bo_va;
 struct amdgpu_job;
@@ -111,6 +112,7 @@ struct amdgpu_vm {
 
 	/* client id */
 	u64                     client_id;
+	struct amdgpu_vm_virt	vm_virt;
 };
 
 struct amdgpu_vm_id {
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 2/3 drm/amdgpu:add new file for SRIOV

In reply to a message not in the archive

for SRIOV usage, CSA is only used per device and each VM will map on it.

Change-Id Ibc63d87be59d7d89b96117e4d1b7e970a872580d
---
 drivers/gpu/drm/amd/amdgpu/Makefile      |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 105 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |   5 ++
 3 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
index 4185b03..0b8e470 100644
@@ -30,7 +30,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
 	atombios_encoders.o amdgpu_sa.o atombios_i2c.o \
 	amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \
 	amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \
-	amdgpu_gtt_mgr.o amdgpu_vram_mgr.o
+	amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o
 
 # add asic specific block
 amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c new file +105 -0

105 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +5 -0
index cc36d28..827162a 100644
@@ -68,4 +68,9 @@ static inline bool is_virtual_machine(void)
 #endif
 }
 
+struct amdgpu_vm;
+int amdgpu_allocate_static_csa(struct amdgpu_device *adev);
+void amdgpu_deallocate_static_csa(struct amdgpu_device *adev);
+int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm);
+
 #endif
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#4 lore raw

PATCH 3/3 drm/amdgpu:invoke CSA functions

In reply to a message not in the archive
Change-Id I110af93c4f17ab18d1be199c6ebe9ee965483a66
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c     | 14 ++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/vi.c            |  3 +++
 4 files changed, 35 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +14 -0
index 6159afc..083ab73 100644
@@ -771,6 +771,20 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
 	if (r)
 		return r;
 
+	if (amdgpu_sriov_vf(adev)) {
+		struct fence *f;
+		bo_va = vm->vm_virt.csa_bo_va;
+		BUG_ON(!bo_va);
+		r = amdgpu_vm_bo_update(adev, bo_va, false);
+		if (r)
+			return r;
+
+		f = bo_va->last_pt_update;
+		r = amdgpu_sync_fence(adev, &p->job->sync, f);
+		if (r)
+			return r;
+	}
+
 	if (p->bo_list) {
 		for (i = 0; i < p->bo_list->num_entries; i++) {
 			struct fence *f;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index f82919d..21b757c 100644
@@ -1384,6 +1384,15 @@ static int amdgpu_init(struct amdgpu_device *adev)
 				return r;
 			}
 			adev->ip_blocks[i].status.hw = true;
+
+			/* right after GMC hw init, we create CSA */
+			if (amdgpu_sriov_vf(adev)) {
+				r = amdgpu_allocate_static_csa(adev);
+				if (r) {
+					DRM_ERROR("allocate CSA failed %d\n", r);
+					return r;
+				}
+			}
 		}
 	}
 
@@ -1517,6 +1526,9 @@ static int amdgpu_fini(struct amdgpu_device *adev)
 		adev->ip_blocks[i].status.late_initialized = false;
 	}
 
+	if (amdgpu_sriov_vf(adev))
+		amdgpu_deallocate_static_csa(adev);
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6 -0
index 47bc8e1..9b37317 100644
@@ -650,6 +650,12 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
 		goto out_suspend;
 	}
 
+	if (amdgpu_sriov_vf(adev)) {
+		r = amdgpu_map_static_csa(adev, &fpriv->vm);
+		if (r)
+			goto out_suspend;
+	}
+
 	mutex_init(&fpriv->bo_list_lock);
 	idr_init(&fpriv->bo_list_handles);
 
drivers/gpu/drm/amd/amdgpu/vi.c +3 -0
index 7350a8f..921917b 100644
@@ -455,6 +455,9 @@ static void vi_detect_hw_virtualization(struct amdgpu_device *adev)
 		if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */
 			adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
 	}
+
+	if (amdgpu_sriov_vf(adev))
+		adev->virt.csa_size = 8 * 1024; /* two page now for VI and AI */
 }
 
 static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = {
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx