From: Tanjore Suresh <tansuresh@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-pci@vger.kernel.org, Tanjore Suresh <tansuresh@google.com>
Subject: [PATCH v1 2/3] PCI: Support asynchronous shutdown
Date: Mon, 28 Mar 2022 16:00:07 -0700 [thread overview]
Message-ID: <20220328230008.3587975-3-tansuresh@google.com> (raw)
In-Reply-To: <20220328230008.3587975-2-tansuresh@google.com>
Enhances the base PCI driver to add support for asynchronous
shutdown.
Assume a device takes n secs to shutdown. If a machine has been
populated with M such devices, the total time spent in shutting down
all the devices will be M * n secs, if the shutdown is done
synchronously. For example, if NVMe PCI Controllers take 5 secs
to shutdown and if there are 16 such NVMe controllers in a system,
system will spend a total of 80 secs to shutdown all
NVMe devices in that system.
In order to speed up the shutdown time, asynchronous interface to
shutdown has been implemented. This will significantly reduce
the machine reboot time.
Signed-off-by: Tanjore Suresh <tansuresh@google.com>
---
drivers/pci/pci-driver.c | 17 ++++++++++++++---
include/linux/pci.h | 2 ++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 4ceeb75fc899..0d0b46d71e88 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -501,14 +501,16 @@ static void pci_device_remove(struct device *dev)
pci_dev_put(pci_dev);
}
-static void pci_device_shutdown(struct device *dev)
+static void pci_device_shutdown_pre(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct pci_driver *drv = pci_dev->driver;
pm_runtime_resume(dev);
- if (drv && drv->shutdown)
+ if (drv && drv->shutdown_pre)
+ drv->shutdown_pre(pci_dev);
+ else if (drv && drv->shutdown)
drv->shutdown(pci_dev);
/*
@@ -522,6 +524,14 @@ static void pci_device_shutdown(struct device *dev)
pci_clear_master(pci_dev);
}
+static void pci_device_shutdown_post(struct device *dev)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+ struct pci_driver *drv = pci_dev->driver;
+
+ if (drv && drv->shutdown_post)
+ drv->shutdown_post(pci_dev);
+}
#ifdef CONFIG_PM
/* Auxiliary functions used for system resume and run-time resume. */
@@ -1625,7 +1635,8 @@ struct bus_type pci_bus_type = {
.uevent = pci_uevent,
.probe = pci_device_probe,
.remove = pci_device_remove,
- .shutdown = pci_device_shutdown,
+ .shutdown_pre = pci_device_shutdown_pre,
+ .shutdown_post = pci_device_shutdown_post,
.dev_groups = pci_dev_groups,
.bus_groups = pci_bus_groups,
.drv_groups = pci_drv_groups,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b957eeb89c7a..19047fcb3c8a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -905,6 +905,8 @@ struct pci_driver {
int (*suspend)(struct pci_dev *dev, pm_message_t state); /* Device suspended */
int (*resume)(struct pci_dev *dev); /* Device woken up */
void (*shutdown)(struct pci_dev *dev);
+ void (*shutdown_pre)(struct pci_dev *dev);
+ void (*shutdown_post)(struct pci_dev *dev);
int (*sriov_configure)(struct pci_dev *dev, int num_vfs); /* On PF */
int (*sriov_set_msix_vec_count)(struct pci_dev *vf, int msix_vec_count); /* On PF */
u32 (*sriov_get_vf_total_msix)(struct pci_dev *pf);
--
2.35.1.1021.g381101b075-goog
next prev parent reply other threads:[~2022-03-28 23:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 23:00 [PATCH v1 0/3] Asynchronous shutdown interface and example implementation Tanjore Suresh
2022-03-28 23:00 ` [PATCH v1 1/3] driver core: Support asynchronous driver shutdown Tanjore Suresh
2022-03-28 23:00 ` Tanjore Suresh [this message]
2022-03-28 23:00 ` [PATCH v1 3/3] nvme: Add async shutdown support Tanjore Suresh
2022-03-29 0:19 ` [PATCH v1 1/3] driver core: Support asynchronous driver shutdown Oliver O'Halloran
2022-03-30 14:12 ` Belanger, Martin
2022-03-31 12:07 ` Daniel Wagner
2022-03-31 16:57 ` Jonathan Derrick
2022-03-29 5:26 ` [PATCH v1 0/3] Asynchronous shutdown interface and example implementation Greg Kroah-Hartman
2022-03-30 2:07 ` Keith Busch
2022-03-30 6:25 ` Lukas Wunner
2022-03-30 11:13 ` Rafael J. Wysocki
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=20220328230008.3587975-3-tansuresh@google.com \
--to=tansuresh@google.com \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sagi@grimberg.me \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®