drm/amdkfd: CRIU checkpoint and restore xnack mode
authorRajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Fri, 19 Nov 2021 15:23:05 +0000 (10:23 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Feb 2022 22:59:52 +0000 (17:59 -0500)
Recoverable page faults are represented by the xnack mode setting inside
a kfd process and are used to represent the device page faults. For CR,
we don't consider negative values which are typically used for querying
the current xnack mode without modifying it.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h

index ab5107a3fe36b068be290958c18634a3c79d774a..3ec44f71307df298c3363399d13e68dd061211a8 100644 (file)
@@ -1848,6 +1848,11 @@ static int criu_checkpoint_process(struct kfd_process *p,
        memset(&process_priv, 0, sizeof(process_priv));
 
        process_priv.version = KFD_CRIU_PRIV_VERSION;
+       /* For CR, we don't consider negative xnack mode which is used for
+        * querying without changing it, here 0 simply means disabled and 1
+        * means enabled so retry for finding a valid PTE.
+        */
+       process_priv.xnack_mode = p->xnack_enabled ? 1 : 0;
 
        ret = copy_to_user(user_priv_data + *priv_offset,
                                &process_priv, sizeof(process_priv));
@@ -2241,6 +2246,16 @@ static int criu_restore_process(struct kfd_process *p,
                return -EINVAL;
        }
 
+       pr_debug("Setting XNACK mode\n");
+       if (process_priv.xnack_mode && !kfd_process_xnack_mode(p, true)) {
+               pr_err("xnack mode cannot be set\n");
+               ret = -EPERM;
+               goto exit;
+       } else {
+               pr_debug("set xnack mode: %d\n", process_priv.xnack_mode);
+               p->xnack_enabled = process_priv.xnack_mode;
+       }
+
 exit:
        return ret;
 }
index df68c4274bd93b551966ac39c228b271c4b67f01..903ad4a263f09964a359d22b512e950f94beb683 100644 (file)
@@ -1056,6 +1056,7 @@ void kfd_process_set_trap_handler(struct qcm_process_device *qpd,
 
 struct kfd_criu_process_priv_data {
        uint32_t version;
+       uint32_t xnack_mode;
 };
 
 struct kfd_criu_device_priv_data {