Skip to contentSkip to conversation

powerpc/pseries: Introduce api_version to migration sysfs interface

PATCH In review Tyrel Datwyler 2 participants 3 messages Mar 5, 2015 – Mar 24, 2015 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/pseries: Introduce api_version to migration sysfs interface

The /sys/kernel/mobility/migration interface was added all the way back in 2.6.37. However, the drmgr userspace tool was never augmented to use this interface to perfrom migrations. Instead it has continued using a faux rtas call coupled with performing the device tree update processing in userspace and communicating it back to the kernel via the ugly /proc/ppc64/ofdt interface.

Up until 3.12 the device tree update code in the kernel was badly broken and bit rotting. This code was fixed in 3.12 and is now utilized by the kernel suspend code as of 3.15. The kernel is now better suited to handle the post-mobility fixup of the device tree and drmgr should be transitioned to using the sysfs migration interface.

This patch introduces the api_version sysfs file to /sys/kernel/mobility as a means for drmgr to query the current implementation level of the kernel migration code. This initial versioning indicates it is capable of perfroming all current PAPR requirements for migration including the post-mobility firmware activation and device tree update.

Cc Nathan Fontenot <[email protected]>
Cc Cyril Bur <[email protected]>
---
 arch/powerpc/platforms/pseries/mobility.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/mobility.c +16 -1
index bdf62c1..ceb18d3 100644
@@ -338,7 +338,16 @@ static ssize_t migrate_store(struct class *class, struct class_attribute *attr,
 	return count;
 }
 
+/*
+ * Used by drmgr to determine the kernel behavior of the migration interface.
+ *
+ * Version 1: Performs all PAPR requirements for migration including
+ *	firmware activation and device tree update.
+ */
+#define MIGRATION_API_VERSION	1
+
 static CLASS_ATTR(migration, S_IWUSR, NULL, migrate_store);
+static CLASS_ATTR_STRING(api_version, S_IRUGO, __stringify(MIGRATION_API_VERSION));
 
 static int __init mobility_sysfs_init(void)
 {
@@ -349,7 +358,13 @@ static int __init mobility_sysfs_init(void)
 		return -ENOMEM;
 
 	rc = sysfs_create_file(mobility_kobj, &class_attr_migration.attr);
+	if (rc)
+		pr_err("mobility: unable to create migration sysfs file (%d)\n", rc);
 
-	return rc;
+	rc = sysfs_create_file(mobility_kobj, &class_attr_api_version.attr.attr);
+	if (rc)
+		pr_err("mobility: unable to create api_version sysfs file (%d)\n", rc);
+
+	return 0;
 }
 machine_device_initcall(pseries, mobility_sysfs_init);
Signature · 1 line
1.7.12.2
#1 lore raw
Quoted 19 lines · Tyrel Datwyler

The /sys/kernel/mobility/migration interface was added all the way back in 2.6.37. However, the drmgr userspace tool was never augmented to use this interface to perfrom migrations. Instead it has continued using a faux rtas call coupled with performing the device tree update processing in userspace and communicating it back to the kernel via the ugly /proc/ppc64/ofdt interface.

Up until 3.12 the device tree update code in the kernel was badly broken and bit rotting. This code was fixed in 3.12 and is now utilized by the kernel suspend code as of 3.15. The kernel is now better suited to handle the post-mobility fixup of the device tree and drmgr should be transitioned to using the sysfs migration interface.

This patch introduces the api_version sysfs file to /sys/kernel/mobility as a means for drmgr to query the current implementation level of the kernel migration code. This initial versioning indicates it is capable of perfroming all current PAPR requirements for migration including the post-mobility firmware activation and device tree update.

Quoted 4 lines
Cc Nathan Fontenot <[email protected]>
Cc Cyril Bur <[email protected]>

---

Ping. Does this look acceptable for -next?

-Tyrel

Quoted 40 lines
 arch/powerpc/platforms/pseries/mobility.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/mobility.c +16 -1
index bdf62c1..ceb18d3 100644
@@ -338,7 +338,16 @@ static ssize_t migrate_store(struct class *class, struct class_attribute *attr,
 	return count;
 }
 
+/*
+ * Used by drmgr to determine the kernel behavior of the migration interface.
+ *
+ * Version 1: Performs all PAPR requirements for migration including
+ *	firmware activation and device tree update.
+ */
+#define MIGRATION_API_VERSION	1
+
 static CLASS_ATTR(migration, S_IWUSR, NULL, migrate_store);
+static CLASS_ATTR_STRING(api_version, S_IRUGO, __stringify(MIGRATION_API_VERSION));
 
 static int __init mobility_sysfs_init(void)
 {
@@ -349,7 +358,13 @@ static int __init mobility_sysfs_init(void)
 		return -ENOMEM;
 
 	rc = sysfs_create_file(mobility_kobj, &class_attr_migration.attr);
+	if (rc)
+		pr_err("mobility: unable to create migration sysfs file (%d)\n", rc);
 
-	return rc;
+	rc = sysfs_create_file(mobility_kobj, &class_attr_api_version.attr.attr);
+	if (rc)
+		pr_err("mobility: unable to create api_version sysfs file (%d)\n", rc);
+
+	return 0;
 }
 machine_device_initcall(pseries, mobility_sysfs_init);
#2 lore raw
In reply to Tyrel Datwyler
Quoted 13 lines · Tyrel Datwyler

The /sys/kernel/mobility/migration interface was added all the way back in 2.6.37. However, the drmgr userspace tool was never augmented to use this interface to perfrom migrations. Instead it has continued using a faux rtas call coupled with performing the device tree update processing in userspace and communicating it back to the kernel via the ugly /proc/ppc64/ofdt interface.

Up until 3.12 the device tree update code in the kernel was badly broken and bit rotting. This code was fixed in 3.12 and is now utilized by the kernel suspend code as of 3.15. The kernel is now better suited to handle the post-mobility fixup of the device tree and drmgr should be transitioned to using the sysfs migration interface.

Quoted 5 lines

This patch introduces the api_version sysfs file to /sys/kernel/mobility as a means for drmgr to query the current implementation level of the kernel migration code. This initial versioning indicates it is capable of perfroming all current PAPR requirements for migration including the post-mobility firmware activation and device tree update.

I've put this in next.

Please send a follow-up patch that adds documentation for this and the other sysfs files in Documentation/ABI.

cheers