[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159625232903.3040297.3259451012924415121.stgit@dwillia2-desk3.amr.corp.intel.com>
Date: Fri, 31 Jul 2020 20:25:29 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: akpm@...ux-foundation.org
Cc: Jason Gunthorpe <jgg@...lanox.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Wei Yang <richardw.yang@...ux.intel.com>,
Tom Lendacky <thomas.lendacky@....com>, peterz@...radead.org,
vishal.l.verma@...el.com, ard.biesheuvel@...aro.org,
vishal.l.verma@...el.com, linux-mm@...ck.org,
linux-nvdimm@...ts.01.org, joao.m.martins@...cle.com,
linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
dri-devel@...ts.freedesktop.org
Subject: [PATCH v3 05/23] resource: Report parent to walk_iomem_res_desc()
callback
In support of detecting whether a resource might have been been claimed,
report the parent to the walk_iomem_res_desc() callback. For example,
the ACPI HMAT parser publishes "hmem" platform devices per target range.
However, if the HMAT is disabled / missing a fallback driver can attach
devices to the raw memory ranges as a fallback if it sees unclaimed /
orphan "Soft Reserved" resources in the resource tree.
Otherwise, find_next_iomem_res() returns a resource with garbage data
from the stack allocation in __walk_iomem_res_desc() for the res->parent
field.
There are currently no users that expect ->child and ->sibling to be
valid, and the resource_lock would be needed to traverse them. Use a
compound literal to implicitly zero initialize the fields that are not
being returned in addition to setting ->parent.
Cc: Jason Gunthorpe <jgg@...lanox.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Wei Yang <richardw.yang@...ux.intel.com>
Cc: Tom Lendacky <thomas.lendacky@....com>
Signed-off-by: Dan Williams <dan.j.williams@...el.com>
---
kernel/resource.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index 841737bbda9e..f1175ce93a1d 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -382,10 +382,13 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end,
if (p) {
/* copy data */
- res->start = max(start, p->start);
- res->end = min(end, p->end);
- res->flags = p->flags;
- res->desc = p->desc;
+ *res = (struct resource) {
+ .start = max(start, p->start),
+ .end = min(end, p->end),
+ .flags = p->flags,
+ .desc = p->desc,
+ .parent = p->parent,
+ };
}
read_unlock(&resource_lock);
Powered by blists - more mailing lists