On Mon, 24 Feb 2025 19:37:03 +0100
Eric Auger <eric.au...@redhat.com> wrote:

> Hi Alex,
> 
> On 2/20/25 11:48 PM, Alex Williamson wrote:
> > Switch callers directly initializing the PCI PM capability with
> > pci_add_capability() to use pci_pm_init().
> >
> > Cc: Dmitry Fleytman <dmitry.fleyt...@gmail.com>
> > Cc: Akihiko Odaki <akihiko.od...@daynix.com>
> > Cc: Jason Wang <jasow...@redhat.com>
> > Cc: Stefan Weil <s...@weilnetz.de>
> > Cc: Sriram Yagnaraman <sriram.yagnara...@ericsson.com>
> > Cc: Keith Busch <kbu...@kernel.org>
> > Cc: Klaus Jensen <i...@irrelevant.dk>
> > Cc: Jesper Devantier <f...@defmacro.it>
> > Cc: Michael S. Tsirkin <m...@redhat.com>
> > Cc: Marcel Apfelbaum <marcel.apfelb...@gmail.com>
> > Cc: Cédric Le Goater <c...@redhat.com>
> > Signed-off-by: Alex Williamson <alex.william...@redhat.com>
> > ---
> >  hw/net/e1000e.c                 | 3 +--
> >  hw/net/eepro100.c               | 4 +---
> >  hw/net/igb.c                    | 3 +--
> >  hw/nvme/ctrl.c                  | 3 +--
> >  hw/pci-bridge/pcie_pci_bridge.c | 2 +-
> >  hw/vfio/pci.c                   | 2 +-
> >  hw/virtio/virtio-pci.c          | 3 +--
> >  7 files changed, 7 insertions(+), 13 deletions(-)
> >
> > diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
> > index f637853073e2..b72cbab7e889 100644
> > --- a/hw/net/e1000e.c
> > +++ b/hw/net/e1000e.c
> > @@ -372,8 +372,7 @@ static int
> >  e1000e_add_pm_capability(PCIDevice *pdev, uint8_t offset, uint16_t pmc)
> >  {
> >      Error *local_err = NULL;
> > -    int ret = pci_add_capability(pdev, PCI_CAP_ID_PM, offset,
> > -                                 PCI_PM_SIZEOF, &local_err);
> > +    int ret = pci_pm_init(pdev, offset, &local_err);
> >  
> >      if (local_err) {
> >          error_report_err(local_err);
> > diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> > index 6d853229aec2..29a39865a608 100644
> > --- a/hw/net/eepro100.c
> > +++ b/hw/net/eepro100.c
> > @@ -551,9 +551,7 @@ static void e100_pci_reset(EEPRO100State *s, Error 
> > **errp)
> >      if (info->power_management) {
> >          /* Power Management Capabilities */
> >          int cfg_offset = 0xdc;
> > -        int r = pci_add_capability(&s->dev, PCI_CAP_ID_PM,
> > -                                   cfg_offset, PCI_PM_SIZEOF,
> > -                                   errp);
> > +        int r = pci_pm_init(&s->dev, cfg_offset, errp);
> >          if (r < 0) {
> >              return;
> >          }
> > diff --git a/hw/net/igb.c b/hw/net/igb.c
> > index 4d93ce629f95..700dbc746d3d 100644
> > --- a/hw/net/igb.c
> > +++ b/hw/net/igb.c
> > @@ -356,8 +356,7 @@ static int
> >  igb_add_pm_capability(PCIDevice *pdev, uint8_t offset, uint16_t pmc)
> >  {
> >      Error *local_err = NULL;
> > -    int ret = pci_add_capability(pdev, PCI_CAP_ID_PM, offset,
> > -                                 PCI_PM_SIZEOF, &local_err);
> > +    int ret = pci_pm_init(pdev, offset, &local_err);
> >  
> >      if (local_err) {
> >          error_report_err(local_err);
> > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > index 68903d1d7067..1faea3d2b85b 100644
> > --- a/hw/nvme/ctrl.c
> > +++ b/hw/nvme/ctrl.c
> > @@ -8503,8 +8503,7 @@ static int nvme_add_pm_capability(PCIDevice *pci_dev, 
> > uint8_t offset)
> >      Error *err = NULL;
> >      int ret;
> >  
> > -    ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, offset,
> > -                             PCI_PM_SIZEOF, &err);
> > +    ret = pci_pm_init(pci_dev, offset, &err);
> >      if (err) {
> >          error_report_err(err);
> >          return ret;  
> nit: below there is a redundant
>     pci_set_word(pci_dev->wmask + offset + PCI_PM_CTRL,
>                  PCI_PM_CTRL_STATE_MASK);

Indeed there is, thanks for spotting that!  I'll fix it in the next
spin.  Thanks,

Alex


Reply via email to