Skip to contentSkip to conversation

drm/amdkfd: Record vmid pasid mapping in the driver for non HWS mode

PATCH In review Zhao, Yong 2 participants 8 messages Sep 26, 2019 6 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Zhao, Yong

author
#0 lore raw

PATCH 1/2 drm/amdkfd: Record vmid pasid mapping in the driver for non HWS mode

This makes possible the vmid pasid mapping query through software.

Change-Id Ib539aae277a227cc39f6469ae23c46c4d289b87b
---
 .../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
index e7f0a32e0e44..455f49a25ccb 100644
@@ -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, sizeof(dqm->vmid_pasid));
+
 	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
index eed8f950b663..99c8b36301ef 100644
@@ -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
index 0d2c7fa1fa46..a08015720841 100644
@@ -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]

author
#2 lore raw

PATCH 2/2 drm/amdkfd: Query vmid pasid mapping through stored info for non HWS

Because we record the mapping under non HWS mode 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 I781cb9d30dc0cc93379908ff1cf8da798bb26f13
---
 drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +2 -2
index ab8a695c4a3c..9fff01c0fb9e 100644
@@ -58,8 +58,8 @@ 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];
+		WARN_ONCE(pasid == 0, "No PASID assigned for VMID %d\n", vmid);
 
 		/* 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]

#4 lore raw

Re: [PATCH 2/2] drm/amdkfd: Query vmid pasid mapping through stored info for non HWS

Quoted 17 lines · Yong

Because we record the mapping under non HWS mode 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 I781cb9d30dc0cc93379908ff1cf8da798bb26f13
---
  drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0 -0
index ab8a695c4a3c..9fff01c0fb9e 100644

drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 62

Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +2 -2
@@ -58,8 +58,8 @@ 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];
+		WARN_ONCE(pasid == 0, "No PASID assigned for VMID %d\n", vmid);

When this happens, you'll now get to WARN_ONCE messages. One here and then the one a few lines lower: WARN_ONCE(pasid == 0, "Bug: No PASID in KFD interrupt"). My point was, your messages is redundant. The original WARN_ONCE already covers both the HWS and non-HWS cases.

Regards,
  Felix

drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 65

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): 56a5fc99-0fd7-0194-a4e9-f533207adc6b-5C7GfCeVMHo@public.gmane.org

author
#6 lore raw

Re: [PATCH 2/2] drm/amdkfd: Query vmid pasid mapping through stored info for non HWS

Okay, I will delete that message.

Yong

Quoted 30 lines · Felix
Quoted 17 lines · Yong

Because we record the mapping under non HWS mode 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 I781cb9d30dc0cc93379908ff1cf8da798bb26f13
---
   drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +0 -0
index ab8a695c4a3c..9fff01c0fb9e 100644

drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c static bool event_interrupt_isr_v9(struct kfd_dev *dev, · line 62

Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +2 -2
@@ -58,8 +58,8 @@ 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];
+		WARN_ONCE(pasid == 0, "No PASID assigned for VMID %d\n", vmid);

When this happens, you'll now get to WARN_ONCE messages. One here and then the one a few lines lower: WARN_ONCE(pasid == 0, "Bug: No PASID in KFD interrupt"). My point was, your messages is redundant. The original WARN_ONCE already covers both the HWS and non-HWS cases.

Quoted 6 lines

Regards,
  Felix

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

Reviewed-by Felix Kuehling
#7 lore raw
In reply to a message not in the archive

Minor nit-pick inline. Otherwise this patch is

Quoted 101 lines · Yong

This makes possible the vmid pasid mapping query through software.

Change-Id Ib539aae277a227cc39f6469ae23c46c4d289b87b
---
  .../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
index e7f0a32e0e44..455f49a25ccb 100644
@@ -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, sizeof(dqm->vmid_pasid));
+
  	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
index eed8f950b663..99c8b36301ef 100644
@@ -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
index 0d2c7fa1fa46..a08015720841 100644

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 47

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
@@ -43,6 +43,8 @@
 
  #include "amd_shared.h"
 
+#define VMID_NUM 16
+

Any good reason why this is not defined in kfd_device_queue_manager.h? It's only used there.

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 50

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0 -0
  #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

A message that is not in the archive (sent off-list or not yet received): d1129739-2f34-4bc3-96f7-a9a9c999313a-5C7GfCeVMHo@public.gmane.org

author
#9 lore raw
Quoted 107 lines · Felix

Minor nit-pick inline. Otherwise this patch is

Quoted 102 lines · Yong

This makes possible the vmid pasid mapping query through software.

Change-Id Ib539aae277a227cc39f6469ae23c46c4d289b87b
---
   .../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
index e7f0a32e0e44..455f49a25ccb 100644
@@ -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, sizeof(dqm->vmid_pasid));
+
   	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
index eed8f950b663..99c8b36301ef 100644
@@ -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
index 0d2c7fa1fa46..a08015720841 100644
@@ -43,6 +43,8 @@
 
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 47

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
   #include "amd_shared.h"
 
+#define VMID_NUM 16
+

Any good reason why this is not defined in kfd_device_queue_manager.h? It's only used there.

[yz] It could be used by other places in the future, as they use 16 directly now.

Quoted 5 lines

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 50

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0 -0
   #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

A message that is not in the archive (sent off-list or not yet received): 397a92e1-a5cc-0607-43c6-2922273a1459-5C7GfCeVMHo@public.gmane.org

#11 lore raw
Quoted 16 lines · Yong
Quoted 15 lines · Felix

Minor nit-pick inline. Otherwise this patch is

Quoted 10 lines · Yong

This makes possible the vmid pasid mapping query through software.

Change-Id Ib539aae277a227cc39f6469ae23c46c4d289b87b
---
    .../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(-)

[snip]

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +2 -1
index eed8f950b663..99c8b36301ef 100644
@@ -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
index 0d2c7fa1fa46..a08015720841 100644
@@ -43,6 +43,8 @@
 
Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 47

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
    #include "amd_shared.h"
 
+#define VMID_NUM 16
+

Any good reason why this is not defined in kfd_device_queue_manager.h? It's only used there.

[yz] It could be used by other places in the future, as they use 16 directly now.

Can you point out those places? A quick grep for hard-coded 16 in kfd doesn't show up anything VMID-related on a first glance.

Regards,
  Felix

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 50

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0 -0
    #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

A message that is not in the archive (sent off-list or not yet received): 02740fdf-0bfe-9f42-600f-aa4a491cdc46-5C7GfCeVMHo@public.gmane.org

author
#13 lore raw
Quoted 45 lines · Felix
Quoted 16 lines · Yong
Quoted 15 lines · Felix

Minor nit-pick inline. Otherwise this patch is

Quoted 10 lines · Yong

This makes possible the vmid pasid mapping query through software.

Change-Id Ib539aae277a227cc39f6469ae23c46c4d289b87b
---
     .../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(-)

[snip]

Quoted 27 lines
Quoted 27 lines
Quoted 20 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +2 -1
index eed8f950b663..99c8b36301ef 100644
@@ -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
index 0d2c7fa1fa46..a08015720841 100644

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 47

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
@@ -43,6 +43,8 @@
 
     #include "amd_shared.h"
 
+#define VMID_NUM 16
+

Any good reason why this is not defined in kfd_device_queue_manager.h? It's only used there.

Quoted 8 lines
Quoted 2 lines

[yz] It could be used by other places in the future, as they use 16 directly now.

Can you point out those places? A quick grep for hard-coded 16 in kfd doesn't show up anything VMID-related on a first glance.

Regards,
  Felix

Oh, thye are in amdgpu_amdkfd_gfx* files. I have put the define in kfd_device_queue_manager.h . With that, I will directly push later.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 50

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0 -0
     #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