Skip to contentSkip to conversation

drm/amdgpu: Add amdgpu_sriov_multi_vf_mode function

PATCH In review Emily Deng 2 participants 8 messages Feb 20, 2025 – Feb 25, 2025

Subsystems (4)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/3 drm/amdgpu: Add amdgpu_sriov_multi_vf_mode function

Use amdgpu_sriov_multi_vf_mode to replace amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev).

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h    | 2 ++
 drivers/gpu/drm/amd/pm/amdgpu_pm.c          | 4 ++--
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c   | 8 ++++----
 4 files changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 49ca8c814455..a1450f13d963 100644
@@ -1990,7 +1990,7 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)
 	uint32_t max_freq, min_freq;
 	struct amdgpu_device *adev = (struct amdgpu_device *)data;
 
-	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+	if (amdgpu_sriov_multi_vf_mode(adev))
 		return -EINVAL;
 
 	ret = pm_runtime_get_sync(adev_to_drm(adev)->dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +2 -0
index 270a032e2d70..0ab5f0ca2c8c 100644
@@ -352,6 +352,8 @@ static inline bool is_virtual_machine(void)
 
 #define amdgpu_sriov_is_pp_one_vf(adev) \
 	((adev)->virt.gim_feature & AMDGIM_FEATURE_PP_ONE_VF)
+#define amdgpu_sriov_multi_vf_mode(adev) \
+	(amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
 #define amdgpu_sriov_is_debug(adev) \
 	((!amdgpu_in_reset(adev)) && adev->virt.tdr_debug)
 #define amdgpu_sriov_is_normal(adev) \
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -2
index 1d04f1b79ded..178d4b5d4209 100644
@@ -1936,7 +1936,7 @@ static int pp_od_clk_voltage_attr_update(struct amdgpu_device *adev, struct amdg
 	if (gc_ver == IP_VERSION(9, 4, 3) ||
 	    gc_ver == IP_VERSION(9, 4, 4) ||
 	    gc_ver == IP_VERSION(9, 5, 0)) {
-		if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+		if (amdgpu_sriov_multi_vf_mode(adev))
 			*states = ATTR_STATE_UNSUPPORTED;
 		return 0;
 	}
@@ -1971,7 +1971,7 @@ static int pp_dpm_dcefclk_attr_update(struct amdgpu_device *adev, struct amdgpu_
 	 * setting should not be allowed from VF if not in one VF mode.
 	 */
 	if (gc_ver >= IP_VERSION(10, 0, 0) ||
-	    (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))) {
+	    (amdgpu_sriov_multi_vf_mode(adev))) {
 		dev_attr->attr.mode &= ~S_IWUGO;
 		dev_attr->store = NULL;
 	}
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4 -4
index 488360d2aaae..40a1fb741ec5 100644
@@ -1812,7 +1812,7 @@ static int smu_hw_init(struct amdgpu_ip_block *ip_block)
 	struct amdgpu_device *adev = ip_block->adev;
 	struct smu_context *smu = adev->powerplay.pp_handle;
 
-	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)) {
+	if (amdgpu_sriov_multi_vf_mode(adev)) {
 		smu->pm_enabled = false;
 		return 0;
 	}
@@ -2035,7 +2035,7 @@ static int smu_hw_fini(struct amdgpu_ip_block *ip_block)
 	struct smu_context *smu = adev->powerplay.pp_handle;
 	int i, ret;
 
-	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+	if (amdgpu_sriov_multi_vf_mode(adev))
 		return 0;
 
 	for (i = 0; i < adev->vcn.num_vcn_inst; i++)
@@ -2103,7 +2103,7 @@ static int smu_suspend(struct amdgpu_ip_block *ip_block)
 	int ret;
 	uint64_t count;
 
-	if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+	if (amdgpu_sriov_multi_vf_mode(adev))
 		return 0;
 
 	if (!smu->pm_enabled)
@@ -2139,7 +2139,7 @@ static int smu_resume(struct amdgpu_ip_block *ip_block)
 	struct amdgpu_device *adev = ip_block->adev;
 	struct smu_context *smu = adev->powerplay.pp_handle;
 
-	if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
+	if (amdgpu_sriov_multi_vf_mode(adev))
 		return 0;
 
 	if (!smu->pm_enabled)
Signature · 1 line
2.36.1
author
#1 lore raw

PATCH 2/3 drm/amdgpu: set CP_HQD_PQ_DOORBELL_CONTROL.DOORBELL_MODE to 1 for sriov multiple vf.

In sriov multiple vf, Set CP_HQD_PQ_DOORBELL_CONTROL.DOORBELL_MODE to 1 to read WPTR from MQD.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c       |  2 +-
 .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c   | 27 ++++++++++++++++---
 2 files changed, 25 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
index f4635fc8a7ca..c6961e8d5e8f 100644
@@ -1848,7 +1848,7 @@ static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)
 				    DOORBELL_SOURCE, 0);
 		tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
 				    DOORBELL_HIT, 0);
-		if (amdgpu_sriov_vf(adev))
+		if (amdgpu_sriov_multi_vf_mode(adev))
 			tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
 					    DOORBELL_MODE, 1);
 	} else {
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +24 -3
index ff417d5361c4..6b38967d5631 100644
@@ -551,7 +551,7 @@ static void init_mqd_hiq_v9_4_3(struct mqd_manager *mm, void **mqd,
 		m->cp_hqd_pq_control |= CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |
 					1 << CP_HQD_PQ_CONTROL__PRIV_STATE__SHIFT |
 					1 << CP_HQD_PQ_CONTROL__KMD_QUEUE__SHIFT;
-		if (amdgpu_sriov_vf(mm->dev->adev))
+		if (amdgpu_sriov_multi_vf_mode(mm->dev->adev))
 			m->cp_hqd_pq_doorbell_control |= 1 <<
 				CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_MODE__SHIFT;
 		m->cp_mqd_stride_size = kfd_hiq_mqd_stride(mm->dev);
@@ -664,7 +664,9 @@ static void init_mqd_v9_4_3(struct mqd_manager *mm, void **mqd,
 		get_xcc_mqd(mqd_mem_obj, &xcc_mqd_mem_obj, offset*xcc);
 
 		init_mqd(mm, (void **)&m, &xcc_mqd_mem_obj, &xcc_gart_addr, q);
-
+		if (amdgpu_sriov_multi_vf_mode(mm->dev->adev))
+				m->cp_hqd_pq_doorbell_control |= 1 <<
+					CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_MODE__SHIFT;
 		m->cp_mqd_stride_size = offset;
 
 		/*
@@ -724,6 +726,9 @@ static void update_mqd_v9_4_3(struct mqd_manager *mm, void *mqd,
 		m = get_mqd(mqd + size * xcc);
 		update_mqd(mm, m, q, minfo);
 
+		if (amdgpu_sriov_multi_vf_mode(mm->dev->adev))
+				m->cp_hqd_pq_doorbell_control |= 1 <<
+					CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_MODE__SHIFT;
 		update_cu_mask(mm, m, minfo, xcc);
 
 		if (q->format == KFD_QUEUE_FORMAT_AQL) {
@@ -746,6 +751,21 @@ static void update_mqd_v9_4_3(struct mqd_manager *mm, void *mqd,
 	}
 }
 
+static void restore_mqd_v9_4_3(struct mqd_manager *mm, void **mqd,
+			struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr,
+			struct queue_properties *qp,
+			const void *mqd_src,
+			const void *ctl_stack_src, u32 ctl_stack_size)
+{
+	restore_mqd(mm, mqd, mqd_mem_obj, gart_addr, qp, mqd_src, ctl_stack_src, ctl_stack_size);
+	if (amdgpu_sriov_multi_vf_mode(mm->dev->adev)) {
+		struct v9_mqd *m;
+
+		m = (struct v9_mqd *) mqd_mem_obj->cpu_ptr;
+		m->cp_hqd_pq_doorbell_control |= 1 <<
+				CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_MODE__SHIFT;
+	}
+}
 static int destroy_mqd_v9_4_3(struct mqd_manager *mm, void *mqd,
 		   enum kfd_preempt_type type, unsigned int timeout,
 		   uint32_t pipe_id, uint32_t queue_id)
@@ -880,7 +900,6 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type,
 		mqd->is_occupied = kfd_is_occupied_cp;
 		mqd->get_checkpoint_info = get_checkpoint_info;
 		mqd->checkpoint_mqd = checkpoint_mqd;
-		mqd->restore_mqd = restore_mqd;
 		mqd->mqd_size = sizeof(struct v9_mqd);
 		mqd->mqd_stride = mqd_stride_v9;
 #if defined(CONFIG_DEBUG_FS)
@@ -892,12 +911,14 @@ struct mqd_manager *mqd_manager_init_v9(enum KFD_MQD_TYPE type,
 			mqd->init_mqd = init_mqd_v9_4_3;
 			mqd->load_mqd = load_mqd_v9_4_3;
 			mqd->update_mqd = update_mqd_v9_4_3;
+			mqd->restore_mqd = restore_mqd_v9_4_3;
 			mqd->destroy_mqd = destroy_mqd_v9_4_3;
 			mqd->get_wave_state = get_wave_state_v9_4_3;
 		} else {
 			mqd->init_mqd = init_mqd;
 			mqd->load_mqd = load_mqd;
 			mqd->update_mqd = update_mqd;
+			mqd->restore_mqd = restore_mqd;
 			mqd->destroy_mqd = kfd_destroy_mqd_cp;
 			mqd->get_wave_state = get_wave_state;
 		}
Signature · 1 line
2.36.1
author
#2 lore raw

PATCH 3/3 drm/amdkfd: Skip update vmid in while update queue

In reply to Emily Deng

Avoid updating the vmid to 0 during the queue update process, as this may trigger a wptr poll address page fault when a ring doorbell is activated
in doorbell_mode=1.

---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +2 -2
index 6b38967d5631..3028c16264b2 100644
@@ -219,6 +219,8 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
 		m->cp_hqd_wg_state_offset = q->ctl_stack_size;
 	}
 
+	m->cp_hqd_vmid = q->vmid;
+
 	*mqd = m;
 	if (gart_addr)
 		*gart_addr = addr;
@@ -288,8 +290,6 @@ static void update_mqd(struct mqd_manager *mm, void *mqd,
 
 	m->cp_hqd_iq_timer = 0;
 
-	m->cp_hqd_vmid = q->vmid;
-
 	if (q->format == KFD_QUEUE_FORMAT_AQL) {
 		m->cp_hqd_pq_control |= CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |
 				2 << CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
Signature · 1 line
2.36.1
#3 lore raw

RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Emily Deng
Best Wishes

Quoted 43 lines

-----Original Message-----
From: Emily Deng <[email protected]>
Sent: Thursday, February 20, 2025 2:25 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Avoid updating the vmid to 0 during the queue update process, as this may trigger a wptr poll address page fault when a ring doorbell is activated in doorbell_mode=1.

---
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +2 -2
index 6b38967d5631..3028c16264b2 100644
@@ -219,6 +219,8 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
              m->cp_hqd_wg_state_offset = q->ctl_stack_size;
      }
 
+      m->cp_hqd_vmid = q->vmid;
+
      *mqd = m;
      if (gart_addr)
              *gart_addr = addr;
@@ -288,8 +290,6 @@ static void update_mqd(struct mqd_manager *mm, void
 *mqd,
 
      m->cp_hqd_iq_timer = 0;
 
-      m->cp_hqd_vmid = q->vmid;
-
      if (q->format == KFD_QUEUE_FORMAT_AQL) {
              m->cp_hqd_pq_control |=

CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |

                              2 <<

CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
--
2.36.1

#4 lore raw

RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Felix,
Could you help review this? Thanks.

Emily Deng
Best Wishes

Quoted 60 lines

-----Original Message-----
From: Deng, Emily <[email protected]>
Sent: Friday, February 21, 2025 9:44 AM
To: Deng, Emily <[email protected]>; [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Emily Deng
Best Wishes

Quoted 9 lines

-----Original Message-----
From: Emily Deng <[email protected]>
Sent: Thursday, February 20, 2025 2:25 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Avoid updating the vmid to 0 during the queue update process, as this may trigger a wptr poll address page fault when a ring doorbell is activated in

doorbell_mode=1.

Quoted 34 lines

---
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +2 -2
index 6b38967d5631..3028c16264b2 100644
@@ -219,6 +219,8 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
              m->cp_hqd_wg_state_offset = q->ctl_stack_size;
      }
 
+      m->cp_hqd_vmid = q->vmid;
+
      *mqd = m;
      if (gart_addr)
              *gart_addr = addr;
@@ -288,8 +290,6 @@ static void update_mqd(struct mqd_manager *mm, void
 *mqd,
 
      m->cp_hqd_iq_timer = 0;
 
-      m->cp_hqd_vmid = q->vmid;
-
      if (q->format == KFD_QUEUE_FORMAT_AQL) {
              m->cp_hqd_pq_control |=

CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |

                              2 <<

CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
--
2.36.1

#5 lore raw

RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Quoted 83 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Deng, Emily
Sent: Monday, February 24, 2025 9:53 AM
To: Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Felix,
Could you help review this? Thanks.

Emily Deng
Best Wishes

Quoted 34 lines

-----Original Message-----
From: Deng, Emily <[email protected]>
Sent: Friday, February 21, 2025 9:44 AM
To: Deng, Emily <[email protected]>; [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Emily Deng
Best Wishes

Quoted 11 lines

-----Original Message-----
From: Emily Deng <[email protected]>
Sent: Thursday, February 20, 2025 2:25 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Avoid updating the vmid to 0 during the queue update process, as this may trigger a wptr poll address page fault when a ring doorbell is activated in

doorbell_mode=1.

Quoted 6 lines

---
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void init_mqd(struct mqd_manager *mm, void

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -0
index 6b38967d5631..3028c16264b2 100644
@@ -219,6 +219,8 @@ static void init_mqd(struct mqd_manager *mm, void

**mqd,

Quoted 23 lines
Quoted 22 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +2 -2
              m->cp_hqd_wg_state_offset = q->ctl_stack_size;
      }
 
+      m->cp_hqd_vmid = q->vmid;
+
      *mqd = m;
      if (gart_addr)
              *gart_addr = addr;
@@ -288,8 +290,6 @@ static void update_mqd(struct mqd_manager *mm,
 void *mqd,
 
      m->cp_hqd_iq_timer = 0;
 
-      m->cp_hqd_vmid = q->vmid;
-
      if (q->format == KFD_QUEUE_FORMAT_AQL) {
              m->cp_hqd_pq_control |=

CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |

                              2 <<

CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
--
2.36.1

#6 lore raw

RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 10 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Deng, Emily
Sent: Monday, February 24, 2025 8:05 PM
To: Deng, Emily <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Quoted 55 lines

[AMD Official Use Only - AMD Internal Distribution Only]

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Quoted 49 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Deng, Emily
Sent: Monday, February 24, 2025 9:53 AM
To: Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Felix,
Could you help review this? Thanks.

Emily Deng
Best Wishes

Quoted 28 lines

-----Original Message-----
From: Deng, Emily <[email protected]>
Sent: Friday, February 21, 2025 9:44 AM
To: Deng, Emily <[email protected]>; [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Emily Deng
Best Wishes

Quoted 11 lines

-----Original Message-----
From: Emily Deng <[email protected]>
Sent: Thursday, February 20, 2025 2:25 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Avoid updating the vmid to 0 during the queue update process, as this may trigger a wptr poll address page fault when a ring doorbell is activated in

doorbell_mode=1.

Have you observed this page fault? If you have it, can you please paste the page fault backtrace.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void init_mqd(struct mqd_manager *mm,

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -0
index 6b38967d5631..3028c16264b2 100644
@@ -219,6 +219,8 @@ static void init_mqd(struct mqd_manager *mm,

void

Quoted 6 lines

**mqd,

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +2 -0
              m->cp_hqd_wg_state_offset = q->ctl_stack_size;
      }
 
+      m->cp_hqd_vmid = q->vmid;
+

q->vmid would be 0 at the time of calling init_mqd when using HW scheduler as it's the HWS which assigns the VMID.
Driver only assigns VMID when there is no HWS, which is not a production use-case.

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd(struct mqd_manager

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -0
      *mqd = m;
      if (gart_addr)
              *gart_addr = addr;
@@ -288,8 +290,6 @@ static void update_mqd(struct mqd_manager

*mm,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -1
 void *mqd,
 
      m->cp_hqd_iq_timer = 0;
 
-      m->cp_hqd_vmid = q->vmid;

Maybe we can just remove his vmid assignment if this is indeed causing a page fault. But I haven't seen a page fault because of this before.

Regards,
Mukul

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -1
-
      if (q->format == KFD_QUEUE_FORMAT_AQL) {
              m->cp_hqd_pq_control |=

CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |

                              2 <<

CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
--
2.36.1

#7 lore raw

RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Yes, I hit the page fault while doorbell_mode=1. Error log is as follow.

[▒~L 2▒~\~H 25 00:12:10 2025 < 0.000002>] kfd_ioctl_create_event:844: amdgpu: Created event (id:0x00000002) (kfd_ioctl_cree
ate_event)
[▒~L 2▒~\~H 25 00:12:10 2025 < 0.000020>] amdgpu 0000:04:00.0: amdgpu: [gfxhub0] no-retry page fault (src_id:0 ring:153 vmm
id:0 pasid:0)
[▒~L 2▒~\~H 25 00:12:10 2025 < 0.000123>] amdgpu 0000:04:00.0: amdgpu: in page starting at address 0x00007f40fb3c1000 frr
om IH client 0x1b (UTCL2)
[▒~L 2▒~\~H 25 00:12:10 2025 < 0.000069>] amdgpu 0000:04:00.0: amdgpu: cookie node_id 1 fault from die AID0.XCD0

Emily Deng
Best Wishes

Quoted 132 lines

-----Original Message-----
From: Joshi, Mukul <[email protected]>
Sent: Tuesday, February 25, 2025 10:45 AM
To: Deng, Emily <[email protected]>; Deng, Emily <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 10 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Deng, Emily
Sent: Monday, February 24, 2025 8:05 PM
To: Deng, Emily <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Quoted 55 lines

[AMD Official Use Only - AMD Internal Distribution Only]

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Quoted 49 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Deng, Emily
Sent: Monday, February 24, 2025 9:53 AM
To: Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Felix,
Could you help review this? Thanks.

Emily Deng
Best Wishes

Quoted 28 lines

-----Original Message-----
From: Deng, Emily <[email protected]>
Sent: Friday, February 21, 2025 9:44 AM
To: Deng, Emily <[email protected]>; [email protected]
Subject: RE: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

[AMD Official Use Only - AMD Internal Distribution Only]

Ping......

Emily Deng
Best Wishes

Quoted 11 lines

-----Original Message-----
From: Emily Deng <[email protected]>
Sent: Thursday, February 20, 2025 2:25 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH 3/3] drm/amdkfd: Skip update vmid in while update queue

Avoid updating the vmid to 0 during the queue update process, as this may trigger a wptr poll address page fault when a ring doorbell is activated in

doorbell_mode=1.

Have you observed this page fault? If you have it, can you please paste the page fault backtrace.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void init_mqd(struct mqd_manager *mm,

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -0
index 6b38967d5631..3028c16264b2 100644
@@ -219,6 +219,8 @@ static void init_mqd(struct mqd_manager *mm,

void

Quoted 6 lines

**mqd,

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +2 -0
              m->cp_hqd_wg_state_offset = q->ctl_stack_size;
      }
 
+      m->cp_hqd_vmid = q->vmid;
+

q->vmid would be 0 at the time of calling init_mqd when using HW q->scheduler as it's the
HWS which assigns the VMID.
Driver only assigns VMID when there is no HWS, which is not a production use-case.

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd(struct mqd_manager

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -0
      *mqd = m;
      if (gart_addr)
              *gart_addr = addr;
@@ -288,8 +290,6 @@ static void update_mqd(struct mqd_manager

*mm,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -1
 void *mqd,
 
      m->cp_hqd_iq_timer = 0;
 
-      m->cp_hqd_vmid = q->vmid;

Maybe we can just remove his vmid assignment if this is indeed causing a page fault.
But I haven't seen a page fault because of this before.

Regards,
Mukul

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -1
-
      if (q->format == KFD_QUEUE_FORMAT_AQL) {
              m->cp_hqd_pq_control |=

CP_HQD_PQ_CONTROL__NO_UPDATE_RPTR_MASK |

                              2 <<

CP_HQD_PQ_CONTROL__SLOT_BASED_WPTR__SHIFT |
--
2.36.1