From: Xiaogang Chen <[email protected]>

Fixes: 7ef6b2d4b7e5 (drm/amdkfd: remap unaligned svm ranges that have split)

When split svm ranges that have been mapped using huge page should use huge
page size(2MB) to check split range alignment, not prange->granularity that
means migration granularity.

Signed-off-by: Xiaogang Chen <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 521c14c7a789..c60d8134db45 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1146,11 +1146,14 @@ svm_range_split_tail(struct svm_range *prange, uint64_t 
new_last,
 {
        struct svm_range *tail = NULL;
        int r = svm_range_split(prange, prange->start, new_last, &tail);
+       bool huge_page_mapping = IS_ALIGNED(prange->start, 512);
 
        if (!r) {
                list_add(&tail->list, insert_list);
-               if (!IS_ALIGNED(new_last + 1, 1UL << prange->granularity))
-                       list_add(&tail->update_list, remap_list);
+               if (huge_page_mapping) {
+                       if (!IS_ALIGNED(tail->start, 512))
+                               list_add(&tail->update_list, remap_list);
+               }
        }
        return r;
 }
@@ -1162,11 +1165,16 @@ svm_range_split_head(struct svm_range *prange, uint64_t 
new_start,
        struct svm_range *head = NULL;
        int r = svm_range_split(prange, new_start, prange->last, &head);
 
+       bool huge_page_mapping = IS_ALIGNED(prange->start, 512);
+
        if (!r) {
                list_add(&head->list, insert_list);
-               if (!IS_ALIGNED(new_start, 1UL << prange->granularity))
-                       list_add(&head->update_list, remap_list);
+               if (huge_page_mapping) {
+                       if (!IS_ALIGNED(prange->start, 512))
+                               list_add(&head->update_list, remap_list);
+               }
        }
+
        return r;
 }
 
-- 
2.34.1

Reply via email to