From: Yang Yanchao yangyanchao6@huawei.com
euleros inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7WLVX
---------------------------------------------
Make sure that the mmap is successfully executed when no device exists.
Fixes: 46a7894b5e4c ("mm: gmem: Introduce GMEM") Signed-off-by: Yang Yanchao yangyanchao6@huawei.com --- mm/mmap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c index bff71a766e0a..f2ff7b09bfbd 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2453,6 +2453,9 @@ static void munmap_in_peer_devices(struct mm_struct *mm, if (!obj) return;
+ if (mm->gm_as == NULL) + goto end; + do { xa_lock(obj->logical_page_table); gm_mapping = vm_object_lookup(obj, addr); @@ -2480,9 +2483,6 @@ static void munmap_in_peer_devices(struct mm_struct *mm, mutex_unlock(&gm_mapping->lock); } while (addr += HPAGE_SIZE, addr != end);
- if (!mm->gm_as) - return; - list_for_each_entry_safe(ctx, tmp, &mm->gm_as->gm_ctx_list, gm_as_link) { if (!gm_dev_is_peer(ctx->dev)) continue; @@ -2747,8 +2747,12 @@ static int alloc_va_in_peer_devices(struct mm_struct *mm, gm_ret_t ret;
pr_debug("gmem: start mmap, as %p\n", mm->gm_as); - if (!mm->gm_as) - return -ENODEV; + if (!mm->gm_as) { + ret = gm_as_create(0, ULONG_MAX, GM_AS_ALLOC_DEFAULT, NPU_PAGE_SIZE, + &mm->gm_as); + if (ret) + return ret; + }
if (!vma->vm_obj) vma->vm_obj = vm_object_create(vma);
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/2102 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/2...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/2102 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/2...