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

@@ -41,10 +41,9 @@
#include <linux/fdtable.h>
#define SIZE_2MB (2*1024*1024)
#define ALIGN_2MB(size) ((size + SIZE_2MB - 1) & ~(SIZE_2MB - 1))
#define PAGE_SHIFT_2MB 21
#define PAGES_PER_2MB (SIZE_2MB / PAGE_SIZE)
#define ALIGN_GRANULE_SIZE(size, GRANULE_SIZE) ((size + GRANULE_SIZE - 1) & ~(GRANULE_SIZE - 1))
#define PAGE_SHIFT_GRANULE(GRANULE_SIZE) (order_base_2(GRANULE_SIZE))
#define PAGES_PER_GRANULE(GRANULE_SIZE) (GRANULE_SIZE / PAGE_SIZE)
#define DMA_ERROR_CODE (~(dma_addr_t)0)
@@ -487,14 +486,20 @@ struct dma_coherent_mem_replica {
};
int nvmap_dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
dma_addr_t device_addr, size_t size, int flags, bool is_compression);
dma_addr_t device_addr, size_t size, int flags, bool is_compression,
u32 granule_size);
#endif
int nvmap_probe(struct platform_device *pdev);
int nvmap_remove(struct platform_device *pdev);
int nvmap_init(struct platform_device *pdev);
int nvmap_create_carveout(const struct nvmap_platform_carveout *co);
#ifdef NVMAP_LOADABLE_MODULE
int nvmap_co_setup(struct reserved_mem *rmem, u32 granule_size);
#else
int nvmap_co_setup(struct reserved_mem *rmem);
#endif
struct device *dma_dev_from_handle(unsigned long type);
struct nvmap_heap_block *nvmap_carveout_alloc(struct nvmap_client *dev,