From: Parth Gajjar <[email protected]>

Added 0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch
Replaced direct modifications to vma->vm_flags with modifier calls.

Signed-off-by: Parth Gajjar <[email protected]>
Signed-off-by: Sandeep Gundlupet Raju <[email protected]>

Sync 2022.1 through 2023.2

Signed-off: Mark Hatle <[email protected]>
---
 ...lags-direct-modifications-with-modif.patch | 81 +++++++++++++++++++
 .../mali/kernel-module-mali_2022.1.bb         |  1 +
 .../mali/kernel-module-mali_2022.2.bb         |  5 ++
 .../mali/kernel-module-mali_2023.1.bb         |  1 +
 .../mali/kernel-module-mali_2023.2.bb         |  1 +
 5 files changed, 89 insertions(+)
 create mode 100644 
meta-xilinx-core/recipes-graphics/mali/kernel-module-mali/0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch

diff --git 
a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali/0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch
 
b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali/0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch
new file mode 100644
index 00000000..72275a4c
--- /dev/null
+++ 
b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali/0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch
@@ -0,0 +1,81 @@
+From e3e0f5e3fa0ddb396393d444bce6e575f7a16189 Mon Sep 17 00:00:00 2001
+From: Parth Gajjar <[email protected]>
+Date: Thu, 21 Dec 2023 22:41:32 -0800
+Subject: [PATCH] Replace vma->vm_flags direct modifications with modifier
+ calls
+
+Replace direct modifications to vma->vm_flags with calls to modifier
+functions to be able to track flag changes and to keep vma locking
+correctness. (Kernel 6.3)
+
+Signed-off-by: Parth Gajjar <[email protected]>
+---
+ linux/mali_memory.c     | 10 ++++++++++
+ linux/mali_memory_cow.c | 13 ++++++++++---
+ 2 files changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/linux/mali_memory.c b/linux/mali_memory.c
+index 2b2b209..c21d0b7 100644
+--- a/linux/mali_memory.c
++++ b/linux/mali_memory.c
+@@ -266,11 +266,17 @@ int mali_mmap(struct file *filp, struct vm_area_struct 
*vma)
+                * that it's present and can never be paged out (see also 
previous
+                * entry)
+                */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
++              vm_flags_set(vma, VM_IO | VM_DONTCOPY | VM_PFNMAP);
++#else
+               vma->vm_flags |= VM_IO;
+               vma->vm_flags |= VM_DONTCOPY;
+               vma->vm_flags |= VM_PFNMAP;
++#endif
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
+               vma->vm_flags |= VM_RESERVED;
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
++              vm_flags_set(vma, VM_DONTDUMP | VM_DONTEXPAND);
+ #else
+               vma->vm_flags |= VM_DONTDUMP;
+               vma->vm_flags |= VM_DONTEXPAND;
+@@ -288,7 +294,11 @@ int mali_mmap(struct file *filp, struct vm_area_struct 
*vma)
+       if (!(vma->vm_flags & VM_WRITE)) {
+               MALI_DEBUG_PRINT(4, ("mmap allocation with read only !\n"));
+               /* add VM_WRITE for do_page_fault will check this when a write 
fault */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
++              vm_flags_set(vma, VM_WRITE | VM_READ);
++#else
+               vma->vm_flags |= VM_WRITE | VM_READ;
++#endif
+               vma->vm_page_prot = PAGE_READONLY;
+               vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+               mem_bkend->flags |= MALI_MEM_BACKEND_FLAG_COW_CPU_NO_WRITE;
+diff --git a/linux/mali_memory_cow.c b/linux/mali_memory_cow.c
+index 6fadd42..e631431 100644
+--- a/linux/mali_memory_cow.c
++++ b/linux/mali_memory_cow.c
+@@ -391,13 +391,20 @@ _mali_osk_errcode_t 
mali_memory_cow_modify_range(mali_mem_backend *backend,
+                       }
+               } else {
+                       /* used to trigger page fault for swappable cowed 
memory. */
+-                      alloc->cpu_mapping.vma->vm_flags |= VM_PFNMAP;
+-                      alloc->cpu_mapping.vma->vm_flags |= VM_MIXEDMAP;
+-
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
++                      vm_flags_set(alloc->cpu_mapping.vma, VM_PFNMAP | 
VM_MIXEDMAP);
++#else
++                      alloc->cpu_mapping.vma->vm_flags |= VM_PFNMAP;
++                      alloc->cpu_mapping.vma->vm_flags |= VM_MIXEDMAP;
++#endif
+                       zap_vma_ptes(alloc->cpu_mapping.vma, 
alloc->cpu_mapping.vma->vm_start + range_start, range_size);
+                       /* delete this flag to let swappble is ummapped regard 
to stauct page not page frame. */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
++                      vm_flags_clear(alloc->cpu_mapping.vma, VM_PFNMAP | 
VM_MIXEDMAP);
++#else
+                       alloc->cpu_mapping.vma->vm_flags &= ~VM_PFNMAP;
+                       alloc->cpu_mapping.vma->vm_flags &= ~VM_MIXEDMAP;
++#endif
+               }
+       }
+ 
+-- 
+2.25.1
+
diff --git 
a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.1.bb 
b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.1.bb
index 56431a7f..9f17d744 100644
--- a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.1.bb
+++ b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.1.bb
@@ -35,6 +35,7 @@ SRC_URI = " \
        file://0025-Import-DMA_BUF-module-and-update-register_shrinker-f.patch \
        file://0026-Fix-gpu-driver-probe-failure.patch \
        file://0027-Updated-clock-name-and-structure-to-match-LIMA-drive.patch \
+       file://0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch \
        "
 SRC_URI[md5sum] = "85ea110dd6675c70b7d01af87ec9633c"
 SRC_URI[sha256sum] = 
"7a67127341d17640c1fff5dad80258fb2a37c8a2121b81525fe2327e4532ce2b"
diff --git 
a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.2.bb 
b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.2.bb
index e8e46543..9f17d744 100644
--- a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.2.bb
+++ b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2022.2.bb
@@ -31,6 +31,11 @@ SRC_URI = " \
        file://0021-Use-updated-timekeeping-functions-in-kernel-5.6.patch \
        file://0022-Set-HAVE_UNLOCKED_IOCTL-default-to-true.patch \
        file://0023-Use-PTR_ERR_OR_ZERO-instead-of-PTR_RET.patch \
+       file://0024-Use-community-device-tree-names.patch \
+       file://0025-Import-DMA_BUF-module-and-update-register_shrinker-f.patch \
+       file://0026-Fix-gpu-driver-probe-failure.patch \
+       file://0027-Updated-clock-name-and-structure-to-match-LIMA-drive.patch \
+       file://0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch \
        "
 SRC_URI[md5sum] = "85ea110dd6675c70b7d01af87ec9633c"
 SRC_URI[sha256sum] = 
"7a67127341d17640c1fff5dad80258fb2a37c8a2121b81525fe2327e4532ce2b"
diff --git 
a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.1.bb 
b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.1.bb
index 56431a7f..9f17d744 100644
--- a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.1.bb
+++ b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.1.bb
@@ -35,6 +35,7 @@ SRC_URI = " \
        file://0025-Import-DMA_BUF-module-and-update-register_shrinker-f.patch \
        file://0026-Fix-gpu-driver-probe-failure.patch \
        file://0027-Updated-clock-name-and-structure-to-match-LIMA-drive.patch \
+       file://0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch \
        "
 SRC_URI[md5sum] = "85ea110dd6675c70b7d01af87ec9633c"
 SRC_URI[sha256sum] = 
"7a67127341d17640c1fff5dad80258fb2a37c8a2121b81525fe2327e4532ce2b"
diff --git 
a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.2.bb 
b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.2.bb
index 56431a7f..9f17d744 100644
--- a/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.2.bb
+++ b/meta-xilinx-core/recipes-graphics/mali/kernel-module-mali_2023.2.bb
@@ -35,6 +35,7 @@ SRC_URI = " \
        file://0025-Import-DMA_BUF-module-and-update-register_shrinker-f.patch \
        file://0026-Fix-gpu-driver-probe-failure.patch \
        file://0027-Updated-clock-name-and-structure-to-match-LIMA-drive.patch \
+       file://0028-Replace-vma-vm_flags-direct-modifications-with-modif.patch \
        "
 SRC_URI[md5sum] = "85ea110dd6675c70b7d01af87ec9633c"
 SRC_URI[sha256sum] = 
"7a67127341d17640c1fff5dad80258fb2a37c8a2121b81525fe2327e4532ce2b"
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5328): 
https://lists.yoctoproject.org/g/meta-xilinx/message/5328
Mute This Topic: https://lists.yoctoproject.org/mt/106179145/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-xilinx/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to