drm/amdkfd: Record vmid pasid mapping in the driver
Subsystems (3)
PATCH 1/2 drm/amdkfd: Record vmid pasid mapping in the driver
This makes possible the vmid pasid mapping query through software.
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 33 ++++++++++++------- .../drm/amd/amdkfd/kfd_device_queue_manager.h | 3 +- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++ 3 files changed, 25 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +21 -12
@@ -224,20 +224,30 @@ static int allocate_vmid(struct device_queue_manager *dqm,struct qcm_process_device *qpd, struct queue *q) { - int bit, allocated_vmid; + int allocated_vmid = -1, i; -if (dqm->vmid_bitmap ==0 ) -return -ENOMEM ; +for (i = dqm->dev->vm_info.first_vmid_kfd; + i <= dqm->dev->vm_info.last_vmid_kfd; i++) { +if (!dqm->vmid_pasid[i]) { + allocated_vmid = i; +break ; + } + } + +if (allocated_vmid <0 ) { +pr_err ("no more vmid to allocate\n" ); +return -ENOSPC ; + } + +pr_debug ("vmid allocated: %d\n" , allocated_vmid); + + dqm->vmid_pasid[allocated_vmid] = q->process->pasid; - bit =ffs (dqm->vmid_bitmap) -1 ; - dqm->vmid_bitmap &= ~(1 << bit); +set_pasid_vmid_mapping (dqm, q->process->pasid, allocated_vmid); - allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd; -pr_debug ("vmid allocation %d\n" , allocated_vmid); qpd->vmid = allocated_vmid; q->properties.vmid = allocated_vmid; -set_pasid_vmid_mapping (dqm, q->process->pasid, q->properties.vmid);program_sh_mem_settings (dqm, qpd);/* qpd->page_table_base is set earlier when register_process()
@@ -278,8 +288,6 @@ static void deallocate_vmid(struct device_queue_manager *dqm, struct qcm_process_device *qpd, struct queue *q) { - int bit = qpd->vmid - dqm->dev->vm_info.first_vmid_kfd; -/* On GFX v7, CP doesn't flush TC at dequeue */ if (q->device->device_info->asic_family ==CHIP_HAWAII )if (flush_texture_cache_nocpsch (q->device, qpd))
@@ -289,8 +297,8 @@ static void deallocate_vmid(struct device_queue_manager *dqm,/* Release the vmid mapping */ set_pasid_vmid_mapping (dqm,0 , qpd->vmid); + dqm->vmid_pasid[qpd->vmid] =0 ; - dqm->vmid_bitmap |= (1 << bit); qpd->vmid =0 ; q->properties.vmid =0 ; }
@@ -1017,7 +1025,8 @@ static int initialize_nocpsch(struct device_queue_manager *dqm) dqm->allocated_queues[pipe] |=1 << queue; } - dqm->vmid_bitmap = (1 << dqm->dev->vm_info.vmid_num_kfd) -1 ; +memset (dqm->vmid_pasid,0 ,VMID_NUM *sizeof (uint16_t )); + dqm->sdma_bitmap = ~0ULL >> (64 -get_num_sdma_queues (dqm)); dqm->xgmi_sdma_bitmap = ~0ULL >> (64 -get_num_xgmi_sdma_queues (dqm));
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +2 -1
@@ -188,7 +188,8 @@ struct device_queue_manager {unsigned int *allocated_queues;uint64_t sdma_bitmap;uint64_t xgmi_sdma_bitmap; -unsigned int vmid_bitmap; +/* the pasid mapping for each kfd vmid */ +uint16_t vmid_pasid[VMID_NUM ];uint64_t pipelines_addr;struct kfd_mem_obj *pipeline_mem;uint64_t fence_gpu_addr;
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
@@ -43,6 +43,8 @@#include "amd_shared.h" +#define VMID_NUM 16 +#define KFD_MAX_RING_ENTRY_SIZE 8#define KFD_SYSFS_FILE_MODE 0444
Signature · 6 lines
2.17.1 _______________________________________________ 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): [email protected]
PATCH 2/2 drm/amdkfd: Query vmid pasid mapping through stored info
Because we record the mapping in the software, we can query pasid through vmid using the stored mapping instead of reading from ATC registers.
This also prepares for the defeatured ATC block in future ASICs.
--- drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +3 -2
@@ -58,8 +58,9 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,memcpy (patched_ihre, ih_ring_entry, dev->device_info->ih_ring_entry_size); - pasid = dev->kfd2kgd->get_atc_vmid_pasid_mapping_pasid ( - dev->kgd, vmid); + pasid = dev->dqm->vmid_pasid[vmid]; +if (!pasid) +pr_err ("pasid is not queried correctly\n" );/* Patch the pasid field */ patched_ihre[3] = cpu_to_le32((le32_to_cpu(patched_ihre[3])
Signature · 6 lines
2.17.1 _______________________________________________ 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): [email protected]
Re: [PATCH 2/2] drm/amdkfd: Query vmid pasid mapping through stored info
Quoted 17 lines · Yong
Because we record the mapping in the software, we can query pasid through vmid using the stored mapping instead of reading from ATC registers.
This also prepares for the defeatured ATC block in future ASICs.
Change-Id I781cb9d30dc0cc93379908ff1cf8da798bb26f13Signed-off-by Yong Zhao <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 63
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +3
-2@@ -58,8 +58,9 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,memcpy (patched_ihre, ih_ring_entry, dev->device_info->ih_ring_entry_size); - pasid = dev->kfd2kgd->get_atc_vmid_pasid_mapping_pasid ( - dev->kgd, vmid); + pasid = dev->dqm->vmid_pasid[vmid]; +if (!pasid) +pr_err ("pasid is not queried correctly\n" );
This error message is not helpful. A helpful message may be something like "No PASID assigned for VMID %d". That said, printing error messages in an interrupt handler that can be potentially very frequent is not the best idea. There is already a WARN_ONCE a few lines below that should be triggered if PASID is not assigned.
Regards,
Felix
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 66
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0
-0/* Patch the pasid field */ patched_ihre[3] = cpu_to_le32((le32_to_cpu(patched_ihre[3])
_______________________________________________
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): ae7610f9-97bb-45f4-56ed-7a3dcbc4758c-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdkfd: Query vmid pasid mapping through stored info
I think this is only for none-hws case . HWS may dynamic change the mapping and driver will not get updated . If that's the case , please specify this is for none hardware scheduler case in the header .
Regards
shaoyun.liu
Quoted 37 lines · Felix
Quoted 17 lines · Yong
Because we record the mapping in the software, we can query pasid through vmid using the stored mapping instead of reading from ATC registers.
This also prepares for the defeatured ATC block in future ASICs.
Change-Id I781cb9d30dc0cc93379908ff1cf8da798bb26f13Signed-off-by Yong Zhao <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0
-0drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 63
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +3
-2@@ -58,8 +58,9 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,memcpy (patched_ihre, ih_ring_entry, dev->device_info->ih_ring_entry_size); - pasid = dev->kfd2kgd->get_atc_vmid_pasid_mapping_pasid ( - dev->kgd, vmid); + pasid = dev->dqm->vmid_pasid[vmid]; +if (!pasid) +pr_err ("pasid is not queried correctly\n" );This error message is not helpful. A helpful message may be something like "No PASID assigned for VMID %d". That said, printing error messages in an interrupt handler that can be potentially very frequent is not the best idea. There is already a
WARN_ONCEa few lines below that should be triggered if PASID is not assigned.Regards,
FelixQuoted 1 line
Quoted 6 lines
Quoted 2 lines
/* Patch the pasid field */ patched_ihre[3] = cpu_to_le32((le32_to_cpu(patched_ihre[3])_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): a1e7533b-90eb-9c0c-3fa2-e214ad2ad4aa-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdkfd: Query vmid pasid mapping through stored info
Quoted 1 line · Shaoyun
I think this is only for none-hws case .
Yes. This is inside an if (!pasid && dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS).
Regards,
Felix
Quoted 48 lines
HWS may dynamic change the
mapping and driver will not get updated . If that's the case , please specify this is for none hardware scheduler case in the header .Regards
shaoyun.liu
Quoted 39 lines · Felix
Quoted 17 lines · Yong
Because we record the mapping in the software, we can query pasid through vmid using the stored mapping instead of reading from ATC registers.
This also prepares for the defeatured ATC block in future ASICs.
Change-Id I781cb9d30dc0cc93379908ff1cf8da798bb26f13Signed-off-by Yong Zhao <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0
-0drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 63
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +3
-2@@ -58,8 +58,9 @@ static bool event_interrupt_isr_v9(struct kfd_dev *dev,memcpy (patched_ihre, ih_ring_entry, dev->device_info->ih_ring_entry_size); - pasid = dev->kfd2kgd->get_atc_vmid_pasid_mapping_pasid ( - dev->kgd, vmid); + pasid = dev->dqm->vmid_pasid[vmid]; +if (!pasid) +pr_err ("pasid is not queried correctly\n" );This error message is not helpful. A helpful message may be something like "No PASID assigned for VMID %d". That said, printing error messages in an interrupt handler that can be potentially very frequent is not the best idea. There is already a
WARN_ONCEa few lines below that should be triggered if PASID is not assigned.Regards,
FelixQuoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0
-0/* Patch the pasid field */ patched_ihre[3] = cpu_to_le32((le32_to_cpu(patched_ihre[3])
Quoted 8 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 73 lines · Yong
This makes possible the vmid pasid mapping query through software.
Change-Id Ib539aae277a227cc39f6469ae23c46c4d289b87bSigned-off-by Yong Zhao <[email protected]>--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 33 ++++++++++++------- .../drm/amd/amdkfd/kfd_device_queue_manager.h | 3 +- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++ 3 files changed, 25 insertions(+), 13 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +19
-11@@ -224,20 +224,30 @@ static int allocate_vmid(struct device_queue_manager *dqm,struct qcm_process_device *qpd, struct queue *q) { - int bit, allocated_vmid; + int allocated_vmid = -1, i; -if (dqm->vmid_bitmap ==0 ) -return -ENOMEM ; +for (i = dqm->dev->vm_info.first_vmid_kfd; + i <= dqm->dev->vm_info.last_vmid_kfd; i++) { +if (!dqm->vmid_pasid[i]) { + allocated_vmid = i; +break ; + } + } + +if (allocated_vmid <0 ) { +pr_err ("no more vmid to allocate\n" ); +return -ENOSPC ; + } + +pr_debug ("vmid allocated: %d\n" , allocated_vmid); + + dqm->vmid_pasid[allocated_vmid] = q->process->pasid; - bit =ffs (dqm->vmid_bitmap) -1 ; - dqm->vmid_bitmap &= ~(1 << bit); +set_pasid_vmid_mapping (dqm, q->process->pasid, allocated_vmid); - allocated_vmid = bit + dqm->dev->vm_info.first_vmid_kfd; -pr_debug ("vmid allocation %d\n" , allocated_vmid); qpd->vmid = allocated_vmid; q->properties.vmid = allocated_vmid; -set_pasid_vmid_mapping (dqm, q->process->pasid, q->properties.vmid);program_sh_mem_settings (dqm, qpd);/* qpd->page_table_base is set earlier when register_process() @@ -278,8 +288,6 @@ static void deallocate_vmid(struct device_queue_manager *dqm, struct qcm_process_device *qpd, struct queue *q) { - int bit = qpd->vmid - dqm->dev->vm_info.first_vmid_kfd; -/* On GFX v7, CP doesn't flush TC at dequeue */ if (q->device->device_info->asic_family ==CHIP_HAWAII )if (flush_texture_cache_nocpsch (q->device, qpd))@@ -289,8 +297,8 @@ static void deallocate_vmid(struct device_queue_manager *dqm,/* Release the vmid mapping */ set_pasid_vmid_mapping (dqm,0 , qpd->vmid); + dqm->vmid_pasid[qpd->vmid] =0 ; - dqm->vmid_bitmap |= (1 << bit); qpd->vmid =0 ; q->properties.vmid =0 ; }
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int initialize_nocpsch(struct device_queue_manager *dqm) · line 1028
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -1017,7 +1025,8 @@ static int initialize_nocpsch(struct device_queue_manager *dqm) dqm->allocated_queues[pipe] |=1 << queue; } - dqm->vmid_bitmap = (1 << dqm->dev->vm_info.vmid_num_kfd) -1 ; +memset (dqm->vmid_pasid,0 ,VMID_NUM *sizeof (uint16_t ));
Just use sizeof(dqm->vmid_pasid) to get the array size to avoid problems if the array size ever changes in the future.
Regards,
Felix
Quoted 23 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-0+ dqm->sdma_bitmap = ~0ULL >> (64 -get_num_sdma_queues (dqm)); dqm->xgmi_sdma_bitmap = ~0ULL >> (64 -get_num_xgmi_sdma_queues (dqm));drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +2
-1@@ -188,7 +188,8 @@ struct device_queue_manager {unsigned int *allocated_queues;uint64_t sdma_bitmap;uint64_t xgmi_sdma_bitmap; -unsigned int vmid_bitmap; +/* the pasid mapping for each kfd vmid */ +uint16_t vmid_pasid[VMID_NUM ];uint64_t pipelines_addr;struct kfd_mem_obj *pipeline_mem;uint64_t fence_gpu_addr;drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 50
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0@@ -43,6 +43,8 @@#include "amd_shared.h" +#define VMID_NUM 16 +#define KFD_MAX_RING_ENTRY_SIZE 8#define KFD_SYSFS_FILE_MODE 0444
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx