ACPI: Fixes and cleanups related to iomaps management
Subsystems (2)
cover ACPI: Fixes and cleanups related to iomaps management
Hi Len,
The following series of patches implements some fixes of the ACPI iomaps management. I found the problems trying to resolve the issue of creating iomaps of regions that have been mapped already when we save the NVS region.
The first two patches are the same as https://patchwork.kernel.org/patch/490071/
(except for the changelog) and https://patchwork.kernel.org/patch/490061/,
respectively, and they are 2.6.38 regression fix material. The other patches are not that urgent, because the related issues are generally long-standing, but some bugs addressed by them (especially [3/11]) may be actively hurting people right now, so the patches look suitable for .38 to me as well, but this is your call.
[1/11] - Introduce acpi_os_ioremap() to be called by ACPI code creating
iomaps, so that they are mapped in the consistent way.
[2/11] - Move the call to suspend_nvs_free() to acpi_pm_finish() so that it's
executed before device drivers' resume routines to avoid possible iomaps conflicts.
[3/11] - Fix routines for reading and writing iomem (RCU bug and mapping
regions on the fly).
[4/11] - (cleanup) Do not export local functions in osl.c.
[5/11] - Use a mutex (instead of a spinlock) for the locking of iomap
manipulations in osl.c.
[6/11] - Avoid unnecessary walks of the list of iomaps in osl.c.
[7/11] - Avoid creating iomaps for regions that have been mapped already.
[8/11] - Replace krefs used for iomap refcounting with simple reference
counters (they are manipulated under a lock anyway).
[9/11] - Introduce function for getting a reference to an ACPI iomap (to be
used by the NVS save/restore code).
[10/11] - Make the NVS code use existing iomaps if possible.
[11/11] - (cleanup) Remove an unnecessary field from struct nvs_page.
The patches have been tested on HP nx6325, Toshiba Portege R500 and Acer Ferrari One without causing any visible problems to happen. Also Jeff has tested [1/11] and [2/11] and he reports that they fix the synchronize_rcu() problem for him. [Jeff, can you test the whole series, please, and see if it doesn't introduce any new issues, [10/11] in particular?]
Thanks,
Rafael
PATCH 1/11 ACPI: Introduce acpi_os_ioremap()
From: Rafael J. Wysocki <[email protected]>
Commit ca9b600 (ACPI / PM: Make suspend_nvs_save() use acpi_os_map_memory()) attempted to prevent the code in osl.c and nvs.c from using different ioremap() variants by making the latter use acpi_os_map_memory() for mapping the NVS pages. However, that also requires acpi_os_unmap_memory() to be used for unmapping them, which causes synchronize_rcu() to be executed many times in a row unnecessarily and introduces substantial delays during resume on some systems.
Instead of using acpi_os_map_memory() for mapping the NVS pages in nvs.c introduce acpi_os_ioremap() calling ioremap_cache() and make the code in both osl.c and nvs.c use it.
--- drivers/acpi/nvs.c | 7 ++++--- drivers/acpi/osl.c | 12 +++++++----- include/linux/acpi.h | 3 --- include/linux/acpi_io.h | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 11 deletions(-)
drivers/acpi/osl.c +7 -5
@@ -38,6 +38,7 @@#include <linux/workqueue.h> #include <linux/nmi.h> #include <linux/acpi.h> +#include <linux/acpi_io.h> #include <linux/efi.h> #include <linux/ioport.h> #include <linux/list.h>
@@ -302,9 +303,10 @@ void __iomem *__init_refok acpi_os_map_memory(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map, *tmp_map; -unsigned long flags, pg_sz; +unsigned long flags;void __iomem *virt; -phys_addr_t pg_off; +acpi_physical_address pg_off; +acpi_size pg_sz;if (phys >ULONG_MAX ) { printk(KERN_ERR PREFIX "Cannot map memory that high\n");
@@ -320,7 +322,7 @@ acpi_os_map_memory(acpi_physical_address pg_off =round_down (phys,PAGE_SIZE ); pg_sz =round_up (phys + size,PAGE_SIZE ) - pg_off; - virt =ioremap_cache (pg_off, pg_sz); + virt =acpi_os_ioremap (pg_off, pg_sz);if (!virt) {kfree (map);return NULL ;
@@ -642,7 +644,7 @@ acpi_os_read_memory(acpi_physical_addres virt_addr =acpi_map_vaddr_lookup (phys_addr, size);rcu_read_unlock ();if (!virt_addr) { - virt_addr =ioremap_cache (phys_addr, size); + virt_addr =acpi_os_ioremap (phys_addr, size); unmap =1 ; }if (!value)
@@ -678,7 +680,7 @@ acpi_os_write_memory(acpi_physical_addre virt_addr =acpi_map_vaddr_lookup (phys_addr, size);rcu_read_unlock ();if (!virt_addr) { - virt_addr =ioremap_cache (phys_addr, size); + virt_addr =acpi_os_ioremap (phys_addr, size); unmap =1 ; }
drivers/acpi/nvs.c +4 -3
@@ -12,6 +12,7 @@#include <linux/mm.h> #include <linux/slab.h> #include <linux/acpi.h> +#include <linux/acpi_io.h> #include <acpi/acpiosxf.h> /*
@@ -80,7 +81,7 @@ void suspend_nvs_free(void)free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) { -acpi_os_unmap_memory (entry->kaddr, entry->size); +iounmap (entry->kaddr); entry->kaddr =NULL ; } }
@@ -114,8 +115,8 @@ int suspend_nvs_save(void)list_for_each_entry (entry, &nvs_list, node)if (entry->data) { - entry->kaddr =acpi_os_map_memory (entry->phys_start, - entry->size); + entry->kaddr =acpi_os_ioremap (entry->phys_start, + entry->size);if (!entry->kaddr) {suspend_nvs_free ();return -ENOMEM ;
include/linux/acpi.h +0 -3
@@ -306,9 +306,6 @@ extern acpi_status acpi_pci_osc_control_ u32 *mask, u32 req);extern void acpi_early_init (void ); -int acpi_os_map_generic_address (struct acpi_generic_address *addr); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); -#else /* !CONFIG_ACPI */ #define acpi_disabled 1
include/linux/acpi_io.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ACPI_IO_H_ +#define _ACPI_IO_H_ + +#include <linux/io.h> +#include <acpi/acpi.h> + +static inline void __iomem *acpi_os_ioremap (acpi_physical_address phys, +acpi_size size) +{ +return ioremap_cache (phys, size); +} + +int acpi_os_map_generic_address (struct acpi_generic_address *addr); +void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); + +#endif
PATCH 1/11 ACPI: Introduce acpi_os_ioremap()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Commit ca9b600 (ACPI / PM: Make suspend_nvs_save() use acpi_os_map_memory()) attempted to prevent the code in osl.c and nvs.c from using different ioremap() variants by making the latter use acpi_os_map_memory() for mapping the NVS pages. However, that also requires acpi_os_unmap_memory() to be used for unmapping them, which causes synchronize_rcu() to be executed many times in a row unnecessarily and introduces substantial delays during resume on some systems.
Instead of using acpi_os_map_memory() for mapping the NVS pages in nvs.c introduce acpi_os_ioremap() calling ioremap_cache() and make the code in both osl.c and nvs.c use it.
--- drivers/acpi/nvs.c | 7 ++++--- drivers/acpi/osl.c | 12 +++++++----- include/linux/acpi.h | 3 --- include/linux/acpi_io.h | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 11 deletions(-)
drivers/acpi/osl.c +7 -5
@@ -38,6 +38,7 @@#include <linux/workqueue.h> #include <linux/nmi.h> #include <linux/acpi.h> +#include <linux/acpi_io.h> #include <linux/efi.h> #include <linux/ioport.h> #include <linux/list.h>
@@ -302,9 +303,10 @@ void __iomem *__init_refok acpi_os_map_memory(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map, *tmp_map; -unsigned long flags, pg_sz; +unsigned long flags;void __iomem *virt; -phys_addr_t pg_off; +acpi_physical_address pg_off; +acpi_size pg_sz;if (phys >ULONG_MAX ) { printk(KERN_ERR PREFIX "Cannot map memory that high\n");
@@ -320,7 +322,7 @@ acpi_os_map_memory(acpi_physical_address pg_off =round_down (phys,PAGE_SIZE ); pg_sz =round_up (phys + size,PAGE_SIZE ) - pg_off; - virt =ioremap_cache (pg_off, pg_sz); + virt =acpi_os_ioremap (pg_off, pg_sz);if (!virt) {kfree (map);return NULL ;
@@ -642,7 +644,7 @@ acpi_os_read_memory(acpi_physical_addres virt_addr =acpi_map_vaddr_lookup (phys_addr, size);rcu_read_unlock ();if (!virt_addr) { - virt_addr =ioremap_cache (phys_addr, size); + virt_addr =acpi_os_ioremap (phys_addr, size); unmap =1 ; }if (!value)
@@ -678,7 +680,7 @@ acpi_os_write_memory(acpi_physical_addre virt_addr =acpi_map_vaddr_lookup (phys_addr, size);rcu_read_unlock ();if (!virt_addr) { - virt_addr =ioremap_cache (phys_addr, size); + virt_addr =acpi_os_ioremap (phys_addr, size); unmap =1 ; }
drivers/acpi/nvs.c +4 -3
@@ -12,6 +12,7 @@#include <linux/mm.h> #include <linux/slab.h> #include <linux/acpi.h> +#include <linux/acpi_io.h> #include <acpi/acpiosxf.h> /*
@@ -80,7 +81,7 @@ void suspend_nvs_free(void)free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) { -acpi_os_unmap_memory (entry->kaddr, entry->size); +iounmap (entry->kaddr); entry->kaddr =NULL ; } }
@@ -114,8 +115,8 @@ int suspend_nvs_save(void)list_for_each_entry (entry, &nvs_list, node)if (entry->data) { - entry->kaddr =acpi_os_map_memory (entry->phys_start, - entry->size); + entry->kaddr =acpi_os_ioremap (entry->phys_start, + entry->size);if (!entry->kaddr) {suspend_nvs_free ();return -ENOMEM ;
include/linux/acpi.h +0 -3
@@ -306,9 +306,6 @@ extern acpi_status acpi_pci_osc_control_ u32 *mask, u32 req);extern void acpi_early_init (void ); -int acpi_os_map_generic_address (struct acpi_generic_address *addr); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); -#else /* !CONFIG_ACPI */ #define acpi_disabled 1
include/linux/acpi_io.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ACPI_IO_H_ +#define _ACPI_IO_H_ + +#include <linux/io.h> +#include <acpi/acpi.h> + +static inline void __iomem *acpi_os_ioremap (acpi_physical_address phys, +acpi_size size) +{ +return ioremap_cache (phys, size); +} + +int acpi_os_map_generic_address (struct acpi_generic_address *addr); +void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); + +#endif
PATCH 2/11 ACPI / PM: Call suspend_nvs_free() earlier during resume
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
It turns out that some device drivers map pages from the ACPI NVS region during resume using ioremap(), which conflicts with the ioremap_cache() used for mapping those pages by the NVS save/restore code in nvs.c.
Make the NVS pages mapped by the code in nvs.c be unmapped before device drivers' resume routines run.
--- drivers/acpi/sleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/sleep.c +1 -1
@@ -166,6 +166,7 @@ static void acpi_pm_finish(void)u32 acpi_state = acpi_target_sleep_state;acpi_ec_unblock_transactions (); +suspend_nvs_free ();if (acpi_state ==ACPI_STATE_S0 )return ;
@@ -186,7 +187,6 @@ static void acpi_pm_finish(void)*/ static void acpi_pm_end (void ) { -suspend_nvs_free ();/* * This is necessary in case acpi_pm_finish() is not called during a * failing transition to a sleep state.
PATCH 3/11 ACPI: Fix acpi_os_read_memory() and acpi_os_write_memory()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_read_memory() and acpi_os_write_memory() do two wrong things. First, they shouldn't call rcu_read_unlock() before the looked up address is actually used for I/O, because in that case the mapping it belongs to may be removed before the I/O is done. Second, they shouldn't use the physical address if there's no mapping for it, because that may lead to problems (at least for the "write" case it's like sending data to a random physical address in the hope it's going to work).
Make the rcu_read_unlock() be called by these functions when the I/O is complete and modify them to dump stack and return error code if the requested physical address is not present in the ACPI iomaps.
--- drivers/acpi/osl.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
drivers/acpi/osl.c +13 -18
@@ -638,17 +638,17 @@ acpi_os_read_memory(acpi_physical_addres {u32 dummy;void __iomem *virt_addr; -int size = width /8 , unmap =0 ; + +if (!value) + value = &dummy;rcu_read_lock (); - virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock (); + virt_addr =acpi_map_vaddr_lookup (phys_addr, width /8 );if (!virt_addr) { - virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +rcu_read_unlock (); +WARN (true,"Address not mapped: %llx\n" , phys_addr); +return AE_BAD_ADDRESS ; } -if (!value) - value = &dummy;switch (width) {case 8 :
@@ -663,9 +663,7 @@ acpi_os_read_memory(acpi_physical_addresdefault :BUG (); } - -if (unmap) -iounmap (virt_addr); +rcu_read_unlock ();return AE_OK ; }
@@ -674,14 +672,13 @@ acpi_status acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) { void __iomem *virt_addr; -int size = width /8 , unmap =0 ;rcu_read_lock (); - virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock (); + virt_addr =acpi_map_vaddr_lookup (phys_addr, width /8 );if (!virt_addr) { - virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +rcu_read_unlock (); +WARN (true,"Address not mapped: %llx\n" , phys_addr); +return AE_BAD_ADDRESS ; }switch (width) {
@@ -697,9 +694,7 @@ acpi_os_write_memory(acpi_physical_addredefault :BUG (); } - -if (unmap) -iounmap (virt_addr); +rcu_read_unlock ();return AE_OK ; }
PATCH 3/11 ACPI: Fix acpi_os_read_memory() and acpi_os_write_memory()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_read_memory() and acpi_os_write_memory() do two wrong things. First, they shouldn't call rcu_read_unlock() before the looked up address is actually used for I/O, because in that case the mapping it belongs to may be removed before the I/O is done. Second, they shouldn't use the physical address if there's no mapping for it, because that may lead to problems (at least for the "write" case it's like sending data to a random physical address in the hope it's going to work).
Make the rcu_read_unlock() be called by these functions when the I/O is complete and modify them to dump stack and return error code if the requested physical address is not present in the ACPI iomaps.
--- drivers/acpi/osl.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
drivers/acpi/osl.c +13 -18
@@ -638,17 +638,17 @@ acpi_os_read_memory(acpi_physical_addres {u32 dummy;void __iomem *virt_addr; -int size = width /8 , unmap =0 ; + +if (!value) + value = &dummy;rcu_read_lock (); - virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock (); + virt_addr =acpi_map_vaddr_lookup (phys_addr, width /8 );if (!virt_addr) { - virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +rcu_read_unlock (); +WARN (true,"Address not mapped: %llx\n" , phys_addr); +return AE_BAD_ADDRESS ; } -if (!value) - value = &dummy;switch (width) {case 8 :
@@ -663,9 +663,7 @@ acpi_os_read_memory(acpi_physical_addresdefault :BUG (); } - -if (unmap) -iounmap (virt_addr); +rcu_read_unlock ();return AE_OK ; }
@@ -674,14 +672,13 @@ acpi_status acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) { void __iomem *virt_addr; -int size = width /8 , unmap =0 ;rcu_read_lock (); - virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock (); + virt_addr =acpi_map_vaddr_lookup (phys_addr, width /8 );if (!virt_addr) { - virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +rcu_read_unlock (); +WARN (true,"Address not mapped: %llx\n" , phys_addr); +return AE_BAD_ADDRESS ; }switch (width) {
@@ -697,9 +694,7 @@ acpi_os_write_memory(acpi_physical_addredefault :BUG (); } - -if (unmap) -iounmap (virt_addr); +rcu_read_unlock ();return AE_OK ; }
PATCH 4/11 ACPI: Do not export functions that are only used in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_map_generic_address() and acpi_os_unmap_generic_address() are only used in drivers/acpi/osl.c, so make them static and remove the extern definitions of them from include/linux/acpi_io.h.
--- drivers/acpi/osl.c | 6 ++---- include/linux/acpi_io.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/acpi/osl.c +2 -4
@@ -397,7 +397,7 @@ void __init early_acpi_os_unmap_memory(v__acpi_unmap_table (virt, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr) +static int acpi_os_map_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;
@@ -413,9 +413,8 @@ int acpi_os_map_generic_address(struct areturn 0 ; } -EXPORT_SYMBOL_GPL (acpi_os_map_generic_address); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) +static void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;unsigned long flags;
@@ -433,7 +432,6 @@ void acpi_os_unmap_generic_address(strucacpi_os_unmap_memory (virt, size); } -EXPORT_SYMBOL_GPL (acpi_os_unmap_generic_address);#ifdef ACPI_FUTURE_USAGE acpi_status
include/linux/acpi_io.h +0 -3
@@ -10,7 +10,4 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); -#endif
PATCH 5/11 ACPI: Change acpi_ioremap_lock into a mutex
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
There's no reason why acpi_ioremap_lock has to be a spinlock, because all of the functions it is used in may sleep anyway and there's no reason why it should be locked with interrupts off. Use a mutex instead (that's going to allow us to put some more operations under the lock later).
--- drivers/acpi/osl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/acpi/osl.c +9 -12
@@ -109,7 +109,7 @@ struct acpi_ioremap { };static LIST_HEAD (acpi_ioremaps); -static DEFINE_SPINLOCK (acpi_ioremap_lock); +static DEFINE_MUTEX (acpi_ioremap_lock);static void __init acpi_osi_setup_late (void );
@@ -303,7 +303,6 @@ void __iomem *__init_refok acpi_os_map_memory(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map, *tmp_map; -unsigned long flags;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -334,18 +333,18 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock);/* Check if page has already been mapped. */ tmp_map =acpi_map_lookup (phys, size);if (tmp_map) {kref_get (&tmp_map->ref); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);iounmap (map->virt);kfree (map);return tmp_map->virt + (phys - tmp_map->phys); }list_add_tail_rcu (&map->list, &acpi_ioremaps); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }
@@ -362,7 +361,6 @@ static void acpi_kref_del_iomap(struct kvoid __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -unsigned long flags;int del;if (!acpi_gbl_permanent_mmap) {
@@ -370,17 +368,17 @@ void __ref acpi_os_unmap_memory(void __ireturn ; } -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); map =acpi_map_lookup_virt (virt, size);if (!map) { -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock); printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt);dump_stack ();return ; } del =kref_put (&map->ref, acpi_kref_del_iomap); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);if (!del)return ;
@@ -417,7 +415,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt; -unsigned long flags;acpi_size size = addr->bit_width /8 ;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )
@@ -426,9 +423,9 @@ static void acpi_os_unmap_generic_addresif (!addr->address || !addr->bit_width)return ; -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); virt =acpi_map_vaddr_lookup (addr->address, size); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);acpi_os_unmap_memory (virt, size); }
PATCH 5/11 ACPI: Change acpi_ioremap_lock into a mutex
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
There's no reason why acpi_ioremap_lock has to be a spinlock, because all of the functions it is used in may sleep anyway and there's no reason why it should be locked with interrupts off. Use a mutex instead (that's going to allow us to put some more operations under the lock later).
--- drivers/acpi/osl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/acpi/osl.c +9 -12
@@ -109,7 +109,7 @@ struct acpi_ioremap { };static LIST_HEAD (acpi_ioremaps); -static DEFINE_SPINLOCK (acpi_ioremap_lock); +static DEFINE_MUTEX (acpi_ioremap_lock);static void __init acpi_osi_setup_late (void );
@@ -303,7 +303,6 @@ void __iomem *__init_refok acpi_os_map_memory(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map, *tmp_map; -unsigned long flags;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -334,18 +333,18 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock);/* Check if page has already been mapped. */ tmp_map =acpi_map_lookup (phys, size);if (tmp_map) {kref_get (&tmp_map->ref); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);iounmap (map->virt);kfree (map);return tmp_map->virt + (phys - tmp_map->phys); }list_add_tail_rcu (&map->list, &acpi_ioremaps); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }
@@ -362,7 +361,6 @@ static void acpi_kref_del_iomap(struct kvoid __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -unsigned long flags;int del;if (!acpi_gbl_permanent_mmap) {
@@ -370,17 +368,17 @@ void __ref acpi_os_unmap_memory(void __ireturn ; } -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); map =acpi_map_lookup_virt (virt, size);if (!map) { -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock); printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt);dump_stack ();return ; } del =kref_put (&map->ref, acpi_kref_del_iomap); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);if (!del)return ;
@@ -417,7 +415,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt; -unsigned long flags;acpi_size size = addr->bit_width /8 ;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )
@@ -426,9 +423,9 @@ static void acpi_os_unmap_generic_addresif (!addr->address || !addr->bit_width)return ; -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); virt =acpi_map_vaddr_lookup (addr->address, size); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);acpi_os_unmap_memory (virt, size); }
PATCH 6/11 ACPI: Avoid walking the list of iomaps in osl.c twice in a row
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make acpi_os_unmap_generic_address() use acpi_map_lookup() to find the desired iomap and drop the reference to it directly (and eventually remove it if necessary) instead of calling acpi_os_unmap_memory(), which requires us to walk the list of ACPI iomaps twice in a row (first, to get the virtual address associated with the iomap and second, to get the iomap itself).
--- drivers/acpi/osl.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +20 -13
@@ -358,6 +358,13 @@ static void acpi_kref_del_iomap(struct klist_del_rcu (&map->list); } +static void acpi_os_remove_map (struct acpi_ioremap *map) +{ +synchronize_rcu (); +iounmap (map->virt); +kfree (map); +} +void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map;
@@ -372,20 +379,14 @@ void __ref acpi_os_unmap_memory(void __i map =acpi_map_lookup_virt (virt, size);if (!map) {mutex_unlock (&acpi_ioremap_lock); - printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); -dump_stack (); +WARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -if (!del) -return ; - -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (del) +acpi_os_remove_map (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -414,8 +415,8 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) { -void __iomem *virt; -acpi_size size = addr->bit_width /8 ; +struct acpi_ioremap *map; +int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -424,10 +425,16 @@ static void acpi_os_unmap_generic_addresreturn ;mutex_lock (&acpi_ioremap_lock); - virt =acpi_map_vaddr_lookup (addr->address, size); + map =acpi_map_lookup (addr->address, addr->bit_width /8 ); +if (!map) { +mutex_unlock (&acpi_ioremap_lock); +return ; + } + del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -acpi_os_unmap_memory (virt, size); +if (del) +acpi_os_remove_map (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 7/11 ACPI: Make acpi_os_map_memory() avoid creating unnecessary mappings
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify acpi_os_map_memory() so that it doesn't call acpi_os_ioremap() unconditionally every time it is executed (except when acpi_gbl_permanent_mmap is unset), which pretty much defeats the purpose of maintaining the list of ACPI iomaps in osl.c.
--- drivers/acpi/osl.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +15 -13
@@ -302,7 +302,7 @@ acpi_map_lookup_virt(void __iomem *virt, void __iomem *__init_refokacpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -struct acpi_ioremap *map, *tmp_map; +struct acpi_ioremap *map;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -315,14 +315,25 @@ acpi_os_map_memory(acpi_physical_addressif (!acpi_gbl_permanent_mmap)return __acpi_map_table ((unsigned long )phys, size); +mutex_lock (&acpi_ioremap_lock); +/* Check if there's a suitable mapping already. */ + map =acpi_map_lookup (phys, size); +if (map) { +kref_get (&map->ref); + goto out; + } + map =kzalloc (sizeof (*map),GFP_KERNEL ); -if (!map) +if (!map) { +mutex_unlock (&acpi_ioremap_lock);return NULL ; + } pg_off =round_down (phys,PAGE_SIZE ); pg_sz =round_up (phys + size,PAGE_SIZE ) - pg_off; virt =acpi_os_ioremap (pg_off, pg_sz);if (!virt) { +mutex_unlock (&acpi_ioremap_lock);kfree (map);return NULL ; }
@@ -333,19 +344,10 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -mutex_lock (&acpi_ioremap_lock); -/* Check if page has already been mapped. */ - tmp_map =acpi_map_lookup (phys, size); -if (tmp_map) { -kref_get (&tmp_map->ref); -mutex_unlock (&acpi_ioremap_lock); -iounmap (map->virt); -kfree (map); -return tmp_map->virt + (phys - tmp_map->phys); - }list_add_tail_rcu (&map->list, &acpi_ioremaps); -mutex_unlock (&acpi_ioremap_lock); + out: +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }EXPORT_SYMBOL_GPL (acpi_os_map_memory);
PATCH 7/11 ACPI: Make acpi_os_map_memory() avoid creating unnecessary mappings
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify acpi_os_map_memory() so that it doesn't call acpi_os_ioremap() unconditionally every time it is executed (except when acpi_gbl_permanent_mmap is unset), which pretty much defeats the purpose of maintaining the list of ACPI iomaps in osl.c.
--- drivers/acpi/osl.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +15 -13
@@ -302,7 +302,7 @@ acpi_map_lookup_virt(void __iomem *virt, void __iomem *__init_refokacpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -struct acpi_ioremap *map, *tmp_map; +struct acpi_ioremap *map;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -315,14 +315,25 @@ acpi_os_map_memory(acpi_physical_addressif (!acpi_gbl_permanent_mmap)return __acpi_map_table ((unsigned long )phys, size); +mutex_lock (&acpi_ioremap_lock); +/* Check if there's a suitable mapping already. */ + map =acpi_map_lookup (phys, size); +if (map) { +kref_get (&map->ref); + goto out; + } + map =kzalloc (sizeof (*map),GFP_KERNEL ); -if (!map) +if (!map) { +mutex_unlock (&acpi_ioremap_lock);return NULL ; + } pg_off =round_down (phys,PAGE_SIZE ); pg_sz =round_up (phys + size,PAGE_SIZE ) - pg_off; virt =acpi_os_ioremap (pg_off, pg_sz);if (!virt) { +mutex_unlock (&acpi_ioremap_lock);kfree (map);return NULL ; }
@@ -333,19 +344,10 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -mutex_lock (&acpi_ioremap_lock); -/* Check if page has already been mapped. */ - tmp_map =acpi_map_lookup (phys, size); -if (tmp_map) { -kref_get (&tmp_map->ref); -mutex_unlock (&acpi_ioremap_lock); -iounmap (map->virt); -kfree (map); -return tmp_map->virt + (phys - tmp_map->phys); - }list_add_tail_rcu (&map->list, &acpi_ioremaps); -mutex_unlock (&acpi_ioremap_lock); + out: +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }EXPORT_SYMBOL_GPL (acpi_os_map_memory);
PATCH 8/11 ACPI: Do not use krefs under a mutex in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The reference counting of ACPI iomaps is carried out entirely under acpi_ioremap_lock, so it is sufficient to use simple counters instead of krefs for this purpose.
--- drivers/acpi/osl.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/acpi/osl.c +16 -20
@@ -105,7 +105,7 @@ struct acpi_ioremap {void __iomem *virt;acpi_physical_address phys;acpi_size size; -struct kref ref; +unsigned long refcount; };static LIST_HEAD (acpi_ioremaps);
@@ -319,7 +319,7 @@ acpi_os_map_memory(acpi_physical_address/* Check if there's a suitable mapping already. */ map =acpi_map_lookup (phys, size);if (map) { -kref_get (&map->ref); + map->refcount++; goto out; }
@@ -342,7 +342,7 @@ acpi_os_map_memory(acpi_physical_address map->virt = virt; map->phys = pg_off; map->size = pg_sz; -kref_init (&map->ref); + map->refcount =1 ;list_add_tail_rcu (&map->list, &acpi_ioremaps);
@@ -352,25 +352,24 @@ acpi_os_map_memory(acpi_physical_address }EXPORT_SYMBOL_GPL (acpi_os_map_memory); -static void acpi_kref_del_iomap (struct kref *ref) +static void acpi_os_drop_map_ref (struct acpi_ioremap *map) { -struct acpi_ioremap *map; - - map = container_of(ref, struct acpi_ioremap, ref); -list_del_rcu (&map->list); +if (!--map->refcount) +list_del_rcu (&map->list); } -static void acpi_os_remove_map (struct acpi_ioremap *map) +static void acpi_os_map_cleanup (struct acpi_ioremap *map) { -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (!map->refcount) { +synchronize_rcu (); +iounmap (map->virt); +kfree (map); + } }void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -int del;if (!acpi_gbl_permanent_mmap) {__acpi_unmap_table (virt, size);
@@ -384,11 +383,10 @@ void __ref acpi_os_unmap_memory(void __iWARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -418,7 +416,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {struct acpi_ioremap *map; -int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -432,11 +429,10 @@ static void acpi_os_unmap_generic_addresmutex_unlock (&acpi_ioremap_lock);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 8/11 ACPI: Do not use krefs under a mutex in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The reference counting of ACPI iomaps is carried out entirely under acpi_ioremap_lock, so it is sufficient to use simple counters instead of krefs for this purpose.
--- drivers/acpi/osl.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/acpi/osl.c +16 -20
@@ -105,7 +105,7 @@ struct acpi_ioremap {void __iomem *virt;acpi_physical_address phys;acpi_size size; -struct kref ref; +unsigned long refcount; };static LIST_HEAD (acpi_ioremaps);
@@ -319,7 +319,7 @@ acpi_os_map_memory(acpi_physical_address/* Check if there's a suitable mapping already. */ map =acpi_map_lookup (phys, size);if (map) { -kref_get (&map->ref); + map->refcount++; goto out; }
@@ -342,7 +342,7 @@ acpi_os_map_memory(acpi_physical_address map->virt = virt; map->phys = pg_off; map->size = pg_sz; -kref_init (&map->ref); + map->refcount =1 ;list_add_tail_rcu (&map->list, &acpi_ioremaps);
@@ -352,25 +352,24 @@ acpi_os_map_memory(acpi_physical_address }EXPORT_SYMBOL_GPL (acpi_os_map_memory); -static void acpi_kref_del_iomap (struct kref *ref) +static void acpi_os_drop_map_ref (struct acpi_ioremap *map) { -struct acpi_ioremap *map; - - map = container_of(ref, struct acpi_ioremap, ref); -list_del_rcu (&map->list); +if (!--map->refcount) +list_del_rcu (&map->list); } -static void acpi_os_remove_map (struct acpi_ioremap *map) +static void acpi_os_map_cleanup (struct acpi_ioremap *map) { -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (!map->refcount) { +synchronize_rcu (); +iounmap (map->virt); +kfree (map); + } }void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -int del;if (!acpi_gbl_permanent_mmap) {__acpi_unmap_table (virt, size);
@@ -384,11 +383,10 @@ void __ref acpi_os_unmap_memory(void __iWARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -418,7 +416,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {struct acpi_ioremap *map; -int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -432,11 +429,10 @@ static void acpi_os_unmap_generic_addresmutex_unlock (&acpi_ioremap_lock);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 9/11 ACPI: Introduce acpi_os_get_iomem()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Introduce function acpi_os_get_iomem() that may be used by its callers to get a reference to an ACPI iomap.
--- drivers/acpi/osl.c | 16 ++++++++++++++++ include/linux/acpi_io.h | 2 ++ 2 files changed, 18 insertions(+)
drivers/acpi/osl.c +16 -0
@@ -285,6 +285,22 @@ acpi_map_vaddr_lookup(acpi_physical_addrreturn NULL ; } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size) +{ +struct acpi_ioremap *map; +void __iomem *virt =NULL ; + +mutex_lock (&acpi_ioremap_lock); + map =acpi_map_lookup (phys, size); +if (map) { + virt = map->virt + (phys - map->phys); + map->refcount++; + } +mutex_unlock (&acpi_ioremap_lock); +return virt; +} +EXPORT_SYMBOL_GPL (acpi_os_get_iomem); +/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap *acpi_map_lookup_virt (void __iomem *virt,acpi_size size)
include/linux/acpi_io.h +2 -0
@@ -10,4 +10,6 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size); +#endif
PATCH 9/11 ACPI: Introduce acpi_os_get_iomem()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Introduce function acpi_os_get_iomem() that may be used by its callers to get a reference to an ACPI iomap.
--- drivers/acpi/osl.c | 16 ++++++++++++++++ include/linux/acpi_io.h | 2 ++ 2 files changed, 18 insertions(+)
drivers/acpi/osl.c +16 -0
@@ -285,6 +285,22 @@ acpi_map_vaddr_lookup(acpi_physical_addrreturn NULL ; } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size) +{ +struct acpi_ioremap *map; +void __iomem *virt =NULL ; + +mutex_lock (&acpi_ioremap_lock); + map =acpi_map_lookup (phys, size); +if (map) { + virt = map->virt + (phys - map->phys); + map->refcount++; + } +mutex_unlock (&acpi_ioremap_lock); +return virt; +} +EXPORT_SYMBOL_GPL (acpi_os_get_iomem); +/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap *acpi_map_lookup_virt (void __iomem *virt,acpi_size size)
include/linux/acpi_io.h +2 -0
@@ -10,4 +10,6 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size); +#endif
PATCH 10/11 ACPI / PM: Use existing ACPI iomaps for NVS save/restore
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify the NVS save/restore code to use acpi_os_get_iomem() and acpi_os_unmap_memory() to acquire and release references to ACPI iomaps, respectively. If there's no ACPI iomap corresponding to the given NVS page, acpi_os_ioremap() is used to map that page and iounmap() is used to unmap it during resume. [If the page is not present in the ACPI iomaps already, it doesn't make sense to add its mapping to the list of ACPI iomaps, because it's going to be thrown away during the subsequent resume anyway.]
Testing on my HP nx6325 shows that approx. 90% of the NVS pages have already been mapped by ACPI before suspend and are present in the ACPI iomaps, so this change appears to be the right thing to do in general.
--- drivers/acpi/nvs.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/acpi/nvs.c +16 -3
@@ -26,6 +26,7 @@ struct nvs_page {unsigned int size;void *kaddr;void *data; +bool unmap;struct list_head node; };
@@ -81,7 +82,13 @@ void suspend_nvs_free(void)free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) { -iounmap (entry->kaddr); +if (entry->unmap) { +iounmap (entry->kaddr); + entry->unmap = false; + }else { +acpi_os_unmap_memory (entry->kaddr, + entry->size); + } entry->kaddr =NULL ; } }
@@ -115,8 +122,14 @@ int suspend_nvs_save(void)list_for_each_entry (entry, &nvs_list, node)if (entry->data) { - entry->kaddr =acpi_os_ioremap (entry->phys_start, - entry->size); +unsigned long phys = entry->phys_start; +unsigned int size = entry->size; + + entry->kaddr =acpi_os_get_iomem (phys, size); +if (!entry->kaddr) { + entry->kaddr =acpi_os_ioremap (phys, size); + entry->unmap = true; + }if (!entry->kaddr) {suspend_nvs_free ();return -ENOMEM ;
PATCH 11/11 ACPI / PM: Make NVS save/restore code use slightly less memory
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Remove the unnecessary field phys_start from struct nvs_page and rework the code in nvs.c to reflect that change.
--- drivers/acpi/nvs.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-)
drivers/acpi/nvs.c +28 -17
@@ -22,7 +22,6 @@*/ struct nvs_page { -unsigned long phys_start;unsigned int size;void *kaddr;void *data;
@@ -31,6 +30,8 @@ struct nvs_page { };static LIST_HEAD (nvs_list); +static unsigned long nvs_start; +static unsigned int nvs_offset;/** * suspend_nvs_register - register platform NVS memory region to save
@@ -44,25 +45,28 @@ static LIST_HEAD(nvs_list);int suspend_nvs_register (unsigned long start,unsigned long size) {struct nvs_page *entry, *next; +unsigned int offset; + nvs_start =round_down (start,PAGE_SIZE ); + nvs_offset = start - nvs_start; + offset = nvs_offset;while (size >0 ) { -unsigned int nr_bytes; +unsigned int nr_bytes =PAGE_SIZE - offset; entry =kzalloc (sizeof (struct nvs_page ),GFP_KERNEL );if (!entry) - goto Error; + goto err_out;list_add_tail (&entry->node, &nvs_list); - entry->phys_start = start; - nr_bytes =PAGE_SIZE - (start & ~PAGE_MASK ); entry->size = (size < nr_bytes) ? size : nr_bytes; start += entry->size; size -= entry->size; + offset -= offset; }return 0 ; - Error: + err_out:list_for_each_entry_safe (entry, next, &nvs_list, node) {list_del (&entry->node);kfree (entry);
@@ -117,25 +121,32 @@ int suspend_nvs_alloc(void)int suspend_nvs_save (void ) {struct nvs_page *entry; +unsigned long page_addr = nvs_start; +unsigned int offset = nvs_offset;printk (KERN_INFO "PM: Saving platform NVS memory\n" ); -list_for_each_entry (entry, &nvs_list, node) -if (entry->data) { -unsigned long phys = entry->phys_start; -unsigned int size = entry->size; +list_for_each_entry (entry, &nvs_list, node) { +unsigned long phys = page_addr + offset; +unsigned int size = entry->size; - entry->kaddr =acpi_os_get_iomem (phys, size); -if (!entry->kaddr) { - entry->kaddr =acpi_os_ioremap (phys, size); - entry->unmap = true; - } +if (!entry->data) +return -ENOMEM ; + + entry->kaddr =acpi_os_get_iomem (phys, size); +if (!entry->kaddr) { + entry->kaddr =acpi_os_ioremap (phys, size);if (!entry->kaddr) {suspend_nvs_free (); -return -ENOMEM ; +return -EIO ; } -memcpy (entry->data, entry->kaddr, entry->size); + entry->unmap = true; } +memcpy (entry->data, entry->kaddr, entry->size); + + page_addr +=PAGE_SIZE ; + offset -= offset; + }return 0 ; }
PATCH 2/11 ACPI / PM: Call suspend_nvs_free() earlier during resume
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
It turns out that some device drivers map pages from the ACPI NVS region during resume using ioremap(), which conflicts with the ioremap_cache() used for mapping those pages by the NVS save/restore code in nvs.c.
Make the NVS pages mapped by the code in nvs.c be unmapped before device drivers' resume routines run.
--- drivers/acpi/sleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/sleep.c +1 -1
@@ -166,6 +166,7 @@ static void acpi_pm_finish(void)u32 acpi_state = acpi_target_sleep_state;acpi_ec_unblock_transactions (); +suspend_nvs_free ();if (acpi_state ==ACPI_STATE_S0 )return ;
@@ -186,7 +187,6 @@ static void acpi_pm_finish(void)*/ static void acpi_pm_end (void ) { -suspend_nvs_free ();/* * This is necessary in case acpi_pm_finish() is not called during a * failing transition to a sleep state.
PATCH 4/11 ACPI: Do not export functions that are only used in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_map_generic_address() and acpi_os_unmap_generic_address() are only used in drivers/acpi/osl.c, so make them static and remove the extern definitions of them from include/linux/acpi_io.h.
--- drivers/acpi/osl.c | 6 ++---- include/linux/acpi_io.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/acpi/osl.c +2 -4
@@ -397,7 +397,7 @@ void __init early_acpi_os_unmap_memory(v__acpi_unmap_table (virt, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr) +static int acpi_os_map_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;
@@ -413,9 +413,8 @@ int acpi_os_map_generic_address(struct areturn 0 ; } -EXPORT_SYMBOL_GPL (acpi_os_map_generic_address); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) +static void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;unsigned long flags;
@@ -433,7 +432,6 @@ void acpi_os_unmap_generic_address(strucacpi_os_unmap_memory (virt, size); } -EXPORT_SYMBOL_GPL (acpi_os_unmap_generic_address);#ifdef ACPI_FUTURE_USAGE acpi_status
include/linux/acpi_io.h +0 -3
@@ -10,7 +10,4 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); -#endif
PATCH 6/11 ACPI: Avoid walking the list of iomaps in osl.c twice in a row
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make acpi_os_unmap_generic_address() use acpi_map_lookup() to find the desired iomap and drop the reference to it directly (and eventually remove it if necessary) instead of calling acpi_os_unmap_memory(), which requires us to walk the list of ACPI iomaps twice in a row (first, to get the virtual address associated with the iomap and second, to get the iomap itself).
--- drivers/acpi/osl.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +20 -13
@@ -358,6 +358,13 @@ static void acpi_kref_del_iomap(struct klist_del_rcu (&map->list); } +static void acpi_os_remove_map (struct acpi_ioremap *map) +{ +synchronize_rcu (); +iounmap (map->virt); +kfree (map); +} +void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map;
@@ -372,20 +379,14 @@ void __ref acpi_os_unmap_memory(void __i map =acpi_map_lookup_virt (virt, size);if (!map) {mutex_unlock (&acpi_ioremap_lock); - printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); -dump_stack (); +WARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -if (!del) -return ; - -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (del) +acpi_os_remove_map (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -414,8 +415,8 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) { -void __iomem *virt; -acpi_size size = addr->bit_width /8 ; +struct acpi_ioremap *map; +int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -424,10 +425,16 @@ static void acpi_os_unmap_generic_addresreturn ;mutex_lock (&acpi_ioremap_lock); - virt =acpi_map_vaddr_lookup (addr->address, size); + map =acpi_map_lookup (addr->address, addr->bit_width /8 ); +if (!map) { +mutex_unlock (&acpi_ioremap_lock); +return ; + } + del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -acpi_os_unmap_memory (virt, size); +if (del) +acpi_os_remove_map (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 10/11 ACPI / PM: Use existing ACPI iomaps for NVS save/restore
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify the NVS save/restore code to use acpi_os_get_iomem() and acpi_os_unmap_memory() to acquire and release references to ACPI iomaps, respectively. If there's no ACPI iomap corresponding to the given NVS page, acpi_os_ioremap() is used to map that page and iounmap() is used to unmap it during resume. [If the page is not present in the ACPI iomaps already, it doesn't make sense to add its mapping to the list of ACPI iomaps, because it's going to be thrown away during the subsequent resume anyway.]
Testing on my HP nx6325 shows that approx. 90% of the NVS pages have already been mapped by ACPI before suspend and are present in the ACPI iomaps, so this change appears to be the right thing to do in general.
--- drivers/acpi/nvs.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/acpi/nvs.c +16 -3
@@ -26,6 +26,7 @@ struct nvs_page {unsigned int size;void *kaddr;void *data; +bool unmap;struct list_head node; };
@@ -81,7 +82,13 @@ void suspend_nvs_free(void)free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) { -iounmap (entry->kaddr); +if (entry->unmap) { +iounmap (entry->kaddr); + entry->unmap = false; + }else { +acpi_os_unmap_memory (entry->kaddr, + entry->size); + } entry->kaddr =NULL ; } }
@@ -115,8 +122,14 @@ int suspend_nvs_save(void)list_for_each_entry (entry, &nvs_list, node)if (entry->data) { - entry->kaddr =acpi_os_ioremap (entry->phys_start, - entry->size); +unsigned long phys = entry->phys_start; +unsigned int size = entry->size; + + entry->kaddr =acpi_os_get_iomem (phys, size); +if (!entry->kaddr) { + entry->kaddr =acpi_os_ioremap (phys, size); + entry->unmap = true; + }if (!entry->kaddr) {suspend_nvs_free ();return -ENOMEM ;
PATCH 11/11 ACPI / PM: Make NVS save/restore code use slightly less memory
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Remove the unnecessary field phys_start from struct nvs_page and rework the code in nvs.c to reflect that change.
--- drivers/acpi/nvs.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-)
drivers/acpi/nvs.c +28 -17
@@ -22,7 +22,6 @@*/ struct nvs_page { -unsigned long phys_start;unsigned int size;void *kaddr;void *data;
@@ -31,6 +30,8 @@ struct nvs_page { };static LIST_HEAD (nvs_list); +static unsigned long nvs_start; +static unsigned int nvs_offset;/** * suspend_nvs_register - register platform NVS memory region to save
@@ -44,25 +45,28 @@ static LIST_HEAD(nvs_list);int suspend_nvs_register (unsigned long start,unsigned long size) {struct nvs_page *entry, *next; +unsigned int offset; + nvs_start =round_down (start,PAGE_SIZE ); + nvs_offset = start - nvs_start; + offset = nvs_offset;while (size >0 ) { -unsigned int nr_bytes; +unsigned int nr_bytes =PAGE_SIZE - offset; entry =kzalloc (sizeof (struct nvs_page ),GFP_KERNEL );if (!entry) - goto Error; + goto err_out;list_add_tail (&entry->node, &nvs_list); - entry->phys_start = start; - nr_bytes =PAGE_SIZE - (start & ~PAGE_MASK ); entry->size = (size < nr_bytes) ? size : nr_bytes; start += entry->size; size -= entry->size; + offset -= offset; }return 0 ; - Error: + err_out:list_for_each_entry_safe (entry, next, &nvs_list, node) {list_del (&entry->node);kfree (entry);
@@ -117,25 +121,32 @@ int suspend_nvs_alloc(void)int suspend_nvs_save (void ) {struct nvs_page *entry; +unsigned long page_addr = nvs_start; +unsigned int offset = nvs_offset;printk (KERN_INFO "PM: Saving platform NVS memory\n" ); -list_for_each_entry (entry, &nvs_list, node) -if (entry->data) { -unsigned long phys = entry->phys_start; -unsigned int size = entry->size; +list_for_each_entry (entry, &nvs_list, node) { +unsigned long phys = page_addr + offset; +unsigned int size = entry->size; - entry->kaddr =acpi_os_get_iomem (phys, size); -if (!entry->kaddr) { - entry->kaddr =acpi_os_ioremap (phys, size); - entry->unmap = true; - } +if (!entry->data) +return -ENOMEM ; + + entry->kaddr =acpi_os_get_iomem (phys, size); +if (!entry->kaddr) { + entry->kaddr =acpi_os_ioremap (phys, size);if (!entry->kaddr) {suspend_nvs_free (); -return -ENOMEM ; +return -EIO ; } -memcpy (entry->data, entry->kaddr, entry->size); + entry->unmap = true; } +memcpy (entry->data, entry->kaddr, entry->size); + + page_addr +=PAGE_SIZE ; + offset -= offset; + }return 0 ; }
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.
This seems to have an issue. Notebook tries to suspend ... then resume immediately.
Quoted 5 lines
The patches have been tested on HP nx6325, Toshiba Portege R500 and Acer Ferrari One without causing any visible problems to happen. Also Jeff has tested [1/11] and [2/11] and he reports that they fix the
synchronize_rcu()problem for him. [Jeff, can you test the whole series, please, and see if it doesn't introduce any new issues, [10/11] in particular?]
So, everything seems ok except 11/11.
Jeff.
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.
This seems to have an issue. Notebook tries to suspend ... then resume immediately.
Quoted 5 lines
The patches have been tested on HP nx6325, Toshiba Portege R500 and Acer Ferrari One without causing any visible problems to happen. Also Jeff has tested [1/11] and [2/11] and he reports that they fix the
synchronize_rcu()problem for him. [Jeff, can you test the whole series, please, and see if it doesn't introduce any new issues, [10/11] in particular?]
So, everything seems ok except 11/11.
Jeff.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Jeff Chua
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.This seems to have an issue. Notebook tries to suspend ... then resume immediately.
That's unexpected. Please apply the debug patch below in addition to the whole series and send a dmesg output containing a (failing) suspend attempt (with the patch applied).
Thanks,
Rafael
--- drivers/acpi/nvs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/acpi/nvs.c +19 -1
@@ -87,9 +87,15 @@ void suspend_nvs_free(void) entry->data =NULL ;if (entry->kaddr) {if (entry->unmap) { +pr_info ("%s: Unmapping %p\n" , __func__, + entry->kaddr); +iounmap (entry->kaddr); entry->unmap = false; }else { +pr_info ("%s: Dropping %p\n" , __func__, + entry->kaddr); +acpi_os_unmap_memory (entry->kaddr, entry->size); }
@@ -139,9 +145,17 @@ int suspend_nvs_save(void)if (!entry->kaddr) {suspend_nvs_free ();return -EIO ; + }else { +pr_info ("%s: Mapped %p\n" , __func__, + entry->kaddr); } entry->unmap = true; + }else { +pr_info ("%s: Got address %p\n" , __func__, entry->kaddr); } +pr_info ("%s: Saving %p <- %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->data, entry->kaddr, entry->size); page_addr +=PAGE_SIZE ;
@@ -164,6 +178,10 @@ void suspend_nvs_restore(void)printk (KERN_INFO "PM: Restoring platform NVS memory\n" );list_for_each_entry (entry, &nvs_list, node) -if (entry->data) +if (entry->data) { +pr_info ("%s: Restoring %p -> %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->kaddr, entry->data, entry->size); + } }
Quoted 10 lines · Jeff Chua
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.This seems to have an issue. Notebook tries to suspend ... then resume immediately.
That's unexpected. Please apply the debug patch below in addition to the whole series and send a dmesg output containing a (failing) suspend attempt (with the patch applied).
Thanks,
Rafael
--- drivers/acpi/nvs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/acpi/nvs.c +19 -1
@@ -87,9 +87,15 @@ void suspend_nvs_free(void) entry->data =NULL ;if (entry->kaddr) {if (entry->unmap) { +pr_info ("%s: Unmapping %p\n" , __func__, + entry->kaddr); +iounmap (entry->kaddr); entry->unmap = false; }else { +pr_info ("%s: Dropping %p\n" , __func__, + entry->kaddr); +acpi_os_unmap_memory (entry->kaddr, entry->size); }
@@ -139,9 +145,17 @@ int suspend_nvs_save(void)if (!entry->kaddr) {suspend_nvs_free ();return -EIO ; + }else { +pr_info ("%s: Mapped %p\n" , __func__, + entry->kaddr); } entry->unmap = true; + }else { +pr_info ("%s: Got address %p\n" , __func__, entry->kaddr); } +pr_info ("%s: Saving %p <- %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->data, entry->kaddr, entry->size); page_addr +=PAGE_SIZE ;
@@ -164,6 +178,10 @@ void suspend_nvs_restore(void)printk (KERN_INFO "PM: Restoring platform NVS memory\n" );list_for_each_entry (entry, &nvs_list, node) -if (entry->data) +if (entry->data) { +pr_info ("%s: Restoring %p -> %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->kaddr, entry->data, entry->size); + } }
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Jeff Chua
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.This seems to have an issue. Notebook tries to suspend ... then resume immediately.
That's unexpected. Please apply the debug patch below in addition to the whole series and send a dmesg output containing a (failing) suspend attempt (with the patch applied).
Attached.
Thanks,
Jeff
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Jeff Chua
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.This seems to have an issue. Notebook tries to suspend ... then resume immediately.
That's unexpected. Please apply the debug patch below in addition to the whole series and send a dmesg output containing a (failing) suspend attempt (with the patch applied).
Attached.
Thanks,
Jeff
Quoted 10 lines · Jeff Chua
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Jeff Chua
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
This seems to have an issue. Notebook tries to suspend ... then resume immediately.
That's unexpected. Please apply the debug patch below in addition to the whole series and send a dmesg output containing a (failing) suspend attempt (with the patch applied).
Attached.
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Thanks,
Rafael
--- drivers/acpi/nvs.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/acpi/nvs.c +26 -1
@@ -87,9 +87,15 @@ void suspend_nvs_free(void) entry->data =NULL ;if (entry->kaddr) {if (entry->unmap) { +pr_info ("%s: Unmapping %p\n" , __func__, + entry->kaddr); +iounmap (entry->kaddr); entry->unmap = false; }else { +pr_info ("%s: Dropping %p\n" , __func__, + entry->kaddr); +acpi_os_unmap_memory (entry->kaddr, entry->size); }
@@ -130,6 +136,8 @@ int suspend_nvs_save(void)unsigned long phys = page_addr + offset;unsigned int size = entry->size; +pr_info ("%s: phys = %lx, size = %d\n" , __func__, phys, size); +if (!entry->data)return -ENOMEM ;
@@ -137,11 +145,24 @@ int suspend_nvs_save(void)if (!entry->kaddr) { entry->kaddr =acpi_os_ioremap (phys, size);if (!entry->kaddr) { + +pr_info ("%s: acpi_os_ioremap() failed\n" , + __func__); +suspend_nvs_free ();return -EIO ; + }else { +pr_info ("%s: Mapped %p\n" , __func__, + entry->kaddr); } entry->unmap = true; + }else { +pr_info ("%s: Got address %p\n" , __func__, entry->kaddr); } + +pr_info ("%s: Saving %p <- %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->data, entry->kaddr, entry->size); page_addr +=PAGE_SIZE ;
@@ -164,6 +185,10 @@ void suspend_nvs_restore(void)printk (KERN_INFO "PM: Restoring platform NVS memory\n" );list_for_each_entry (entry, &nvs_list, node) -if (entry->data) +if (entry->data) { +pr_info ("%s: Restoring %p -> %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->kaddr, entry->data, entry->size); + } }
Quoted 10 lines · Jeff Chua
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Jeff Chua
Quoted 1 line · Rafael J. Wysocki
[10/11] - Make the NVS code use existing iomaps if possible.
Seems ok.
Quoted 1 line
[11/11] - (cleanup) Remove an unnecessary field from struct
nvs_page.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
This seems to have an issue. Notebook tries to suspend ... then resume immediately.
That's unexpected. Please apply the debug patch below in addition to the whole series and send a dmesg output containing a (failing) suspend attempt (with the patch applied).
Attached.
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Thanks,
Rafael
--- drivers/acpi/nvs.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/acpi/nvs.c +26 -1
@@ -87,9 +87,15 @@ void suspend_nvs_free(void) entry->data =NULL ;if (entry->kaddr) {if (entry->unmap) { +pr_info ("%s: Unmapping %p\n" , __func__, + entry->kaddr); +iounmap (entry->kaddr); entry->unmap = false; }else { +pr_info ("%s: Dropping %p\n" , __func__, + entry->kaddr); +acpi_os_unmap_memory (entry->kaddr, entry->size); }
@@ -130,6 +136,8 @@ int suspend_nvs_save(void)unsigned long phys = page_addr + offset;unsigned int size = entry->size; +pr_info ("%s: phys = %lx, size = %d\n" , __func__, phys, size); +if (!entry->data)return -ENOMEM ;
@@ -137,11 +145,24 @@ int suspend_nvs_save(void)if (!entry->kaddr) { entry->kaddr =acpi_os_ioremap (phys, size);if (!entry->kaddr) { + +pr_info ("%s: acpi_os_ioremap() failed\n" , + __func__); +suspend_nvs_free ();return -EIO ; + }else { +pr_info ("%s: Mapped %p\n" , __func__, + entry->kaddr); } entry->unmap = true; + }else { +pr_info ("%s: Got address %p\n" , __func__, entry->kaddr); } + +pr_info ("%s: Saving %p <- %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->data, entry->kaddr, entry->size); page_addr +=PAGE_SIZE ;
@@ -164,6 +185,10 @@ void suspend_nvs_restore(void)printk (KERN_INFO "PM: Restoring platform NVS memory\n" );list_for_each_entry (entry, &nvs_list, node) -if (entry->data) +if (entry->data) { +pr_info ("%s: Restoring %p -> %p\n" , __func__, + entry->data, entry->kaddr); +memcpy (entry->kaddr, entry->data, entry->size); + } }
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 6 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Attached.
Jeff
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 6 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Attached.
Jeff
Quoted 9 lines · Jeff Chua
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 6 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Attached.
OK, I suspect the new code tries to map one page too many, but I still don't know how many pages we are _supposed_ to map, because there's no e820 information in your dmesg (I'm not sure exactly why).
Anyway, I'll have a replacement for [11/11] later today.
Thanks,
Rafael
Quoted 9 lines · Jeff Chua
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 6 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Attached.
OK, I suspect the new code tries to map one page too many, but I still don't know how many pages we are _supposed_ to map, because there's no e820 information in your dmesg (I'm not sure exactly why).
Anyway, I'll have a replacement for [11/11] later today.
Thanks,
Rafael
Quoted 9 lines · Jeff Chua
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 6 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Attached.
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Thanks,
Rafael
---
Subject: ACPI / PM: Make NVS save/restore code use slightly less memory (test)
Remove the unnecessary field phys_start from struct nvs_page and modify the code in nvs.c to use an array of struct nvs_page objects instead of a list which makes it a bit more straightforward (in addition to saving a little memory).
--- drivers/acpi/nvs.c | 125 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 46 deletions(-)
drivers/acpi/nvs.c +79 -46
@@ -22,15 +22,15 @@*/ struct nvs_page { -unsigned long phys_start;unsigned int size; -void *kaddr; +void __iomem *kaddr;void *data;bool unmap; -struct list_head node; }; -static LIST_HEAD (nvs_list); +static struct nvs_page *nvs; +static unsigned long nvs_start; +static unsigned int nvs_span;/** * suspend_nvs_register - register platform NVS memory region to save
@@ -43,31 +43,40 @@ static LIST_HEAD(nvs_list);*/ int suspend_nvs_register (unsigned long start,unsigned long size) { -struct nvs_page *entry, *next; +struct nvs_page *p, *p_end; +unsigned int head, tail; -while (size >0 ) { -unsigned int nr_bytes; +pr_info ("PM: Registering ACPI NVS region at %lx (%ld bytes)\n" , + start, size); - entry =kzalloc (sizeof (struct nvs_page ),GFP_KERNEL ); -if (!entry) - goto Error; - -list_add_tail (&entry->node, &nvs_list); - entry->phys_start = start; - nr_bytes =PAGE_SIZE - (start & ~PAGE_MASK ); - entry->size = (size < nr_bytes) ? size : nr_bytes; - - start += entry->size; - size -= entry->size; + nvs_start = start; + head =PAGE_SIZE - (start & ~PAGE_MASK ); +if (head) { + nvs_span =1 ; + size -= size > head ? head : size; + }else { + nvs_span =0 ; + head =PAGE_SIZE ; } -return 0 ; + nvs_span += size >>PAGE_SHIFT ; + tail = size & ~PAGE_MASK ; +if (tail) + nvs_span++; +else + tail =PAGE_SIZE ; + + nvs =kzalloc (sizeof (*nvs) * nvs_span,GFP_KERNEL ); +if (!nvs) +return -ENOMEM ; + + p = nvs; + p->size = head; +for (p++, p_end = nvs + nvs_span -1 ; p < p_end; p++) + p->size =PAGE_SIZE ; +if (p_end > nvs) + p_end->size = tail; - Error: -list_for_each_entry_safe (entry, next, &nvs_list, node) { -list_del (&entry->node); -kfree (entry); - } -return -ENOMEM ; +return 0 ; }/**
@@ -75,17 +84,23 @@ int suspend_nvs_register(unsigned long s*/ void suspend_nvs_free (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end; -list_for_each_entry (entry, &nvs_list, node) +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++)if (entry->data) {free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) {if (entry->unmap) { +pr_info ("%s: Unmapping %p\n" , __func__, + entry->kaddr); +iounmap (entry->kaddr); entry->unmap = false; }else { +pr_info ("%s: Releasing %p\n" , __func__, + entry->kaddr); +acpi_os_unmap_memory (entry->kaddr, entry->size); }
@@ -99,9 +114,9 @@ void suspend_nvs_free(void)*/ int suspend_nvs_alloc (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end; -list_for_each_entry (entry, &nvs_list, node) { +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++) { entry->data = (void *)__get_free_page (GFP_KERNEL );if (!entry->data) {suspend_nvs_free ();
@@ -116,26 +131,44 @@ int suspend_nvs_alloc(void)*/ int suspend_nvs_save (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end; +unsigned long phys = nvs_start;printk (KERN_INFO "PM: Saving platform NVS memory\n" ); -list_for_each_entry (entry, &nvs_list, node) -if (entry->data) { -unsigned long phys = entry->phys_start; -unsigned int size = entry->size; +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++) { +unsigned int size = entry->size; +void __iomem *kaddr; - entry->kaddr =acpi_os_get_iomem (phys, size); -if (!entry->kaddr) { - entry->kaddr =acpi_os_ioremap (phys, size); - entry->unmap = true; - } -if (!entry->kaddr) { -suspend_nvs_free (); -return -ENOMEM ; - } -memcpy (entry->data, entry->kaddr, entry->size); +if (!entry->data) { +suspend_nvs_free (); +return -ENOMEM ; + } + +pr_info ("%s: Trying to map %lx, %d\n" , __func__, phys, size); + + kaddr =acpi_os_get_iomem (phys, size); +if (!kaddr) { + kaddr =acpi_os_ioremap (phys, size); + entry->unmap = !!kaddr; + }else { +pr_info ("%s: Got address %p\n" , __func__, kaddr); } + entry->kaddr = kaddr; + +if (!entry->kaddr) { +pr_info ("%s: Mapping failed\n" , __func__); + +suspend_nvs_free (); +return -EIO ; + }else { +pr_info ("%s: Using address %p\n" , __func__, entry->kaddr); + } + +memcpy (entry->data, entry->kaddr, size); + + phys += size; + }return 0 ; }
@@ -148,11 +181,11 @@ int suspend_nvs_save(void)*/ void suspend_nvs_restore (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end;printk (KERN_INFO "PM: Restoring platform NVS memory\n" ); -list_for_each_entry (entry, &nvs_list, node) +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++)if (entry->data)memcpy (entry->kaddr, entry->data, entry->size); }
Quoted 9 lines · Jeff Chua
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 6 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg output containing a (failing) suspend attempt.
Please attach full dmesg, so that I can see the size and address of your system's NVS region.
Attached.
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Thanks,
Rafael
---
Subject: ACPI / PM: Make NVS save/restore code use slightly less memory (test)
Remove the unnecessary field phys_start from struct nvs_page and modify the code in nvs.c to use an array of struct nvs_page objects instead of a list which makes it a bit more straightforward (in addition to saving a little memory).
--- drivers/acpi/nvs.c | 125 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 46 deletions(-)
drivers/acpi/nvs.c +79 -46
@@ -22,15 +22,15 @@*/ struct nvs_page { -unsigned long phys_start;unsigned int size; -void *kaddr; +void __iomem *kaddr;void *data;bool unmap; -struct list_head node; }; -static LIST_HEAD (nvs_list); +static struct nvs_page *nvs; +static unsigned long nvs_start; +static unsigned int nvs_span;/** * suspend_nvs_register - register platform NVS memory region to save
@@ -43,31 +43,40 @@ static LIST_HEAD(nvs_list);*/ int suspend_nvs_register (unsigned long start,unsigned long size) { -struct nvs_page *entry, *next; +struct nvs_page *p, *p_end; +unsigned int head, tail; -while (size >0 ) { -unsigned int nr_bytes; +pr_info ("PM: Registering ACPI NVS region at %lx (%ld bytes)\n" , + start, size); - entry =kzalloc (sizeof (struct nvs_page ),GFP_KERNEL ); -if (!entry) - goto Error; - -list_add_tail (&entry->node, &nvs_list); - entry->phys_start = start; - nr_bytes =PAGE_SIZE - (start & ~PAGE_MASK ); - entry->size = (size < nr_bytes) ? size : nr_bytes; - - start += entry->size; - size -= entry->size; + nvs_start = start; + head =PAGE_SIZE - (start & ~PAGE_MASK ); +if (head) { + nvs_span =1 ; + size -= size > head ? head : size; + }else { + nvs_span =0 ; + head =PAGE_SIZE ; } -return 0 ; + nvs_span += size >>PAGE_SHIFT ; + tail = size & ~PAGE_MASK ; +if (tail) + nvs_span++; +else + tail =PAGE_SIZE ; + + nvs =kzalloc (sizeof (*nvs) * nvs_span,GFP_KERNEL ); +if (!nvs) +return -ENOMEM ; + + p = nvs; + p->size = head; +for (p++, p_end = nvs + nvs_span -1 ; p < p_end; p++) + p->size =PAGE_SIZE ; +if (p_end > nvs) + p_end->size = tail; - Error: -list_for_each_entry_safe (entry, next, &nvs_list, node) { -list_del (&entry->node); -kfree (entry); - } -return -ENOMEM ; +return 0 ; }/**
@@ -75,17 +84,23 @@ int suspend_nvs_register(unsigned long s*/ void suspend_nvs_free (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end; -list_for_each_entry (entry, &nvs_list, node) +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++)if (entry->data) {free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) {if (entry->unmap) { +pr_info ("%s: Unmapping %p\n" , __func__, + entry->kaddr); +iounmap (entry->kaddr); entry->unmap = false; }else { +pr_info ("%s: Releasing %p\n" , __func__, + entry->kaddr); +acpi_os_unmap_memory (entry->kaddr, entry->size); }
@@ -99,9 +114,9 @@ void suspend_nvs_free(void)*/ int suspend_nvs_alloc (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end; -list_for_each_entry (entry, &nvs_list, node) { +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++) { entry->data = (void *)__get_free_page (GFP_KERNEL );if (!entry->data) {suspend_nvs_free ();
@@ -116,26 +131,44 @@ int suspend_nvs_alloc(void)*/ int suspend_nvs_save (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end; +unsigned long phys = nvs_start;printk (KERN_INFO "PM: Saving platform NVS memory\n" ); -list_for_each_entry (entry, &nvs_list, node) -if (entry->data) { -unsigned long phys = entry->phys_start; -unsigned int size = entry->size; +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++) { +unsigned int size = entry->size; +void __iomem *kaddr; - entry->kaddr =acpi_os_get_iomem (phys, size); -if (!entry->kaddr) { - entry->kaddr =acpi_os_ioremap (phys, size); - entry->unmap = true; - } -if (!entry->kaddr) { -suspend_nvs_free (); -return -ENOMEM ; - } -memcpy (entry->data, entry->kaddr, entry->size); +if (!entry->data) { +suspend_nvs_free (); +return -ENOMEM ; + } + +pr_info ("%s: Trying to map %lx, %d\n" , __func__, phys, size); + + kaddr =acpi_os_get_iomem (phys, size); +if (!kaddr) { + kaddr =acpi_os_ioremap (phys, size); + entry->unmap = !!kaddr; + }else { +pr_info ("%s: Got address %p\n" , __func__, kaddr); } + entry->kaddr = kaddr; + +if (!entry->kaddr) { +pr_info ("%s: Mapping failed\n" , __func__); + +suspend_nvs_free (); +return -EIO ; + }else { +pr_info ("%s: Using address %p\n" , __func__, entry->kaddr); + } + +memcpy (entry->data, entry->kaddr, size); + + phys += size; + }return 0 ; }
@@ -148,11 +181,11 @@ int suspend_nvs_save(void)*/ void suspend_nvs_restore (void ) { -struct nvs_page *entry; +struct nvs_page *entry, *end;printk (KERN_INFO "PM: Restoring platform NVS memory\n" ); -list_for_each_entry (entry, &nvs_list, node) +for (entry = nvs, end = nvs + nvs_span; entry < end; entry++)if (entry->data)memcpy (entry->kaddr, entry->data, entry->size); }
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Rafael,
dmesg attached. This time, it worked!
I discovered CONFIG_THINKPAD_ACPI caused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.
Thanks,
Jeff
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Rafael,
dmesg attached. This time, it worked!
I discovered CONFIG_THINKPAD_ACPI caused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.
Thanks,
Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Quoted 8 lines
Rafael,
dmesg attached. This time, it worked!
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.
Here's the dmesg.
Jeff
Quoted 13 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Quoted 8 lines
Rafael,
dmesg attached. This time, it worked!
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.
Here's the dmesg.
Jeff
Quoted 10 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 9 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
Quoted 6 lines
Quoted 2 lines
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Rafael,
dmesg attached. This time, it worked!
Great, thanks a lot!
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.
Well, we should tell the thinkpad_acpi maintainer about that, then (CCed).
It also would be good to file a Bugzilla report about that, if poss.
Rafael
Quoted 10 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 9 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
Quoted 6 lines
Quoted 2 lines
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Rafael,
dmesg attached. This time, it worked!
Great, thanks a lot!
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.
Well, we should tell the thinkpad_acpi maintainer about that, then (CCed).
It also would be good to file a Bugzilla report about that, if poss.
Rafael
Quoted 16 lines · Jeff Chua
Quoted 15 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Rafael,
Quoted 8 lines
Quoted 6 lines
dmesg attached. This time, it worked!
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Here's the dmesg.
Thanks!
Well, and this:
Brought up 4 CPUs
2011-01-22T11:32:56.424328+08:00 boston kernel: Total of 4 processors activated (17023.83 BogoMIPS). 2011-01-22T11:32:56.424329+08:00 boston kernel: PM: Registering ACPI NVS region at bb371000 (528384 bytes) 2011-01-22T11:32:56.424332+08:00 boston kernel: PM: Registering ACPI NVS region at bb668000 (524288 bytes) 2011-01-22T11:32:56.424334+08:00 boston kernel: PM: Registering ACPI NVS region at bb76b000 (49152 bytes) 2011-01-22T11:32:56.424335+08:00 boston kernel: PM: Registering ACPI NVS region at bb77a000 (28672 bytes) 2011-01-22T11:32:56.424337+08:00 boston kernel: PM: Registering ACPI NVS region at bb782000 (36864 bytes) 2011-01-22T11:32:56.424338+08:00 boston kernel: PM: Registering ACPI NVS region at bb78c000 (77824 bytes) 2011-01-22T11:32:56.424339+08:00 boston kernel: NET: Registered protocol family 16
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Rafael
Quoted 16 lines · Jeff Chua
Quoted 15 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 11 lines · Jeff Chua
Quoted 3 lines
2011/1/21 Rafael J. Wysocki <[email protected]>:
Quoted 2 lines
Thanks, but unfortunately this wasn't conclusive. Please apply the patch below instead of the previous one (on top of [1/11] - [11/11]) and collect dmesg
So, below is a replacement for [11/11]. Please test it on top of [1/11] - [10/11] (the current Linus' tree already contains [1/11] and [2/11]) and let me know if it works for you (in either case, please attach dmesg output containing a suspend attempt).
If it works, I'll remove the diagnostic messages and submit along with the rest of the patchset.
Rafael,
Quoted 8 lines
Quoted 6 lines
dmesg attached. This time, it worked!
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Here's the dmesg.
Thanks!
Well, and this:
Brought up 4 CPUs
2011-01-22T11:32:56.424328+08:00 boston kernel: Total of 4 processors activated (17023.83 BogoMIPS). 2011-01-22T11:32:56.424329+08:00 boston kernel: PM: Registering ACPI NVS region at bb371000 (528384 bytes) 2011-01-22T11:32:56.424332+08:00 boston kernel: PM: Registering ACPI NVS region at bb668000 (524288 bytes) 2011-01-22T11:32:56.424334+08:00 boston kernel: PM: Registering ACPI NVS region at bb76b000 (49152 bytes) 2011-01-22T11:32:56.424335+08:00 boston kernel: PM: Registering ACPI NVS region at bb77a000 (28672 bytes) 2011-01-22T11:32:56.424337+08:00 boston kernel: PM: Registering ACPI NVS region at bb782000 (36864 bytes) 2011-01-22T11:32:56.424338+08:00 boston kernel: PM: Registering ACPI NVS region at bb78c000 (77824 bytes) 2011-01-22T11:32:56.424339+08:00 boston kernel: NET: Registered protocol family 16
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Rafael
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 4 lines · Jeff Chua
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
Thanks,
Jeff
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 4 lines · Jeff Chua
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
Thanks,
Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 4 lines · Jeff Chua
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
No, that doesn't matter. NVS regions are just sitting there regardless of what happens at run time.
Thanks,
Rafael
Quoted 8 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 4 lines · Jeff Chua
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
No, that doesn't matter. NVS regions are just sitting there regardless of what happens at run time.
Thanks,
Rafael
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 1 line · Jeff Chua
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
No, that doesn't matter. NVS regions are just sitting there regardless of what happens at run time.
Strange. If I didn't offline, it hanged during suspend even without thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.
Jeff
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 1 line · Jeff Chua
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
No, that doesn't matter. NVS regions are just sitting there regardless of what happens at run time.
Strange. If I didn't offline, it hanged during suspend even without thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.
Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).
What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
Did something change in that area that caused the driver to hang? A pointer to the ML threads, documentation, or patchset/git commit with those changes would be enough answer, and I will pursue it from there.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).
What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
Did something change in that area that caused the driver to hang? A pointer to the ML threads, documentation, or patchset/git commit with those changes would be enough answer, and I will pursue it from there.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 11 lines · Jeff Chua
Quoted 10 lines · Rafael J. Wysocki
Quoted 8 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 4 lines · Jeff Chua
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
Quoted 7 lines
Quoted 2 lines
No, that doesn't matter. NVS regions are just sitting there regardless of what happens at run time.
Strange. If I didn't offline, it hanged during suspend even without
thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.
That means there's a problem in the CPU hotplug code that manifests itslef during suspend. Is this 100% reproducible? Did it happen with 2.6.37?
Rafael
Quoted 11 lines · Jeff Chua
Quoted 10 lines · Rafael J. Wysocki
Quoted 8 lines · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 4 lines · Jeff Chua
means that my patch [11/11] _and_ the replacement are totally wrong, because you have _multiple_ NVS regions. That really helped, thanks a lot.
Would it be different if I offline all CPUs before suspending to ram? It seems to help with suspending to disk.
Quoted 7 lines
Quoted 2 lines
No, that doesn't matter. NVS regions are just sitting there regardless of what happens at run time.
Strange. If I didn't offline, it hanged during suspend even without
thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.
That means there's a problem in the CPU hotplug code that manifests itslef during suspend. Is this 100% reproducible? Did it happen with 2.6.37?
Rafael
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
No difference. Basically, there are two differences between suspend and hibernation, as far as drivers are concerned:
(1) It's better to use the ->freeze()/->thaw() and ->poweroff()/->restore() callbacks for hibernation.
(2) It may be _much_ more difficult to get free memory during hibernation (so theoretically attempts to get memory during hibernation are more likely to block).
Quoted 3 lines
Did something change in that area that caused the driver to hang? A pointer to the ML threads, documentation, or patchset/git commit with those changes would be enough answer, and I will pursue it from there.
I'm not aware of any such changes.
Besides, the problem reported by Jeff seems to be caused by CPU hotplug.
Thanks,
Rafael
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
No difference. Basically, there are two differences between suspend and hibernation, as far as drivers are concerned:
(1) It's better to use the ->freeze()/->thaw() and ->poweroff()/->restore() callbacks for hibernation.
(2) It may be _much_ more difficult to get free memory during hibernation (so theoretically attempts to get memory during hibernation are more likely to block).
Quoted 3 lines
Did something change in that area that caused the driver to hang? A pointer to the ML threads, documentation, or patchset/git commit with those changes would be enough answer, and I will pursue it from there.
I'm not aware of any such changes.
Besides, the problem reported by Jeff seems to be caused by CPU hotplug.
Thanks,
Rafael
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
Quoted 7 lines
No difference. Basically, there are two differences between suspend and hibernation, as far as drivers are concerned:
(1) It's better to use the ->freeze()/->thaw() and ->poweroff()/->restore() callbacks for hibernation.
(2) It may be _much_ more difficult to get free memory during hibernation (so theoretically attempts to get memory during hibernation are more likely to block).
So, if there is nothing wrong with mutex use by itself...
Thinkpad-acpi calls the thinkpad firmware (using normal ACPI method calls), which does SMI traps into the SMBIOS to do whatever it wants done. And that includes writing to the NVS (both the peecee RTC CMOS, and ACPI-backed "NVS").
Quoted 1 line
Besides, the problem reported by Jeff seems to be caused by CPU hotplug.
Something weird going on with CPU hotplug could throw Lenovo's way-too-complex-for-comfort SMM firmware out of wack alright.
That can be checked. Lobotomize the driver so that it does not do the acpi calls in the suspend path (but keep everything else). If it still locks, it is not the firmware.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
Quoted 7 lines
No difference. Basically, there are two differences between suspend and hibernation, as far as drivers are concerned:
(1) It's better to use the ->freeze()/->thaw() and ->poweroff()/->restore() callbacks for hibernation.
(2) It may be _much_ more difficult to get free memory during hibernation (so theoretically attempts to get memory during hibernation are more likely to block).
So, if there is nothing wrong with mutex use by itself...
Thinkpad-acpi calls the thinkpad firmware (using normal ACPI method calls), which does SMI traps into the SMBIOS to do whatever it wants done. And that includes writing to the NVS (both the peecee RTC CMOS, and ACPI-backed "NVS").
Quoted 1 line
Besides, the problem reported by Jeff seems to be caused by CPU hotplug.
Something weird going on with CPU hotplug could throw Lenovo's way-too-complex-for-comfort SMM firmware out of wack alright.
That can be checked. Lobotomize the driver so that it does not do the acpi calls in the suspend path (but keep everything else). If it still locks, it is not the firmware.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Jeff Chua
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jeff Chua
Strange. If I didn't offline, it hanged during suspend even without
thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.That means there's a problem in the CPU hotplug code that manifests itslef during suspend. Is this 100% reproducible? Did it happen with 2.6.37?
Quite reproducible. Once "something" trigger the hang, no matter how I reset the system, it'll still hang at suspend. And at other times, it just worked. I tried many things, but it seems if I go back to use an earlier version (2.6.37 works perfectly for suspend-to-disk/mem), then switched back to the newer broken version, it'll work for a few cycles before hanging at suspend-to-disk.
I guess it could be CPU hotplug, and may be that thinkpad-acpi is triggering the broken cpu hotplug to fail.
Jeff
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Jeff Chua
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jeff Chua
Strange. If I didn't offline, it hanged during suspend even without
thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.That means there's a problem in the CPU hotplug code that manifests itslef during suspend. Is this 100% reproducible? Did it happen with 2.6.37?
Quite reproducible. Once "something" trigger the hang, no matter how I reset the system, it'll still hang at suspend. And at other times, it just worked. I tried many things, but it seems if I go back to use an earlier version (2.6.37 works perfectly for suspend-to-disk/mem), then switched back to the newer broken version, it'll work for a few cycles before hanging at suspend-to-disk.
I guess it could be CPU hotplug, and may be that thinkpad-acpi is triggering the broken cpu hotplug to fail.
Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 21 lines · Jeff Chua
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Jeff Chua
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jeff Chua
Strange. If I didn't offline, it hanged during suspend even without
thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.That means there's a problem in the CPU hotplug code that manifests itslef during suspend. Is this 100% reproducible? Did it happen with 2.6.37?
Quite reproducible. Once "something" trigger the hang, no matter how I reset the system, it'll still hang at suspend. And at other times, it just worked. I tried many things, but it seems if I go back to use an earlier version (2.6.37 works perfectly for suspend-to-disk/mem), then switched back to the newer broken version, it'll work for a few cycles before hanging at suspend-to-disk.
Quoted 2 lines
I guess it could be CPU hotplug, and may be that thinkpad-acpi is triggering the broken cpu hotplug to fail.
So please try with this commit on top:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ec30f343d61391ab23705e50a525da1d55395780
Thanks,
Rafael
Quoted 21 lines · Jeff Chua
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Jeff Chua
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Jeff Chua
2011/1/22 Rafael J. Wysocki <[email protected]>:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Jeff Chua
Strange. If I didn't offline, it hanged during suspend even without
thinkpad_acpi. I could see that the suspend code does the offline automatically, but executing the offline before calling suspend makes it no hanging.That means there's a problem in the CPU hotplug code that manifests itslef during suspend. Is this 100% reproducible? Did it happen with 2.6.37?
Quite reproducible. Once "something" trigger the hang, no matter how I reset the system, it'll still hang at suspend. And at other times, it just worked. I tried many things, but it seems if I go back to use an earlier version (2.6.37 works perfectly for suspend-to-disk/mem), then switched back to the newer broken version, it'll work for a few cycles before hanging at suspend-to-disk.
Quoted 2 lines
I guess it could be CPU hotplug, and may be that thinkpad-acpi is triggering the broken cpu hotplug to fail.
So please try with this commit on top:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ec30f343d61391ab23705e50a525da1d55395780
Thanks,
Rafael
Quoted 27 lines · Henrique de Moraes Holschuh
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
Quoted 7 lines
No difference. Basically, there are two differences between suspend and hibernation, as far as drivers are concerned:
(1) It's better to use the ->freeze()/->thaw() and ->poweroff()/->restore() callbacks for hibernation.
(2) It may be _much_ more difficult to get free memory during hibernation (so theoretically attempts to get memory during hibernation are more likely to block).So, if there is nothing wrong with mutex use by itself...
Thinkpad-acpi calls the thinkpad firmware (using normal ACPI method calls), which does SMI traps into the SMBIOS to do whatever it wants done. And that includes writing to the NVS (both the peecee RTC CMOS, and ACPI-backed "NVS").
Quoted 8 lines
Quoted 1 line
Besides, the problem reported by Jeff seems to be caused by CPU hotplug.
Something weird going on with CPU hotplug could throw Lenovo's way-too-complex-for-comfort SMM firmware out of wack alright.
That can be checked. Lobotomize the driver so that it does not do the acpi calls in the suspend path (but keep everything else). If it still locks, it is not the firmware.
It turns out there's a bug in intel_idle causing people a lot of pain with CPU hotplugging. Should be fixed now it the Linus' tree.
Thanks,
Rafael
Quoted 27 lines · Henrique de Moraes Holschuh
Quoted 11 lines · Rafael J. Wysocki
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines
I discovered
CONFIG_THINKPAD_ACPIcaused suspend-to-disk to hang. I need the Thinkpad ACPI to control the fan and bluetooth. It looks like the thinkpad acpi is trying acquire locks while suspending. Disabling cmos, light, led and hotkeys makes suspend-to-disk works again.Well, we should tell the
thinkpad_acpimaintainer about that, then (CCed).What are the requirements re. mutexes for sleep-to-disk versus sleep-to-ram?
Quoted 7 lines
No difference. Basically, there are two differences between suspend and hibernation, as far as drivers are concerned:
(1) It's better to use the ->freeze()/->thaw() and ->poweroff()/->restore() callbacks for hibernation.
(2) It may be _much_ more difficult to get free memory during hibernation (so theoretically attempts to get memory during hibernation are more likely to block).So, if there is nothing wrong with mutex use by itself...
Thinkpad-acpi calls the thinkpad firmware (using normal ACPI method calls), which does SMI traps into the SMBIOS to do whatever it wants done. And that includes writing to the NVS (both the peecee RTC CMOS, and ACPI-backed "NVS").
Quoted 8 lines
Quoted 1 line
Besides, the problem reported by Jeff seems to be caused by CPU hotplug.
Something weird going on with CPU hotplug could throw Lenovo's way-too-complex-for-comfort SMM firmware out of wack alright.
That can be checked. Lobotomize the driver so that it does not do the acpi calls in the suspend path (but keep everything else). If it still locks, it is not the firmware.
It turns out there's a bug in intel_idle causing people a lot of pain with CPU hotplugging. Should be fixed now it the Linus' tree.
Thanks,
Rafael
cover ACPI: Fixes and cleanups related to iomaps management (v2)
In reply to Rafael J. WysockiHi Len,
The following series of patches implements some fixes of the ACPI iomaps management. I found the problems trying to resolve the issue of creating iomaps of regions that have been mapped already when we save the NVS region.
To me, they are not extremely urgent, because the related issues are generally long-standing, but some bugs addressed by them (especially [1/9]) may be actively hurting people right now, so they look suitable for .38 as well. This is your call, though.
[1/8] - Fix routines for reading and writing iomem (RCU bug; new version of the
patch).
[2/8] - (cleanup) Do not export local functions in osl.c (this one is the same
as https://patchwork.kernel.org/patch/491551/).
[3/8] - Use a mutex (instead of a spinlock) for the locking of iomap
manipulations in osl.c (same as
https://patchwork.kernel.org/patch/491751/).
[4/8] - Avoid unnecessary walks of the list of iomaps in osl.c (same as
https://patchwork.kernel.org/patch/491671/).
[5/8] - Avoid creating iomaps for regions that have been mapped already (same
as https://patchwork.kernel.org/patch/491741/).
[6/8] - Replace krefs used for iomap refcounting with simple reference
counters (they are manipulated under a lock anyway; same as
https://patchwork.kernel.org/patch/491681/).
[7/8] - Introduce function for getting a reference to an ACPI iomap (to be
used by the NVS save/restore code; same as
https://patchwork.kernel.org/patch/491701/).
[8/8] - Make the NVS code use existing iomaps if possible (new version).
The patches have been tested on HP nx6325, Toshiba Portege R500 and Acer Ferrari One without causing any visible problems to happen.
Thanks,
Rafael
cover ACPI: Fixes and cleanups related to iomaps management (v2)
In reply to Rafael J. WysockiHi Len,
The following series of patches implements some fixes of the ACPI iomaps management. I found the problems trying to resolve the issue of creating iomaps of regions that have been mapped already when we save the NVS region.
To me, they are not extremely urgent, because the related issues are generally long-standing, but some bugs addressed by them (especially [1/9]) may be actively hurting people right now, so they look suitable for .38 as well. This is your call, though.
[1/8] - Fix routines for reading and writing iomem (RCU bug; new version of the
patch).
[2/8] - (cleanup) Do not export local functions in osl.c (this one is the same
as https://patchwork.kernel.org/patch/491551/).
[3/8] - Use a mutex (instead of a spinlock) for the locking of iomap
manipulations in osl.c (same as
https://patchwork.kernel.org/patch/491751/).
[4/8] - Avoid unnecessary walks of the list of iomaps in osl.c (same as
https://patchwork.kernel.org/patch/491671/).
[5/8] - Avoid creating iomaps for regions that have been mapped already (same
as https://patchwork.kernel.org/patch/491741/).
[6/8] - Replace krefs used for iomap refcounting with simple reference
counters (they are manipulated under a lock anyway; same as
https://patchwork.kernel.org/patch/491681/).
[7/8] - Introduce function for getting a reference to an ACPI iomap (to be
used by the NVS save/restore code; same as
https://patchwork.kernel.org/patch/491701/).
[8/8] - Make the NVS code use existing iomaps if possible (new version).
The patches have been tested on HP nx6325, Toshiba Portege R500 and Acer Ferrari One without causing any visible problems to happen.
Thanks,
Rafael
PATCH 1/8 ACPI: Fix acpi_os_read_memory() and acpi_os_write_memory() (v2)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_read_memory() and acpi_os_write_memory() do two wrong things. First, they shouldn't call rcu_read_unlock() before the looked up address is actually used for I/O, because in that case the iomap it belongs to may be removed before the I/O is done. Second, if they have to create a new mapping, they should check the returned virtual address and tell the caller that the operation failed if it is NULL (in fact, I think they even should not attempt to map an address that's not present in one of the existing ACPI iomaps, because that may cause problems to happen when they are called from nonpreemptible context and their callers ought to know what they are doing and map the requisite memory regions beforehand).
Make these functions call rcu_read_unlock() when the I/O is complete (or if it's necessary to map the given address "on the fly") and return an error code if the requested physical address is not present in the existing ACPI iomaps and cannot be mapped.
--- drivers/acpi/osl.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/acpi/osl.c +18 -7
@@ -636,17 +636,21 @@ EXPORT_SYMBOL(acpi_os_write_port);acpi_status acpi_os_read_memory (acpi_physical_address phys_addr,u32 * value,u32 width) { -u32 dummy;void __iomem *virt_addr; -int size = width /8 , unmap =0 ; +unsigned int size = width /8 ; +bool unmap = false; +u32 dummy;rcu_read_lock (); virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock ();if (!virt_addr) { +rcu_read_unlock (); virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +if (!virt_addr) +return AE_BAD_ADDRESS ; + unmap = true; } +if (!value) value = &dummy;
@@ -666,6 +670,8 @@ acpi_os_read_memory(acpi_physical_addresif (unmap)iounmap (virt_addr); +else +rcu_read_unlock ();return AE_OK ; }
@@ -674,14 +680,17 @@ acpi_status acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) { void __iomem *virt_addr; -int size = width /8 , unmap =0 ; +unsigned int size = width /8 ; +bool unmap = false;rcu_read_lock (); virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock ();if (!virt_addr) { +rcu_read_unlock (); virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +if (!virt_addr) +return AE_BAD_ADDRESS ; + unmap = true; }switch (width) {
@@ -700,6 +709,8 @@ acpi_os_write_memory(acpi_physical_addreif (unmap)iounmap (virt_addr); +else +rcu_read_unlock ();return AE_OK ; }
PATCH 2/8 ACPI: Do not export functions that are only used in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_map_generic_address() and acpi_os_unmap_generic_address() are only used in drivers/acpi/osl.c, so make them static and remove the extern definitions of them from include/linux/acpi_io.h.
--- drivers/acpi/osl.c | 6 ++---- include/linux/acpi_io.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/acpi/osl.c +2 -4
@@ -397,7 +397,7 @@ void __init early_acpi_os_unmap_memory(v__acpi_unmap_table (virt, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr) +static int acpi_os_map_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;
@@ -413,9 +413,8 @@ int acpi_os_map_generic_address(struct areturn 0 ; } -EXPORT_SYMBOL_GPL (acpi_os_map_generic_address); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) +static void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;unsigned long flags;
@@ -433,7 +432,6 @@ void acpi_os_unmap_generic_address(strucacpi_os_unmap_memory (virt, size); } -EXPORT_SYMBOL_GPL (acpi_os_unmap_generic_address);#ifdef ACPI_FUTURE_USAGE acpi_status
include/linux/acpi_io.h +0 -3
@@ -10,7 +10,4 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); -#endif
PATCH 3/8 ACPI: Change acpi_ioremap_lock into a mutex
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
There's no reason why acpi_ioremap_lock has to be a spinlock, because all of the functions it is used in may sleep anyway and there's no reason why it should be locked with interrupts off. Use a mutex instead (that's going to allow us to put some more operations under the lock later).
--- drivers/acpi/osl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/acpi/osl.c +9 -12
@@ -109,7 +109,7 @@ struct acpi_ioremap { };static LIST_HEAD (acpi_ioremaps); -static DEFINE_SPINLOCK (acpi_ioremap_lock); +static DEFINE_MUTEX (acpi_ioremap_lock);static void __init acpi_osi_setup_late (void );
@@ -303,7 +303,6 @@ void __iomem *__init_refok acpi_os_map_memory(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map, *tmp_map; -unsigned long flags;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -334,18 +333,18 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock);/* Check if page has already been mapped. */ tmp_map =acpi_map_lookup (phys, size);if (tmp_map) {kref_get (&tmp_map->ref); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);iounmap (map->virt);kfree (map);return tmp_map->virt + (phys - tmp_map->phys); }list_add_tail_rcu (&map->list, &acpi_ioremaps); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }
@@ -362,7 +361,6 @@ static void acpi_kref_del_iomap(struct kvoid __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -unsigned long flags;int del;if (!acpi_gbl_permanent_mmap) {
@@ -370,17 +368,17 @@ void __ref acpi_os_unmap_memory(void __ireturn ; } -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); map =acpi_map_lookup_virt (virt, size);if (!map) { -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock); printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt);dump_stack ();return ; } del =kref_put (&map->ref, acpi_kref_del_iomap); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);if (!del)return ;
@@ -417,7 +415,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt; -unsigned long flags;acpi_size size = addr->bit_width /8 ;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )
@@ -426,9 +423,9 @@ static void acpi_os_unmap_generic_addresif (!addr->address || !addr->bit_width)return ; -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); virt =acpi_map_vaddr_lookup (addr->address, size); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);acpi_os_unmap_memory (virt, size); }
PATCH 4/8 ACPI: Avoid walking the list of memory mappings in osl.c twice in a row
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make acpi_os_unmap_generic_address() use acpi_map_lookup() to find the desired iomap and drop the reference to it directly (and eventually remove it if necessary) instead of calling acpi_os_unmap_memory(), which requires us to walk the list of ACPI iomaps twice in a row (first, to get the virtual address associated with the iomap and second, to get the iomap itself).
--- drivers/acpi/osl.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +20 -13
@@ -358,6 +358,13 @@ static void acpi_kref_del_iomap(struct klist_del_rcu (&map->list); } +static void acpi_os_remove_map (struct acpi_ioremap *map) +{ +synchronize_rcu (); +iounmap (map->virt); +kfree (map); +} +void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map;
@@ -372,20 +379,14 @@ void __ref acpi_os_unmap_memory(void __i map =acpi_map_lookup_virt (virt, size);if (!map) {mutex_unlock (&acpi_ioremap_lock); - printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); -dump_stack (); +WARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -if (!del) -return ; - -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (del) +acpi_os_remove_map (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -414,8 +415,8 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) { -void __iomem *virt; -acpi_size size = addr->bit_width /8 ; +struct acpi_ioremap *map; +int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -424,10 +425,16 @@ static void acpi_os_unmap_generic_addresreturn ;mutex_lock (&acpi_ioremap_lock); - virt =acpi_map_vaddr_lookup (addr->address, size); + map =acpi_map_lookup (addr->address, addr->bit_width /8 ); +if (!map) { +mutex_unlock (&acpi_ioremap_lock); +return ; + } + del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -acpi_os_unmap_memory (virt, size); +if (del) +acpi_os_remove_map (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 5/8 ACPI: Make acpi_os_map_memory() avoid creating unnecessary mappings
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify acpi_os_map_memory() so that it doesn't call acpi_os_ioremap() unconditionally every time it is executed (except when acpi_gbl_permanent_mmap is unset), which pretty much defeats the purpose of maintaining the list of ACPI iomaps in osl.c.
--- drivers/acpi/osl.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +15 -13
@@ -302,7 +302,7 @@ acpi_map_lookup_virt(void __iomem *virt, void __iomem *__init_refokacpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -struct acpi_ioremap *map, *tmp_map; +struct acpi_ioremap *map;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -315,14 +315,25 @@ acpi_os_map_memory(acpi_physical_addressif (!acpi_gbl_permanent_mmap)return __acpi_map_table ((unsigned long )phys, size); +mutex_lock (&acpi_ioremap_lock); +/* Check if there's a suitable mapping already. */ + map =acpi_map_lookup (phys, size); +if (map) { +kref_get (&map->ref); + goto out; + } + map =kzalloc (sizeof (*map),GFP_KERNEL ); -if (!map) +if (!map) { +mutex_unlock (&acpi_ioremap_lock);return NULL ; + } pg_off =round_down (phys,PAGE_SIZE ); pg_sz =round_up (phys + size,PAGE_SIZE ) - pg_off; virt =acpi_os_ioremap (pg_off, pg_sz);if (!virt) { +mutex_unlock (&acpi_ioremap_lock);kfree (map);return NULL ; }
@@ -333,19 +344,10 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -mutex_lock (&acpi_ioremap_lock); -/* Check if page has already been mapped. */ - tmp_map =acpi_map_lookup (phys, size); -if (tmp_map) { -kref_get (&tmp_map->ref); -mutex_unlock (&acpi_ioremap_lock); -iounmap (map->virt); -kfree (map); -return tmp_map->virt + (phys - tmp_map->phys); - }list_add_tail_rcu (&map->list, &acpi_ioremaps); -mutex_unlock (&acpi_ioremap_lock); + out: +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }EXPORT_SYMBOL_GPL (acpi_os_map_memory);
PATCH 5/8 ACPI: Make acpi_os_map_memory() avoid creating unnecessary mappings
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify acpi_os_map_memory() so that it doesn't call acpi_os_ioremap() unconditionally every time it is executed (except when acpi_gbl_permanent_mmap is unset), which pretty much defeats the purpose of maintaining the list of ACPI iomaps in osl.c.
--- drivers/acpi/osl.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +15 -13
@@ -302,7 +302,7 @@ acpi_map_lookup_virt(void __iomem *virt, void __iomem *__init_refokacpi_os_map_memory (acpi_physical_address phys,acpi_size size) { -struct acpi_ioremap *map, *tmp_map; +struct acpi_ioremap *map;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -315,14 +315,25 @@ acpi_os_map_memory(acpi_physical_addressif (!acpi_gbl_permanent_mmap)return __acpi_map_table ((unsigned long )phys, size); +mutex_lock (&acpi_ioremap_lock); +/* Check if there's a suitable mapping already. */ + map =acpi_map_lookup (phys, size); +if (map) { +kref_get (&map->ref); + goto out; + } + map =kzalloc (sizeof (*map),GFP_KERNEL ); -if (!map) +if (!map) { +mutex_unlock (&acpi_ioremap_lock);return NULL ; + } pg_off =round_down (phys,PAGE_SIZE ); pg_sz =round_up (phys + size,PAGE_SIZE ) - pg_off; virt =acpi_os_ioremap (pg_off, pg_sz);if (!virt) { +mutex_unlock (&acpi_ioremap_lock);kfree (map);return NULL ; }
@@ -333,19 +344,10 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -mutex_lock (&acpi_ioremap_lock); -/* Check if page has already been mapped. */ - tmp_map =acpi_map_lookup (phys, size); -if (tmp_map) { -kref_get (&tmp_map->ref); -mutex_unlock (&acpi_ioremap_lock); -iounmap (map->virt); -kfree (map); -return tmp_map->virt + (phys - tmp_map->phys); - }list_add_tail_rcu (&map->list, &acpi_ioremaps); -mutex_unlock (&acpi_ioremap_lock); + out: +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }EXPORT_SYMBOL_GPL (acpi_os_map_memory);
PATCH 6/8 ACPI: Do not use krefs under a mutex in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The reference counting of ACPI iomaps is carried out entirely under acpi_ioremap_lock, so it is sufficient to use simple counters instead of krefs for this purpose.
--- drivers/acpi/osl.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/acpi/osl.c +16 -20
@@ -105,7 +105,7 @@ struct acpi_ioremap {void __iomem *virt;acpi_physical_address phys;acpi_size size; -struct kref ref; +unsigned long refcount; };static LIST_HEAD (acpi_ioremaps);
@@ -319,7 +319,7 @@ acpi_os_map_memory(acpi_physical_address/* Check if there's a suitable mapping already. */ map =acpi_map_lookup (phys, size);if (map) { -kref_get (&map->ref); + map->refcount++; goto out; }
@@ -342,7 +342,7 @@ acpi_os_map_memory(acpi_physical_address map->virt = virt; map->phys = pg_off; map->size = pg_sz; -kref_init (&map->ref); + map->refcount =1 ;list_add_tail_rcu (&map->list, &acpi_ioremaps);
@@ -352,25 +352,24 @@ acpi_os_map_memory(acpi_physical_address }EXPORT_SYMBOL_GPL (acpi_os_map_memory); -static void acpi_kref_del_iomap (struct kref *ref) +static void acpi_os_drop_map_ref (struct acpi_ioremap *map) { -struct acpi_ioremap *map; - - map = container_of(ref, struct acpi_ioremap, ref); -list_del_rcu (&map->list); +if (!--map->refcount) +list_del_rcu (&map->list); } -static void acpi_os_remove_map (struct acpi_ioremap *map) +static void acpi_os_map_cleanup (struct acpi_ioremap *map) { -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (!map->refcount) { +synchronize_rcu (); +iounmap (map->virt); +kfree (map); + } }void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -int del;if (!acpi_gbl_permanent_mmap) {__acpi_unmap_table (virt, size);
@@ -384,11 +383,10 @@ void __ref acpi_os_unmap_memory(void __iWARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -418,7 +416,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {struct acpi_ioremap *map; -int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -432,11 +429,10 @@ static void acpi_os_unmap_generic_addresmutex_unlock (&acpi_ioremap_lock);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 7/8 ACPI: Introduce acpi_os_get_iomem()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Introduce function acpi_os_get_iomem() that may be used by its callers to get a reference to an ACPI iomap.
--- drivers/acpi/osl.c | 16 ++++++++++++++++ include/linux/acpi_io.h | 2 ++ 2 files changed, 18 insertions(+)
drivers/acpi/osl.c +16 -0
@@ -285,6 +285,22 @@ acpi_map_vaddr_lookup(acpi_physical_addrreturn NULL ; } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size) +{ +struct acpi_ioremap *map; +void __iomem *virt =NULL ; + +mutex_lock (&acpi_ioremap_lock); + map =acpi_map_lookup (phys, size); +if (map) { + virt = map->virt + (phys - map->phys); + map->refcount++; + } +mutex_unlock (&acpi_ioremap_lock); +return virt; +} +EXPORT_SYMBOL_GPL (acpi_os_get_iomem); +/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap *acpi_map_lookup_virt (void __iomem *virt,acpi_size size)
include/linux/acpi_io.h +2 -0
@@ -10,4 +10,6 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size); +#endif
PATCH 8/8 ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify the NVS save/restore code to use acpi_os_get_iomem() and acpi_os_unmap_memory() to acquire and release references to ACPI iomaps, respectively. If there's no ACPI iomap corresponding to the given NVS page, acpi_os_ioremap() is used to map that page and iounmap() is used to unmap it during resume. [If the page is not present in the ACPI iomaps already, it doesn't make sense to add its mapping to the list of ACPI iomaps, because it's going to be thrown away during the subsequent resume anyway.]
Testing on my HP nx6325 shows that approx. 90% of the NVS pages have already been mapped by ACPI before suspend and are present in the ACPI iomaps on this box, so this change appears to be the right thing to do in general.
--- drivers/acpi/nvs.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/nvs.c +19 -3
@@ -26,6 +26,7 @@ struct nvs_page {unsigned int size;void *kaddr;void *data; +bool unmap;struct list_head node; };
@@ -44,6 +45,9 @@ int suspend_nvs_register(unsigned long s {struct nvs_page *entry, *next; +pr_info ("PM: Registering ACPI NVS region at %lx (%ld bytes)\n" , + start, size); +while (size >0 ) {unsigned int nr_bytes;
@@ -81,7 +85,13 @@ void suspend_nvs_free(void)free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) { -iounmap (entry->kaddr); +if (entry->unmap) { +iounmap (entry->kaddr); + entry->unmap = false; + }else { +acpi_os_unmap_memory (entry->kaddr, + entry->size); + } entry->kaddr =NULL ; } }
@@ -115,8 +125,14 @@ int suspend_nvs_save(void)list_for_each_entry (entry, &nvs_list, node)if (entry->data) { - entry->kaddr =acpi_os_ioremap (entry->phys_start, - entry->size); +unsigned long phys = entry->phys_start; +unsigned int size = entry->size; + + entry->kaddr =acpi_os_get_iomem (phys, size); +if (!entry->kaddr) { + entry->kaddr =acpi_os_ioremap (phys, size); + entry->unmap = !!entry->kaddr; + }if (!entry->kaddr) {suspend_nvs_free ();return -ENOMEM ;
PATCH 2/8 ACPI: Do not export functions that are only used in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_map_generic_address() and acpi_os_unmap_generic_address() are only used in drivers/acpi/osl.c, so make them static and remove the extern definitions of them from include/linux/acpi_io.h.
--- drivers/acpi/osl.c | 6 ++---- include/linux/acpi_io.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/acpi/osl.c +2 -4
@@ -397,7 +397,7 @@ void __init early_acpi_os_unmap_memory(v__acpi_unmap_table (virt, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr) +static int acpi_os_map_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;
@@ -413,9 +413,8 @@ int acpi_os_map_generic_address(struct areturn 0 ; } -EXPORT_SYMBOL_GPL (acpi_os_map_generic_address); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) +static void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt;unsigned long flags;
@@ -433,7 +432,6 @@ void acpi_os_unmap_generic_address(strucacpi_os_unmap_memory (virt, size); } -EXPORT_SYMBOL_GPL (acpi_os_unmap_generic_address);#ifdef ACPI_FUTURE_USAGE acpi_status
include/linux/acpi_io.h +0 -3
@@ -10,7 +10,4 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } -int acpi_os_map_generic_address (struct acpi_generic_address *addr); -void acpi_os_unmap_generic_address (struct acpi_generic_address *addr); -#endif
PATCH 4/8 ACPI: Avoid walking the list of memory mappings in osl.c twice in a row
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make acpi_os_unmap_generic_address() use acpi_map_lookup() to find the desired iomap and drop the reference to it directly (and eventually remove it if necessary) instead of calling acpi_os_unmap_memory(), which requires us to walk the list of ACPI iomaps twice in a row (first, to get the virtual address associated with the iomap and second, to get the iomap itself).
--- drivers/acpi/osl.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/acpi/osl.c +20 -13
@@ -358,6 +358,13 @@ static void acpi_kref_del_iomap(struct klist_del_rcu (&map->list); } +static void acpi_os_remove_map (struct acpi_ioremap *map) +{ +synchronize_rcu (); +iounmap (map->virt); +kfree (map); +} +void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map;
@@ -372,20 +379,14 @@ void __ref acpi_os_unmap_memory(void __i map =acpi_map_lookup_virt (virt, size);if (!map) {mutex_unlock (&acpi_ioremap_lock); - printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt); -dump_stack (); +WARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -if (!del) -return ; - -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (del) +acpi_os_remove_map (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -414,8 +415,8 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) { -void __iomem *virt; -acpi_size size = addr->bit_width /8 ; +struct acpi_ioremap *map; +int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -424,10 +425,16 @@ static void acpi_os_unmap_generic_addresreturn ;mutex_lock (&acpi_ioremap_lock); - virt =acpi_map_vaddr_lookup (addr->address, size); + map =acpi_map_lookup (addr->address, addr->bit_width /8 ); +if (!map) { +mutex_unlock (&acpi_ioremap_lock); +return ; + } + del =kref_put (&map->ref, acpi_kref_del_iomap);mutex_unlock (&acpi_ioremap_lock); -acpi_os_unmap_memory (virt, size); +if (del) +acpi_os_remove_map (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 1/8 ACPI: Fix acpi_os_read_memory() and acpi_os_write_memory() (v2)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The functions acpi_os_read_memory() and acpi_os_write_memory() do two wrong things. First, they shouldn't call rcu_read_unlock() before the looked up address is actually used for I/O, because in that case the iomap it belongs to may be removed before the I/O is done. Second, if they have to create a new mapping, they should check the returned virtual address and tell the caller that the operation failed if it is NULL (in fact, I think they even should not attempt to map an address that's not present in one of the existing ACPI iomaps, because that may cause problems to happen when they are called from nonpreemptible context and their callers ought to know what they are doing and map the requisite memory regions beforehand).
Make these functions call rcu_read_unlock() when the I/O is complete (or if it's necessary to map the given address "on the fly") and return an error code if the requested physical address is not present in the existing ACPI iomaps and cannot be mapped.
--- drivers/acpi/osl.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/acpi/osl.c +18 -7
@@ -636,17 +636,21 @@ EXPORT_SYMBOL(acpi_os_write_port);acpi_status acpi_os_read_memory (acpi_physical_address phys_addr,u32 * value,u32 width) { -u32 dummy;void __iomem *virt_addr; -int size = width /8 , unmap =0 ; +unsigned int size = width /8 ; +bool unmap = false; +u32 dummy;rcu_read_lock (); virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock ();if (!virt_addr) { +rcu_read_unlock (); virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +if (!virt_addr) +return AE_BAD_ADDRESS ; + unmap = true; } +if (!value) value = &dummy;
@@ -666,6 +670,8 @@ acpi_os_read_memory(acpi_physical_addresif (unmap)iounmap (virt_addr); +else +rcu_read_unlock ();return AE_OK ; }
@@ -674,14 +680,17 @@ acpi_status acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) { void __iomem *virt_addr; -int size = width /8 , unmap =0 ; +unsigned int size = width /8 ; +bool unmap = false;rcu_read_lock (); virt_addr =acpi_map_vaddr_lookup (phys_addr, size); -rcu_read_unlock ();if (!virt_addr) { +rcu_read_unlock (); virt_addr =acpi_os_ioremap (phys_addr, size); - unmap =1 ; +if (!virt_addr) +return AE_BAD_ADDRESS ; + unmap = true; }switch (width) {
@@ -700,6 +709,8 @@ acpi_os_write_memory(acpi_physical_addreif (unmap)iounmap (virt_addr); +else +rcu_read_unlock ();return AE_OK ; }
PATCH 3/8 ACPI: Change acpi_ioremap_lock into a mutex
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
There's no reason why acpi_ioremap_lock has to be a spinlock, because all of the functions it is used in may sleep anyway and there's no reason why it should be locked with interrupts off. Use a mutex instead (that's going to allow us to put some more operations under the lock later).
--- drivers/acpi/osl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/acpi/osl.c +9 -12
@@ -109,7 +109,7 @@ struct acpi_ioremap { };static LIST_HEAD (acpi_ioremaps); -static DEFINE_SPINLOCK (acpi_ioremap_lock); +static DEFINE_MUTEX (acpi_ioremap_lock);static void __init acpi_osi_setup_late (void );
@@ -303,7 +303,6 @@ void __iomem *__init_refok acpi_os_map_memory(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map, *tmp_map; -unsigned long flags;void __iomem *virt;acpi_physical_address pg_off;acpi_size pg_sz;
@@ -334,18 +333,18 @@ acpi_os_map_memory(acpi_physical_address map->size = pg_sz;kref_init (&map->ref); -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock);/* Check if page has already been mapped. */ tmp_map =acpi_map_lookup (phys, size);if (tmp_map) {kref_get (&tmp_map->ref); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);iounmap (map->virt);kfree (map);return tmp_map->virt + (phys - tmp_map->phys); }list_add_tail_rcu (&map->list, &acpi_ioremaps); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);return map->virt + (phys - map->phys); }
@@ -362,7 +361,6 @@ static void acpi_kref_del_iomap(struct kvoid __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -unsigned long flags;int del;if (!acpi_gbl_permanent_mmap) {
@@ -370,17 +368,17 @@ void __ref acpi_os_unmap_memory(void __ireturn ; } -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); map =acpi_map_lookup_virt (virt, size);if (!map) { -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock); printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt);dump_stack ();return ; } del =kref_put (&map->ref, acpi_kref_del_iomap); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);if (!del)return ;
@@ -417,7 +415,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {void __iomem *virt; -unsigned long flags;acpi_size size = addr->bit_width /8 ;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )
@@ -426,9 +423,9 @@ static void acpi_os_unmap_generic_addresif (!addr->address || !addr->bit_width)return ; -spin_lock_irqsave (&acpi_ioremap_lock, flags); +mutex_lock (&acpi_ioremap_lock); virt =acpi_map_vaddr_lookup (addr->address, size); -spin_unlock_irqrestore (&acpi_ioremap_lock, flags); +mutex_unlock (&acpi_ioremap_lock);acpi_os_unmap_memory (virt, size); }
PATCH 6/8 ACPI: Do not use krefs under a mutex in osl.c
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The reference counting of ACPI iomaps is carried out entirely under acpi_ioremap_lock, so it is sufficient to use simple counters instead of krefs for this purpose.
--- drivers/acpi/osl.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/acpi/osl.c +16 -20
@@ -105,7 +105,7 @@ struct acpi_ioremap {void __iomem *virt;acpi_physical_address phys;acpi_size size; -struct kref ref; +unsigned long refcount; };static LIST_HEAD (acpi_ioremaps);
@@ -319,7 +319,7 @@ acpi_os_map_memory(acpi_physical_address/* Check if there's a suitable mapping already. */ map =acpi_map_lookup (phys, size);if (map) { -kref_get (&map->ref); + map->refcount++; goto out; }
@@ -342,7 +342,7 @@ acpi_os_map_memory(acpi_physical_address map->virt = virt; map->phys = pg_off; map->size = pg_sz; -kref_init (&map->ref); + map->refcount =1 ;list_add_tail_rcu (&map->list, &acpi_ioremaps);
@@ -352,25 +352,24 @@ acpi_os_map_memory(acpi_physical_address }EXPORT_SYMBOL_GPL (acpi_os_map_memory); -static void acpi_kref_del_iomap (struct kref *ref) +static void acpi_os_drop_map_ref (struct acpi_ioremap *map) { -struct acpi_ioremap *map; - - map = container_of(ref, struct acpi_ioremap, ref); -list_del_rcu (&map->list); +if (!--map->refcount) +list_del_rcu (&map->list); } -static void acpi_os_remove_map (struct acpi_ioremap *map) +static void acpi_os_map_cleanup (struct acpi_ioremap *map) { -synchronize_rcu (); -iounmap (map->virt); -kfree (map); +if (!map->refcount) { +synchronize_rcu (); +iounmap (map->virt); +kfree (map); + } }void __ref acpi_os_unmap_memory (void __iomem *virt,acpi_size size) {struct acpi_ioremap *map; -int del;if (!acpi_gbl_permanent_mmap) {__acpi_unmap_table (virt, size);
@@ -384,11 +383,10 @@ void __ref acpi_os_unmap_memory(void __iWARN (true,PREFIX "%s: bad address %p\n" , __func__, virt);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }EXPORT_SYMBOL_GPL (acpi_os_unmap_memory);
@@ -418,7 +416,6 @@ static int acpi_os_map_generic_address(sstatic void acpi_os_unmap_generic_address (struct acpi_generic_address *addr) {struct acpi_ioremap *map; -int del;if (addr->space_id !=ACPI_ADR_SPACE_SYSTEM_MEMORY )return ;
@@ -432,11 +429,10 @@ static void acpi_os_unmap_generic_addresmutex_unlock (&acpi_ioremap_lock);return ; } - del =kref_put (&map->ref, acpi_kref_del_iomap); +acpi_os_drop_map_ref (map);mutex_unlock (&acpi_ioremap_lock); -if (del) -acpi_os_remove_map (map); +acpi_os_map_cleanup (map); }#ifdef ACPI_FUTURE_USAGE
PATCH 7/8 ACPI: Introduce acpi_os_get_iomem()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Introduce function acpi_os_get_iomem() that may be used by its callers to get a reference to an ACPI iomap.
--- drivers/acpi/osl.c | 16 ++++++++++++++++ include/linux/acpi_io.h | 2 ++ 2 files changed, 18 insertions(+)
drivers/acpi/osl.c +16 -0
@@ -285,6 +285,22 @@ acpi_map_vaddr_lookup(acpi_physical_addrreturn NULL ; } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size) +{ +struct acpi_ioremap *map; +void __iomem *virt =NULL ; + +mutex_lock (&acpi_ioremap_lock); + map =acpi_map_lookup (phys, size); +if (map) { + virt = map->virt + (phys - map->phys); + map->refcount++; + } +mutex_unlock (&acpi_ioremap_lock); +return virt; +} +EXPORT_SYMBOL_GPL (acpi_os_get_iomem); +/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap *acpi_map_lookup_virt (void __iomem *virt,acpi_size size)
include/linux/acpi_io.h +2 -0
@@ -10,4 +10,6 @@ static inline void __iomem *acpi_os_iore return ioremap_cache(phys, size); } +void __iomem *acpi_os_get_iomem (acpi_physical_address phys,unsigned int size); +#endif
PATCH 8/8 ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify the NVS save/restore code to use acpi_os_get_iomem() and acpi_os_unmap_memory() to acquire and release references to ACPI iomaps, respectively. If there's no ACPI iomap corresponding to the given NVS page, acpi_os_ioremap() is used to map that page and iounmap() is used to unmap it during resume. [If the page is not present in the ACPI iomaps already, it doesn't make sense to add its mapping to the list of ACPI iomaps, because it's going to be thrown away during the subsequent resume anyway.]
Testing on my HP nx6325 shows that approx. 90% of the NVS pages have already been mapped by ACPI before suspend and are present in the ACPI iomaps on this box, so this change appears to be the right thing to do in general.
--- drivers/acpi/nvs.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/nvs.c +19 -3
@@ -26,6 +26,7 @@ struct nvs_page {unsigned int size;void *kaddr;void *data; +bool unmap;struct list_head node; };
@@ -44,6 +45,9 @@ int suspend_nvs_register(unsigned long s {struct nvs_page *entry, *next; +pr_info ("PM: Registering ACPI NVS region at %lx (%ld bytes)\n" , + start, size); +while (size >0 ) {unsigned int nr_bytes;
@@ -81,7 +85,13 @@ void suspend_nvs_free(void)free_page ((unsigned long )entry->data); entry->data =NULL ;if (entry->kaddr) { -iounmap (entry->kaddr); +if (entry->unmap) { +iounmap (entry->kaddr); + entry->unmap = false; + }else { +acpi_os_unmap_memory (entry->kaddr, + entry->size); + } entry->kaddr =NULL ; } }
@@ -115,8 +125,14 @@ int suspend_nvs_save(void)list_for_each_entry (entry, &nvs_list, node)if (entry->data) { - entry->kaddr =acpi_os_ioremap (entry->phys_start, - entry->size); +unsigned long phys = entry->phys_start; +unsigned int size = entry->size; + + entry->kaddr =acpi_os_get_iomem (phys, size); +if (!entry->kaddr) { + entry->kaddr =acpi_os_ioremap (phys, size); + entry->unmap = !!entry->kaddr; + }if (!entry->kaddr) {suspend_nvs_free ();return -ENOMEM ;
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit831d52bc153971b70e64eccfbed2b232394f22f8 and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
Thanks,
Jeff
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Rafael J. WysockiThe suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit831d52bc153971b70e64eccfbed2b232394f22f8 and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
Thanks,
Jeff
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Jeff ChuaQuoted 7 lines · Jeff Chua
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit
831d52bc153971b70e64eccfbed2b232394f22f8and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
No idea. I bet on DRI.
Thanks,
Rafael
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Jeff ChuaQuoted 7 lines · Jeff Chua
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit
831d52bc153971b70e64eccfbed2b232394f22f8and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
No idea. I bet on DRI.
Thanks,
Rafael
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Jeff ChuaQuoted 7 lines · Jeff Chua
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit
831d52bc153971b70e64eccfbed2b232394f22f8and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
BTW, please don't reply to messages containing patches with reports of problems that aren't caused by those patches. It's confusing at best and at worst it may result in the patches being rejected.
Thanks,
Rafael
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Jeff ChuaQuoted 7 lines · Jeff Chua
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit
831d52bc153971b70e64eccfbed2b232394f22f8and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
BTW, please don't reply to messages containing patches with reports of problems that aren't caused by those patches. It's confusing at best and at worst it may result in the patches being rejected.
Thanks,
Rafael
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Jeff ChuaQuoted 8 lines · Jeff Chua
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit
831d52bc153971b70e64eccfbed2b232394f22f8and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
Hmm. It's almost certainly one of the DRI patches, but which one? I think bisection is the only way to figure it out. It shouldn't be too bad, since there's only 120 commits in that range.
In fact, you can almost certainly just bisect from 89840966c579 to bb5b583b5279, which is just 31 commits and should get you bisected in just five tries or so.
Linus
Re: [PATCH 8/8] ACPI / PM: Use existing ACPI iomaps for NVS save/restore (v2)
In reply to Jeff ChuaQuoted 8 lines · Jeff Chua
The suspend monster is back! The suspend-to-ram is fine, but upon resume, screen is blank. Haven't bisected in case someone has also done so.
It's very recent. ... between commit
831d52bc153971b70e64eccfbed2b232394f22f8and44f2c5c841da1b1e0864d768197ab1497b5c2cc1.
Hmm. It's almost certainly one of the DRI patches, but which one? I think bisection is the only way to figure it out. It shouldn't be too bad, since there's only 120 commits in that range.
In fact, you can almost certainly just bisect from 89840966c579 to bb5b583b5279, which is just 31 commits and should get you bisected in just five tries or so.
Linus