[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/5] pci: Use PCI PM capability initializer
From: |
Eric Auger |
Subject: |
Re: [PATCH 2/5] pci: Use PCI PM capability initializer |
Date: |
Mon, 24 Feb 2025 19:37:03 +0100 |
User-agent: |
Mozilla Thunderbird |
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.fleytman@gmail.com>
> Cc: Akihiko Odaki <akihiko.odaki@daynix.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Stefan Weil <sw@weilnetz.de>
> Cc: Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Klaus Jensen <its@irrelevant.dk>
> Cc: Jesper Devantier <foss@defmacro.it>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> Cc: Cédric Le Goater <clg@redhat.com>
> Signed-off-by: Alex Williamson <alex.williamson@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);
Thanks
Eric
> diff --git a/hw/pci-bridge/pcie_pci_bridge.c b/hw/pci-bridge/pcie_pci_bridge.c
> index fd4514a595ce..9fa656b43b42 100644
> --- a/hw/pci-bridge/pcie_pci_bridge.c
> +++ b/hw/pci-bridge/pcie_pci_bridge.c
> @@ -52,7 +52,7 @@ static void pcie_pci_bridge_realize(PCIDevice *d, Error
> **errp)
> goto cap_error;
> }
>
> - pos = pci_add_capability(d, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, errp);
> + pos = pci_pm_init(d, 0, errp);
> if (pos < 0) {
> goto pm_error;
> }
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 89d900e9cf0c..6903f831e45f 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2216,7 +2216,7 @@ static bool vfio_add_std_cap(VFIOPCIDevice *vdev,
> uint8_t pos, Error **errp)
> case PCI_CAP_ID_PM:
> vfio_check_pm_reset(vdev, pos);
> vdev->pm_cap = pos;
> - ret = pci_add_capability(pdev, cap_id, pos, size, errp) >= 0;
> + ret = pci_pm_init(pdev, pos, errp) >= 0;
> break;
> case PCI_CAP_ID_AF:
> vfio_check_af_flr(vdev, pos);
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index c773a9130c7e..afe8b5551c5c 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -2204,8 +2204,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev,
> Error **errp)
> pos = pcie_endpoint_cap_init(pci_dev, 0);
> assert(pos > 0);
>
> - pos = pci_add_capability(pci_dev, PCI_CAP_ID_PM, 0,
> - PCI_PM_SIZEOF, errp);
> + pos = pci_pm_init(pci_dev, 0, errp);
> if (pos < 0) {
> return;
> }
- [PATCH 0/5] PCI: Implement basic PCI PM capability backing, Alex Williamson, 2025/02/20
- [PATCH 1/5] hw/pci: Basic support for PCI power management, Alex Williamson, 2025/02/20
- [PATCH 2/5] pci: Use PCI PM capability initializer, Alex Williamson, 2025/02/20
- Re: [PATCH 2/5] pci: Use PCI PM capability initializer,
Eric Auger <=
- [PATCH 5/5] hw/vfio/pci: Re-order pre-reset, Alex Williamson, 2025/02/20
- [PATCH 3/5] vfio/pci: Delete local pm_cap, Alex Williamson, 2025/02/20
- [PATCH 4/5] pcie, virtio: Remove redundant pm_cap, Alex Williamson, 2025/02/20
- Re: [PATCH 4/5] pcie, virtio: Remove redundant pm_cap, Eric Auger, 2025/02/24