All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] of: of_reserved_mem: only call memblock_free for normal reserved memory
@ 2021-06-11 13:11 ` Dong Aisheng
  0 siblings, 0 replies; 15+ messages in thread
From: Dong Aisheng @ 2021-06-11 13:11 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, dongas86, linux-arm-kernel, Dong Aisheng,
	Rob Herring, devicetree

For nomap case, the memory block will be removed by memblock_remove()
in early_init_dt_alloc_reserved_memory_arch(). So it's meaningless to
call memblock_free() on error path.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/of/of_reserved_mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 4592b71aba5c..367f298a83b2 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -275,9 +275,10 @@ void __init fdt_init_reserved_mem(void)
 			if (err != 0 && err != -ENOENT) {
 				pr_info("node %s compatible matching fail\n",
 					rmem->name);
-				memblock_free(rmem->base, rmem->size);
 				if (nomap)
 					memblock_add(rmem->base, rmem->size);
+				else
+					memblock_free(rmem->base, rmem->size);
 			}
 		}
 	}
-- 
2.25.1


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

* [PATCH 1/2] of: of_reserved_mem: only call memblock_free for normal reserved memory
@ 2021-06-11 13:11 ` Dong Aisheng
  0 siblings, 0 replies; 15+ messages in thread
From: Dong Aisheng @ 2021-06-11 13:11 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, dongas86, linux-arm-kernel, Dong Aisheng,
	Rob Herring, devicetree

For nomap case, the memory block will be removed by memblock_remove()
in early_init_dt_alloc_reserved_memory_arch(). So it's meaningless to
call memblock_free() on error path.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/of/of_reserved_mem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 4592b71aba5c..367f298a83b2 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -275,9 +275,10 @@ void __init fdt_init_reserved_mem(void)
 			if (err != 0 && err != -ENOENT) {
 				pr_info("node %s compatible matching fail\n",
 					rmem->name);
-				memblock_free(rmem->base, rmem->size);
 				if (nomap)
 					memblock_add(rmem->base, rmem->size);
+				else
+					memblock_free(rmem->base, rmem->size);
 			}
 		}
 	}
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
  2021-06-11 13:11 ` Dong Aisheng
@ 2021-06-11 13:11   ` Dong Aisheng
  -1 siblings, 0 replies; 15+ messages in thread
From: Dong Aisheng @ 2021-06-11 13:11 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, dongas86, linux-arm-kernel, Dong Aisheng,
	Rob Herring, devicetree

Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
nomap memory is changed to call memblock_mark_nomap() instead of
memblock_remove(). But it only changed the reserved memory with fixed
addr and size case in early_init_dt_reserve_memory_arch(), not
including the dynamical allocation by size case in
early_init_dt_alloc_reserved_memory_arch().

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/of/of_reserved_mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 367f298a83b2..ebba88395bf8 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
 
 	*res_base = base;
 	if (nomap)
-		return memblock_remove(base, size);
+		return memblock_mark_nomap(base, size);
 
 	return memblock_reserve(base, size);
 }
@@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
 				pr_info("node %s compatible matching fail\n",
 					rmem->name);
 				if (nomap)
-					memblock_add(rmem->base, rmem->size);
+					memblock_clear_nomap(rmem->base, rmem->size);
 				else
 					memblock_free(rmem->base, rmem->size);
 			}
-- 
2.25.1


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

* [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
@ 2021-06-11 13:11   ` Dong Aisheng
  0 siblings, 0 replies; 15+ messages in thread
From: Dong Aisheng @ 2021-06-11 13:11 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, dongas86, linux-arm-kernel, Dong Aisheng,
	Rob Herring, devicetree

Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
nomap memory is changed to call memblock_mark_nomap() instead of
memblock_remove(). But it only changed the reserved memory with fixed
addr and size case in early_init_dt_reserve_memory_arch(), not
including the dynamical allocation by size case in
early_init_dt_alloc_reserved_memory_arch().

Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/of/of_reserved_mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 367f298a83b2..ebba88395bf8 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
 
 	*res_base = base;
 	if (nomap)
-		return memblock_remove(base, size);
+		return memblock_mark_nomap(base, size);
 
 	return memblock_reserve(base, size);
 }
@@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
 				pr_info("node %s compatible matching fail\n",
 					rmem->name);
 				if (nomap)
-					memblock_add(rmem->base, rmem->size);
+					memblock_clear_nomap(rmem->base, rmem->size);
 				else
 					memblock_free(rmem->base, rmem->size);
 			}
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
  2021-06-11 13:11   ` Dong Aisheng
  (?)
@ 2021-06-11 17:10     ` Rob Herring
  -1 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-11 17:10 UTC (permalink / raw)
  To: Dong Aisheng, Quentin Perret, Stephen Boyd, Nicolas Boichat,
	KarimAllah Ahmed
  Cc: linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel, devicetree

On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> nomap memory is changed to call memblock_mark_nomap() instead of
> memblock_remove(). But it only changed the reserved memory with fixed
> addr and size case in early_init_dt_reserve_memory_arch(), not
> including the dynamical allocation by size case in
> early_init_dt_alloc_reserved_memory_arch().
>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org

Good practice is to Cc the people involved in referenced commits.
Adding them now. This code is a minefield so I'd like other eyes on
it.

> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 367f298a83b2..ebba88395bf8 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
>
>         *res_base = base;
>         if (nomap)
> -               return memblock_remove(base, size);
> +               return memblock_mark_nomap(base, size);
>
>         return memblock_reserve(base, size);
>  }
> @@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
>                                 pr_info("node %s compatible matching fail\n",
>                                         rmem->name);
>                                 if (nomap)
> -                                       memblock_add(rmem->base, rmem->size);
> +                                       memblock_clear_nomap(rmem->base, rmem->size);
>                                 else
>                                         memblock_free(rmem->base, rmem->size);
>                         }
> --
> 2.25.1
>

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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
@ 2021-06-11 17:10     ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-11 17:10 UTC (permalink / raw)
  To: Dong Aisheng, Quentin Perret, Stephen Boyd, Nicolas Boichat,
	KarimAllah Ahmed
  Cc: linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel, devicetree

On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> nomap memory is changed to call memblock_mark_nomap() instead of
> memblock_remove(). But it only changed the reserved memory with fixed
> addr and size case in early_init_dt_reserve_memory_arch(), not
> including the dynamical allocation by size case in
> early_init_dt_alloc_reserved_memory_arch().
>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org

Good practice is to Cc the people involved in referenced commits.
Adding them now. This code is a minefield so I'd like other eyes on
it.

> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 367f298a83b2..ebba88395bf8 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
>
>         *res_base = base;
>         if (nomap)
> -               return memblock_remove(base, size);
> +               return memblock_mark_nomap(base, size);
>
>         return memblock_reserve(base, size);
>  }
> @@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
>                                 pr_info("node %s compatible matching fail\n",
>                                         rmem->name);
>                                 if (nomap)
> -                                       memblock_add(rmem->base, rmem->size);
> +                                       memblock_clear_nomap(rmem->base, rmem->size);
>                                 else
>                                         memblock_free(rmem->base, rmem->size);
>                         }
> --
> 2.25.1
>


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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
@ 2021-06-11 17:10     ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-11 17:10 UTC (permalink / raw)
  To: Dong Aisheng, Quentin Perret, Stephen Boyd, Nicolas Boichat,
	KarimAllah Ahmed
  Cc: linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel, devicetree

On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> nomap memory is changed to call memblock_mark_nomap() instead of
> memblock_remove(). But it only changed the reserved memory with fixed
> addr and size case in early_init_dt_reserve_memory_arch(), not
> including the dynamical allocation by size case in
> early_init_dt_alloc_reserved_memory_arch().
>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org

Good practice is to Cc the people involved in referenced commits.
Adding them now. This code is a minefield so I'd like other eyes on
it.

> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 367f298a83b2..ebba88395bf8 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
>
>         *res_base = base;
>         if (nomap)
> -               return memblock_remove(base, size);
> +               return memblock_mark_nomap(base, size);
>
>         return memblock_reserve(base, size);
>  }
> @@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
>                                 pr_info("node %s compatible matching fail\n",
>                                         rmem->name);
>                                 if (nomap)
> -                                       memblock_add(rmem->base, rmem->size);
> +                                       memblock_clear_nomap(rmem->base, rmem->size);
>                                 else
>                                         memblock_free(rmem->base, rmem->size);
>                         }
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* RE: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
  2021-06-11 17:10     ` Rob Herring
@ 2021-06-12 11:20       ` Aisheng Dong
  -1 siblings, 0 replies; 15+ messages in thread
From: Aisheng Dong @ 2021-06-12 11:20 UTC (permalink / raw)
  To: Rob Herring, Quentin Perret, Stephen Boyd, Nicolas Boichat,
	KarimAllah Ahmed
  Cc: linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel, devicetree

> From: Rob Herring <robh+dt@kernel.org>
> Sent: Saturday, June 12, 2021 1:11 AM
> 
> On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com>
> wrote:
> >
> > Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the
> > memory region"), nomap memory is changed to call
> memblock_mark_nomap()
> > instead of memblock_remove(). But it only changed the reserved memory
> > with fixed addr and size case in early_init_dt_reserve_memory_arch(),
> > not including the dynamical allocation by size case in
> > early_init_dt_alloc_reserved_memory_arch().
> >
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: devicetree@vger.kernel.org
> 
> Good practice is to Cc the people involved in referenced commits.
> Adding them now. This code is a minefield so I'd like other eyes on it.
> 

Yes, you're right. Thanks for the good suggestion.
Let's wait for their comments.

Regards
Aisheng

> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/of/of_reserved_mem.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/of_reserved_mem.c
> > b/drivers/of/of_reserved_mem.c index 367f298a83b2..ebba88395bf8
> 100644
> > --- a/drivers/of/of_reserved_mem.c
> > +++ b/drivers/of/of_reserved_mem.c
> > @@ -42,7 +42,7 @@ static int __init
> > early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> >
> >         *res_base = base;
> >         if (nomap)
> > -               return memblock_remove(base, size);
> > +               return memblock_mark_nomap(base, size);
> >
> >         return memblock_reserve(base, size);  } @@ -276,7 +276,7 @@
> > void __init fdt_init_reserved_mem(void)
> >                                 pr_info("node %s compatible matching
> fail\n",
> >                                         rmem->name);
> >                                 if (nomap)
> > -                                       memblock_add(rmem->base,
> rmem->size);
> > +
> > + memblock_clear_nomap(rmem->base, rmem->size);
> >                                 else
> >                                         memblock_free(rmem->base,
> rmem->size);
> >                         }
> > --
> > 2.25.1
> >

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

* RE: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
@ 2021-06-12 11:20       ` Aisheng Dong
  0 siblings, 0 replies; 15+ messages in thread
From: Aisheng Dong @ 2021-06-12 11:20 UTC (permalink / raw)
  To: Rob Herring, Quentin Perret, Stephen Boyd, Nicolas Boichat,
	KarimAllah Ahmed
  Cc: linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel, devicetree

> From: Rob Herring <robh+dt@kernel.org>
> Sent: Saturday, June 12, 2021 1:11 AM
> 
> On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com>
> wrote:
> >
> > Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the
> > memory region"), nomap memory is changed to call
> memblock_mark_nomap()
> > instead of memblock_remove(). But it only changed the reserved memory
> > with fixed addr and size case in early_init_dt_reserve_memory_arch(),
> > not including the dynamical allocation by size case in
> > early_init_dt_alloc_reserved_memory_arch().
> >
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: devicetree@vger.kernel.org
> 
> Good practice is to Cc the people involved in referenced commits.
> Adding them now. This code is a minefield so I'd like other eyes on it.
> 

Yes, you're right. Thanks for the good suggestion.
Let's wait for their comments.

Regards
Aisheng

> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/of/of_reserved_mem.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/of_reserved_mem.c
> > b/drivers/of/of_reserved_mem.c index 367f298a83b2..ebba88395bf8
> 100644
> > --- a/drivers/of/of_reserved_mem.c
> > +++ b/drivers/of/of_reserved_mem.c
> > @@ -42,7 +42,7 @@ static int __init
> > early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> >
> >         *res_base = base;
> >         if (nomap)
> > -               return memblock_remove(base, size);
> > +               return memblock_mark_nomap(base, size);
> >
> >         return memblock_reserve(base, size);  } @@ -276,7 +276,7 @@
> > void __init fdt_init_reserved_mem(void)
> >                                 pr_info("node %s compatible matching
> fail\n",
> >                                         rmem->name);
> >                                 if (nomap)
> > -                                       memblock_add(rmem->base,
> rmem->size);
> > +
> > + memblock_clear_nomap(rmem->base, rmem->size);
> >                                 else
> >                                         memblock_free(rmem->base,
> rmem->size);
> >                         }
> > --
> > 2.25.1
> >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
  2021-06-11 17:10     ` Rob Herring
@ 2021-06-22  9:22       ` Quentin Perret
  -1 siblings, 0 replies; 15+ messages in thread
From: Quentin Perret @ 2021-06-22  9:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Dong Aisheng, Stephen Boyd, Nicolas Boichat, KarimAllah Ahmed,
	linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel,
	devicetree

On Friday 11 Jun 2021 at 11:10:36 (-0600), Rob Herring wrote:
> On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
> >
> > Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> > nomap memory is changed to call memblock_mark_nomap() instead of
> > memblock_remove(). But it only changed the reserved memory with fixed
> > addr and size case in early_init_dt_reserve_memory_arch(), not
> > including the dynamical allocation by size case in
> > early_init_dt_alloc_reserved_memory_arch().
> >
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: devicetree@vger.kernel.org
> 
> Good practice is to Cc the people involved in referenced commits.
> Adding them now. This code is a minefield so I'd like other eyes on
> it.

Apologies for the delayed reply -- was away last week.

I've been starring at this for 15 minutes, and still can't see how it
could go wrong, so FWIW:

Reviewed-by: Quentin Perret <qperret@google.com>

Thanks,
Quentin

> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/of/of_reserved_mem.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> > index 367f298a83b2..ebba88395bf8 100644
> > --- a/drivers/of/of_reserved_mem.c
> > +++ b/drivers/of/of_reserved_mem.c
> > @@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> >
> >         *res_base = base;
> >         if (nomap)
> > -               return memblock_remove(base, size);
> > +               return memblock_mark_nomap(base, size);
> >
> >         return memblock_reserve(base, size);
> >  }
> > @@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
> >                                 pr_info("node %s compatible matching fail\n",
> >                                         rmem->name);
> >                                 if (nomap)
> > -                                       memblock_add(rmem->base, rmem->size);
> > +                                       memblock_clear_nomap(rmem->base, rmem->size);
> >                                 else
> >                                         memblock_free(rmem->base, rmem->size);
> >                         }
> > --
> > 2.25.1
> >

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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
@ 2021-06-22  9:22       ` Quentin Perret
  0 siblings, 0 replies; 15+ messages in thread
From: Quentin Perret @ 2021-06-22  9:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Dong Aisheng, Stephen Boyd, Nicolas Boichat, KarimAllah Ahmed,
	linux-mm, linux-kernel, Dong Aisheng, linux-arm-kernel,
	devicetree

On Friday 11 Jun 2021 at 11:10:36 (-0600), Rob Herring wrote:
> On Fri, Jun 11, 2021 at 7:13 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
> >
> > Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> > nomap memory is changed to call memblock_mark_nomap() instead of
> > memblock_remove(). But it only changed the reserved memory with fixed
> > addr and size case in early_init_dt_reserve_memory_arch(), not
> > including the dynamical allocation by size case in
> > early_init_dt_alloc_reserved_memory_arch().
> >
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: devicetree@vger.kernel.org
> 
> Good practice is to Cc the people involved in referenced commits.
> Adding them now. This code is a minefield so I'd like other eyes on
> it.

Apologies for the delayed reply -- was away last week.

I've been starring at this for 15 minutes, and still can't see how it
could go wrong, so FWIW:

Reviewed-by: Quentin Perret <qperret@google.com>

Thanks,
Quentin

> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/of/of_reserved_mem.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> > index 367f298a83b2..ebba88395bf8 100644
> > --- a/drivers/of/of_reserved_mem.c
> > +++ b/drivers/of/of_reserved_mem.c
> > @@ -42,7 +42,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
> >
> >         *res_base = base;
> >         if (nomap)
> > -               return memblock_remove(base, size);
> > +               return memblock_mark_nomap(base, size);
> >
> >         return memblock_reserve(base, size);
> >  }
> > @@ -276,7 +276,7 @@ void __init fdt_init_reserved_mem(void)
> >                                 pr_info("node %s compatible matching fail\n",
> >                                         rmem->name);
> >                                 if (nomap)
> > -                                       memblock_add(rmem->base, rmem->size);
> > +                                       memblock_clear_nomap(rmem->base, rmem->size);
> >                                 else
> >                                         memblock_free(rmem->base, rmem->size);
> >                         }
> > --
> > 2.25.1
> >

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] of: of_reserved_mem: only call memblock_free for normal reserved memory
  2021-06-11 13:11 ` Dong Aisheng
@ 2021-06-24 19:05   ` Rob Herring
  -1 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-24 19:05 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: linux-mm, linux-arm-kernel, Rob Herring, devicetree, dongas86,
	linux-kernel

On Fri, 11 Jun 2021 21:11:52 +0800, Dong Aisheng wrote:
> For nomap case, the memory block will be removed by memblock_remove()
> in early_init_dt_alloc_reserved_memory_arch(). So it's meaningless to
> call memblock_free() on error path.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

Applied, thanks!

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

* Re: [PATCH 1/2] of: of_reserved_mem: only call memblock_free for normal reserved memory
@ 2021-06-24 19:05   ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-24 19:05 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: linux-mm, linux-arm-kernel, Rob Herring, devicetree, dongas86,
	linux-kernel

On Fri, 11 Jun 2021 21:11:52 +0800, Dong Aisheng wrote:
> For nomap case, the memory block will be removed by memblock_remove()
> in early_init_dt_alloc_reserved_memory_arch(). So it's meaningless to
> call memblock_free() on error path.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

Applied, thanks!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
  2021-06-11 13:11   ` Dong Aisheng
@ 2021-06-24 19:07     ` Rob Herring
  -1 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-24 19:07 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: linux-kernel, linux-mm, linux-arm-kernel, Rob Herring, dongas86,
	devicetree

On Fri, 11 Jun 2021 21:11:53 +0800, Dong Aisheng wrote:
> Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> nomap memory is changed to call memblock_mark_nomap() instead of
> memblock_remove(). But it only changed the reserved memory with fixed
> addr and size case in early_init_dt_reserve_memory_arch(), not
> including the dynamical allocation by size case in
> early_init_dt_alloc_reserved_memory_arch().
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Applied, thanks!

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

* Re: [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing
@ 2021-06-24 19:07     ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2021-06-24 19:07 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: linux-kernel, linux-mm, linux-arm-kernel, Rob Herring, dongas86,
	devicetree

On Fri, 11 Jun 2021 21:11:53 +0800, Dong Aisheng wrote:
> Since commit 86588296acbf ("fdt: Properly handle "no-map" field in the memory region"),
> nomap memory is changed to call memblock_mark_nomap() instead of
> memblock_remove(). But it only changed the reserved memory with fixed
> addr and size case in early_init_dt_reserve_memory_arch(), not
> including the dynamical allocation by size case in
> early_init_dt_alloc_reserved_memory_arch().
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/of_reserved_mem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Applied, thanks!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-06-24 19:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 13:11 [PATCH 1/2] of: of_reserved_mem: only call memblock_free for normal reserved memory Dong Aisheng
2021-06-11 13:11 ` Dong Aisheng
2021-06-11 13:11 ` [PATCH 2/2] of: of_reserved_mem: mark nomap memory instead of removing Dong Aisheng
2021-06-11 13:11   ` Dong Aisheng
2021-06-11 17:10   ` Rob Herring
2021-06-11 17:10     ` Rob Herring
2021-06-11 17:10     ` Rob Herring
2021-06-12 11:20     ` Aisheng Dong
2021-06-12 11:20       ` Aisheng Dong
2021-06-22  9:22     ` Quentin Perret
2021-06-22  9:22       ` Quentin Perret
2021-06-24 19:07   ` Rob Herring
2021-06-24 19:07     ` Rob Herring
2021-06-24 19:05 ` [PATCH 1/2] of: of_reserved_mem: only call memblock_free for normal reserved memory Rob Herring
2021-06-24 19:05   ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.