2021-12-06 22:52:37

by Thomas Gleixner

[permalink] [raw]
Subject: [patch V2 19/31] PCI: hv: Rework MSI handling

Replace the about to vanish iterators and make use of the filtering. Take
the descriptor lock around the iterators.

Signed-off-by: Thomas Gleixner <[email protected]>
---
drivers/pci/controller/pci-hyperv.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -3445,18 +3445,23 @@ static int hv_pci_suspend(struct hv_devi

static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg)
{
- struct msi_desc *entry;
struct irq_data *irq_data;
+ struct msi_desc *entry;
+ int ret = 0;

- for_each_pci_msi_entry(entry, pdev) {
+ msi_lock_descs(&pdev->dev);
+ msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
irq_data = irq_get_irq_data(entry->irq);
- if (WARN_ON_ONCE(!irq_data))
- return -EINVAL;
+ if (WARN_ON_ONCE(!irq_data)) {
+ ret = -EINVAL;
+ break;
+ }

hv_compose_msi_msg(irq_data, &entry->msg);
}
+ msi_unlock_descs(&pdev->dev);

- return 0;
+ return ret;
}

/*



2021-12-07 21:08:21

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [patch V2 19/31] PCI: hv: Rework MSI handling

On Mon, Dec 06, 2021 at 11:51:33PM +0100, Thomas Gleixner wrote:
> Replace the about to vanish iterators and make use of the filtering. Take
> the descriptor lock around the iterators.
>
> Signed-off-by: Thomas Gleixner <[email protected]>

Acked-by: Bjorn Helgaas <[email protected]>

> ---
> drivers/pci/controller/pci-hyperv.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -3445,18 +3445,23 @@ static int hv_pci_suspend(struct hv_devi
>
> static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg)
> {
> - struct msi_desc *entry;
> struct irq_data *irq_data;
> + struct msi_desc *entry;
> + int ret = 0;
>
> - for_each_pci_msi_entry(entry, pdev) {
> + msi_lock_descs(&pdev->dev);
> + msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
> irq_data = irq_get_irq_data(entry->irq);
> - if (WARN_ON_ONCE(!irq_data))
> - return -EINVAL;
> + if (WARN_ON_ONCE(!irq_data)) {
> + ret = -EINVAL;
> + break;
> + }
>
> hv_compose_msi_msg(irq_data, &entry->msg);
> }
> + msi_unlock_descs(&pdev->dev);
>
> - return 0;
> + return ret;
> }
>
> /*
>

Subject: [tip: irq/msi] PCI: hv: Rework MSI handling

The following commit has been merged into the irq/msi branch of tip:

Commit-ID: dc2b453290c471266a2d56d7ead981e3c5cea05e
Gitweb: https://git.kernel.org/tip/dc2b453290c471266a2d56d7ead981e3c5cea05e
Author: Thomas Gleixner <[email protected]>
AuthorDate: Mon, 06 Dec 2021 23:51:33 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Thu, 16 Dec 2021 22:22:19 +01:00

PCI: hv: Rework MSI handling

Replace the about to vanish iterators and make use of the filtering. Take
the descriptor lock around the iterators.

Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Michael Kelley <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Acked-by: Bjorn Helgaas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
drivers/pci/controller/pci-hyperv.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 6733cb1..45b6ff8 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -3445,18 +3445,23 @@ static int hv_pci_suspend(struct hv_device *hdev)

static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg)
{
- struct msi_desc *entry;
struct irq_data *irq_data;
+ struct msi_desc *entry;
+ int ret = 0;

- for_each_pci_msi_entry(entry, pdev) {
+ msi_lock_descs(&pdev->dev);
+ msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
irq_data = irq_get_irq_data(entry->irq);
- if (WARN_ON_ONCE(!irq_data))
- return -EINVAL;
+ if (WARN_ON_ONCE(!irq_data)) {
+ ret = -EINVAL;
+ break;
+ }

hv_compose_msi_msg(irq_data, &entry->msg);
}
+ msi_unlock_descs(&pdev->dev);

- return 0;
+ return ret;
}

/*