[PATCH] AMDGPU: init saw registers for mmhub v1.0

2024-09-12 Thread Zhu Lingshan
This commits init registers in the Stand Along Walker for mmhub v1.0, to support ISP use cases. Signed-off-by: Zhu Lingshan Reported-and-Tested-by: Du Bin --- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 48 +++ .../include/asic_reg/mmhub/mmhub_1_0_offset.h | 23 + 2

Re: [PATCH v2] drm/amdkfd: change kfd process kref count at creation

2024-10-14 Thread Zhu Lingshan
On 10/14/2024 11:07 PM, Chen, Xiaogang wrote: > > On 10/13/2024 8:55 PM, Zhu Lingshan wrote: >> On 10/13/2024 1:30 AM, Chen, Xiaogang wrote: >>> On 10/11/2024 9:56 PM, Zhu Lingshan wrote: >>>> On 10/11/2024 10:41 PM, Xiaogang.Chen wrote: >>>>> F

[PATCH] amdkfd: Explicitly specify data type amdkfd_process_info in related functions

2024-10-14 Thread Zhu Lingshan
sing a specified data type other than void* can help improve readability. There are other benifits like: type safety, avoid casting and better compling chekings. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h| 10 +++--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

Re: [PATCH v2] drm/amdkfd: change kfd process kref count at creation

2024-10-13 Thread Zhu Lingshan
On 10/13/2024 1:30 AM, Chen, Xiaogang wrote: > > On 10/11/2024 9:56 PM, Zhu Lingshan wrote: >> On 10/11/2024 10:41 PM, Xiaogang.Chen wrote: >>> From: Xiaogang Chen >>> >>> kfd process kref count(process->ref) is initialized to 1 by kref_init. After >&

Re: [PATCH] amdkfd: Explicitly specify data type amdkfd_process_info in related functions

2024-10-21 Thread Zhu Lingshan
Gentle Ping On 10/15/2024 11:51 AM, Zhu Lingshan wrote: > This commit specifies data type struct amdkfd_process_info > rather than general void* in ralted functions. > > kfd_process->kgd_process_info is initialized > in init_kfd_vm() by such code: > > static int init_kfd

Re: [PATCH v2] drm/amdkfd: change kfd process kref count at creation

2024-10-11 Thread Zhu Lingshan
On 10/11/2024 10:41 PM, Xiaogang.Chen wrote: > From: Xiaogang Chen > > kfd process kref count(process->ref) is initialized to 1 by kref_init. After > it is created not need to increaes its kref. Instad add kfd process kref at > kfd > process mmu notifier allocation since we decrease the ref at fr

Re: [PATCH] amdkfd: Explicitly specify data type amdkfd_process_info in related functions

2024-10-22 Thread Zhu Lingshan
On 10/22/2024 12:20 PM, Felix Kuehling wrote: > > On 2024-10-14 23:51, Zhu Lingshan wrote: >> This commit specifies data type struct amdkfd_process_info >> rather than general void* in ralted functions. > Several interfaces in amdgpu_amdkfd.h use void * as opaque pointers,

Re: [RESEND] amdkfd: always include uapi header in priv.h

2024-11-05 Thread Zhu Lingshan
On 11/5/2024 4:43 AM, Felix Kuehling wrote: > On 2024-10-31 22:15, Zhu Lingshan wrote: >> On 10/31/2024 11:27 PM, Felix Kuehling wrote: >>> On 2024-10-31 6:47, Zhu Lingshan wrote: >>>> The header usr/linux/kfd_ioctl.h is a duplicate of uapi/linux/kfd_ioctl.h. >>

Re: [RESEND] amdkfd: check ret code for ioctls

2024-11-11 Thread Zhu Lingshan
On 11/5/2024 4:50 AM, Felix Kuehling wrote: > > On 2024-10-31 22:35, Zhu Lingshan wrote: >> On 10/31/2024 11:30 PM, Felix Kuehling wrote: >>> On 2024-10-31 6:50, Zhu Lingshan wrote: >>>> The ioctl functions may fail, causing the args unreliable. >>>>

Re: [RESEND] amdkfd: check ret code for ioctls

2024-11-11 Thread Zhu Lingshan
On 11/12/2024 6:21 AM, Felix Kuehling wrote: > > On 2024-11-11 03:08, Zhu Lingshan wrote: >> On 11/5/2024 4:50 AM, Felix Kuehling wrote: >>> On 2024-10-31 22:35, Zhu Lingshan wrote: >>>> On 10/31/2024 11:30 PM, Felix Kuehling wrote: >>>>> On 2024-

Re: [RESEND] amdkfd: check ret code for ioctls

2024-11-12 Thread Zhu Lingshan
On 11/13/2024 7:46 AM, Felix Kuehling wrote: > > On 2024-11-12 2:35, Zhu Lingshan wrote: >> On 11/12/2024 6:21 AM, Felix Kuehling wrote: >>> On 2024-11-11 03:08, Zhu Lingshan wrote: >>>> On 11/5/2024 4:50 AM, Felix Kuehling wrote: >>>>> On 2024-10-31

[RESEND] amdkfd: always include uapi header in priv.h

2024-10-31 Thread Zhu Lingshan
the kernel. This commit modifies kfd_priv.h to always include the header from uapi to ensure the latest changes are reflected. We should always include the source code header other than the duplication. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed

[RESEND] amdkfd: check ret code for ioctls

2024-10-31 Thread Zhu Lingshan
fail. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 3e6b4736a7fe..a184ca0023b5 100644 --- a/drivers/gpu/drm/amd/amdkfd

Re: [RESEND] amdkfd: always include uapi header in priv.h

2024-10-31 Thread Zhu Lingshan
On 10/31/2024 11:27 PM, Felix Kuehling wrote: > On 2024-10-31 6:47, Zhu Lingshan wrote: >> The header usr/linux/kfd_ioctl.h is a duplicate of uapi/linux/kfd_ioctl.h. > I don't see usr/linux/kfd_ioctl.h. Which branch are you looking at? The mainline master branch: https://github.c

Re: [RESEND] amdkfd: check ret code for ioctls

2024-10-31 Thread Zhu Lingshan
On 10/31/2024 11:30 PM, Felix Kuehling wrote: > > On 2024-10-31 6:50, Zhu Lingshan wrote: >> The ioctl functions may fail, causing the args unreliable. >> Therefore, the args should not be copied to user space. >> >> The return code provides enough information for &

Re: [PATCH] amdkfd: Explicitly specify data type amdkfd_process_info in related functions

2024-10-31 Thread Zhu Lingshan
On 10/22/2024 4:01 PM, Zhu Lingshan wrote: > > On 10/22/2024 12:20 PM, Felix Kuehling wrote: >> On 2024-10-14 23:51, Zhu Lingshan wrote: >>> This commit specifies data type struct amdkfd_process_info >>> rather than general void* in ralted functions. >> Sever

[PATCH 1/2] drm/amdgpu/discovery: add ISP discovery entries for old APUs

2024-09-24 Thread Zhu Lingshan
From: Alex Deucher Raven1/2 and Picasso have ISP 2.0.0, however their ISP blocks are not in the IP discovery table yet. This commit fixes this issue by adding new ISP entries for Raven and Picasso in the IP discovery table. Signed-off-by: Alex Deucher Signed-off-by: Zhu Lingshan --- drivers

[PATCH 2/2] drm/amdgpu: init saw registers for mmhub v1.0

2024-09-24 Thread Zhu Lingshan
This commits init registers in the Stand Along Walker for mmhub v1.0, to support ISP use cases. Signed-off-by: Zhu Lingshan Reported-and-Tested-by: Du Bin --- drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 49 +++ .../include/asic_reg/mmhub/mmhub_1_0_offset.h | 23 + 2

[PATCH 0/2] Init SAW for mmhub 1.0

2024-09-24 Thread Zhu Lingshan
This series intends to initialize the Stand Along Walker for mmhub 1.0, to support the Image Signal Processor Plese help review. Thanks Zhu Lingshan Alex Deucher (1): drm/amdgpu/discovery: add ISP discovery entries for old APUs Zhu Lingshan (1): drm/amdgpu: init saw registers for mmhub

Re: [PATCH] amdkfd: Explicitly specify data type amdkfd_process_info in related functions

2024-11-07 Thread Zhu Lingshan
On 11/5/2024 5:49 AM, Felix Kuehling wrote: > On 2024-10-31 23:20, Zhu Lingshan wrote: >> On 10/22/2024 4:01 PM, Zhu Lingshan wrote: >>> On 10/22/2024 12:20 PM, Felix Kuehling wrote: >>>> On 2024-10-14 23:51, Zhu Lingshan wrote: >>>>> This commit s

Re: [PATCH] drm/amdkfd: test release process eviction fence before signal

2025-01-01 Thread Zhu Lingshan
Hello Prike This issue has already been fixed, please see: https://www.spinics.net/lists/amd-gfx/msg117071.html Thanks Lingshan On 1/2/2025 2:30 PM, Prike Liang wrote: > It requires to validate the release process eviction fence before > signal the fence. > > Signed-off-by: Prike Liang > --- >

[PATCH] amdkfd: properly free gang_ctx_bo when failed to init user queue

2025-02-05 Thread Zhu Lingshan
, passing this void* parameter into the function's execution process(which expects void** and dereferencing void**) will result in errors. Signed-off-by: Zhu Lingshan Fixes: fb91065851cd ("drm/amdkfd: Refactor queue wptr_bo GART mapping") --- drivers/gpu/drm/amd/amdkfd/kfd_process_

[PATCH] amdkfd: wq_release signals dma_fence only when available

2024-12-11 Thread Zhu Lingshan
x10 [ 503.954210] ret_from_fork_asm+0x1a/0x30 [ 503.958142] [ 503.960328] ---[ end trace ]--- Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_proces

Re: [PATCH] amdkfd: wq_release signals dma_fence only when available

2024-12-11 Thread Zhu Lingshan
On 12/12/2024 12:19 PM, Felix Kuehling wrote: > > On 2024-12-11 22:06, Zhu Lingshan wrote: >> kfd_process_wq_release() signals eviction fence by >> dma_fence_signal() which wanrs if dma_fence >> is NULL. > That's news to me. Looking at the dma_fence_signal implement

[PATCH] amdkfd: enlarge the hashtable of kfd_process

2024-12-12 Thread Zhu Lingshan
This commit enlarges the hashtable size of kfd_process to 256 Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index

[PATCH V2] amdkfd: wq_release signals dma_fence only when available

2024-12-12 Thread Zhu Lingshan
x10 [ 503.954210] ret_from_fork_asm+0x1a/0x30 [ 503.958142] [ 503.960328] ---[ end trace ]--- Signed-off-by: Zhu Lingshan Fixes: 967d226eaae8 ("dma-buf: add WARN_ON() illegal dma-fence signaling") --- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++- 1 fi

Re: [RESEND] amdkfd: always include uapi header in priv.h

2024-12-13 Thread Zhu Lingshan
On 11/5/2024 6:35 PM, Lazar, Lijo wrote: > > On 11/5/2024 2:13 AM, Felix Kuehling wrote: >> On 2024-10-31 22:15, Zhu Lingshan wrote: >>> On 10/31/2024 11:27 PM, Felix Kuehling wrote: >>>> On 2024-10-31 6:47, Zhu Lingshan wrote: >>>>> The header us

RE: [PATCH] drm/amdkfd: test release process eviction fence before signal

2025-01-02 Thread Zhu, Lingshan
draft this patch to resolve the HIP stream test that complained about the KFD process signals an invalidate fence on the latest drm-next branch. BTW, it looks like your patch still hasn't landed in the drm-next branch. Regards, Prike > -Original Message- > From: Zhu, Lings

RE: [PATCH] amdkfd: initialize svm lists at where they are defined

2025-02-27 Thread Zhu, Lingshan
[Public] Ping -Original Message- From: Zhu, Lingshan Sent: Friday, February 21, 2025 5:24 PM To: Kuehling, Felix ; Deucher, Alexander Cc: Huang, Ray ; amd-gfx@lists.freedesktop.org; Zhu, Lingshan Subject: [PATCH] amdkfd: initialize svm lists at where they are defined This commit

Re: [PATCH] amdkfd: initialize svm lists at where they are defined

2025-03-03 Thread Zhu Lingshan
On 3/4/2025 1:49 PM, Felix Kuehling wrote: > On 2025-02-21 4:23, Zhu Lingshan wrote: >> This commit initialized svm lists at where they are >> defined. This is defensive programing for security >> and consistency. >> >> Initalizing variables ensures that their sta

Re: [PATCH] amdkfd: initialize svm lists at where they are defined

2025-03-04 Thread Zhu Lingshan
On 3/4/2025 11:16 PM, Felix Kuehling wrote: > On 2025-03-04 2:40, Zhu Lingshan wrote: >> On 3/4/2025 1:49 PM, Felix Kuehling wrote: >>> On 2025-02-21 4:23, Zhu Lingshan wrote: >>>> This commit initialized svm lists at where they are >>>> defined. This is

[PATCH] amdkfd: initialize svm lists at where they are defined

2025-02-21 Thread Zhu Lingshan
not assume the callee would always initialize them Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index bd3e20d981e0

[PATCH 9/9] amdkfd: introduce new ioctl AMDKFD_IOC_CREATE_PROCESS

2025-07-24 Thread Zhu Lingshan
bumps ioctl minor version. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 41 drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +- include/uapi/linux/kfd_ioctl.h | 8 +++-- 4 files

[PATCH 4/9] amdkfd: Introduce kfd_create_process_sysfs as a separate function

2025-07-24 Thread Zhu Lingshan
KFD creates sysfs entries for a kfd_process in function kfd_create_process when creating it. This commit extracts the code creating sysfs entries to a separate function because it would be invoked in other code path like creating secondary kfd contexts (kfd_process). Signed-off-by: Zhu Lingshan

[PATCH 6/9] amdkfd: process svm ioctl only on the primary kfd process

2025-07-24 Thread Zhu Lingshan
svm ioctl should only be processed on the primary kfd process because only the lifecycle of the primary kfd process is tied to the user space applicaiton. Another reason is in virtualization the hypervisor owns the primary kfd process as a privileged one. Signed-off-by: Zhu Lingshan

[PATCH 8/9] amdkfd: identify a secondary kfd process by its id

2025-07-24 Thread Zhu Lingshan
of the sysfs entry of a secondary kfd process is "context_%u" where %u is the process id. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 6 ++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 82 +++- 2 files changed, 85 insertions(+), 3

[PATCH 7/9] amdkfd: process USERPTR allocation only on the primary kfd process

2025-07-24 Thread Zhu Lingshan
The lifecycle of the primary kfd process is tied to the user space program, all secondary kfd process would be destroyed when fd close. Thus only the primary kfd process should process USERPTR memory allocation. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6

[PATCH 0/9] amdkfd: Implement kfd multiple contexts

2025-07-24 Thread Zhu Lingshan
e 2 Zhu Lingshan (9): amdkfd: enlarge the hashtable of kfd_process amdkfd: mark the first kfd_process as the primary one amdkfd: find_process_by_mm always return the primary context amdkfd: Introduce kfd_create_process_sysfs as a separate function amdkfd: destroy kfd second

[PATCH 2/9] amdkfd: mark the first kfd_process as the primary one

2025-07-24 Thread Zhu Lingshan
The first kfd_process is created through open(), this commit marks it as the primary kfd_process. Only the primary process should register the mmu_notifier. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 20

[PATCH 1/9] amdkfd: enlarge the hashtable of kfd_process

2025-07-24 Thread Zhu Lingshan
This commit enlarges the hashtable size of kfd_process to 256, because of the multiple contexts feature allowing each application create multiple kfd_processes Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH 3/9] amdkfd: find_process_by_mm always return the primary context

2025-07-24 Thread Zhu Lingshan
Up until this commit, the kfd multiple contexts feature has not been fully implemented in mainline kernel yet. For backawrd compatibility, not break existing use cases, this commit changes function find_process_by_mm, let it always return the primary kfd_process. Signed-off-by: Zhu Lingshan

[PATCH 5/9] amdkfd: destroy kfd secondary contexts through fd close

2025-07-24 Thread Zhu Lingshan
kfd_process_notifier_release_internal unconditionally. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 9 -- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 41 +--- 3 files changed, 31 insertions(+), 20

Re: [PATCH 8/9] amdkfd: identify a secondary kfd process by its id

2025-07-28 Thread Zhu, Lingshan
Thanks, Felix. All issues have been fixed, and I will send out V2 soon. Thanks Lingshan On 7/29/2025 3:48 AM, Felix Kuehling wrote: > On 2025-07-24 22:43, Zhu Lingshan wrote: >> This commit introduces a new id field for >> struct kfd process, which helps identify >> a kfd p

Re: [PATCH 9/9] amdkfd: introduce new ioctl AMDKFD_IOC_CREATE_PROCESS

2025-07-28 Thread Zhu, Lingshan
On 7/29/2025 3:59 AM, Felix Kuehling wrote: > On 2025-07-24 22:43, Zhu Lingshan wrote: >> This commit implemetns a new ioctl AMDKFD_IOC_CREATE_PROCESS >> that creates a new secondary kfd_progress on the FD. > > To add a new ioctl upstream, do you have a link to the corr

[PATCH V2 06/10] amdkfd: process svm ioctl only on the primary kfd process

2025-08-01 Thread Zhu Lingshan
svm ioctl should only be processed on the primary kfd process because only the lifecycle of the primary kfd process is tied to the user space applicaiton. Another reason is in virtualization the hypervisor owns the primary kfd process as a privileged one. Signed-off-by: Zhu Lingshan Reviewed

[PATCH V2 10/10] amdkfd: introduce new ioctl AMDKFD_IOC_CREATE_PROCESS

2025-08-01 Thread Zhu Lingshan
bumps ioctl minor version. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 41 drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +- include/uapi/linux/kfd_ioctl.h | 8 +++-- 4 files

[PATCH V2 08/10] amdkfd: identify a secondary kfd process by its id

2025-08-01 Thread Zhu Lingshan
of the sysfs entry of a secondary kfd process is "context_%u" where %u is the process id. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 6 ++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 83 +++- 2 files changed, 86 insertions(+), 3

[PATCH V2 09/10] amdkfd: decommission kfd_get_process and remove DIQ support

2025-08-01 Thread Zhu Lingshan
lls it. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 11 ++-- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +- drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 60 ++- .../drm/amd/amdkfd/kfd_packet_manager_v9.c| 4 -- .../drm/amd/

[PATCH V2 00/10] amdkfd: Implement kfd multiple contexts

2025-08-01 Thread Zhu Lingshan
ret = %d\n", ret); getchar(); // close FDs close(fd2); getchar(); close(fd1); getchar(); return EXIT_SUCCESS; } Zhu Lingshan (10): amdkfd: enlarge the hashtable of kfd_process amdkfd: mark the first kfd_process as the prim

[PATCH V2 01/10] amdkfd: enlarge the hashtable of kfd_process

2025-08-01 Thread Zhu Lingshan
This commit enlarges the hashtable size of kfd_process to 256, because of the multiple contexts feature allowing each application create multiple kfd_processes Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion

[PATCH V2 02/10] amdkfd: mark the first kfd_process as the primary one

2025-08-01 Thread Zhu Lingshan
The first kfd_process is created through open(), this commit marks it as the primary kfd_process. Only the primary process should register the mmu_notifier. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 3 +++ drivers/gpu/drm/amd

[PATCH V2 03/10] amdkfd: find_process_by_mm always return the primary context

2025-08-01 Thread Zhu Lingshan
Up until this commit, the kfd multiple contexts feature has not been fully implemented in mainline kernel yet. For backawrd compatibility, not break existing use cases, this commit changes function find_process_by_mm, let it always return the primary kfd_process. Signed-off-by: Zhu Lingshan

[PATCH V2 05/10] amdkfd: destroy kfd secondary contexts through fd close

2025-08-01 Thread Zhu Lingshan
kfd_process_notifier_release_internal unconditionally. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 9 -- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 41 +--- 3 files changed

[PATCH V2 04/10] amdkfd: Introduce kfd_create_process_sysfs as a separate function

2025-08-01 Thread Zhu Lingshan
KFD creates sysfs entries for a kfd_process in function kfd_create_process when creating it. This commit extracts the code creating sysfs entries to a separate function because it would be invoked in other code path like creating secondary kfd contexts (kfd_process). Signed-off-by: Zhu Lingshan

[PATCH V2 07/10] amdkfd: process USERPTR allocation only on the primary kfd process

2025-08-01 Thread Zhu Lingshan
The lifecycle of the primary kfd process is tied to the user space program, all secondary kfd process would be destroyed when fd close. Thus only the primary kfd process should process USERPTR memory allocation. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd

Re: [PATCH V2 08/10] amdkfd: identify a secondary kfd process by its id

2025-08-03 Thread Zhu, Lingshan
On 8/2/2025 12:05 AM, Felix Kuehling wrote: > On 2025-08-01 4:55, Zhu Lingshan wrote: >> This commit introduces a new id field for >> struct kfd process, which helps identify >> a kfd process among multiple contexts that >> all belong to a single user space program.

Re: [PATCH V2 09/10] amdkfd: decommission kfd_get_process and remove DIQ support

2025-08-03 Thread Zhu, Lingshan
On 8/2/2025 12:10 AM, Felix Kuehling wrote: > On 2025-08-01 4:55, Zhu Lingshan wrote: >> This commit decommissions the function kfd_get_process() >> because it can not locate a specific kfd process among >> mulitple contexts. >> >> This commit refactors t

[PATCH V3 09/13] amdkfd: find kfd_process by filep->private_data in kfd_mmap

2025-08-04 Thread Zhu Lingshan
This commit finds the proper kfd_process by filep->private_data in kfd_mmap, because the function kfd_get_process() can not locate a specific kfd process among multiple contexts. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 11 +++ 1 file changed

[PATCH V3 10/13] amdkfd: process pointer of a HIQ should be set to NULL

2025-08-04 Thread Zhu Lingshan
ned-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 3 ++- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 - drivers/gpu/drm/amd/amdkfd/kfd_process.c | 18 -- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/amd

[PATCH V3 11/13] amdkfd: remove DIQ support

2025-08-04 Thread Zhu Lingshan
This commit remove DIQ support because it has been marked as DEPRECATED since 2022 in commit 5bdd3eb2 Signed-off-by: Zhu Lingshan --- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +-- drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 26 ++--- .../drm/amd/amdkfd

[PATCH V3 12/13] amdkfd: remove test_kq

2025-08-04 Thread Zhu Lingshan
This commit removes test_kq() function becuse it has been marked as unused since 2014 and no other functions calls it. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 31 --- 1 file changed, 31 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd

[PATCH V3 13/13] amdkfd: introduce new ioctl AMDKFD_IOC_CREATE_PROCESS

2025-08-04 Thread Zhu Lingshan
bumps ioctl minor version. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 41 drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +- include/uapi/linux/kfd_ioctl.h | 8 +++-- 4 files

[PATCH V3 06/13] amdkfd: process svm ioctl only on the primary kfd process

2025-08-04 Thread Zhu Lingshan
svm ioctl should only be processed on the primary kfd process because only the lifecycle of the primary kfd process is tied to the user space applicaiton. Another reason is in virtualization the hypervisor owns the primary kfd process as a privileged one. Signed-off-by: Zhu Lingshan Reviewed

[PATCH V3 05/13] amdkfd: destroy kfd secondary contexts through fd close

2025-08-04 Thread Zhu Lingshan
kfd_process_notifier_release_internal unconditionally. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 9 -- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 1 + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 41 +--- 3 files changed

[PATCH V3 08/13] amdkfd: identify a secondary kfd process by its id

2025-08-04 Thread Zhu Lingshan
of the sysfs entry of a secondary kfd process is "context_%u" where %u is the process id. Signed-off-by: Zhu Lingshan --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 6 ++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 83 +++- 2 files changed, 86 insertions(+), 3

[PATCH V3 07/13] amdkfd: process USERPTR allocation only on the primary kfd process

2025-08-04 Thread Zhu Lingshan
The lifecycle of the primary kfd process is tied to the user space program, all secondary kfd process would be destroyed when fd close. Thus only the primary kfd process should process USERPTR memory allocation. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd

[PATCH V3 00/13] amdkfd: Implement kfd multiple contexts

2025-08-04 Thread Zhu Lingshan
ret = %d\n", ret); getchar(); // close FDs close(fd2); getchar(); close(fd1); getchar(); return EXIT_SUCCESS; } Zhu Lingshan (13): amdkfd: enlarge the hashtable of kfd_process amdkfd: mark the first kfd_process as the prim

[PATCH V3 01/13] amdkfd: enlarge the hashtable of kfd_process

2025-08-04 Thread Zhu Lingshan
This commit enlarges the hashtable size of kfd_process to 256, because of the multiple contexts feature allowing each application create multiple kfd_processes Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion

[PATCH V3 04/13] amdkfd: Introduce kfd_create_process_sysfs as a separate function

2025-08-04 Thread Zhu Lingshan
KFD creates sysfs entries for a kfd_process in function kfd_create_process when creating it. This commit extracts the code creating sysfs entries to a separate function because it would be invoked in other code path like creating secondary kfd contexts (kfd_process). Signed-off-by: Zhu Lingshan

[PATCH V3 02/13] amdkfd: mark the first kfd_process as the primary one

2025-08-04 Thread Zhu Lingshan
The first kfd_process is created through open(), this commit marks it as the primary kfd_process. Only the primary process should register the mmu_notifier. Signed-off-by: Zhu Lingshan Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_priv.h| 3 +++ drivers/gpu/drm/amd

[PATCH V3 03/13] amdkfd: find_process_by_mm always return the primary context

2025-08-04 Thread Zhu Lingshan
Up until this commit, the kfd multiple contexts feature has not been fully implemented in mainline kernel yet. For backawrd compatibility, not break existing use cases, this commit changes function find_process_by_mm, let it always return the primary kfd_process. Signed-off-by: Zhu Lingshan