Skip to content

Commit a968fba

Browse files
committed
ACPI: OSL: Use deferred unmapping in acpi_os_unmap_iomem()
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 <[email protected]>
1 parent f4334ef commit a968fba

File tree

1 file changed

+22
-50
lines changed

1 file changed

+22
-50
lines changed

drivers/acpi/osl.c

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,32 @@ static void acpi_os_map_cleanup_deferred(struct work_struct *work)
390390
}
391391

392392
/* Must be called with mutex_lock(&acpi_ioremap_lock) */
393-
static bool acpi_os_drop_map_ref(struct acpi_ioremap *map, bool defer)
393+
static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
394394
{
395395
if (--map->track.refcount)
396-
return true;
396+
return;
397397

398398
list_del_rcu(&map->list);
399399

400-
if (defer) {
401-
INIT_RCU_WORK(&map->track.rwork, acpi_os_map_cleanup_deferred);
402-
queue_rcu_work(system_wq, &map->track.rwork);
403-
}
404-
return defer;
405-
}
406-
407-
static void acpi_os_map_cleanup(struct acpi_ioremap *map)
408-
{
409-
if (!map)
410-
return;
411-
412-
synchronize_rcu_expedited();
413-
acpi_os_map_remove(map);
400+
INIT_RCU_WORK(&map->track.rwork, acpi_os_map_cleanup_deferred);
401+
queue_rcu_work(system_wq, &map->track.rwork);
414402
}
415403

416-
static void __ref __acpi_os_unmap_iomem(void __iomem *virt, acpi_size size,
417-
bool defer)
404+
/**
405+
* acpi_os_unmap_iomem - Drop a memory mapping reference.
406+
* @virt: Start of the address range to drop a reference to.
407+
* @size: Size of the address range to drop a reference to.
408+
*
409+
* Look up the given virtual address range in the list of existing ACPI memory
410+
* mappings, drop a reference to it and if there are no more active references
411+
* to it, queue it up for later removal.
412+
*
413+
* During early init (when acpi_permanent_mmap has not been set yet) this
414+
* routine simply calls __acpi_unmap_table() to get the job done. Since
415+
* __acpi_unmap_table() is an __init function, the __ref annotation is needed
416+
* here.
417+
*/
418+
void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
418419
{
419420
struct acpi_ioremap *map;
420421

@@ -431,49 +432,20 @@ static void __ref __acpi_os_unmap_iomem(void __iomem *virt, acpi_size size,
431432
WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
432433
return;
433434
}
434-
if (acpi_os_drop_map_ref(map, defer))
435-
map = NULL;
435+
acpi_os_drop_map_ref(map);
436436

437437
mutex_unlock(&acpi_ioremap_lock);
438-
439-
acpi_os_map_cleanup(map);
440-
}
441-
442-
/**
443-
* acpi_os_unmap_iomem - Drop a memory mapping reference.
444-
* @virt: Start of the address range to drop a reference to.
445-
* @size: Size of the address range to drop a reference to.
446-
*
447-
* Look up the given virtual address range in the list of existing ACPI memory
448-
* mappings, drop a reference to it and unmap it if there are no more active
449-
* references to it.
450-
*
451-
* During early init (when acpi_permanent_mmap has not been set yet) this
452-
* routine simply calls __acpi_unmap_table() to get the job done. Since
453-
* __acpi_unmap_table() is an __init function, the __ref annotation is needed
454-
* here.
455-
*/
456-
void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
457-
{
458-
__acpi_os_unmap_iomem(virt, size, false);
459438
}
460439
EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem);
461440

462441
/**
463442
* acpi_os_unmap_memory - Drop a memory mapping reference.
464443
* @virt: Start of the address range to drop a reference to.
465444
* @size: Size of the address range to drop a reference to.
466-
*
467-
* Look up the given virtual address range in the list of existing ACPI memory
468-
* mappings, drop a reference to it and if there are no more active references
469-
* to it, queue it up for later removal.
470-
*
471-
* During early init (when acpi_permanent_mmap has not been set yet) this
472-
* routine behaves like acpi_os_unmap_iomem().
473445
*/
474446
void __ref acpi_os_unmap_memory(void *virt, acpi_size size)
475447
{
476-
__acpi_os_unmap_iomem((void __iomem *)virt, size, true);
448+
acpi_os_unmap_iomem((void __iomem *)virt, size);
477449
}
478450
EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
479451

@@ -518,7 +490,7 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
518490
mutex_unlock(&acpi_ioremap_lock);
519491
return;
520492
}
521-
acpi_os_drop_map_ref(map, true);
493+
acpi_os_drop_map_ref(map);
522494

523495
mutex_unlock(&acpi_ioremap_lock);
524496
}

0 commit comments

Comments
 (0)