[EXT] Re: [PATCH] nvme: Add abrupt shutdown support
Keith Busch
kbusch at kernel.org
Tue Jul 6 08:07:11 PDT 2021
On Tue, Jul 06, 2021 at 08:14:45AM +0000, Shivamurthy Shastri (sshivamurthy) wrote:
> > Is it the device that wants an abrupt shutdown or the platform? If the
> > platform's power is running on limited back-up supply, and could inform
> > the kernel's power management subsystem of this, then a driver could use
> > that to determine if the quick shutdown is appropriate.
>
> Yes, the platform is running on limited back-up supply. In this case, abrupt shutdown
> option will help to achieve shutdown with relatively low back-up requirements.
>
> Please let me know if you want to include the abrupt shutdown as part of
>
> static const struct dev_pm_ops nvme_dev_pm_ops = {
> .suspend = nvme_suspend,
> .....
Are you suggesting creating a new pm callback just for this? I don't
think that's necessary.
I was considering just adding a bit to the pm_suspend_global_flags,
something like the patch below. You just have to fill in the platform
specific parts to set the flag.
---
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 8af13ba60c7e..f43c0b2313d0 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -210,9 +210,10 @@ extern int suspend_valid_only_mem(suspend_state_t state);
extern unsigned int pm_suspend_global_flags;
-#define PM_SUSPEND_FLAG_FW_SUSPEND BIT(0)
-#define PM_SUSPEND_FLAG_FW_RESUME BIT(1)
-#define PM_SUSPEND_FLAG_NO_PLATFORM BIT(2)
+#define PM_SUSPEND_FLAG_FW_SUSPEND BIT(0)
+#define PM_SUSPEND_FLAG_FW_RESUME BIT(1)
+#define PM_SUSPEND_FLAG_NO_PLATFORM BIT(2)
+#define PM_SUSPEND_FLAG_POWER_LOSS_IMMINENT BIT(3)
static inline void pm_suspend_clear_flags(void)
{
@@ -234,6 +235,11 @@ static inline void pm_set_suspend_no_platform(void)
pm_suspend_global_flags |= PM_SUSPEND_FLAG_NO_PLATFORM;
}
+static inline void pm_set_power_loss_imminent(void)
+{
+ pm_suspend_global_flags |= PM_SUSPEND_FLAG_POWER_LOSS_IMMINENT;
+}
+
/**
* pm_suspend_via_firmware - Check if platform firmware will suspend the system.
*
@@ -291,6 +297,21 @@ static inline bool pm_suspend_no_platform(void)
return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_NO_PLATFORM);
}
+/**
+ * pm_power_loss_imminent - Check if platform is running on limited backup
+ * power source
+ *
+ * To be called during system-wide power management transitions to sleep states.
+ *
+ * Return 'true' if power loss may be imminent due to platform running on
+ * limited backup supply. If set during a shutdown, drivers should use any
+ * available shortcuts to prepare their device for abrupt power loss.
+ */
+static inline bool pm_power_loss_imminent(void)
+{
+ return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_POWER_LOSS_IMMINENT);
+}
+
/* Suspend-to-idle state machnine. */
enum s2idle_states {
S2IDLE_STATE_NONE, /* Not suspended/suspending. */
--
More information about the Linux-nvme
mailing list