mirror of
https://github.com/LineageOS/android_kernel_samsung_msm8226.git
synced 2026-09-29 00:00:25 +02:00
gpu: ion: Add support for specifying a default prefetch size
Some heaps now support prefetching memory before allocation occurs. This currently requires a size to be given to prefetch a given size. Clients may not know what size they need to prefetch for a given heap. Since the optimal size may change with the target, add an option into devicetree to specify what size should be prefetched by default. Clients may specify a size of 0 to prefetch a the default size. Change-Id: If15e4051d53fe284129c309101c41ee423f890f9 Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
This commit is contained in:
@@ -37,6 +37,8 @@ Optional properties for Ion heaps
|
||||
- qcom,memory-reservation-size: size of reserved memory for the ION heap.
|
||||
- qcom,memory-reservation-type: type of memory to be reserved
|
||||
(see memory-reserve.txt for information about memory reservations)
|
||||
- qcom,default-prefetch-size: Based value to be used for prefetching
|
||||
optimizations. Ignored if the heap does not support prefetching.
|
||||
|
||||
Example:
|
||||
qcom,ion {
|
||||
|
||||
@@ -92,6 +92,7 @@ struct ion_cma_secure_heap {
|
||||
atomic_t total_allocated;
|
||||
atomic_t total_pool_size;
|
||||
unsigned long heap_size;
|
||||
unsigned long default_prefetch_size;
|
||||
};
|
||||
|
||||
static void ion_secure_pool_pages(struct work_struct *work);
|
||||
@@ -224,6 +225,9 @@ int ion_secure_cma_prefetch(struct ion_heap *heap, void *data)
|
||||
if ((int) heap->type != ION_HEAP_TYPE_SECURE_DMA)
|
||||
return -EINVAL;
|
||||
|
||||
if (len == 0)
|
||||
len = sheap->default_prefetch_size;
|
||||
|
||||
/*
|
||||
* Only prefetch as much space as there is left in the pool so
|
||||
* check against the current free size of the heap.
|
||||
@@ -667,14 +671,19 @@ struct ion_heap *ion_secure_cma_heap_create(struct ion_platform_heap *data)
|
||||
sheap->shrinker.seeks = DEFAULT_SEEKS;
|
||||
sheap->shrinker.batch = 0;
|
||||
sheap->shrinker.shrink = ion_secure_cma_shrinker;
|
||||
sheap->default_prefetch_size = sheap->heap_size;
|
||||
register_shrinker(&sheap->shrinker);
|
||||
|
||||
|
||||
if (!sheap->bitmap) {
|
||||
kfree(sheap);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
if (data->extra_data) {
|
||||
struct ion_cma_pdata *extra = data->extra_data;
|
||||
sheap->default_prefetch_size = extra->default_prefetch_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* we initially mark everything in the allocator as being free so that
|
||||
* allocations can come in later
|
||||
|
||||
@@ -554,7 +554,8 @@ static void check_for_heap_overlap(const struct ion_platform_heap heap_list[],
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static int msm_init_extra_data(struct ion_platform_heap *heap,
|
||||
static int msm_init_extra_data(struct device_node *node,
|
||||
struct ion_platform_heap *heap,
|
||||
const struct ion_heap_desc *heap_desc)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -580,6 +581,28 @@ static int msm_init_extra_data(struct ion_platform_heap *heap,
|
||||
ret = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
case ION_HEAP_TYPE_SECURE_DMA:
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
ret = of_property_read_u32(node,
|
||||
"qcom,default-prefetch-size", &val);
|
||||
|
||||
if (!ret) {
|
||||
heap->extra_data = kzalloc(sizeof(struct ion_cma_pdata),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!heap->extra_data) {
|
||||
ret = -ENOMEM;
|
||||
} else {
|
||||
struct ion_cma_pdata *extra = heap->extra_data;
|
||||
extra->default_prefetch_size = val;
|
||||
}
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
heap->extra_data = 0;
|
||||
break;
|
||||
@@ -639,7 +662,8 @@ static int msm_ion_populate_heap(struct device_node *node,
|
||||
if (ret)
|
||||
break;
|
||||
heap->type = heap_type;
|
||||
ret = msm_init_extra_data(heap, &ion_heap_meta[i]);
|
||||
ret = msm_init_extra_data(node, heap,
|
||||
&ion_heap_meta[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,14 @@ struct ion_co_heap_pdata {
|
||||
enum ion_memory_types memory_type;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct ion_cma_pdata - extra data for CMA regions
|
||||
* @default_prefetch_size - default size to use for prefetching
|
||||
*/
|
||||
struct ion_cma_pdata {
|
||||
unsigned long default_prefetch_size;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ION
|
||||
/**
|
||||
* msm_ion_client_create - allocate a client using the ion_device specified in
|
||||
|
||||
Reference in New Issue
Block a user