From: Vaibhav Gupta <vaibhavgupta40@gmail.com>
To: Bjorn Helgaas <helgaas@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Bjorn Helgaas <bjorn@helgaas.com>,
Vaibhav Gupta <vaibhav.varodek@gmail.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2] scsi: stex: use generic power management
Date: Mon, 17 Aug 2020 13:39:45 +0530 [thread overview]
Message-ID: <20200817080945.GG5869@gmail.com> (raw)
In-Reply-To: <20200730101658.576205-1-vaibhavgupta40@gmail.com>
On Thu, Jul 30, 2020 at 03:46:58PM +0530, Vaibhav Gupta wrote:
> Drivers using legacy power management .suspen()/.resume() callbacks
> have to manage PCI states and device's PM states themselves. They also
> need to take care of standard configuration registers.
>
> Switch to generic power management framework using a single
> "struct dev_pm_ops" variable to take the unnecessary load from the driver.
> This also avoids the need for the driver to directly call most of the PCI
> helper functions and device power state control functions, as through
> the generic framework PCI Core takes care of the necessary operations,
> and drivers are required to do only device-specific jobs.
>
> Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
> ---
> drivers/scsi/stex.c | 37 +++++++++++++++++++++++++++++++------
> 1 file changed, 31 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index d4f10c0d813c..5ef6f3cbac11 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -1972,9 +1972,9 @@ static int stex_choice_sleep_mic(struct st_hba *hba, pm_message_t state)
> }
> }
>
> -static int stex_suspend(struct pci_dev *pdev, pm_message_t state)
> +static int stex_suspend_late(struct device *dev, pm_message_t state)
> {
> - struct st_hba *hba = pci_get_drvdata(pdev);
> + struct st_hba *hba = dev_get_drvdata(dev);
>
> if ((hba->cardtype == st_yel || hba->cardtype == st_P3)
> && hba->supports_pm == 1)
> @@ -1984,9 +1984,24 @@ static int stex_suspend(struct pci_dev *pdev, pm_message_t state)
> return 0;
> }
>
> -static int stex_resume(struct pci_dev *pdev)
> +static int __maybe_unused stex_suspend(struct device *dev)
> {
> - struct st_hba *hba = pci_get_drvdata(pdev);
> + return stex_suspend_late(dev, PMSG_SUSPEND);
> +}
> +
> +static int __maybe_unused stex_hibernate(struct device *dev)
> +{
> + return stex_suspend_late(dev, PMSG_HIBERNATE);
> +}
> +
> +static int __maybe_unused stex_freeze(struct device *dev)
> +{
> + return stex_suspend_late(dev, PMSG_FREEZE);
> +}
> +
> +static int __maybe_unused stex_resume(struct device *dev)
> +{
> + struct st_hba *hba = dev_get_drvdata(dev);
>
> hba->mu_status = MU_STATE_STARTING;
> stex_handshake(hba);
> @@ -2000,14 +2015,24 @@ static int stex_halt(struct notifier_block *nb, unsigned long event, void *buf)
> }
> MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
>
> +static const struct dev_pm_ops stex_pm_ops = {
> +#ifdef CONFIG_PM_SLEEP
> + .suspend = stex_suspend,
> + .resume = stex_resume,
> + .freeze = stex_freeze,
> + .thaw = stex_resume,
> + .poweroff = stex_hibernate,
> + .restore = stex_resume,
> +#endif
> +};
> +
> static struct pci_driver stex_pci_driver = {
> .name = DRV_NAME,
> .id_table = stex_pci_tbl,
> .probe = stex_probe,
> .remove = stex_remove,
> .shutdown = stex_shutdown,
> - .suspend = stex_suspend,
> - .resume = stex_resume,
> + .driver.pm = &stex_pm_ops,
> };
>
> static int __init stex_init(void)
> --
> 2.27.0
>
prev parent reply other threads:[~2020-08-17 8:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-30 10:16 [PATCH v2] scsi: stex: use generic power management Vaibhav Gupta
2020-07-30 10:21 ` Vaibhav Gupta
2020-08-17 8:09 ` Vaibhav Gupta [this message]
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=20200817080945.GG5869@gmail.com \
--to=vaibhavgupta40@gmail.com \
--cc=bhelgaas@google.com \
--cc=bjorn@helgaas.com \
--cc=helgaas@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=skhan@linuxfoundation.org \
--cc=vaibhav.varodek@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).