linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ACPI: OSL: Always use deferred unmapping of memory
@ 2020-07-02 12:09 Rafael J. Wysocki
  2020-07-02 12:11 ` [PATCH 1/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address() Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-07-02 12:09 UTC (permalink / raw)
  To: Linux ACPI
  Cc: LKML, Erik Kaneda, Bob Moore, Len Brown, Dan Williams, Dan Williams

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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address()
  2020-07-02 12:09 [PATCH 0/3] ACPI: OSL: Always use deferred unmapping of memory Rafael J. Wysocki
@ 2020-07-02 12:11 ` Rafael J. Wysocki
  2020-07-02 12:13 ` [PATCH 2/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_iomem() Rafael J. Wysocki
  2020-07-02 12:14 ` [PATCH 3/3] ACPI: OSL: Clean up the removal of unused memory mappings Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-07-02 12:11 UTC (permalink / raw)
  To: Linux ACPI
  Cc: LKML, Erik Kaneda, Bob Moore, Len Brown, Dan Williams, Dan Williams

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

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 <rafael.j.wysocki@intel.com>
---
 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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_iomem()
  2020-07-02 12:09 [PATCH 0/3] ACPI: OSL: Always use deferred unmapping of memory Rafael J. Wysocki
  2020-07-02 12:11 ` [PATCH 1/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address() Rafael J. Wysocki
@ 2020-07-02 12:13 ` Rafael J. Wysocki
  2020-07-02 12:14 ` [PATCH 3/3] ACPI: OSL: Clean up the removal of unused memory mappings Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-07-02 12:13 UTC (permalink / raw)
  To: Linux ACPI
  Cc: LKML, Erik Kaneda, Bob Moore, Len Brown, Dan Williams, Dan Williams

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

There is no reason (knwon to me) why any of the existing users of
acpi_os_unmap_iomem() 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.

While at it, fold __acpi_os_unmap_iomem() back into
acpi_os_unmap_iomem(), which has become a simple wrapper around it,
and make acpi_os_unmap_memory() call the latter.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/osl.c | 72 ++++++++++++++--------------------------------
 1 file changed, 22 insertions(+), 50 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 5c56f084e8b0..816d9f8ac6b6 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -390,31 +390,32 @@ static void acpi_os_map_cleanup_deferred(struct work_struct *work)
 }
 
 /* Must be called with mutex_lock(&acpi_ioremap_lock) */
-static bool acpi_os_drop_map_ref(struct acpi_ioremap *map, bool defer)
+static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
 {
 	if (--map->track.refcount)
-		return true;
+		return;
 
 	list_del_rcu(&map->list);
 
-	if (defer) {
-		INIT_RCU_WORK(&map->track.rwork, acpi_os_map_cleanup_deferred);
-		queue_rcu_work(system_wq, &map->track.rwork);
-	}
-	return defer;
-}
-
-static void acpi_os_map_cleanup(struct acpi_ioremap *map)
-{
-	if (!map)
-		return;
-
-	synchronize_rcu_expedited();
-	acpi_os_map_remove(map);
+	INIT_RCU_WORK(&map->track.rwork, acpi_os_map_cleanup_deferred);
+	queue_rcu_work(system_wq, &map->track.rwork);
 }
 
-static void __ref __acpi_os_unmap_iomem(void __iomem *virt, acpi_size size,
-					bool defer)
+/**
+ * acpi_os_unmap_iomem - Drop a memory mapping reference.
+ * @virt: Start of the address range to drop a reference to.
+ * @size: Size of the address range to drop a reference to.
+ *
+ * Look up the given virtual address range in the list of existing ACPI memory
+ * mappings, drop a reference to it and if there are no more active references
+ * to it, queue it up for later removal.
+ *
+ * During early init (when acpi_permanent_mmap has not been set yet) this
+ * routine simply calls __acpi_unmap_table() to get the job done.  Since
+ * __acpi_unmap_table() is an __init function, the __ref annotation is needed
+ * here.
+ */
+void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
 {
 	struct acpi_ioremap *map;
 
@@ -431,31 +432,9 @@ static void __ref __acpi_os_unmap_iomem(void __iomem *virt, acpi_size size,
 		WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
 		return;
 	}
-	if (acpi_os_drop_map_ref(map, defer))
-		map = NULL;
+	acpi_os_drop_map_ref(map);
 
 	mutex_unlock(&acpi_ioremap_lock);
-
-	acpi_os_map_cleanup(map);
-}
-
-/**
- * acpi_os_unmap_iomem - Drop a memory mapping reference.
- * @virt: Start of the address range to drop a reference to.
- * @size: Size of the address range to drop a reference to.
- *
- * Look up the given virtual address range in the list of existing ACPI memory
- * mappings, drop a reference to it and unmap it if there are no more active
- * references to it.
- *
- * During early init (when acpi_permanent_mmap has not been set yet) this
- * routine simply calls __acpi_unmap_table() to get the job done.  Since
- * __acpi_unmap_table() is an __init function, the __ref annotation is needed
- * here.
- */
-void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
-{
-	__acpi_os_unmap_iomem(virt, size, false);
 }
 EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem);
 
@@ -463,17 +442,10 @@ EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem);
  * acpi_os_unmap_memory - Drop a memory mapping reference.
  * @virt: Start of the address range to drop a reference to.
  * @size: Size of the address range to drop a reference to.
- *
- * Look up the given virtual address range in the list of existing ACPI memory
- * mappings, drop a reference to it and if there are no more active references
- * to it, queue it up for later removal.
- *
- * During early init (when acpi_permanent_mmap has not been set yet) this
- * routine behaves like acpi_os_unmap_iomem().
  */
 void __ref acpi_os_unmap_memory(void *virt, acpi_size size)
 {
-	__acpi_os_unmap_iomem((void __iomem *)virt, size, true);
+	acpi_os_unmap_iomem((void __iomem *)virt, size);
 }
 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
 
@@ -518,7 +490,7 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
 		mutex_unlock(&acpi_ioremap_lock);
 		return;
 	}
-	acpi_os_drop_map_ref(map, true);
+	acpi_os_drop_map_ref(map);
 
 	mutex_unlock(&acpi_ioremap_lock);
 }
-- 
2.26.2





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ACPI: OSL: Clean up the removal of unused memory mappings
  2020-07-02 12:09 [PATCH 0/3] ACPI: OSL: Always use deferred unmapping of memory Rafael J. Wysocki
  2020-07-02 12:11 ` [PATCH 1/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address() Rafael J. Wysocki
  2020-07-02 12:13 ` [PATCH 2/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_iomem() Rafael J. Wysocki
@ 2020-07-02 12:14 ` Rafael J. Wysocki
  2 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-07-02 12:14 UTC (permalink / raw)
  To: Linux ACPI
  Cc: LKML, Erik Kaneda, Bob Moore, Len Brown, Dan Williams, Dan Williams

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

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 <rafael.j.wysocki@intel.com>
---
 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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-02 12:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 12:09 [PATCH 0/3] ACPI: OSL: Always use deferred unmapping of memory Rafael J. Wysocki
2020-07-02 12:11 ` [PATCH 1/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address() Rafael J. Wysocki
2020-07-02 12:13 ` [PATCH 2/3] ACPI: OSL: Use deferred unmapping in acpi_os_unmap_iomem() Rafael J. Wysocki
2020-07-02 12:14 ` [PATCH 3/3] ACPI: OSL: Clean up the removal of unused memory mappings Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).