All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pstore/ram: Rework logic for detecting ramoops reserved memory region
@ 2021-06-25 11:17 Mukesh Ojha
  2021-07-05 10:39 ` Mukesh Ojha
  0 siblings, 1 reply; 2+ messages in thread
From: Mukesh Ojha @ 2021-06-25 11:17 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck, linux-kernel
  Cc: Isaac J. Manjarres, Mukesh Ojha

From: "Isaac J. Manjarres" <isaacm@codeaurora.org>

The reserved memory region for ramoops is assumed to be at a fixed
and known location when read from the devicetree. This is not desirable
in environments where it is preferred for the region to be dynamically
allocated at runtime, as opposed to it being fixed at compile time.

Change the logic for detecting the start and size of the ramoops
memory region by looking up the reserved memory region instead of
using platform_get_resource(), which assumes that the location
of the memory is known ahead of time.

Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
---
 fs/pstore/ram.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index fefe3d3..5f90455 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -21,6 +21,7 @@
 #include <linux/pstore_ram.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_reserved_mem.h>
 #include "internal.h"
 
 #define RAMOOPS_KERNMSG_HDR "===="
@@ -633,21 +634,21 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 {
 	struct device_node *of_node = pdev->dev.of_node;
 	struct device_node *parent_node;
-	struct resource *res;
+	struct reserved_mem *rmem;
 	u32 value;
 	int ret;
 
 	dev_dbg(&pdev->dev, "using Device Tree\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
+	rmem = of_reserved_mem_lookup(of_node);
+	if (!rmem) {
 		dev_err(&pdev->dev,
 			"failed to locate DT /reserved-memory resource\n");
 		return -EINVAL;
 	}
 
-	pdata->mem_size = resource_size(res);
-	pdata->mem_address = res->start;
+	pdata->mem_size = rmem->size;
+	pdata->mem_address = rmem->base;
 	/*
 	 * Setting "unbuffered" is deprecated and will be ignored if
 	 * "mem_type" is also specified.
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


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

* Re: [PATCH] pstore/ram: Rework logic for detecting ramoops reserved memory region
  2021-06-25 11:17 [PATCH] pstore/ram: Rework logic for detecting ramoops reserved memory region Mukesh Ojha
@ 2021-07-05 10:39 ` Mukesh Ojha
  0 siblings, 0 replies; 2+ messages in thread
From: Mukesh Ojha @ 2021-07-05 10:39 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck, linux-kernel; +Cc: Isaac J. Manjarres

Hi Kees,

Could  you please review this ?

-Mukesh

On 6/25/2021 4:47 PM, Mukesh Ojha wrote:
> From: "Isaac J. Manjarres" <isaacm@codeaurora.org>
>
> The reserved memory region for ramoops is assumed to be at a fixed
> and known location when read from the devicetree. This is not desirable
> in environments where it is preferred for the region to be dynamically
> allocated at runtime, as opposed to it being fixed at compile time.
>
> Change the logic for detecting the start and size of the ramoops
> memory region by looking up the reserved memory region instead of
> using platform_get_resource(), which assumes that the location
> of the memory is known ahead of time.
>
> Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
> Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
> ---
>   fs/pstore/ram.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index fefe3d3..5f90455 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -21,6 +21,7 @@
>   #include <linux/pstore_ram.h>
>   #include <linux/of.h>
>   #include <linux/of_address.h>
> +#include <linux/of_reserved_mem.h>
>   #include "internal.h"
>   
>   #define RAMOOPS_KERNMSG_HDR "===="
> @@ -633,21 +634,21 @@ static int ramoops_parse_dt(struct platform_device *pdev,
>   {
>   	struct device_node *of_node = pdev->dev.of_node;
>   	struct device_node *parent_node;
> -	struct resource *res;
> +	struct reserved_mem *rmem;
>   	u32 value;
>   	int ret;
>   
>   	dev_dbg(&pdev->dev, "using Device Tree\n");
>   
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> +	rmem = of_reserved_mem_lookup(of_node);
> +	if (!rmem) {
>   		dev_err(&pdev->dev,
>   			"failed to locate DT /reserved-memory resource\n");
>   		return -EINVAL;
>   	}
>   
> -	pdata->mem_size = resource_size(res);
> -	pdata->mem_address = res->start;
> +	pdata->mem_size = rmem->size;
> +	pdata->mem_address = rmem->base;
>   	/*
>   	 * Setting "unbuffered" is deprecated and will be ignored if
>   	 * "mem_type" is also specified.

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

end of thread, other threads:[~2021-07-05 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25 11:17 [PATCH] pstore/ram: Rework logic for detecting ramoops reserved memory region Mukesh Ojha
2021-07-05 10:39 ` Mukesh Ojha

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.