Michal Suchanek ec48ee
From 52719fce3f4c7a8ac9eaa191e8d75a697f9fbcbc Mon Sep 17 00:00:00 2001
Michal Suchanek ec48ee
From: Nathan Lynch <nathanl@linux.ibm.com>
Michal Suchanek ec48ee
Date: Mon, 7 Dec 2020 15:51:49 -0600
Michal Suchanek ec48ee
Subject: [PATCH] powerpc/pseries/hibernation: drop pseries_suspend_begin()
Michal Suchanek ec48ee
 from suspend ops
Michal Suchanek ec48ee
Michal Suchanek ec48ee
References: bsc#1181674 ltc#189159
Michal Suchanek ec48ee
Patch-mainline: v5.11-rc1
Michal Suchanek ec48ee
Git-commit: 52719fce3f4c7a8ac9eaa191e8d75a697f9fbcbc
Michal Suchanek ec48ee
Michal Suchanek ec48ee
There are three ways pseries_suspend_begin() can be reached:
Michal Suchanek ec48ee
Michal Suchanek ec48ee
1. When "mem" is written to /sys/power/state:
Michal Suchanek ec48ee
Michal Suchanek ec48ee
kobj_attr_store()
Michal Suchanek ec48ee
-> state_store()
Michal Suchanek ec48ee
  -> pm_suspend()
Michal Suchanek ec48ee
    -> suspend_devices_and_enter()
Michal Suchanek ec48ee
      -> pseries_suspend_begin()
Michal Suchanek ec48ee
Michal Suchanek ec48ee
This never works because there is no way to supply a valid stream id
Michal Suchanek ec48ee
using this interface, and H_VASI_STATE is called with a stream id of
Michal Suchanek ec48ee
zero. So this call path is useless at best.
Michal Suchanek ec48ee
Michal Suchanek ec48ee
2. When a stream id is written to /sys/devices/system/power/hibernate.
Michal Suchanek ec48ee
pseries_suspend_begin() is polled directly from store_hibernate()
Michal Suchanek ec48ee
until the stream is in the "Suspending" state (i.e. the platform is
Michal Suchanek ec48ee
ready for the OS to suspend execution):
Michal Suchanek ec48ee
Michal Suchanek ec48ee
dev_attr_store()
Michal Suchanek ec48ee
-> store_hibernate()
Michal Suchanek ec48ee
  -> pseries_suspend_begin()
Michal Suchanek ec48ee
Michal Suchanek ec48ee
3. When a stream id is written to /sys/devices/system/power/hibernate
Michal Suchanek ec48ee
(continued). After #2, pseries_suspend_begin() is called once again
Michal Suchanek ec48ee
from the pm core:
Michal Suchanek ec48ee
Michal Suchanek ec48ee
dev_attr_store()
Michal Suchanek ec48ee
-> store_hibernate()
Michal Suchanek ec48ee
  -> pm_suspend()
Michal Suchanek ec48ee
    -> suspend_devices_and_enter()
Michal Suchanek ec48ee
      -> pseries_suspend_begin()
Michal Suchanek ec48ee
Michal Suchanek ec48ee
This is redundant because the VASI suspend state is already known to
Michal Suchanek ec48ee
be Suspending.
Michal Suchanek ec48ee
Michal Suchanek ec48ee
The begin() callback of platform_suspend_ops is optional, so we can
Michal Suchanek ec48ee
simply remove that assignment with no loss of function.
Michal Suchanek ec48ee
Michal Suchanek ec48ee
Fixes: 32d8ad4e621d ("powerpc/pseries: Partition hibernation support")
Michal Suchanek ec48ee
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Michal Suchanek ec48ee
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Michal Suchanek ec48ee
Link: https://lore.kernel.org/r/20201207215200.1785968-18-nathanl@linux.ibm.com
Michal Suchanek ec48ee
Acked-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek ec48ee
---
Michal Suchanek ec48ee
 arch/powerpc/platforms/pseries/suspend.c | 1 -
Michal Suchanek ec48ee
 1 file changed, 1 deletion(-)
Michal Suchanek ec48ee
Michal Suchanek ec48ee
diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
Michal Suchanek ec48ee
index 81e0ac58d620..3eaa9d59dc7a 100644
Michal Suchanek ec48ee
--- a/arch/powerpc/platforms/pseries/suspend.c
Michal Suchanek ec48ee
+++ b/arch/powerpc/platforms/pseries/suspend.c
Michal Suchanek ec48ee
@@ -187,7 +187,6 @@ static struct bus_type suspend_subsys = {
Michal Suchanek ec48ee
 
Michal Suchanek ec48ee
 static const struct platform_suspend_ops pseries_suspend_ops = {
Michal Suchanek ec48ee
 	.valid		= suspend_valid_only_mem,
Michal Suchanek ec48ee
-	.begin		= pseries_suspend_begin,
Michal Suchanek ec48ee
 	.prepare_late	= pseries_prepare_late,
Michal Suchanek ec48ee
 	.enter		= pseries_suspend_enter,
Michal Suchanek ec48ee
 };
Michal Suchanek ec48ee
-- 
Michal Suchanek ec48ee
2.26.2
Michal Suchanek ec48ee