mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure
@ 2026-11-15 12:05 ` Avi Weiss
  2026-11-16  9:24   ` Feng Tang
  2026-11-16 17:03   ` Marek Szyprowski
  0 siblings, 2 replies; 4+ messages in thread
From: Avi Weiss @ 2026-11-15 12:05 UTC (permalink / raw)
  To: Marek Szyprowski; +Cc: Robin Murphy, Feng Tang, iommu, linux-kernel, Avi Weiss

dma_contiguous_reserve() returns when reserving the default CMA area
fails, skipping independently configured NUMA CMA areas that might
still be reservable.

Register the default area only when its reservation succeeds, then
continue with NUMA CMA reservation even if the default area fails.

Fixes: 7e6ace2535d0 ("dma-contiguous: add kconfig option to setup numa cma area if not configured explicitly")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 kernel/dma/contiguous.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 90937dc7c627..0b6500bb6cd9 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -287,8 +287,6 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
 						  selected_limit,
 						  &dma_contiguous_default_area,
 						  fixed);
-		if (ret)
-			return;
 
 		/*
 		 * We need to insert the new area in our list to avoid
@@ -305,9 +303,11 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
 		 * but we also need to insert it in our list to avoid
 		 * having a default area but an empty list.
 		 */
-		ret = dma_contiguous_insert_area(dma_contiguous_default_area);
-		if (ret)
-			pr_warn("Couldn't queue default CMA region for heap creation.");
+		if (!ret) {
+			ret = dma_contiguous_insert_area(dma_contiguous_default_area);
+			if (ret)
+				pr_warn("Couldn't queue default CMA region for heap creation.");
+		}
 	}
 
 	dma_numa_cma_reserve();

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure
  2026-11-15 12:05 ` [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure Avi Weiss
@ 2026-11-16  9:24   ` Feng Tang
  2026-11-16 11:32     ` Avi
  2026-11-16 17:03   ` Marek Szyprowski
  1 sibling, 1 reply; 4+ messages in thread
From: Feng Tang @ 2026-11-16  9:24 UTC (permalink / raw)
  To: Avi Weiss; +Cc: Marek Szyprowski, Robin Murphy, iommu, linux-kernel

On Sun, Nov 15, 2026 at 02:05:35PM +0200, Avi Weiss wrote:
> dma_contiguous_reserve() returns when reserving the default CMA area
> fails, skipping independently configured NUMA CMA areas that might
> still be reservable.
> 
> Register the default area only when its reservation succeeds, then
> continue with NUMA CMA reservation even if the default area fails.
> 
> Fixes: 7e6ace2535d0 ("dma-contiguous: add kconfig option to setup numa cma area if not configured explicitly")
> Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
> ---
>  kernel/dma/contiguous.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index 90937dc7c627..0b6500bb6cd9 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -287,8 +287,6 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>  						  selected_limit,
>  						  &dma_contiguous_default_area,
>  						  fixed);
> -		if (ret)
> -			return;
>  
>  		/*
>  		 * We need to insert the new area in our list to avoid
> @@ -305,9 +303,11 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>  		 * but we also need to insert it in our list to avoid
>  		 * having a default area but an empty list.
>  		 */
> -		ret = dma_contiguous_insert_area(dma_contiguous_default_area);
> -		if (ret)
> -			pr_warn("Couldn't queue default CMA region for heap creation.");
> +		if (!ret) {
> +			ret = dma_contiguous_insert_area(dma_contiguous_default_area);
> +			if (ret)
> +				pr_warn("Couldn't queue default CMA region for heap creation.");
> +		}

Thanks for the fix!

Reviewed-by: Feng Tang <feng.tang@linux.alibaba.com>

one nitpick is, is the below code more readable? (I'm OK with
your patch as is):

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 90937dc7c627..3daa9ae3ab7d 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -288,7 +288,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
 						  &dma_contiguous_default_area,
 						  fixed);
 		if (ret)
-			return;
+			goto numa_resv;
 
 		/*
 		 * We need to insert the new area in our list to avoid
@@ -310,6 +310,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
 			pr_warn("Couldn't queue default CMA region for heap creation.");
 	}
 
+numa_resv:
 	dma_numa_cma_reserve();
 }


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure
  2026-11-16  9:24   ` Feng Tang
@ 2026-11-16 11:32     ` Avi
  0 siblings, 0 replies; 4+ messages in thread
From: Avi @ 2026-11-16 11:32 UTC (permalink / raw)
  To: Feng Tang; +Cc: Marek Szyprowski, Robin Murphy, iommu, linux-kernel

I think both quite clear, but I don't mind either way ;-)

On Mon, Nov 16, 2026 at 4:24 AM Feng Tang <feng.tang@linux.alibaba.com> wrote:
>
> On Sun, Nov 15, 2026 at 02:05:35PM +0200, Avi Weiss wrote:
> > dma_contiguous_reserve() returns when reserving the default CMA area
> > fails, skipping independently configured NUMA CMA areas that might
> > still be reservable.
> >
> > Register the default area only when its reservation succeeds, then
> > continue with NUMA CMA reservation even if the default area fails.
> >
> > Fixes: 7e6ace2535d0 ("dma-contiguous: add kconfig option to setup numa cma area if not configured explicitly")
> > Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
> > ---
> >  kernel/dma/contiguous.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> > index 90937dc7c627..0b6500bb6cd9 100644
> > --- a/kernel/dma/contiguous.c
> > +++ b/kernel/dma/contiguous.c
> > @@ -287,8 +287,6 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
> >                                                 selected_limit,
> >                                                 &dma_contiguous_default_area,
> >                                                 fixed);
> > -             if (ret)
> > -                     return;
> >
> >               /*
> >                * We need to insert the new area in our list to avoid
> > @@ -305,9 +303,11 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
> >                * but we also need to insert it in our list to avoid
> >                * having a default area but an empty list.
> >                */
> > -             ret = dma_contiguous_insert_area(dma_contiguous_default_area);
> > -             if (ret)
> > -                     pr_warn("Couldn't queue default CMA region for heap creation.");
> > +             if (!ret) {
> > +                     ret = dma_contiguous_insert_area(dma_contiguous_default_area);
> > +                     if (ret)
> > +                             pr_warn("Couldn't queue default CMA region for heap creation.");
> > +             }
>
> Thanks for the fix!
>
> Reviewed-by: Feng Tang <feng.tang@linux.alibaba.com>
>
> one nitpick is, is the below code more readable? (I'm OK with
> your patch as is):
>
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index 90937dc7c627..3daa9ae3ab7d 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -288,7 +288,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>                                                   &dma_contiguous_default_area,
>                                                   fixed);
>                 if (ret)
> -                       return;
> +                       goto numa_resv;
>
>                 /*
>                  * We need to insert the new area in our list to avoid
> @@ -310,6 +310,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>                         pr_warn("Couldn't queue default CMA region for heap creation.");
>         }
>
> +numa_resv:
>         dma_numa_cma_reserve();
>  }
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure
  2026-11-15 12:05 ` [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure Avi Weiss
  2026-11-16  9:24   ` Feng Tang
@ 2026-11-16 17:03   ` Marek Szyprowski
  1 sibling, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2026-11-16 17:03 UTC (permalink / raw)
  To: Avi Weiss; +Cc: Robin Murphy, Feng Tang, iommu, linux-kernel

On 15.11.2026 13:05, Avi Weiss wrote:
> dma_contiguous_reserve() returns when reserving the default CMA area
> fails, skipping independently configured NUMA CMA areas that might
> still be reservable.
>
> Register the default area only when its reservation succeeds, then
> continue with NUMA CMA reservation even if the default area fails.
>
> Fixes: 7e6ace2535d0 ("dma-contiguous: add kconfig option to setup numa cma area if not configured explicitly")
> Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>


When reservation of the default CMA area fails, there is something really
wrong with system configuration. I don't think that it is worth trying to
setup NUMA related regions in such case.


> ---
>  kernel/dma/contiguous.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index 90937dc7c627..0b6500bb6cd9 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -287,8 +287,6 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>  						  selected_limit,
>  						  &dma_contiguous_default_area,
>  						  fixed);
> -		if (ret)
> -			return;
>  
>  		/*
>  		 * We need to insert the new area in our list to avoid
> @@ -305,9 +303,11 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>  		 * but we also need to insert it in our list to avoid
>  		 * having a default area but an empty list.
>  		 */
> -		ret = dma_contiguous_insert_area(dma_contiguous_default_area);
> -		if (ret)
> -			pr_warn("Couldn't queue default CMA region for heap creation.");
> +		if (!ret) {
> +			ret = dma_contiguous_insert_area(dma_contiguous_default_area);
> +			if (ret)
> +				pr_warn("Couldn't queue default CMA region for heap creation.");
> +		}
>  	}
>  
>  	dma_numa_cma_reserve();
>
> base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-16 17:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20261115120547eucas1p227eb5bfbcb903d677f033dd69643f44b@eucas1p2.samsung.com>
2026-11-15 12:05 ` [PATCH] dma-contiguous: reserve NUMA CMA areas after default reservation failure Avi Weiss
2026-11-16  9:24   ` Feng Tang
2026-11-16 11:32     ` Avi
2026-11-16 17:03   ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®