diff options
author | yuan.tian <yuan.tian@nxp.com> | 2022-07-15 12:04:31 +0800 |
---|---|---|
committer | yuan.tian <yuan.tian@nxp.com> | 2022-07-25 13:11:40 +0800 |
commit | b602e41c182343c61da7851366f8259695cbba27 (patch) | |
tree | 5fc3c2fbccd25c44a9944f5829e81ee88852433d /drivers/mxc/gpu-viv | |
parent | 697982f948f6f0f16eb3981e1635d8ae46f1d3b9 (diff) |
MGS-6739 [#imx-2760] 0049-IMX-2916-CL502884-KERNEL-SPACE-234062-align-the-flat
234062: align the
flat-mapping address/size to gpu page size(IMX-2916)
Signed-off-by: Ke Feng <ke.feng@verisilicon.com>
Signed-off-by: yuan.tian <yuan.tian@nxp.com>
Diffstat (limited to 'drivers/mxc/gpu-viv')
-rw-r--r-- | drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c index f4b05a79061c..ae1a5cc5effd 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c @@ -673,6 +673,8 @@ _FillFlatMapping( gctUINT64 end = base + flatSize; gctUINT32 reqVirtualBase = 0; gctUINT32 flatVirtualBase = 0; + gctUINT32 pageOffset = 0; + gctUINT32 virtPageOffset = 0; gctUINT32 i; /************************ Get flat mapping type and range. ************************/ @@ -748,6 +750,29 @@ _FillFlatMapping( reqVirtualBase = *GpuBaseAddress; } + if (area->mappingStart != gcvINVALID_ADDRESS && mtlb >= area->mappingStart && mtlb < area->mappingEnd) + { + pageOffset = flatBase & (gcdMMU_PAGE_4K_SIZE - 1); + virtPageOffset = reqVirtualBase & (gcdMMU_PAGE_4K_SIZE - 1); + reqVirtualBase = reqVirtualBase & ~(gcdMMU_PAGE_4K_SIZE - 1); + flatBase = flatBase & ~(gcdMMU_PAGE_4K_SIZE - 1); + flatSize = (physBase + flatSize - flatBase + gcdMMU_PAGE_4K_SIZE - 1) & (~(gcdMMU_PAGE_4K_SIZE - 1)); + PhysBase = flatBase; + physBase = (gctUINT32)flatBase; + } + else + { + pageOffset = flatBase & (gcdMMU_PAGE_1M_SIZE - 1); + virtPageOffset = reqVirtualBase & (gcdMMU_PAGE_1M_SIZE - 1); + reqVirtualBase = reqVirtualBase & ~(gcdMMU_PAGE_1M_SIZE - 1); + flatBase = flatBase & ~(gcdMMU_PAGE_1M_SIZE - 1); + flatSize = (physBase + flatSize - flatBase + gcdMMU_PAGE_1M_SIZE - 1) & (~(gcdMMU_PAGE_1M_SIZE - 1)); + PhysBase = flatBase; + physBase = (gctUINT32)flatBase; + } + if (reqVirtualBase && pageOffset != virtPageOffset) + return gcvSTATUS_NOT_SUPPORTED; + /* * if no partcial physical range overlap to request entire shift mapping, * it is specific shift mapping or directly mapping by default. @@ -899,7 +924,7 @@ _FillFlatMapping( /* No matter direct mapping or shift mapping or specific mapping, store gpu virtual ranges */ flatVirtualBase = (mStart << gcdMMU_MTLB_SHIFT) | (sStart << gcdMMU_STLB_1M_SHIFT) - | (physBase & gcdMMU_PAGE_1M_MASK); + | pageOffset; /* Return GPU virtual base address if necessary */ if (GpuBaseAddress) @@ -1189,8 +1214,8 @@ _FillFlatMapping( gcmkASSERT(Mmu->gpuPhysicalRangeCount <= gcdMAX_FLAT_MAPPING_COUNT); /* Store the gpu virtual ranges */ - Mmu->gpuAddressRanges[Mmu->gpuAddressRangeCount].start = flatVirtualBase; - Mmu->gpuAddressRanges[Mmu->gpuAddressRangeCount].end = flatVirtualBase + flatSize - 1; + Mmu->gpuAddressRanges[Mmu->gpuAddressRangeCount].start = flatVirtualBase - pageOffset; + Mmu->gpuAddressRanges[Mmu->gpuAddressRangeCount].end = flatVirtualBase - pageOffset + flatSize - 1; Mmu->gpuAddressRanges[Mmu->gpuAddressRangeCount].size = flatSize; Mmu->gpuAddressRanges[Mmu->gpuAddressRangeCount].flag = mapFlag; Mmu->gpuAddressRangeCount++; |