Merge "ion: msm: Add support for addition/removal of memory to ION heaps"
This commit is contained in:
commit
c5d20367bc
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
@ -229,6 +229,19 @@ struct device *msm_ion_heap_device_by_id(int heap_id)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(msm_ion_heap_device_by_id);
|
EXPORT_SYMBOL(msm_ion_heap_device_by_id);
|
||||||
|
|
||||||
|
bool msm_ion_heap_is_secure(int heap_id)
|
||||||
|
{
|
||||||
|
struct ion_heap *heap = ion_heap_by_id(heap_id);
|
||||||
|
|
||||||
|
if (IS_ERR(heap) || !(heap->type == ION_HEAP_TYPE_SECURE_CARVEOUT ||
|
||||||
|
heap->type == ION_HEAP_TYPE_SYSTEM_SECURE ||
|
||||||
|
heap->type == ION_HEAP_TYPE_HYP_CMA))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(msm_ion_heap_is_secure);
|
||||||
|
|
||||||
int msm_ion_heap_prefetch(int heap_id, struct ion_prefetch_region *regions,
|
int msm_ion_heap_prefetch(int heap_id, struct ion_prefetch_region *regions,
|
||||||
int nr_regions)
|
int nr_regions)
|
||||||
{
|
{
|
||||||
@ -267,6 +280,40 @@ int msm_ion_heap_drain(int heap_id, struct ion_prefetch_region *regions,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(msm_ion_heap_drain);
|
EXPORT_SYMBOL(msm_ion_heap_drain);
|
||||||
|
|
||||||
|
int msm_ion_heap_add_memory(int heap_id, struct sg_table *sgt)
|
||||||
|
{
|
||||||
|
struct ion_heap *heap = ion_heap_by_id(heap_id);
|
||||||
|
struct msm_ion_heap *msm_heap;
|
||||||
|
|
||||||
|
if (IS_ERR(heap))
|
||||||
|
return PTR_ERR(heap);
|
||||||
|
|
||||||
|
msm_heap = to_msm_ion_heap(heap);
|
||||||
|
|
||||||
|
if (msm_heap->msm_heap_ops && msm_heap->msm_heap_ops->add_memory)
|
||||||
|
return msm_heap->msm_heap_ops->add_memory(heap, sgt);
|
||||||
|
|
||||||
|
return -ENOTSUPP;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(msm_ion_heap_add_memory);
|
||||||
|
|
||||||
|
int msm_ion_heap_remove_memory(int heap_id, struct sg_table *sgt)
|
||||||
|
{
|
||||||
|
struct ion_heap *heap = ion_heap_by_id(heap_id);
|
||||||
|
struct msm_ion_heap *msm_heap;
|
||||||
|
|
||||||
|
if (IS_ERR(heap))
|
||||||
|
return PTR_ERR(heap);
|
||||||
|
|
||||||
|
msm_heap = to_msm_ion_heap(heap);
|
||||||
|
|
||||||
|
if (msm_heap->msm_heap_ops && msm_heap->msm_heap_ops->remove_memory)
|
||||||
|
return msm_heap->msm_heap_ops->remove_memory(heap, sgt);
|
||||||
|
|
||||||
|
return -ENOTSUPP;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(msm_ion_heap_remove_memory);
|
||||||
|
|
||||||
static int msm_ion_get_heap_type_from_dt_node(struct device_node *node,
|
static int msm_ion_get_heap_type_from_dt_node(struct device_node *node,
|
||||||
int *heap_type)
|
int *heap_type)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 Google, Inc.
|
* Copyright (C) 2011 Google, Inc.
|
||||||
* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MSM_ION_PRIV_H
|
#ifndef _MSM_ION_PRIV_H
|
||||||
@ -87,6 +87,11 @@ struct ion_platform_heap {
|
|||||||
* @heap_drain: called to asynchronously drain a certain amount of
|
* @heap_drain: called to asynchronously drain a certain amount of
|
||||||
* memory that was prefetched for the heap at an earlier
|
* memory that was prefetched for the heap at an earlier
|
||||||
* point in time.
|
* point in time.
|
||||||
|
* @add_memory: called to add memory to an ION heap. Subsequent
|
||||||
|
* allocations may be satisfied utilizing newly added
|
||||||
|
* memory.
|
||||||
|
* @remove_memory: called to remove memory from an ION heap. Subsequent
|
||||||
|
* allocations will fail if the heap no longer has memory.
|
||||||
* @debug_show: called when the heap debug file is read to add any heap
|
* @debug_show: called when the heap debug file is read to add any heap
|
||||||
* specific debug info to output
|
* specific debug info to output
|
||||||
*/
|
*/
|
||||||
@ -97,6 +102,8 @@ struct msm_ion_heap_ops {
|
|||||||
int (*heap_drain)(struct ion_heap *heap,
|
int (*heap_drain)(struct ion_heap *heap,
|
||||||
struct ion_prefetch_region *regions,
|
struct ion_prefetch_region *regions,
|
||||||
int nr_regions);
|
int nr_regions);
|
||||||
|
int (*add_memory)(struct ion_heap *heap, struct sg_table *sgt);
|
||||||
|
int (*remove_memory)(struct ion_heap *heap, struct sg_table *sgt);
|
||||||
int (*debug_show)(struct ion_heap *heap, struct seq_file *s,
|
int (*debug_show)(struct ion_heap *heap, struct seq_file *s,
|
||||||
void *unused);
|
void *unused);
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <linux/bitmap.h>
|
#include <linux/bitmap.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/scatterlist.h>
|
||||||
#include <uapi/linux/msm_ion.h>
|
#include <uapi/linux/msm_ion.h>
|
||||||
|
|
||||||
struct ion_prefetch_region {
|
struct ion_prefetch_region {
|
||||||
@ -37,6 +38,12 @@ int msm_ion_heap_drain(int heap_id, struct ion_prefetch_region *regions,
|
|||||||
|
|
||||||
int get_ion_flags(u32 vmid);
|
int get_ion_flags(u32 vmid);
|
||||||
|
|
||||||
|
bool msm_ion_heap_is_secure(int heap_id);
|
||||||
|
|
||||||
|
int msm_ion_heap_add_memory(int heap_id, struct sg_table *sgt);
|
||||||
|
|
||||||
|
int msm_ion_heap_remove_memory(int heap_id, struct sg_table *sgt);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline struct device *msm_ion_heap_device_by_id(int heap_id)
|
static inline struct device *msm_ion_heap_device_by_id(int heap_id)
|
||||||
@ -74,5 +81,20 @@ static inline int get_ion_flags(u32 vmid)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool msm_ion_heap_is_secure(int heap_id)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int msm_ion_heap_add_memory(int heap_id, struct sg_table *sgt)
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int msm_ion_heap_remove_memory(int heap_id, struct sg_table *sgt)
|
||||||
|
{
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_ION_MSM_HEAPS */
|
#endif /* CONFIG_ION_MSM_HEAPS */
|
||||||
#endif /* _MSM_ION_H */
|
#endif /* _MSM_ION_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user