Skip to contentSkip to conversation

drm/amdkfd: fix vmfault signalling with additional data.

PATCH In review Jonathan Kim 2 participants 2 messages Jun 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: fix vmfault signalling with additional data.

Exception handling for vmfaults should be raised with additional data.

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 34 +++++++++++++++----------
 1 file changed, 20 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +20 -14
index 7ff5c4e1b7e2..c069ef77daa5 100644
@@ -1240,19 +1240,24 @@ void kfd_signal_vm_fault_event(struct kfd_node *dev, u32 pasid,
 		return;
 	}
 
-	memset(&memory_exception_data, 0, sizeof(memory_exception_data));
-	memory_exception_data.gpu_id = user_gpu_id;
-	memory_exception_data.failure.imprecise = true;
-	/* Set failure reason */
-	if (info) {
-		memory_exception_data.va = (info->page_addr) << PAGE_SHIFT;
-		memory_exception_data.failure.NotPresent =
-			info->prot_valid ? 1 : 0;
-		memory_exception_data.failure.NoExecute =
-			info->prot_exec ? 1 : 0;
-		memory_exception_data.failure.ReadOnly =
-			info->prot_write ? 1 : 0;
-		memory_exception_data.failure.imprecise = 0;
+	/* SoC15 chips and onwards will pass in data from now on. */
+	if (!data) {
+		memset(&memory_exception_data, 0, sizeof(memory_exception_data));
+		memory_exception_data.gpu_id = user_gpu_id;
+		memory_exception_data.failure.imprecise = true;
+
+		/* Set failure reason */
+		if (info) {
+			memory_exception_data.va = (info->page_addr) <<
+								PAGE_SHIFT;
+			memory_exception_data.failure.NotPresent =
+				info->prot_valid ? 1 : 0;
+			memory_exception_data.failure.NoExecute =
+				info->prot_exec ? 1 : 0;
+			memory_exception_data.failure.ReadOnly =
+				info->prot_write ? 1 : 0;
+			memory_exception_data.failure.imprecise = 0;
+		}
 	}
 
 	rcu_read_lock();
@@ -1261,7 +1266,8 @@ void kfd_signal_vm_fault_event(struct kfd_node *dev, u32 pasid,
 	idr_for_each_entry_continue(&p->event_idr, ev, id)
 		if (ev->type == KFD_EVENT_TYPE_MEMORY) {
 			spin_lock(&ev->lock);
-			ev->memory_exception_data = memory_exception_data;
+			ev->memory_exception_data = data ? *data :
+							memory_exception_data;
 			set_event(ev);
 			spin_unlock(&ev->lock);
 		}
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Quoted 80 lines

-----Original Message-----
From: Kim, Jonathan <[email protected]>
Sent: Wednesday, June 7, 2023 10:39 AM
To: [email protected]
Cc: Joshi, Mukul <[email protected]>; Kuehling, Felix <[email protected]>; Kim, Jonathan <[email protected]>; Joshi, Mukul <[email protected]>
Subject: [PATCH] drm/amdkfd: fix vmfault signalling with additional data.

Exception handling for vmfaults should be raised with additional data.

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 34 +++++++++++++++--------
--
 1 file changed, 20 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -13
index 7ff5c4e1b7e2..c069ef77daa5 100644
@@ -1240,19 +1240,24 @@ void kfd_signal_vm_fault_event(struct kfd_node
 *dev, u32 pasid,
              return;
      }
 
-     memset(&memory_exception_data, 0,
 sizeof(memory_exception_data));
-     memory_exception_data.gpu_id = user_gpu_id;
-     memory_exception_data.failure.imprecise = true;
-     /* Set failure reason */
-     if (info) {
-             memory_exception_data.va = (info->page_addr) <<
 PAGE_SHIFT;
-             memory_exception_data.failure.NotPresent =
-                     info->prot_valid ? 1 : 0;
-             memory_exception_data.failure.NoExecute =
-                     info->prot_exec ? 1 : 0;
-             memory_exception_data.failure.ReadOnly =
-                     info->prot_write ? 1 : 0;
-             memory_exception_data.failure.imprecise = 0;
+     /* SoC15 chips and onwards will pass in data from now on. */
+     if (!data) {
+             memset(&memory_exception_data, 0,

sizeof(memory_exception_data));

drivers/gpu/drm/amd/amdkfd/kfd_events.c +17 -1
+             memory_exception_data.gpu_id = user_gpu_id;
+             memory_exception_data.failure.imprecise = true;
+
+             /* Set failure reason */
+             if (info) {
+                     memory_exception_data.va = (info->page_addr) <<
+                                                             PAGE_SHIFT;
+                     memory_exception_data.failure.NotPresent =
+                             info->prot_valid ? 1 : 0;
+                     memory_exception_data.failure.NoExecute =
+                             info->prot_exec ? 1 : 0;
+                     memory_exception_data.failure.ReadOnly =
+                             info->prot_write ? 1 : 0;
+                     memory_exception_data.failure.imprecise = 0;
+             }
      }
 
      rcu_read_lock();
@@ -1261,7 +1266,8 @@ void kfd_signal_vm_fault_event(struct kfd_node
 *dev, u32 pasid,
      idr_for_each_entry_continue(&p->event_idr, ev, id)
              if (ev->type == KFD_EVENT_TYPE_MEMORY) {
                      spin_lock(&ev->lock);
-                     ev->memory_exception_data =
 memory_exception_data;
+                     ev->memory_exception_data = data ? *data :
+
      memory_exception_data;
                      set_event(ev);
                      spin_unlock(&ev->lock);
              }

--
2.25.1