diff mbox series

mm/cma.c: find a named CMA area by name

Message ID 20200116101322.17795-1-buddy.zhang@aliyun.com
State New
Headers show
Series mm/cma.c: find a named CMA area by name | expand

Commit Message

buddy.zhang@aliyun.com Jan. 16, 2020, 10:13 a.m. UTC
From: BuddyZhang <buddy.zhang@aliyun.com>

This function could help developer who want to find a special
named CMA area.

The CMA supports multiple named CMA areas, and the device could
use or exclusive a special CAM arae via "cma_area" on "struct
device". When probing, the device can setup special CMA area which
find by "cma_find_by_name()".

If device can't find named CMA area, "cma_find_by_name()" will
return NULL, and device will used default CMA area.

Signed-off-by: BuddyZhang <buddy.zhang@aliyun.com>
---
 mm/cma.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)


base-commit: 5b483a1a0ea1ab19a5734051c9692c2cfabe1327

Comments

Michal Hocko Jan. 16, 2020, 12:12 p.m. UTC | #1
On Thu 16-01-20 18:13:22, buddy.zhang@aliyun.com wrote:
> From: BuddyZhang <buddy.zhang@aliyun.com>
> 
> This function could help developer who want to find a special
> named CMA area.
> 
> The CMA supports multiple named CMA areas, and the device could
> use or exclusive a special CAM arae via "cma_area" on "struct
> device". When probing, the device can setup special CMA area which
> find by "cma_find_by_name()".
> 
> If device can't find named CMA area, "cma_find_by_name()" will
> return NULL, and device will used default CMA area.

Please do not add new exported symbols without actual users.

> Signed-off-by: BuddyZhang <buddy.zhang@aliyun.com>
> ---
>  mm/cma.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/mm/cma.c b/mm/cma.c
> index be55d1988c67..6581dabcaf34 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -40,6 +40,18 @@ struct cma cma_areas[MAX_CMA_AREAS];
>  unsigned cma_area_count;
>  static DEFINE_MUTEX(cma_mutex);
>  
> +struct cma *cma_find_by_name(const char *name)
> +{
> +	int idx;
> +
> +	for (idx = 0; idx < MAX_CMA_AREAS; idx++) {
> +		if (cma_areas[idx].name && !strcmp(name, cma_areas[idx].name))
> +			return &cma_areas[idx];
> +	}
> +	return NULL;
> +}
> +EXPORT_SYMBOL(cma_find_by_name);
> +
>  phys_addr_t cma_get_base(const struct cma *cma)
>  {
>  	return PFN_PHYS(cma->base_pfn);
> 
> base-commit: 5b483a1a0ea1ab19a5734051c9692c2cfabe1327
> -- 
> 2.17.1
>
Michal Hocko Jan. 17, 2020, 6:28 a.m. UTC | #2
On Fri 17-01-20 10:16:46, buddy.zhang wrote:
[...]
>     So, if device want to use a special named CMA area on module,  
>     "cma_find_by_name()" need export symbols.

My question was whether there actually is any device that would like to
use this functionality. Your patch doesn't add any and there is no
reference to any either. We do not add exports for the functionality
which is not used in the tree.
diff mbox series

Patch

diff --git a/mm/cma.c b/mm/cma.c
index be55d1988c67..6581dabcaf34 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -40,6 +40,18 @@  struct cma cma_areas[MAX_CMA_AREAS];
 unsigned cma_area_count;
 static DEFINE_MUTEX(cma_mutex);
 
+struct cma *cma_find_by_name(const char *name)
+{
+	int idx;
+
+	for (idx = 0; idx < MAX_CMA_AREAS; idx++) {
+		if (cma_areas[idx].name && !strcmp(name, cma_areas[idx].name))
+			return &cma_areas[idx];
+	}
+	return NULL;
+}
+EXPORT_SYMBOL(cma_find_by_name);
+
 phys_addr_t cma_get_base(const struct cma *cma)
 {
 	return PFN_PHYS(cma->base_pfn);