Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0585fb44 authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

ion: msm: Add support for addition/removal of memory to ION heaps



There is currently no interface for adding/removing memory to an
ION heap, so add one.

Change-Id: I68061feca3c29cd8f2370665f40f8005fb8765ff
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent 878cf94a
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -280,6 +280,40 @@ int msm_ion_heap_drain(int heap_id, struct ion_prefetch_region *regions,
}
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,
					      int *heap_type)
{
+8 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * 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
@@ -87,6 +87,11 @@ struct ion_platform_heap {
 * @heap_drain:		called to asynchronously drain a certain amount of
 *			memory that was prefetched for the heap at an earlier
 *			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
 *			specific debug info to output
 */
@@ -97,6 +102,8 @@ struct msm_ion_heap_ops {
	int (*heap_drain)(struct ion_heap *heap,
			  struct ion_prefetch_region *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,
			  void *unused);
};
+15 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include <linux/bitmap.h>
#include <linux/device.h>
#include <linux/scatterlist.h>
#include <uapi/linux/msm_ion.h>

struct ion_prefetch_region {
@@ -39,6 +40,10 @@ 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

static inline struct device *msm_ion_heap_device_by_id(int heap_id)
@@ -81,5 +86,15 @@ 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 /* _MSM_ION_H */