* [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* RE: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device allocation
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
0 siblings, 1 reply; 5+ messages in thread
From: Yu, Lang @ 2024-01-16 13:58 UTC (permalink / raw)
To: Iouri Tarassov, linux-hyperv@vger.kernel.org
[Public]
ping
>-----Original Message-----
>From: Yu, Lang <Lang.Yu@amd.com>
>Sent: Wednesday, December 27, 2023 11:50 AM
>To: Iouri Tarassov <iourit@linux.microsoft.com>
>Cc: linux-hyperv@vger.kernel.org; Yu, Lang <Lang.Yu@amd.com>
>Subject: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device
>allocation
>
>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 [flat|nested] 5+ messages in thread* Re: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device allocation
2024-01-16 13:58 ` Yu, Lang
@ 2024-01-17 2:53 ` Wei Liu
2024-01-17 2:59 ` Yu, Lang
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2024-01-17 2:53 UTC (permalink / raw)
To: Yu, Lang; +Cc: Iouri Tarassov, linux-hyperv@vger.kernel.org, Wei Liu
On Tue, Jan 16, 2024 at 01:58:53PM +0000, Yu, Lang wrote:
> [Public]
>
> ping
>
> >-----Original Message-----
> >From: Yu, Lang <Lang.Yu@amd.com>
> >Sent: Wednesday, December 27, 2023 11:50 AM
> >To: Iouri Tarassov <iourit@linux.microsoft.com>
> >Cc: linux-hyperv@vger.kernel.org; Yu, Lang <Lang.Yu@amd.com>
> >Subject: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device
> >allocation
> >
> >The movtivation is we want to unify CPU VA and GPU VA.
> >
> >Signed-off-by: Lang Yu <Lang.Yu@amd.com>
Hi Lang,
The driver is not merged upstream. I won't take any further action here
because there is nothing I can do. Perhaps you can work directly with
Iouri to merge the change to the driver he maintains.
Thanks,
Wei.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device allocation
2024-01-17 2:53 ` Wei Liu
@ 2024-01-17 2:59 ` Yu, Lang
2024-01-17 3:02 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Yu, Lang @ 2024-01-17 2:59 UTC (permalink / raw)
To: Wei Liu; +Cc: Iouri Tarassov, linux-hyperv@vger.kernel.org
[Public]
>-----Original Message-----
>From: Wei Liu <wei.liu@kernel.org>
>Sent: Wednesday, January 17, 2024 10:53 AM
>To: Yu, Lang <Lang.Yu@amd.com>
>Cc: Iouri Tarassov <iourit@linux.microsoft.com>; linux-hyperv@vger.kernel.org;
>Wei Liu <wei.liu@kernel.org>
>Subject: Re: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device
>allocation
>
>On Tue, Jan 16, 2024 at 01:58:53PM +0000, Yu, Lang wrote:
>> [Public]
>>
>> ping
>>
>> >-----Original Message-----
>> >From: Yu, Lang <Lang.Yu@amd.com>
>> >Sent: Wednesday, December 27, 2023 11:50 AM
>> >To: Iouri Tarassov <iourit@linux.microsoft.com>
>> >Cc: linux-hyperv@vger.kernel.org; Yu, Lang <Lang.Yu@amd.com>
>> >Subject: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA
>> >for device allocation
>> >
>> >The movtivation is we want to unify CPU VA and GPU VA.
>> >
>> >Signed-off-by: Lang Yu <Lang.Yu@amd.com>
>
>Hi Lang,
>
>The driver is not merged upstream. I won't take any further action here because
>there is nothing I can do. Perhaps you can work directly with Iouri to merge the
>change to the driver he maintains.
Thanks. Got it.
https://github.com/microsoft/WSL2-Linux-Kernel?tab=readme-ov-file#feature-requests tells me submitting the change upstream.
Regards,
Lang
>Thanks,
>Wei.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device allocation
2024-01-17 2:59 ` Yu, Lang
@ 2024-01-17 3:02 ` Wei Liu
0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2024-01-17 3:02 UTC (permalink / raw)
To: Yu, Lang; +Cc: Wei Liu, Iouri Tarassov, linux-hyperv@vger.kernel.org
On Wed, Jan 17, 2024 at 02:59:55AM +0000, Yu, Lang wrote:
> [Public]
>
> >-----Original Message-----
> >From: Wei Liu <wei.liu@kernel.org>
> >Sent: Wednesday, January 17, 2024 10:53 AM
> >To: Yu, Lang <Lang.Yu@amd.com>
> >Cc: Iouri Tarassov <iourit@linux.microsoft.com>; linux-hyperv@vger.kernel.org;
> >Wei Liu <wei.liu@kernel.org>
> >Subject: Re: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA for device
> >allocation
> >
> >On Tue, Jan 16, 2024 at 01:58:53PM +0000, Yu, Lang wrote:
> >> [Public]
> >>
> >> ping
> >>
> >> >-----Original Message-----
> >> >From: Yu, Lang <Lang.Yu@amd.com>
> >> >Sent: Wednesday, December 27, 2023 11:50 AM
> >> >To: Iouri Tarassov <iourit@linux.microsoft.com>
> >> >Cc: linux-hyperv@vger.kernel.org; Yu, Lang <Lang.Yu@amd.com>
> >> >Subject: [PATCH] drivers: hv: dxgkrnl: Allow user to specify CPU VA
> >> >for device allocation
> >> >
> >> >The movtivation is we want to unify CPU VA and GPU VA.
> >> >
> >> >Signed-off-by: Lang Yu <Lang.Yu@amd.com>
> >
> >Hi Lang,
> >
> >The driver is not merged upstream. I won't take any further action here because
> >there is nothing I can do. Perhaps you can work directly with Iouri to merge the
> >change to the driver he maintains.
>
> Thanks. Got it.
> https://github.com/microsoft/WSL2-Linux-Kernel?tab=readme-ov-file#feature-requests tells me submitting the change upstream.
That's true in general,but in this case because the driver itself is not
upstreamed yet so it cannot be applied.
Don't let this discourage you. If you author changes to code that is
already upstreamed, do submit them to the respective mailing lists.
Thanks,
Wei.
>
> Regards,
> Lang
>
> >Thanks,
> >Wei.
^ permalink raw reply [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