Re: [PATCH] drm/amd: SVM flag error added at svm_range flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This flag was never meant for user mode. Alex ended up implementing it differently in a way that doesn't need to change the flags exposed to user mode. See his patch "drm/amdkfd: flag added to handle errors from svm validate and map". This patch is no longer needed.


Regards,
  Felix


Am 2023-05-31 um 10:09 schrieb Deucher, Alexander:

[Public]


Where is the userspace code which uses this new interface? Can you add a link to the relevant branch to the commit message?

Alex
------------------------------------------------------------------------
*From:* amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> on behalf of Alex Sierra <alex.sierra@xxxxxxx>
*Sent:* Monday, May 29, 2023 4:09 PM
*To:* amd-gfx@xxxxxxxxxxxxxxxxxxxxx <amd-gfx@xxxxxxxxxxxxxxxxxxxxx>; Kuehling, Felix <Felix.Kuehling@xxxxxxx> *Cc:* Sierra Guiza, Alejandro (Alex) <Alex.Sierra@xxxxxxx>; Yang, Philip <Philip.Yang@xxxxxxx>
*Subject:* [PATCH] drm/amd: SVM flag error added at svm_range flags
If a return error is raised during validation and mapping of a
prange, this flag is set. It is a rare occurrence, but it could happen
when `amdgpu_hmm_range_get_pages_done` returns true. In such cases,
the caller should retry. However, it is important to ensure that the
prange is updated correctly during the retry.

Signed-off-by: Alex Sierra <alex.sierra@xxxxxxx>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 +++++++++++-
 include/uapi/linux/kfd_ioctl.h       |  2 ++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index fcfde9140bce..96abae515bcf 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -756,10 +756,12 @@ svm_range_apply_attrs(struct kfd_process *p, struct svm_range *prange,
                         break;
                 case KFD_IOCTL_SVM_ATTR_SET_FLAGS:
                         *update_mapping = true;
+                       attrs[i].value &= ~KFD_IOCTL_SVM_FLAG_ERROR;
                         prange->flags |= attrs[i].value;
                         break;
                 case KFD_IOCTL_SVM_ATTR_CLR_FLAGS:
                         *update_mapping = true;
+                       attrs[i].value &= ~KFD_IOCTL_SVM_FLAG_ERROR;
                         prange->flags &= ~attrs[i].value;
                         break;
                 case KFD_IOCTL_SVM_ATTR_GRANULARITY:
@@ -778,6 +780,9 @@ svm_range_is_same_attrs(struct kfd_process *p, struct svm_range *prange,
         uint32_t i;
         int gpuidx;

+       if (prange->flags & KFD_IOCTL_SVM_FLAG_ERROR)
+               return false;
+
         for (i = 0; i < nattr; i++) {
                 switch (attrs[i].type) {
                 case KFD_IOCTL_SVM_ATTR_PREFERRED_LOC:
@@ -1657,8 +1662,11 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
 unreserve_out:
         svm_range_unreserve_bos(&ctx);

-       if (!r)
+       prange->flags |= KFD_IOCTL_SVM_FLAG_ERROR;
+       if (!r) {
+               prange->flags &= ~KFD_IOCTL_SVM_FLAG_ERROR;
                 prange->validate_timestamp = ktime_get_boottime();
+       }

         return r;
 }
@@ -3674,9 +3682,11 @@ svm_range_get_attr(struct kfd_process *p, struct mm_struct *mm,
                         break;
                 case KFD_IOCTL_SVM_ATTR_SET_FLAGS:
                         attrs[i].value = flags_and;
+                       attrs[i].value &= ~KFD_IOCTL_SVM_FLAG_ERROR;
                         break;
                 case KFD_IOCTL_SVM_ATTR_CLR_FLAGS:
                         attrs[i].value = ~flags_or;
+                       attrs[i].value &= ~KFD_IOCTL_SVM_FLAG_ERROR;
                         break;
                 case KFD_IOCTL_SVM_ATTR_GRANULARITY:
                         attrs[i].value = (uint32_t)granularity;
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 7e19a2d1e907..2b6f68bd06da 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -1125,6 +1125,8 @@ struct kfd_ioctl_cross_memory_copy_deprecated_args {
 #define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY 0x00000020
 /* Keep GPU memory mapping always valid as if XNACK is disable */
 #define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED 0x00000040
+/* Set during svm validation and map error */
+#define KFD_IOCTL_SVM_FLAG_ERROR       0x80000000

 /**
  * kfd_ioctl_svm_op - SVM ioctl operations
--
2.32.0




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux