diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 4cd90a435b6c..f639e7d49cfa 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "page_pool.h" #include "deferred-free-helper.h" @@ -32,6 +33,10 @@ static struct dma_heap *sys_dma32_heap; static struct dma_heap *sys_uncached_heap; static struct dma_heap *sys_uncached_dma32_heap; +/* Default setting */ +static u32 bank_bit_first = 12; +static u32 bank_bit_mask = 0x7; + struct system_heap_buffer { struct dma_heap *heap; struct list_head attachments; @@ -601,10 +606,10 @@ static struct dma_buf *system_heap_do_allocate(struct dma_heap *heap, list_add_tail(&page->lru, &pages); } else { dma_addr_t phys = page_to_phys(page); - unsigned int bit12_14 = (phys >> 12) & 0x7; + unsigned int bit_index = ((phys >> bank_bit_first) & bank_bit_mask) & 0x7; - list_add_tail(&page->lru, &lists[bit12_14]); - block_index[bit12_14]++; + list_add_tail(&page->lru, &lists[bit_index]); + block_index[bit_index]++; } i++; } @@ -761,6 +766,7 @@ static int system_heap_create(void) { struct dma_heap_export_info exp_info; int i, err = 0; + struct dram_addrmap_info *ddr_map_info; /* * Since swiotlb has memory size limitation, this will calculate @@ -856,6 +862,12 @@ static int system_heap_create(void) mb(); /* make sure we only set allocate after dma_mask is set */ system_uncached_heap_ops.allocate = system_uncached_heap_allocate; + ddr_map_info = sip_smc_get_dram_map(); + if (ddr_map_info) { + bank_bit_first = ddr_map_info->bank_bit_first; + bank_bit_mask = ddr_map_info->bank_bit_mask; + } + return 0; err_dma32_pool: for (i = 0; i < NUM_ORDERS; i++)