---
drivers/acpi/bus.c | 6 ++++++
drivers/acpi/osl.c | 9 ++++++++-
include/acpi/acpi_io.h | 1 +
3 files changed, 15 insertions(+), 1 deletion(-)
===================================================================
@@ -1191,6 +1191,12 @@ static int __init acpi_init(void)
acpi_kobj = NULL;
}
+ /*
+ * acpi_os_read_memory()/acpi_os_write_memory() should not be invoked
+ * before this point.
+ */
+ acpi_sync_memory_unmap = true;
+
init_acpi_device_notify();
result = acpi_bus_init();
if (result) {
===================================================================
@@ -77,6 +77,7 @@ static struct workqueue_struct *kacpi_ho
static bool acpi_os_initialized;
unsigned int acpi_sci_irq = INVALID_ACPI_IRQ;
bool acpi_permanent_mmap = false;
+bool acpi_sync_memory_unmap;
/*
* This list of permanent mappings is for memory that may be accessed from
@@ -378,7 +379,9 @@ static void acpi_os_drop_map_ref(struct
static void acpi_os_map_cleanup(struct acpi_ioremap *map)
{
if (!map->refcount) {
- synchronize_rcu_expedited();
+ if (acpi_sync_memory_unmap)
+ synchronize_rcu_expedited();
+
acpi_unmap(map->phys, map->virt);
kfree(map);
}
@@ -671,6 +674,8 @@ acpi_os_read_memory(acpi_physical_addres
bool unmap = false;
u64 dummy;
+ WARN_ON_ONCE(!acpi_sync_memory_unmap);
+
rcu_read_lock();
virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
if (!virt_addr) {
@@ -716,6 +721,8 @@ acpi_os_write_memory(acpi_physical_addre
unsigned int size = width / 8;
bool unmap = false;
+ WARN_ON_ONCE(!acpi_sync_memory_unmap);
+
rcu_read_lock();
virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
if (!virt_addr) {
===================================================================
@@ -14,6 +14,7 @@ static inline void __iomem *acpi_os_iore
#endif
extern bool acpi_permanent_mmap;
+extern bool acpi_sync_memory_unmap;
void __iomem *__ref
acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);