powerpc/pseries: fix issues in suspend/resume code
v3 cover powerpc/pseries: fix issues in suspend/resume code
This patchset fixes a couple of issues encountered in the suspend/resume code base. First when using the kernel device tree update code update-nodes is unnecessarily called more than once. Second the cpu cache lists are not updated after a suspend/resume which under certain conditions may cause a panic. Finally, since the cache list fix utilzes in kernel device tree update code a means for telling drmgr not to perform a device tree update from userspace is required.
Changes from v2:
- Moved dynamic configuration update code into pseries specific routine per Nathan's suggestion.
Changes from v1:
- Fixed several commit message typos
- Fixed authorship of first two patches
Haren Myneni (2):
powerpc/pseries: Device tree should only be updated once after
suspend/migrate
powerpc/pseries: Update dynamic cache nodes for suspend/resume
operation
Tyrel Datwyler (1):
powerpc/pseries: Report in kernel device tree update to drmgr
arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/platforms/pseries/mobility.c | 26 +++++++----------- arch/powerpc/platforms/pseries/suspend.c | 44 ++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 17 deletions(-)
Signature · 1 line
1.7.12.2
PATCH v3 1/3 powerpc/pseries: Device tree should only be updated once after suspend/migrate
From: Haren Myneni <[email protected]>
The current code makes rtas calls for update-nodes, activate-firmware and then update-nodes again. The FW provides the same data for both update-nodes calls. As a result a proc entry exists error is reported for the second update while adding device nodes.
This patch makes a single rtas call for update-nodes after activating the FW. It also add rtas_busy delay for the activate-firmware rtas call.
--- arch/powerpc/platforms/pseries/mobility.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
arch/powerpc/platforms/pseries/mobility.c +10 -16
@@ -290,13 +290,6 @@ void post_mobility_fixup(void)int rc;int activate_fw_token; - rc =pseries_devicetree_update (MIGRATION_SCOPE ); -if (rc) { -printk (KERN_ERR "Initial post-mobility device tree update " -"failed: %d\n" , rc); -return ; - } - activate_fw_token =rtas_token ("ibm,activate-firmware" );if (activate_fw_token ==RTAS_UNKNOWN_SERVICE ) { printk(KERN_ERR "Could not make post-mobility "
@@ -304,16 +297,17 @@ void post_mobility_fixup(void)return ; } - rc =rtas_call (activate_fw_token,0 ,1 ,NULL ); -if (!rc) { - rc =pseries_devicetree_update (MIGRATION_SCOPE ); -if (rc) -printk (KERN_ERR "Secondary post-mobility device tree " -"update failed: %d\n" , rc); - }else { +do { + rc =rtas_call (activate_fw_token,0 ,1 ,NULL ); + }while (rtas_busy_delay (rc)); + +if (rc)printk (KERN_ERR "Post-mobility activate-fw failed: %d\n" , rc); -return ; - } + + rc =pseries_devicetree_update (MIGRATION_SCOPE ); +if (rc) +printk (KERN_ERR "Post-mobility device tree update " +"failed: %d\n" , rc);return ; }
Signature · 1 line
1.7.12.2
PATCH v3 2/3 powerpc/pseries: Update dynamic cache nodes for suspend/resume operation
In reply to Tyrel DatwylerFrom: Haren Myneni <[email protected]>
pHyp can change cache nodes for suspend/resume operation. The current code updates the device tree after all non boot CPUs are enabled. Hence, we do not modify the cache list based on the latest cache nodes. Also we do not remove cache entries for the primary CPU.
This patch removes the cache list for the boot CPU, updates the device tree before enabling nonboot CPUs and adds cache list for the boot cpu.
--- arch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/platforms/pseries/suspend.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
arch/powerpc/include/asm/rtas.h +1 -0
@@ -283,6 +283,7 @@ extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);#ifdef CONFIG_PPC_PSERIES extern int pseries_devicetree_update (s32 scope); +extern void post_mobility_fixup (void );#endif #ifdef CONFIG_PPC_RTAS_DAEMON
arch/powerpc/platforms/pseries/suspend.c +19 -0
@@ -26,6 +26,7 @@#include <asm/mmu.h> #include <asm/rtas.h> #include <asm/topology.h> +#include "../../kernel/cacheinfo.h" static u64 stream_id;static struct device suspend_dev;
@@ -79,6 +80,23 @@ static int pseries_suspend_cpu(void) }/** +* pseries_suspend_enable_irqs +* +* Post suspend configuration updates +* +**/ +static void pseries_suspend_enable_irqs (void ) +{ +/* +* Update configuration which can be modified based on device tree +* changes during resume. +*/ +cacheinfo_cpu_offline (smp_processor_id ()); +post_mobility_fixup (); +cacheinfo_cpu_online (smp_processor_id ()); +} + +/** * pseries_suspend_enter - Final phase of hibernation * * Return value:
@@ -235,6 +253,7 @@ static int __init pseries_suspend_init(void)return rc; ppc_md.suspend_disable_cpu = pseries_suspend_cpu; + ppc_md.suspend_enable_irqs = pseries_suspend_enable_irqs;suspend_set_ops (&pseries_suspend_ops);return 0 ; }
Signature · 1 line
1.7.12.2
PATCH v3 3/3 powerpc/pseries: Report in kernel device tree update to drmgr
In reply to Tyrel DatwylerTraditionally it has been drmgr's responsibilty to update the device tree through the /proc/ppc64/ofdt interface after a suspend/resume operation. This patchset however has modified suspend/resume ops to preform that update entirely in the kernel during the resume. Therefore, a mechanism is required for drmgr to determine who is responsible for the update. This patch adds a show function to the "hibernate" attribute that returns 1 if the kernel updates the device tree after the resume and 0 if drmgr is responsible.
--- arch/powerpc/platforms/pseries/suspend.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/suspend.c +24 -1
@@ -192,7 +192,30 @@ out:return rc; } -static DEVICE_ATTR(hibernate, S_IWUSR, NULL, store_hibernate); +#define USER_DT_UPDATE 0 +#define KERN_DT_UPDATE 1 + +/** +* show_hibernate - Report device tree update responsibilty +* @dev: subsys root device +* @attr: device attribute struct +* @buf: buffer +* +* Report whether a device tree update is performed by the kernel after a +* resume, or if drmgr must coordinate the update from user space. +* +* Return value: +* 0 if drmgr is to initiate update, and 1 otherwise +**/ +static ssize_t show_hibernate (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +return sprintf (buf,"%d\n" ,KERN_DT_UPDATE ); +} + +static DEVICE_ATTR(hibernate, S_IWUSR | S_IRUGO, + show_hibernate, store_hibernate);static struct bus_type suspend_subsys = { .name ="power" ,
Signature · 1 line
1.7.12.2
Re: [PATCH v3 3/3] powerpc/pseries: Report in kernel device tree update to drmgr
Quoted 7 lines · Tyrel Datwyler
Traditionally it has been drmgr's responsibilty to update the device tree through the
/proc/ppc64/ofdtinterface after a suspend/resume operation. This patchset however has modified suspend/resume ops to preform that update entirely in the kernel during the resume. Therefore, a mechanism is required for drmgr to determine who is responsible for the update. This patch adds a show function to the "hibernate" attribute that returns 1 if the kernel updates the device tree after the resume and 0 if drmgr is responsible.
This is not right.
We cannot change the kernel behaviour in a way that is incompatible with existing userspace, and unless you can explain me why that is not the case, it feels like this patch set does just that ....
What happens if you have an older drmgr which still does the update itself ?
You can't just change user visible behaviours and interface without at least explaining why it's ok to do so at the very least (and ensuring that of course) without breaking existing userspace.
Now it's possible that the double update caused by this series is harmless, in which case please explain it in the changeset, I certainly can't assume it and if it's not, you'll need some other way for drmgr to signal the kernel to indicate it supports the new behaviour before you enable it.
Ben.
Quoted 41 lines
Signed-off-by Tyrel Datwyler <[email protected]>--- arch/powerpc/platforms/pseries/suspend.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)arch/powerpc/platforms/pseries/suspend.c +24
-1@@ -192,7 +192,30 @@ out:return rc; } -static DEVICE_ATTR(hibernate, S_IWUSR, NULL, store_hibernate); +#define USER_DT_UPDATE 0 +#define KERN_DT_UPDATE 1 + +/** +* show_hibernate - Report device tree update responsibilty +* @dev: subsys root device +* @attr: device attribute struct +* @buf: buffer +* +* Report whether a device tree update is performed by the kernel after a +* resume, or if drmgr must coordinate the update from user space. +* +* Return value: +* 0 if drmgr is to initiate update, and 1 otherwise +**/ +static ssize_t show_hibernate (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +return sprintf (buf,"%d\n" ,KERN_DT_UPDATE ); +} + +static DEVICE_ATTR(hibernate, S_IWUSR | S_IRUGO, + show_hibernate, store_hibernate);static struct bus_type suspend_subsys = { .name ="power" ,
Re: [PATCH v3 3/3] powerpc/pseries: Report in kernel device tree update to drmgr
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 7 lines · Tyrel Datwyler
Traditionally it has been drmgr's responsibilty to update the device tree through the
/proc/ppc64/ofdtinterface after a suspend/resume operation. This patchset however has modified suspend/resume ops to preform that update entirely in the kernel during the resume. Therefore, a mechanism is required for drmgr to determine who is responsible for the update. This patch adds a show function to the "hibernate" attribute that returns 1 if the kernel updates the device tree after the resume and 0 if drmgr is responsible.
Quoted 9 lines
This is not right.
We cannot change the kernel behaviour in a way that is incompatible with existing userspace, and unless you can explain me why that is not the case, it feels like this patch set does just that ....
What happens if you have an older drmgr which still does the update itself ?
In this case we get a double update which I clearly neglected to mention in the patch. The first patch in this series actually removes an unnecessary double update from the existing kernel implementation. The same information is returned by the update-nodes/properties call the second time around and aside from being a waste of a few cycles is harmless.
Tyrel
Quoted 60 lines
You can't just change user visible behaviours and interface without at least explaining why it's ok to do so at the very least (and ensuring that of course) without breaking existing userspace.
Now it's possible that the double update caused by this series is harmless, in which case please explain it in the changeset, I certainly can't assume it and if it's not, you'll need some other way for drmgr to signal the kernel to indicate it supports the new behaviour before you enable it.
Ben.
Quoted 31 lines
Signed-off-by Tyrel Datwyler <[email protected]>--- arch/powerpc/platforms/pseries/suspend.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)arch/powerpc/platforms/pseries/suspend.c +17
-1@@ -192,7 +192,30 @@ out:return rc; } -static DEVICE_ATTR(hibernate, S_IWUSR, NULL, store_hibernate); +#define USER_DT_UPDATE 0 +#define KERN_DT_UPDATE 1 + +/** +* show_hibernate - Report device tree update responsibilty +* @dev: subsys root device +* @attr: device attribute struct +* @buf: buffer +* +* Report whether a device tree update is performed by the kernel after a +* resume, or if drmgr must coordinate the update from user space. +* +* Return value: +* 0 if drmgr is to initiate update, and 1 otherwise +**/ +static ssize_t show_hibernate(struct device *dev, + struct device_attribute *attr,arch/powerpc/platforms/pseries/suspend.c out: · line 221
Quoted 10 lines
arch/powerpc/platforms/pseries/suspend.c +7
-0+ char *buf) +{ +return sprintf (buf,"%d\n" ,KERN_DT_UPDATE ); +} + +static DEVICE_ATTR(hibernate, S_IWUSR | S_IRUGO, + show_hibernate, store_hibernate);static struct bus_type suspend_subsys = { .name ="power" ,_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v3 3/3] powerpc/pseries: Report in kernel device tree update to drmgr
Quoted 7 lines · Tyrel Datwyler
In this case we get a double update which I clearly neglected to mention
in the patch. The first patch in this series actually removes an unnecessary double update from the existing kernel implementation. The same information is returned by the update-nodes/properties call the second time around and aside from being a waste of a few cycles is harmless.
Thanks. Can you resend the patches with updated descriptions ? I will try to send them to Linus by end of week.
Cheers,
Ben.
Quoted 22 lines · Tyrel Datwyler
This patchset fixes a couple of issues encountered in the suspend/resume code base. First when using the kernel device tree update code update-nodes is unnecessarily called more than once. Second the cpu cache lists are not updated after a suspend/resume which under certain conditions may cause a panic. Finally, since the cache list fix utilzes in kernel device tree update code a means for telling drmgr not to perform a device tree update from userspace is required.
Changes from v2:
- Moved dynamic configuration update code into pseries specific routine per Nathan's suggestion.Changes from v1:
- Fixed several commit message typos
- Fixed authorship of first two patchesHaren Myneni (2):
powerpc/pseries: Device tree should only be updated once after
suspend/migrate
powerpc/pseries: Update dynamic cache nodes for suspend/resume
operation
Quoted 8 lines
Tyrel Datwyler (1):
powerpc/pseries: Report in kernel device tree update to drmgrarch/powerpc/include/asm/rtas.h | 1 + arch/powerpc/platforms/pseries/mobility.c | 26 +++++++----------- arch/powerpc/platforms/pseries/suspend.c | 44 ++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 17 deletions(-)
Ping?
Nathan, can I at least get your ack on this v3 patchset. We really need to get these upstream.
-Tyrel