Skip to content

Commit 5ec53c5

Browse files
renerucoder
authored andcommitted
watchdog: wdat_wdt: map registers that fall inside ACPI NVS
Some firmwares describe WDAT registers inside memory ranges marked as ACPI NVS in the E820 map, failing with -EBUSY during probe, leaving the hardware watchdog unserviced and triggering periodic system resets. This issue was observed on a OnLogic Karbon 524 device (when watchdog is enabled in BIOS): wdat_wdt wdat_wdt: error -EBUSY: can't request region for resource [mem 0x63df7a98] wdat_wdt wdat_wdt: probe with driver wdat_wdt failed with error -16 Check whether the region falls inside ACPI NVS before requesting it and, if so, map it without reservation. Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br>
1 parent bfc6174 commit 5ec53c5

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

drivers/watchdog/wdat_wdt.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88

99
#include <linux/acpi.h>
10+
#include <linux/io.h>
1011
#include <linux/ioport.h>
12+
#include <linux/mm.h>
1113
#include <linux/module.h>
1214
#include <linux/platform_device.h>
1315
#include <linux/pm.h>
@@ -309,6 +311,29 @@ static struct watchdog_ops wdat_wdt_ops = {
309311
.set_timeout = wdat_wdt_set_timeout,
310312
};
311313

314+
static void __iomem *wdat_wdt_map_mem(struct device *dev, struct resource *res)
315+
{
316+
resource_size_t size = resource_size(res);
317+
void *addr;
318+
319+
/* Map memory region without reserving it if it falls inside ACPI NVS */
320+
if (region_intersects(res->start, size, IORESOURCE_MEM,
321+
IORES_DESC_ACPI_NV_STORAGE) == REGION_INTERSECTS) {
322+
dev_warn(dev, "%pR is inside ACPI NVS, mapping without reservation\n",
323+
res);
324+
325+
addr = devm_memremap(dev, res->start, size, MEMREMAP_WB);
326+
if (IS_ERR(addr)) {
327+
dev_err(dev, "failed to map resource %pR\n", res);
328+
return IOMEM_ERR_PTR(PTR_ERR(addr));
329+
}
330+
331+
return (void __iomem __force *)addr;
332+
}
333+
334+
return devm_ioremap_resource(dev, res);
335+
}
336+
312337
static int wdat_wdt_probe(struct platform_device *pdev)
313338
{
314339
struct device *dev = &pdev->dev;
@@ -362,7 +387,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)
362387

363388
res = &pdev->resource[i];
364389
if (resource_type(res) == IORESOURCE_MEM) {
365-
reg = devm_ioremap_resource(dev, res);
390+
reg = wdat_wdt_map_mem(dev, res);
366391
if (IS_ERR(reg)) {
367392
ret = PTR_ERR(reg);
368393
goto out_put_table;

0 commit comments

Comments
 (0)