2020-06-09 19:32:04

by Piotr Stankiewicz

[permalink] [raw]
Subject: [PATCH v3 02/15] PCI: Add macro for message signalled interrupt types

There are several places in the kernel which check/ask for MSI or MSI-X
interrupts. It would make sense to have a macro which defines all types
of message signalled interrupts, to use in such situations. Add
PCI_IRQ_MSI_TYPES, for this purpose.

Signed-off-by: Piotr Stankiewicz <[email protected]>
Suggested-by: Andy Shevchenko <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Logan Gunthorpe <[email protected]>
---
Documentation/PCI/msi-howto.rst | 5 +++--
include/linux/pci.h | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Documentation/PCI/msi-howto.rst b/Documentation/PCI/msi-howto.rst
index aa2046af69f7..2800ff5aa395 100644
--- a/Documentation/PCI/msi-howto.rst
+++ b/Documentation/PCI/msi-howto.rst
@@ -105,7 +105,8 @@ if it can't meet the minimum number of vectors.
The flags argument is used to specify which type of interrupt can be used
by the device and the driver (PCI_IRQ_LEGACY, PCI_IRQ_MSI, PCI_IRQ_MSIX).
A convenient short-hand (PCI_IRQ_ALL_TYPES) is also available to ask for
-any possible kind of interrupt. If the PCI_IRQ_AFFINITY flag is set,
+any possible kind of interrupt, and (PCI_IRQ_MSI_TYPES) to ask for message
+signalled interrupts (MSI or MSI-X). If the PCI_IRQ_AFFINITY flag is set,
pci_alloc_irq_vectors() will spread the interrupts around the available CPUs.

To get the Linux IRQ numbers passed to request_irq() and free_irq() and the
@@ -160,7 +161,7 @@ the single MSI mode for a device. It could be done by passing two 1s as
Some devices might not support using legacy line interrupts, in which case
the driver can specify that only MSI or MSI-X is acceptable::

- nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_MSI | PCI_IRQ_MSIX);
+ nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_MSI_TYPES);
if (nvec < 0)
goto out_err;

diff --git a/include/linux/pci.h b/include/linux/pci.h
index c79d83304e52..a99094f17b21 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1431,8 +1431,8 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode,
*/
#define PCI_IRQ_VIRTUAL (1 << 4)

-#define PCI_IRQ_ALL_TYPES \
- (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
+#define PCI_IRQ_MSI_TYPES (PCI_IRQ_MSI | PCI_IRQ_MSIX)
+#define PCI_IRQ_ALL_TYPES (PCI_IRQ_LEGACY | PCI_IRQ_MSI_TYPES)

/* kmem_cache style wrapper around pci_alloc_consistent() */

--
2.17.2


2020-06-10 07:12:05

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v3 02/15] PCI: Add macro for message signalled interrupt types

On Tue, Jun 09, 2020 at 06:22:40PM +0200, Piotr Stankiewicz wrote:
> There are several places in the kernel which check/ask for MSI or MSI-X
> interrupts. It would make sense to have a macro which defines all types
> of message signalled interrupts, to use in such situations. Add
> PCI_IRQ_MSI_TYPES, for this purpose.

To state my objection voices in patch 3 here again:

I think this is a very bad idea. Everyone knows what MSI and MSI-X
mean and that directly maps to specification. The new IMS interrupt
scheme from the Intel SIOV spec for example is a message signalled
interrupt type as well and should not be picked up automatically.

If we want to change anything in this area we should probably remove
PCI_IRQ_ALL_TYPES instead..

2020-06-16 07:42:22

by Piotr Stankiewicz

[permalink] [raw]
Subject: RE: [PATCH v3 02/15] PCI: Add macro for message signalled interrupt types

> -----Original Message-----
> From: Christoph Hellwig <[email protected]>
> Sent: Wednesday, June 10, 2020 9:08 AM
>
> On Tue, Jun 09, 2020 at 06:22:40PM +0200, Piotr Stankiewicz wrote:
> > There are several places in the kernel which check/ask for MSI or
> > MSI-X interrupts. It would make sense to have a macro which defines
> > all types of message signalled interrupts, to use in such situations.
> > Add PCI_IRQ_MSI_TYPES, for this purpose.
>
> To state my objection voices in patch 3 here again:
>
> I think this is a very bad idea. Everyone knows what MSI and MSI-X mean and
> that directly maps to specification. The new IMS interrupt scheme from the Intel
> SIOV spec for example is a message signalled interrupt type as well and should
> not be picked up automatically.
>
> If we want to change anything in this area we should probably remove
> PCI_IRQ_ALL_TYPES instead..

Thanks, I've resent only the first patch as v4 of the chain, and dropped the rest.