public inbox for linux-hyperv@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device allocation
@ 2023-12-27  3:49 Lang Yu
  2024-01-16 13:58 ` Yu, Lang
  0 siblings, 1 reply; 5+ messages in thread
From: Lang Yu @ 2023-12-27  3:49 UTC (permalink / raw)
  To: Iouri Tarassov; +Cc: linux-hyperv, Lang Yu

The movtivation is we want to unify CPU VA and GPU VA.

Signed-off-by: Lang Yu <Lang.Yu@amd.com>
---
 drivers/hv/dxgkrnl/dxgvmbus.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/dxgkrnl/dxgvmbus.c b/drivers/hv/dxgkrnl/dxgvmbus.c
index 9320bede3a0a..a4bca27a7cc8 100644
--- a/drivers/hv/dxgkrnl/dxgvmbus.c
+++ b/drivers/hv/dxgkrnl/dxgvmbus.c
@@ -580,7 +580,7 @@ int dxg_unmap_iospace(void *va, u32 size)
 	return 0;
 }
 
-static u8 *dxg_map_iospace(u64 iospace_address, u32 size,
+static u8 *dxg_map_iospace(u64 iospace_address, u64 user_va, u32 size,
 			   unsigned long protection, bool cached)
 {
 	struct vm_area_struct *vma;
@@ -594,7 +594,12 @@ static u8 *dxg_map_iospace(u64 iospace_address, u32 size,
 		return NULL;
 	}
 
-	va = vm_mmap(NULL, 0, size, protection, MAP_SHARED | MAP_ANONYMOUS, 0);
+	if (user_va)
+		va = vm_mmap(untagged_addr(user_va), 0, size, protection,
+			     MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
+	else
+		va = vm_mmap(NULL, 0, size, protection,
+			     MAP_SHARED | MAP_ANONYMOUS, 0);
 	if ((long)va <= 0) {
 		DXG_ERR("vm_mmap failed %lx %d", va, size);
 		return NULL;
@@ -789,9 +794,8 @@ int dxgvmb_send_open_sync_object_nt(struct dxgprocess *process,
 
 	args->sync_object = result.sync_object;
 	if (syncobj->monitored_fence) {
-		void *va = dxg_map_iospace(result.guest_cpu_physical_address,
-					   PAGE_SIZE, PROT_READ | PROT_WRITE,
-					   true);
+		void *va = dxg_map_iospace(result.guest_cpu_physical_address, 0,
+					   PAGE_SIZE, PROT_READ | PROT_WRITE, true);
 		if (va == NULL) {
 			ret = -ENOMEM;
 			goto cleanup;
@@ -1315,8 +1319,8 @@ int dxgvmb_send_create_paging_queue(struct dxgprocess *process,
 	args->paging_queue = result.paging_queue;
 	args->sync_object = result.sync_object;
 	args->fence_cpu_virtual_address =
-	    dxg_map_iospace(result.fence_storage_physical_address, PAGE_SIZE,
-			    PROT_READ | PROT_WRITE, true);
+	    dxg_map_iospace(result.fence_storage_physical_address, 0,
+			    PAGE_SIZE, PROT_READ | PROT_WRITE, true);
 	if (args->fence_cpu_virtual_address == NULL) {
 		ret = -ENOMEM;
 		goto cleanup;
@@ -2867,7 +2871,7 @@ dxgvmb_send_create_sync_object(struct dxgprocess *process,
 	}
 
 	if (syncobj->monitored_fence) {
-		va = dxg_map_iospace(result.fence_storage_address, PAGE_SIZE,
+		va = dxg_map_iospace(result.fence_storage_address, 0, PAGE_SIZE,
 				     PROT_READ | PROT_WRITE, true);
 		if (va == NULL) {
 			ret = -ENOMEM;
@@ -3156,7 +3160,7 @@ int dxgvmb_send_lock2(struct dxgprocess *process,
 		} else {
 			u64 offset = (u64)result.cpu_visible_buffer_offset;
 
-			args->data = dxg_map_iospace(offset,
+			args->data = dxg_map_iospace(offset, args->data,
 					alloc->num_pages << PAGE_SHIFT,
 					PROT_READ | PROT_WRITE, alloc->cached);
 			if (args->data) {
@@ -3712,7 +3716,7 @@ int dxgvmb_send_create_hwqueue(struct dxgprocess *process,
 	}
 
 	hwqueue->progress_fence_mapped_address =
-		dxg_map_iospace((u64)command->hwqueue_progress_fence_cpuva,
+		dxg_map_iospace((u64)command->hwqueue_progress_fence_cpuva, 0,
 				PAGE_SIZE, PROT_READ | PROT_WRITE, true);
 	if (hwqueue->progress_fence_mapped_address == NULL) {
 		ret = -ENOMEM;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-17  3:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27  3:49 [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device allocation Lang Yu
2024-01-16 13:58 ` Yu, Lang
2024-01-17  2:53   ` Wei Liu
2024-01-17  2:59     ` Yu, Lang
2024-01-17  3:02       ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox