Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 241674
b: refs/heads/master
c: 5190726
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed Feb 24, 2011
1 parent 0918a7c commit 771544f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 101 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bb45e394e21eb2abc710ad43d98ebac1069bf355
refs/heads/master: 5190726765b40774c069e187a958e10ccd970e65
2 changes: 0 additions & 2 deletions trunk/drivers/acpi/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ static int acpi_button_add(struct acpi_device *device)
/* Button's GPE is run-wake GPE */
acpi_enable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number);
device->wakeup.run_wake_count++;
device_set_wakeup_enable(&device->dev, true);
}

Expand All @@ -453,7 +452,6 @@ static int acpi_button_remove(struct acpi_device *device, int type)
if (device->wakeup.flags.valid) {
acpi_disable_gpe(device->wakeup.gpe_device,
device->wakeup.gpe_number);
device->wakeup.run_wake_count--;
device_set_wakeup_enable(&device->dev, false);
}

Expand Down
22 changes: 3 additions & 19 deletions trunk/drivers/acpi/nvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct nvs_page {
unsigned int size;
void *kaddr;
void *data;
bool unmap;
struct list_head node;
};

Expand All @@ -45,9 +44,6 @@ int suspend_nvs_register(unsigned long start, unsigned long size)
{
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;

Expand Down Expand Up @@ -85,13 +81,7 @@ void suspend_nvs_free(void)
free_page((unsigned long)entry->data);
entry->data = NULL;
if (entry->kaddr) {
if (entry->unmap) {
iounmap(entry->kaddr);
entry->unmap = false;
} else {
acpi_os_unmap_memory(entry->kaddr,
entry->size);
}
iounmap(entry->kaddr);
entry->kaddr = NULL;
}
}
Expand Down Expand Up @@ -125,14 +115,8 @@ int suspend_nvs_save(void)

list_for_each_entry(entry, &nvs_list, node)
if (entry->data) {
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;
}
entry->kaddr = acpi_os_ioremap(entry->phys_start,
entry->size);
if (!entry->kaddr) {
suspend_nvs_free();
return -ENOMEM;
Expand Down
112 changes: 48 additions & 64 deletions trunk/drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ struct acpi_ioremap {
void __iomem *virt;
acpi_physical_address phys;
acpi_size size;
unsigned long refcount;
struct kref ref;
};

static LIST_HEAD(acpi_ioremaps);
static DEFINE_MUTEX(acpi_ioremap_lock);
static DEFINE_SPINLOCK(acpi_ioremap_lock);

static void __init acpi_osi_setup_late(void);

Expand Down Expand Up @@ -285,22 +285,6 @@ acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size)
return 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)
Expand All @@ -318,7 +302,8 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
void __iomem *__init_refok
acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
{
struct acpi_ioremap *map;
struct acpi_ioremap *map, *tmp_map;
unsigned long flags;
void __iomem *virt;
acpi_physical_address pg_off;
acpi_size pg_sz;
Expand All @@ -331,25 +316,14 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
if (!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) {
map->refcount++;
goto out;
}

map = kzalloc(sizeof(*map), GFP_KERNEL);
if (!map) {
mutex_unlock(&acpi_ioremap_lock);
if (!map)
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;
}
Expand All @@ -358,51 +332,62 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
map->virt = virt;
map->phys = pg_off;
map->size = pg_sz;
map->refcount = 1;

kref_init(&map->ref);

spin_lock_irqsave(&acpi_ioremap_lock, flags);
/* 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);
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);

out:
mutex_unlock(&acpi_ioremap_lock);
return map->virt + (phys - map->phys);
}
EXPORT_SYMBOL_GPL(acpi_os_map_memory);

static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
static void acpi_kref_del_iomap(struct kref *ref)
{
if (!--map->refcount)
list_del_rcu(&map->list);
}
struct acpi_ioremap *map;

static void acpi_os_map_cleanup(struct acpi_ioremap *map)
{
if (!map->refcount) {
synchronize_rcu();
iounmap(map->virt);
kfree(map);
}
map = container_of(ref, struct acpi_ioremap, ref);
list_del_rcu(&map->list);
}

void __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) {
__acpi_unmap_table(virt, size);
return;
}

mutex_lock(&acpi_ioremap_lock);
spin_lock_irqsave(&acpi_ioremap_lock, flags);
map = acpi_map_lookup_virt(virt, size);
if (!map) {
mutex_unlock(&acpi_ioremap_lock);
WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
spin_unlock_irqrestore(&acpi_ioremap_lock, flags);
printk(KERN_ERR PREFIX "%s: bad address %p\n", __func__, virt);
dump_stack();
return;
}
acpi_os_drop_map_ref(map);
mutex_unlock(&acpi_ioremap_lock);

acpi_os_map_cleanup(map);
del = kref_put(&map->ref, acpi_kref_del_iomap);
spin_unlock_irqrestore(&acpi_ioremap_lock, flags);

if (!del)
return;

synchronize_rcu();
iounmap(map->virt);
kfree(map);
}
EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);

Expand All @@ -412,7 +397,7 @@ void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
__acpi_unmap_table(virt, size);
}

static int acpi_os_map_generic_address(struct acpi_generic_address *addr)
int acpi_os_map_generic_address(struct acpi_generic_address *addr)
{
void __iomem *virt;

Expand All @@ -428,28 +413,27 @@ static int acpi_os_map_generic_address(struct acpi_generic_address *addr)

return 0;
}
EXPORT_SYMBOL_GPL(acpi_os_map_generic_address);

static void acpi_os_unmap_generic_address(struct acpi_generic_address *addr)
void acpi_os_unmap_generic_address(struct acpi_generic_address *addr)
{
struct acpi_ioremap *map;
void __iomem *virt;
unsigned long flags;
acpi_size size = addr->bit_width / 8;

if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
return;

if (!addr->address || !addr->bit_width)
return;

mutex_lock(&acpi_ioremap_lock);
map = acpi_map_lookup(addr->address, addr->bit_width / 8);
if (!map) {
mutex_unlock(&acpi_ioremap_lock);
return;
}
acpi_os_drop_map_ref(map);
mutex_unlock(&acpi_ioremap_lock);
spin_lock_irqsave(&acpi_ioremap_lock, flags);
virt = acpi_map_vaddr_lookup(addr->address, size);
spin_unlock_irqrestore(&acpi_ioremap_lock, flags);

acpi_os_map_cleanup(map);
acpi_os_unmap_memory(virt, size);
}
EXPORT_SYMBOL_GPL(acpi_os_unmap_generic_address);

#ifdef ACPI_FUTURE_USAGE
acpi_status
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
acpi_status status;
acpi_event_status event_status;

device->wakeup.run_wake_count = 0;
device->wakeup.flags.notifier_present = 0;

/* Power button, Lid switch always enable wakeup */
Expand Down
16 changes: 4 additions & 12 deletions trunk/drivers/pci/pci-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,11 @@ static int acpi_dev_run_wake(struct device *phys_dev, bool enable)
}

if (enable) {
if (!dev->wakeup.run_wake_count++) {
acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0);
acpi_enable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number);
}
} else if (dev->wakeup.run_wake_count > 0) {
if (!--dev->wakeup.run_wake_count) {
acpi_disable_gpe(dev->wakeup.gpe_device,
dev->wakeup.gpe_number);
acpi_disable_wakeup_device_power(dev);
}
acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0);
acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number);
} else {
error = -EALREADY;
acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number);
acpi_disable_wakeup_device_power(dev);
}

return error;
Expand Down
1 change: 0 additions & 1 deletion trunk/include/acpi/acpi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ struct acpi_device_wakeup {
struct acpi_handle_list resources;
struct acpi_device_wakeup_flags flags;
int prepare_count;
int run_wake_count;
};

/* Device */
Expand Down
3 changes: 2 additions & 1 deletion trunk/include/linux/acpi_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
return ioremap_cache(phys, size);
}

void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size);
int acpi_os_map_generic_address(struct acpi_generic_address *addr);
void acpi_os_unmap_generic_address(struct acpi_generic_address *addr);

#endif

0 comments on commit 771544f

Please sign in to comment.