base-files: minor fix to mmc_get_mac_ascii function
[openwrt/staging/xback.git] / target / linux / bcm27xx / patches-6.1 / 950-0905-drm-v3d-Improve-MMU-support-for-larger-pages.patch
1 From 12c7ea43b930976f35ce75d11fd3f55438868e13 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Fri, 4 Aug 2023 11:26:10 +0100
4 Subject: [PATCH] drm/v3d: Improve MMU support for larger pages
5
6 The built-in MMU driver went most of the way towards supporting larger
7 kernel pages, but dropped the ball when it comes to calculating indexes
8 into the page table. Fix it.
9
10 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
11 ---
12 drivers/gpu/drm/v3d/v3d_mmu.c | 15 ++++++++-------
13 1 file changed, 8 insertions(+), 7 deletions(-)
14
15 --- a/drivers/gpu/drm/v3d/v3d_mmu.c
16 +++ b/drivers/gpu/drm/v3d/v3d_mmu.c
17 @@ -22,6 +22,7 @@
18 #include "v3d_regs.h"
19
20 #define V3D_MMU_PAGE_SHIFT 12
21 +#define V3D_PAGE_FACTOR (PAGE_SIZE >> V3D_MMU_PAGE_SHIFT)
22
23 /* Note: All PTEs for the 1MB superpage must be filled with the
24 * superpage bit set.
25 @@ -88,7 +89,7 @@ void v3d_mmu_insert_ptes(struct v3d_bo *
26 {
27 struct drm_gem_shmem_object *shmem_obj = &bo->base;
28 struct v3d_dev *v3d = to_v3d_dev(shmem_obj->base.dev);
29 - u32 page = bo->node.start;
30 + u32 page = bo->node.start * V3D_PAGE_FACTOR;
31 u32 page_prot = V3D_PTE_WRITEABLE | V3D_PTE_VALID;
32 struct sg_dma_page_iter dma_iter;
33
34 @@ -98,13 +99,13 @@ void v3d_mmu_insert_ptes(struct v3d_bo *
35 u32 pte = page_prot | page_address;
36 u32 i;
37
38 - BUG_ON(page_address + (PAGE_SIZE >> V3D_MMU_PAGE_SHIFT) >=
39 + BUG_ON(page_address + V3D_PAGE_FACTOR >=
40 BIT(24));
41 - for (i = 0; i < PAGE_SIZE >> V3D_MMU_PAGE_SHIFT; i++)
42 + for (i = 0; i < V3D_PAGE_FACTOR; i++)
43 v3d->pt[page++] = pte + i;
44 }
45
46 - WARN_ON_ONCE(page - bo->node.start !=
47 + WARN_ON_ONCE(page - (bo->node.start * V3D_PAGE_FACTOR) !=
48 shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT);
49
50 if (v3d_mmu_flush_all(v3d))
51 @@ -115,10 +116,10 @@ void v3d_mmu_remove_ptes(struct v3d_bo *
52 {
53 struct v3d_dev *v3d = to_v3d_dev(bo->base.base.dev);
54 u32 npages = bo->base.base.size >> V3D_MMU_PAGE_SHIFT;
55 - u32 page;
56 + u32 page = bo->node.start * V3D_PAGE_FACTOR;
57
58 - for (page = bo->node.start; page < bo->node.start + npages; page++)
59 - v3d->pt[page] = 0;
60 + while (npages--)
61 + v3d->pt[page++] = 0;
62
63 if (v3d_mmu_flush_all(v3d))
64 dev_err(v3d->drm.dev, "MMU flush timeout\n");