Commit 03997904 authored by Gerald Schaefer's avatar Gerald Schaefer Committed by Martin Schwidefsky

[S390] pm: memory hotplug power management callbacks

Signed-off-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 4b214a0c
/* /*
* drivers/s390/char/sclp_cmd.c * Copyright IBM Corp. 2007, 2009
* *
* Copyright IBM Corp. 2007
* Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
* Peter Oberparleiter <peter.oberparleiter@de.ibm.com> * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
*/ */
...@@ -12,11 +11,13 @@ ...@@ -12,11 +11,13 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/mmzone.h> #include <linux/mmzone.h>
#include <linux/memory.h> #include <linux/memory.h>
#include <linux/platform_device.h>
#include <asm/chpid.h> #include <asm/chpid.h>
#include <asm/sclp.h> #include <asm/sclp.h>
#include <asm/setup.h> #include <asm/setup.h>
...@@ -292,6 +293,7 @@ static DEFINE_MUTEX(sclp_mem_mutex); ...@@ -292,6 +293,7 @@ static DEFINE_MUTEX(sclp_mem_mutex);
static LIST_HEAD(sclp_mem_list); static LIST_HEAD(sclp_mem_list);
static u8 sclp_max_storage_id; static u8 sclp_max_storage_id;
static unsigned long sclp_storage_ids[256 / BITS_PER_LONG]; static unsigned long sclp_storage_ids[256 / BITS_PER_LONG];
static int sclp_mem_state_changed;
struct memory_increment { struct memory_increment {
struct list_head list; struct list_head list;
...@@ -450,6 +452,8 @@ static int sclp_mem_notifier(struct notifier_block *nb, ...@@ -450,6 +452,8 @@ static int sclp_mem_notifier(struct notifier_block *nb,
rc = -EINVAL; rc = -EINVAL;
break; break;
} }
if (!rc)
sclp_mem_state_changed = 1;
mutex_unlock(&sclp_mem_mutex); mutex_unlock(&sclp_mem_mutex);
return rc ? NOTIFY_BAD : NOTIFY_OK; return rc ? NOTIFY_BAD : NOTIFY_OK;
} }
...@@ -525,6 +529,14 @@ static void __init insert_increment(u16 rn, int standby, int assigned) ...@@ -525,6 +529,14 @@ static void __init insert_increment(u16 rn, int standby, int assigned)
list_add(&new_incr->list, prev); list_add(&new_incr->list, prev);
} }
static int sclp_mem_freeze(struct device *dev)
{
if (!sclp_mem_state_changed)
return 0;
pr_err("Memory hotplug state changed, suspend refused.\n");
return -EPERM;
}
struct read_storage_sccb { struct read_storage_sccb {
struct sccb_header header; struct sccb_header header;
u16 max_id; u16 max_id;
...@@ -534,8 +546,20 @@ struct read_storage_sccb { ...@@ -534,8 +546,20 @@ struct read_storage_sccb {
u32 entries[0]; u32 entries[0];
} __packed; } __packed;
static struct dev_pm_ops sclp_mem_pm_ops = {
.freeze = sclp_mem_freeze,
};
static struct platform_driver sclp_mem_pdrv = {
.driver = {
.name = "sclp_mem",
.pm = &sclp_mem_pm_ops,
},
};
static int __init sclp_detect_standby_memory(void) static int __init sclp_detect_standby_memory(void)
{ {
struct platform_device *sclp_pdev;
struct read_storage_sccb *sccb; struct read_storage_sccb *sccb;
int i, id, assigned, rc; int i, id, assigned, rc;
...@@ -588,7 +612,17 @@ static int __init sclp_detect_standby_memory(void) ...@@ -588,7 +612,17 @@ static int __init sclp_detect_standby_memory(void)
rc = register_memory_notifier(&sclp_mem_nb); rc = register_memory_notifier(&sclp_mem_nb);
if (rc) if (rc)
goto out; goto out;
rc = platform_driver_register(&sclp_mem_pdrv);
if (rc)
goto out;
sclp_pdev = platform_device_register_simple("sclp_mem", -1, NULL, 0);
rc = IS_ERR(sclp_pdev) ? PTR_ERR(sclp_pdev) : 0;
if (rc)
goto out_driver;
sclp_add_standby_memory(); sclp_add_standby_memory();
goto out;
out_driver:
platform_driver_unregister(&sclp_mem_pdrv);
out: out:
free_page((unsigned long) sccb); free_page((unsigned long) sccb);
return rc; return rc;
......
...@@ -128,11 +128,11 @@ config SPARSEMEM_VMEMMAP ...@@ -128,11 +128,11 @@ config SPARSEMEM_VMEMMAP
config MEMORY_HOTPLUG config MEMORY_HOTPLUG
bool "Allow for memory hot-add" bool "Allow for memory hot-add"
depends on SPARSEMEM || X86_64_ACPI_NUMA depends on SPARSEMEM || X86_64_ACPI_NUMA
depends on HOTPLUG && !HIBERNATION && ARCH_ENABLE_MEMORY_HOTPLUG depends on HOTPLUG && !(HIBERNATION && !S390) && ARCH_ENABLE_MEMORY_HOTPLUG
depends on (IA64 || X86 || PPC64 || SUPERH || S390) depends on (IA64 || X86 || PPC64 || SUPERH || S390)
comment "Memory hotplug is currently incompatible with Software Suspend" comment "Memory hotplug is currently incompatible with Software Suspend"
depends on SPARSEMEM && HOTPLUG && HIBERNATION depends on SPARSEMEM && HOTPLUG && HIBERNATION && !S390
config MEMORY_HOTPLUG_SPARSE config MEMORY_HOTPLUG_SPARSE
def_bool y def_bool y
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment