FROMLIST: pstore/ram: Rework logic for detecting ramoops reserved memory region

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.

Bug: 191636717
Link: https://lore.kernel.org/patchwork/patch/1451704/
Change-Id: I24066de9f4fe1f1575cb1bbb1687c37a2b1938a4
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres
2021-06-25 16:47:18 +05:30
committed by Todd Kjos
parent daeabfe7fa
commit bd2ca0ba5b

View File

@@ -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.