All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: "Shivamurthy Shastri (sshivamurthy)" <sshivamurthy@micron.com>
Cc: Christoph Hellwig <hch@lst.de>, "axboe@fb.com" <axboe@fb.com>,
	"sagi@grimberg.me" <sagi@grimberg.me>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"shiva.linuxworks@gmail.com" <shiva.linuxworks@gmail.com>
Subject: Re: [EXT] Re: [PATCH] nvme: Add abrupt shutdown support
Date: Tue, 6 Jul 2021 08:07:11 -0700	[thread overview]
Message-ID: <20210706150711.GA241231@dhcp-10-100-145-180.wdc.com> (raw)
In-Reply-To: <BLAPR08MB690035C831CF24DE356DEF6FB81B9@BLAPR08MB6900.namprd08.prod.outlook.com>

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. */
--

WARNING: multiple messages have this Message-ID (diff)
From: Keith Busch <kbusch@kernel.org>
To: "Shivamurthy Shastri (sshivamurthy)" <sshivamurthy@micron.com>
Cc: Christoph Hellwig <hch@lst.de>, "axboe@fb.com" <axboe@fb.com>,
	"sagi@grimberg.me" <sagi@grimberg.me>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"shiva.linuxworks@gmail.com" <shiva.linuxworks@gmail.com>
Subject: Re: [EXT] Re: [PATCH] nvme: Add abrupt shutdown support
Date: Tue, 6 Jul 2021 08:07:11 -0700	[thread overview]
Message-ID: <20210706150711.GA241231@dhcp-10-100-145-180.wdc.com> (raw)
In-Reply-To: <BLAPR08MB690035C831CF24DE356DEF6FB81B9@BLAPR08MB6900.namprd08.prod.outlook.com>

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. */
--

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2021-07-06 15:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 10:11 [PATCH] nvme: Add abrupt shutdown support shiva.linuxworks
2021-07-05 10:11 ` shiva.linuxworks
2021-07-05 10:15 ` Christoph Hellwig
2021-07-05 10:15   ` Christoph Hellwig
2021-07-05 10:40   ` [EXT] " Shivamurthy Shastri (sshivamurthy)
2021-07-05 10:40     ` Shivamurthy Shastri (sshivamurthy)
2021-07-05 10:42     ` Christoph Hellwig
2021-07-05 10:42       ` Christoph Hellwig
2021-07-05 11:15       ` Shivamurthy Shastri (sshivamurthy)
2021-07-05 11:15         ` Shivamurthy Shastri (sshivamurthy)
2021-07-05 11:53         ` Christoph Hellwig
2021-07-05 11:53           ` Christoph Hellwig
2021-07-05 13:04           ` Keith Busch
2021-07-05 13:04             ` Keith Busch
2021-07-06  8:14             ` Shivamurthy Shastri (sshivamurthy)
2021-07-06  8:14               ` Shivamurthy Shastri (sshivamurthy)
2021-07-06 15:07               ` Keith Busch [this message]
2021-07-06 15:07                 ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210706150711.GA241231@dhcp-10-100-145-180.wdc.com \
    --to=kbusch@kernel.org \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=shiva.linuxworks@gmail.com \
    --cc=sshivamurthy@micron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.