Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:Update
powerpc-utils.908
powerpc-utils.drmgr-use_sysfs_migration_store_t...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File powerpc-utils.drmgr-use_sysfs_migration_store_to_initiate_migratio.patch of Package powerpc-utils.908
From 63f2c6881aa46a87487ea8572df3cf46a6604dc1 Mon Sep 17 00:00:00 2001 From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> Date: Tue, 31 Mar 2015 18:23:59 -0400 Subject: [PATCH] drmgr: Use sysfs migration store to initiate migration when possible The sysfs attribute /sys/kernel/mobility/migration has been present for sometime, but never actually used by drmgr. It can be used to initiate a migration operation in place of the existing faux ibm,supsend-me rtas call. Further, newer kernels are capable of doing the device tree update. We can test the /sys/kernel/mobility/api_version attribute to determine the course of action drmgr should take. Newer kernels will return 1 indicating the kernel is cabable of performing the migration and postmobility fixups. If the attribute is unreadable or returns 0 drmgr should resort to initiating the migration via rtas, and communicate the post mobility device tree update through the /proc/ppc64/ofdt interface to the kernel. Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> --- src/drmgr/drmig_chrp_pmig.c | 56 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/src/drmgr/drmig_chrp_pmig.c b/src/drmgr/drmig_chrp_pmig.c index a7c1ec5..8e8f9d0 100644 --- a/src/drmgr/drmig_chrp_pmig.c +++ b/src/drmgr/drmig_chrp_pmig.c @@ -28,6 +28,13 @@ struct pmap_struct { }; #define SYSFS_HIBERNATION_FILE "/sys/devices/system/power/hibernate" +#define SYSFS_MIGRATION_FILE "/sys/kernel/mobility/migration" +#define SYSFS_MIGRATION_API_FILE "/sys/kernel/mobility/api_version" + +/* drmgr must call ibm,suspend-me and is responsible for postmobility fixups */ +#define MIGRATION_API_V0 0 +/* drmgr must write to sysfs migration store and allow kernel to do postmobility fixups */ +#define MIGRATION_API_V1 1 static struct pmap_struct *plist; static int action = 0; @@ -559,11 +566,48 @@ valid_pmig_options(struct options *opts) int do_migration(uint64_t stream_val) { - int rc; + int rc, fd; + int api_level = 0; + char buf[64]; + + /* If the kernel can also do the device tree update we should let the kernel do all the work. + Check if sysfs migration api_version is readable and use api level to determine how to + perform migration and post-mobility updates. */ + rc = get_int_attribute(SYSFS_MIGRATION_API_FILE, NULL, &api_level, sizeof(&api_level)); + if (rc) + say(DEBUG,"get_int_attribute returned %d for path %s\n", rc, SYSFS_MIGRATION_API_FILE); + + if (api_level == MIGRATION_API_V0) { + say(DEBUG, "about to issue ibm,suspend-me(%llx)\n", stream_val); + rc = rtas_suspend_me(stream_val); + say(DEBUG, "ibm,suspend-me() returned %d\n", rc); + } else if (api_level == MIGRATION_API_V1) { + sprintf(buf, "0x%llx\n", stream_val); + + fd = open(SYSFS_MIGRATION_FILE, O_WRONLY); + if (fd == -1) { + say(ERROR, "Could not open \"%s\" to initiate migration, " + "%m\n", SYSFS_MIGRATION_FILE); + return -1; + } + + say(DEBUG, "Initiating migration via %s with %s\n", + SYSFS_MIGRATION_FILE, buf); + + rc = write(fd, buf, strlen(buf)); + if (rc < 0) { + say(DEBUG, "Write to migration file failed with rc: %d\n", rc); + rc = errno; + } else if (rc > 0) + rc = 0; + + close(fd); + say(DEBUG, "Kernel migration returned %d\n", rc); + } else { + say(ERROR, "Unknown kernel migration api version %d\n", api_level); + rc = -1; + } - say(DEBUG, "about to issue ibm,suspend-me(%llx)\n", stream_val); - rc = rtas_suspend_me(stream_val); - say(DEBUG, "ibm,suspend-me() returned %d\n", rc); return rc; } @@ -604,9 +648,9 @@ void post_mobility_update(int action) char *path; if (action == HIBERNATE) - path = "/sys/devices/system/power/hibernate"; + path = SYSFS_HIBERNATION_FILE; else - path = "/sys/kernel/mobility/migrate"; + path = SYSFS_MIGRATION_API_FILE; /* kernel will return 0 or sysfs attribute will be unreadable if drmgr needs to perform a device tree update */ -- 1.8.5.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor