2020-07-02 12:18:22

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 0/3] ACPI: OSL: Always use deferred unmapping of memory

Hi All,

This series is on top of the git branch at

git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
acpica-osl

and it basically makes the deferred unmapping of ACPI memory introduced by
the first commit in that branch be the only option.

Arguably, it could be done in a single patch, but I prefer to do that in
smaller steps in case something breaks, to make it easier to identify
the point of breakage.

Patch [1/3] causes acpi_os_unmap_generic_address() to use the deferred
unmapping, patch [2/3] makes acpi_os_unmap_iomem() use it too and patch
[3/3] is a cleanup of top of the latter.

Thanks,
Rafael




2020-07-02 12:19:04

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 3/3] ACPI: OSL: Clean up the removal of unused memory mappings

From: "Rafael J. Wysocki" <[email protected]>

Fold acpi_os_map_cleanup_deferred() into acpi_os_map_remove() and
pass the latter to INIT_RCU_WORK() in acpi_os_drop_map_ref() to make
the code more straightforward.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/osl.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 816d9f8ac6b6..6ad8cb05f672 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -377,18 +377,16 @@ void *__ref acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
}
EXPORT_SYMBOL_GPL(acpi_os_map_memory);

-static void acpi_os_map_remove(struct acpi_ioremap *map)
+static void acpi_os_map_remove(struct work_struct *work)
{
+ struct acpi_ioremap *map = container_of(to_rcu_work(work),
+ struct acpi_ioremap,
+ track.rwork);
+
acpi_unmap(map->phys, map->virt);
kfree(map);
}

-static void acpi_os_map_cleanup_deferred(struct work_struct *work)
-{
- acpi_os_map_remove(container_of(to_rcu_work(work), struct acpi_ioremap,
- track.rwork));
-}
-
/* Must be called with mutex_lock(&acpi_ioremap_lock) */
static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
{
@@ -397,7 +395,7 @@ static void acpi_os_drop_map_ref(struct acpi_ioremap *map)

list_del_rcu(&map->list);

- INIT_RCU_WORK(&map->track.rwork, acpi_os_map_cleanup_deferred);
+ INIT_RCU_WORK(&map->track.rwork, acpi_os_map_remove);
queue_rcu_work(system_wq, &map->track.rwork);
}

--
2.26.2




2020-07-02 12:20:39

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH 1/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address()

From: "Rafael J. Wysocki" <[email protected]>

There is no reason (knwon to me) why any of the existing users of
acpi_os_unmap_generic_address() would need to wait for the unused
memory mappings left by it to actually go away, so use the deferred
unmapping of ACPI memory introduced previously in that function.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/acpi/osl.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index abbf8630f774..5c56f084e8b0 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -518,12 +518,9 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
mutex_unlock(&acpi_ioremap_lock);
return;
}
- if (acpi_os_drop_map_ref(map, false))
- map = NULL;
+ acpi_os_drop_map_ref(map, true);

mutex_unlock(&acpi_ioremap_lock);
-
- acpi_os_map_cleanup(map);
}
EXPORT_SYMBOL(acpi_os_unmap_generic_address);

--
2.26.2