[PATCH v3 7/7] firmware: coreboot: Request table region for exclusive access

From: Stephen Boyd
Date: Thu Aug 09 2018 - 13:17:33 EST


Call request_mem_region() on the entire coreboot table to make sure
other devices don't attempt to map the coreboot table in their drivers.
If drivers need that support, it would be better to provide bus APIs
they can use to do that through the mapping created in this file.

Cc: Wei-Ning Huang <wnhuang@xxxxxxxxxxxx>
Cc: Julius Werner <jwerner@xxxxxxxxxxxx>
Cc: Brian Norris <briannorris@xxxxxxxxxxxx>
Cc: Samuel Holland <samuel@xxxxxxxxxxxx>
Signed-off-by: Stephen Boyd <swboyd@xxxxxxxxxxxx>
---
drivers/firmware/google/coreboot_table.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index 814913606d22..94c41d814ea5 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -132,6 +132,7 @@ static int coreboot_table_probe(struct platform_device *pdev)
struct coreboot_table_header *header;
struct resource *res;
struct device *dev = &pdev->dev;
+ const char *name;
void *ptr;
int ret;

@@ -153,10 +154,17 @@ static int coreboot_table_probe(struct platform_device *pdev)
return -ENODEV;
}

- ptr = devm_memremap(dev, res->start,
- header->header_bytes + header->table_bytes,
- MEMREMAP_WB);
+ len = header->header_bytes + header->table_bytes;
+ res->end = res->start + len - 1;
+ name = res->name ?: dev_name(dev);
memunmap(header);
+
+ if (!devm_request_mem_region(dev, res->start, len, name)) {
+ dev_err(dev, "can't request region for resource %pR\n", res);
+ return -EBUSY;
+ }
+
+ ptr = devm_memremap(dev, res->start, len, MEMREMAP_WB);
if (!ptr)
return -ENOMEM;

--
Sent by a computer through tubes