From: Vaibhav Gupta <vaibhavgupta40@gmail.com>
To: Damien Le Moal <Damien.LeMoal@wdc.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Bjorn Helgaas <bjorn@helgaas.com>,
Vaibhav Gupta <vaibhav.varodek@gmail.com>,
Jens Axboe <axboe@kernel.dk>,
Joshua Morris <josh.h.morris@us.ibm.com>,
Philip Kelleher <pjk1939@linux.ibm.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-kernel-mentees@lists.linuxfoundation.org"
<linux-kernel-mentees@lists.linuxfoundation.org>,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v1 3/3] skd: use generic power management
Date: Mon, 20 Jul 2020 18:46:27 +0530 [thread overview]
Message-ID: <20200720131627.GA447599@gmail.com> (raw)
In-Reply-To: <CY4PR04MB37516C5544A7DCAD84921937E77B0@CY4PR04MB3751.namprd04.prod.outlook.com>
On Mon, Jul 20, 2020 at 12:52:14PM +0000, Damien Le Moal wrote:
> On 2020/07/17 17:10, Vaibhav Gupta wrote:
> > Drivers using legacy PM have to manage PCI states and device's PM states
> > themselves. They also need to take care of configuration registers.
> >
> > With improved and powerful support of generic PM, PCI Core takes care of
> > above mentioned, device-independent, jobs.
> >
> > This driver makes use of PCI helper functions like
> > pci_save/restore_state(), pci_enable/disable_device(),
> > pci_request/release_regions(), pci_set_power_state() and
> > pci_set_master() to do required operations. In generic mode, they are no
> > longer needed.
> >
> > Change function parameter in both .suspend() and .resume() to
> > "struct device*" type. Use to_pci_dev() to get "struct pci_dev*" variable.
> >
> > Compile-tested only.
>
> I do not think this belongs into the commit message. This was mentioned in the
> cover letter.
>
The messages in cover letter and commit message are bit similar. But the commit
message has patch specific changes mentioned in it.
> >
> > Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
> > ---
> > drivers/block/skd_main.c | 36 ++++++++++--------------------------
> > 1 file changed, 10 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> > index 51569c199a6c..d8d1042e7338 100644
> > --- a/drivers/block/skd_main.c
> > +++ b/drivers/block/skd_main.c
> > @@ -3315,12 +3315,12 @@ static void skd_pci_remove(struct pci_dev *pdev)
> > return;
> > }
> >
> > -static int skd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
> > +static int __maybe_unused skd_pci_suspend(struct device *dev)
> > {
> > int i;
> > - struct skd_device *skdev;
> > + struct pci_dev *pdev = to_pci_dev(dev);
> > + struct skd_device *skdev = pci_get_drvdata(pdev);
>
> You can just add the pdev declaration here. The other 2 changes are not needed.
>
Okay.
> >
> > - skdev = pci_get_drvdata(pdev);
>
> You can keep this as is.
>
> > if (!skdev) {
> > dev_err(&pdev->dev, "no device data for PCI\n");
> > return -EIO;
> > @@ -3337,35 +3337,23 @@ static int skd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
> > if (skdev->pcie_error_reporting_is_enabled)
> > pci_disable_pcie_error_reporting(pdev);
> >
> > - pci_release_regions(pdev);
> > - pci_save_state(pdev);
> > - pci_disable_device(pdev);
> > - pci_set_power_state(pdev, pci_choose_state(pdev, state));
> > return 0;
> > }
> >
> > -static int skd_pci_resume(struct pci_dev *pdev)
> > +static int __maybe_unused skd_pci_resume(struct device *dev)
> > {
> > int i;
> > int rc = 0;
> > - struct skd_device *skdev;
> >
> > - skdev = pci_get_drvdata(pdev);
>
> Same comment as above. Keep these as is and add only pdev declaration.
>
Okay.
Sending v2 with suggested changes.
--Vaibhav Gupta
> > + struct pci_dev *pdev = to_pci_dev(dev);
> > + struct skd_device *skdev = pci_get_drvdata(pdev);
> > if (!skdev) {
> > dev_err(&pdev->dev, "no device data for PCI\n");
> > return -1;
> > }
> >
> > - pci_set_power_state(pdev, PCI_D0);
> > - pci_enable_wake(pdev, PCI_D0, 0);
> > - pci_restore_state(pdev);
> > + device_wakeup_disable(dev);
> >
> > - rc = pci_enable_device(pdev);
> > - if (rc)
> > - return rc;
> > - rc = pci_request_regions(pdev, DRV_NAME);
> > - if (rc)
> > - goto err_out;
> > rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> > if (rc)
> > rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> > @@ -3374,7 +3362,6 @@ static int skd_pci_resume(struct pci_dev *pdev)
> > goto err_out_regions;
> > }
> >
> > - pci_set_master(pdev);
> > rc = pci_enable_pcie_error_reporting(pdev);
> > if (rc) {
> > dev_err(&pdev->dev,
> > @@ -3427,10 +3414,6 @@ static int skd_pci_resume(struct pci_dev *pdev)
> > pci_disable_pcie_error_reporting(pdev);
> >
> > err_out_regions:
> > - pci_release_regions(pdev);
> > -
> > -err_out:
> > - pci_disable_device(pdev);
> > return rc;
> > }
> >
> > @@ -3450,13 +3433,14 @@ static void skd_pci_shutdown(struct pci_dev *pdev)
> > skd_stop_device(skdev);
> > }
> >
> > +static SIMPLE_DEV_PM_OPS(skd_pci_pm_ops, skd_pci_suspend, skd_pci_resume);
> > +
> > static struct pci_driver skd_driver = {
> > .name = DRV_NAME,
> > .id_table = skd_pci_tbl,
> > .probe = skd_pci_probe,
> > .remove = skd_pci_remove,
> > - .suspend = skd_pci_suspend,
> > - .resume = skd_pci_resume,
> > + .driver.pm = &skd_pci_pm_ops,
> > .shutdown = skd_pci_shutdown,
> > };
> >
> >
>
>
> --
> Damien Le Moal
> Western Digital Research
WARNING: multiple messages have this Message-ID (diff)
From: Vaibhav Gupta <vaibhavgupta40@gmail.com>
To: Damien Le Moal <Damien.LeMoal@wdc.com>
Cc: Jens Axboe <axboe@kernel.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Bjorn Helgaas <helgaas@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Philip Kelleher <pjk1939@linux.ibm.com>,
"linux-kernel-mentees@lists.linuxfoundation.org"
<linux-kernel-mentees@lists.linuxfoundation.org>,
Joshua Morris <josh.h.morris@us.ibm.com>
Subject: Re: [Linux-kernel-mentees] [PATCH v1 3/3] skd: use generic power management
Date: Mon, 20 Jul 2020 18:46:27 +0530 [thread overview]
Message-ID: <20200720131627.GA447599@gmail.com> (raw)
In-Reply-To: <CY4PR04MB37516C5544A7DCAD84921937E77B0@CY4PR04MB3751.namprd04.prod.outlook.com>
On Mon, Jul 20, 2020 at 12:52:14PM +0000, Damien Le Moal wrote:
> On 2020/07/17 17:10, Vaibhav Gupta wrote:
> > Drivers using legacy PM have to manage PCI states and device's PM states
> > themselves. They also need to take care of configuration registers.
> >
> > With improved and powerful support of generic PM, PCI Core takes care of
> > above mentioned, device-independent, jobs.
> >
> > This driver makes use of PCI helper functions like
> > pci_save/restore_state(), pci_enable/disable_device(),
> > pci_request/release_regions(), pci_set_power_state() and
> > pci_set_master() to do required operations. In generic mode, they are no
> > longer needed.
> >
> > Change function parameter in both .suspend() and .resume() to
> > "struct device*" type. Use to_pci_dev() to get "struct pci_dev*" variable.
> >
> > Compile-tested only.
>
> I do not think this belongs into the commit message. This was mentioned in the
> cover letter.
>
The messages in cover letter and commit message are bit similar. But the commit
message has patch specific changes mentioned in it.
> >
> > Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
> > ---
> > drivers/block/skd_main.c | 36 ++++++++++--------------------------
> > 1 file changed, 10 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> > index 51569c199a6c..d8d1042e7338 100644
> > --- a/drivers/block/skd_main.c
> > +++ b/drivers/block/skd_main.c
> > @@ -3315,12 +3315,12 @@ static void skd_pci_remove(struct pci_dev *pdev)
> > return;
> > }
> >
> > -static int skd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
> > +static int __maybe_unused skd_pci_suspend(struct device *dev)
> > {
> > int i;
> > - struct skd_device *skdev;
> > + struct pci_dev *pdev = to_pci_dev(dev);
> > + struct skd_device *skdev = pci_get_drvdata(pdev);
>
> You can just add the pdev declaration here. The other 2 changes are not needed.
>
Okay.
> >
> > - skdev = pci_get_drvdata(pdev);
>
> You can keep this as is.
>
> > if (!skdev) {
> > dev_err(&pdev->dev, "no device data for PCI\n");
> > return -EIO;
> > @@ -3337,35 +3337,23 @@ static int skd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
> > if (skdev->pcie_error_reporting_is_enabled)
> > pci_disable_pcie_error_reporting(pdev);
> >
> > - pci_release_regions(pdev);
> > - pci_save_state(pdev);
> > - pci_disable_device(pdev);
> > - pci_set_power_state(pdev, pci_choose_state(pdev, state));
> > return 0;
> > }
> >
> > -static int skd_pci_resume(struct pci_dev *pdev)
> > +static int __maybe_unused skd_pci_resume(struct device *dev)
> > {
> > int i;
> > int rc = 0;
> > - struct skd_device *skdev;
> >
> > - skdev = pci_get_drvdata(pdev);
>
> Same comment as above. Keep these as is and add only pdev declaration.
>
Okay.
Sending v2 with suggested changes.
--Vaibhav Gupta
> > + struct pci_dev *pdev = to_pci_dev(dev);
> > + struct skd_device *skdev = pci_get_drvdata(pdev);
> > if (!skdev) {
> > dev_err(&pdev->dev, "no device data for PCI\n");
> > return -1;
> > }
> >
> > - pci_set_power_state(pdev, PCI_D0);
> > - pci_enable_wake(pdev, PCI_D0, 0);
> > - pci_restore_state(pdev);
> > + device_wakeup_disable(dev);
> >
> > - rc = pci_enable_device(pdev);
> > - if (rc)
> > - return rc;
> > - rc = pci_request_regions(pdev, DRV_NAME);
> > - if (rc)
> > - goto err_out;
> > rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> > if (rc)
> > rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> > @@ -3374,7 +3362,6 @@ static int skd_pci_resume(struct pci_dev *pdev)
> > goto err_out_regions;
> > }
> >
> > - pci_set_master(pdev);
> > rc = pci_enable_pcie_error_reporting(pdev);
> > if (rc) {
> > dev_err(&pdev->dev,
> > @@ -3427,10 +3414,6 @@ static int skd_pci_resume(struct pci_dev *pdev)
> > pci_disable_pcie_error_reporting(pdev);
> >
> > err_out_regions:
> > - pci_release_regions(pdev);
> > -
> > -err_out:
> > - pci_disable_device(pdev);
> > return rc;
> > }
> >
> > @@ -3450,13 +3433,14 @@ static void skd_pci_shutdown(struct pci_dev *pdev)
> > skd_stop_device(skdev);
> > }
> >
> > +static SIMPLE_DEV_PM_OPS(skd_pci_pm_ops, skd_pci_suspend, skd_pci_resume);
> > +
> > static struct pci_driver skd_driver = {
> > .name = DRV_NAME,
> > .id_table = skd_pci_tbl,
> > .probe = skd_pci_probe,
> > .remove = skd_pci_remove,
> > - .suspend = skd_pci_suspend,
> > - .resume = skd_pci_resume,
> > + .driver.pm = &skd_pci_pm_ops,
> > .shutdown = skd_pci_shutdown,
> > };
> >
> >
>
>
> --
> Damien Le Moal
> Western Digital Research
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next prev parent reply other threads:[~2020-07-20 13:17 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 8:09 [PATCH v1 0/3] block: use generic power management Vaibhav Gupta
2020-07-17 8:09 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-17 8:09 ` [PATCH v1 1/3] mtip32xx: " Vaibhav Gupta
2020-07-17 8:09 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-17 8:09 ` [PATCH v1 2/3] rsxx: " Vaibhav Gupta
2020-07-17 8:09 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-17 8:09 ` [PATCH v1 3/3] skd: " Vaibhav Gupta
2020-07-17 8:09 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-20 12:52 ` Damien Le Moal
2020-07-20 12:52 ` [Linux-kernel-mentees] " Damien Le Moal
2020-07-20 13:16 ` Vaibhav Gupta [this message]
2020-07-20 13:16 ` Vaibhav Gupta
2020-07-21 2:49 ` Damien Le Moal
2020-07-21 2:49 ` [Linux-kernel-mentees] " Damien Le Moal
2020-07-21 7:04 ` Vaibhav Gupta
2020-07-21 7:04 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-20 13:29 ` [PATCH v2 0/3] block: " Vaibhav Gupta
2020-07-20 13:29 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-20 13:30 ` [PATCH v2 1/3] mtip32xx: " Vaibhav Gupta
2020-07-20 13:30 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-20 13:30 ` [PATCH v2 2/3] rsxx: " Vaibhav Gupta
2020-07-20 13:30 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-20 13:30 ` [PATCH v2 3/3] skd: " Vaibhav Gupta
2020-07-20 13:30 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-21 2:57 ` Damien Le Moal
2020-07-21 2:57 ` [Linux-kernel-mentees] " Damien Le Moal
2020-07-21 7:09 ` Vaibhav Gupta
2020-07-21 7:09 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-22 6:28 ` Damien Le Moal
2020-07-22 6:28 ` [Linux-kernel-mentees] " Damien Le Moal
2020-07-22 7:21 ` Vaibhav Gupta
2020-07-22 7:21 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-22 8:33 ` [PATCH v3 0/3] block: " Vaibhav Gupta
2020-07-22 8:33 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-22 8:33 ` [PATCH v3 1/3] mtip32xx: " Vaibhav Gupta
2020-07-22 8:33 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-22 8:33 ` [PATCH v3 2/3] rsxx: " Vaibhav Gupta
2020-07-22 8:33 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-22 8:33 ` [PATCH v3 3/3] skd: " Vaibhav Gupta
2020-07-22 8:33 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-27 2:14 ` Damien Le Moal
2020-07-27 2:14 ` [Linux-kernel-mentees] " Damien Le Moal
2020-08-17 7:55 ` [PATCH v3 0/3] block: " Vaibhav Gupta
2020-08-17 7:55 ` [Linux-kernel-mentees] " Vaibhav Gupta
2021-01-14 11:54 ` [PATCH v4 " Vaibhav Gupta
2021-01-14 11:54 ` [Linux-kernel-mentees] " Vaibhav Gupta
2021-01-14 11:54 ` [PATCH v4 1/3] mtip32xx: " Vaibhav Gupta
2021-01-14 11:54 ` [Linux-kernel-mentees] " Vaibhav Gupta
2021-01-14 11:54 ` [PATCH v4 2/3] rsxx: " Vaibhav Gupta
2021-01-14 11:54 ` [Linux-kernel-mentees] " Vaibhav Gupta
2021-01-14 11:54 ` [PATCH v4 3/3] skd: " Vaibhav Gupta
2021-01-14 11:54 ` [Linux-kernel-mentees] " Vaibhav Gupta
2020-07-22 17:52 ` [PATCH v2 " Bjorn Helgaas
2020-07-22 17:52 ` [Linux-kernel-mentees] " Bjorn Helgaas
2020-07-22 18:07 ` Vaibhav Gupta
2020-07-22 18:07 ` [Linux-kernel-mentees] " Vaibhav Gupta
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=20200720131627.GA447599@gmail.com \
--to=vaibhavgupta40@gmail.com \
--cc=Damien.LeMoal@wdc.com \
--cc=axboe@kernel.dk \
--cc=bhelgaas@google.com \
--cc=bjorn@helgaas.com \
--cc=helgaas@kernel.org \
--cc=josh.h.morris@us.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pjk1939@linux.ibm.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 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.