video: tegra: nvmap: Switch to configurable granule size

In compression carveout, granule size should be configurable via device
tree. Earlier code was written by considering granule size of 2MB,
update the code to use configurable granule size read from DT.

Bug 3956637

Change-Id: Ib1e966117b2bd9511cbcde37a6011c17f38f22e2
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2899865
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Ketan Patil
2023-05-03 15:01:32 +00:00
committed by mobile promotions
parent 408704d52a
commit faa6040875
7 changed files with 105 additions and 57 deletions

View File

@@ -719,22 +719,28 @@ static void alloc_handle(struct nvmap_client *client,
if (h->pgalloc.pages &&
h->heap_type == NVMAP_HEAP_CARVEOUT_COMPRESSION) {
unsigned long page_count;
u32 granule_size = 0;
int i;
struct list_block *lb;
lb = container_of(b, struct list_block, block);
granule_size = lb->heap->granule_size;
page_count = h->size >> PAGE_SHIFT;
/* Iterate over 2MB chunks */
for (i = 0; i < page_count; i += PAGES_PER_2MB) {
/* Iterate over granules */
for (i = 0; i < page_count;
i += PAGES_PER_GRANULE(granule_size)) {
cpu_addr = memremap(page_to_phys(
h->pgalloc.pages[i]),
SIZE_2MB, MEMREMAP_WB);
granule_size,
MEMREMAP_WB);
if (cpu_addr != NULL) {
memset(cpu_addr, 0, SIZE_2MB);
memset(cpu_addr, 0, granule_size);
#ifdef NVMAP_UPSTREAM_KERNEL
arch_invalidate_pmem(cpu_addr,
SIZE_2MB);
granule_size);
#else
__dma_flush_area(cpu_addr,
SIZE_2MB);
granule_size);
#endif
memunmap(cpu_addr);
}