The primary objective of this patch series is to change the behaviour of pci_alloc_irq_vectors_affinity such that it forwards the MSI-X enable error code when appropriate. In the process, though, it was pointed out that there are multiple places in the kernel which check/ask for message signalled interrupts (MSI or MSI-X), which spawned the first patch adding PCI_IRQ_MSI_TYPES. Finally the rest of the chain converts all users to take advantage of PCI_IRQ_MSI_TYPES or PCI_IRQ_ALL_TYPES, as appropriate.
Piotr Stankiewicz (15): PCI: add shorthand define for message signalled interrupt types PCI/MSI: forward MSIx vector enable error code in pci_alloc_irq_vectors_affinity PCI: use PCI_IRQ_MSI_TYPES where appropriate ahci: use PCI_IRQ_MSI_TYPES where appropriate crypto: inside-secure - use PCI_IRQ_MSI_TYPES where appropriate dmaengine: dw-edma: use PCI_IRQ_MSI_TYPES where appropriate drm/amdgpu: use PCI_IRQ_MSI_TYPES where appropriate IB/qib: Use PCI_IRQ_MSI_TYPES where appropriate media: ddbridge: use PCI_IRQ_MSI_TYPES where appropriate vmw_vmci: use PCI_IRQ_ALL_TYPES where appropriate mmc: sdhci: use PCI_IRQ_MSI_TYPES where appropriate amd-xgbe: use PCI_IRQ_MSI_TYPES where appropriate aquantia: atlantic: use PCI_IRQ_ALL_TYPES where appropriate net: hns3: use PCI_IRQ_MSI_TYPES where appropriate scsi: use PCI_IRQ_MSI_TYPES and PCI_IRQ_ALL_TYPES where appropriate
Documentation/PCI/msi-howto.rst | 5 +++-- drivers/ata/ahci.c | 2 +- drivers/crypto/inside-secure/safexcel.c | 2 +- drivers/dma/dw-edma/dw-edma-pcie.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++---- drivers/infiniband/hw/qib/qib_pcie.c | 2 +- drivers/media/pci/ddbridge/ddbridge-main.c | 2 +- drivers/misc/vmw_vmci/vmci_guest.c | 3 +-- drivers/mmc/host/sdhci-pci-gli.c | 3 +-- drivers/mmc/host/sdhci-pci-o2micro.c | 3 +-- drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 4 +--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +-- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +- drivers/pci/msi.c | 4 ++-- drivers/pci/pcie/portdrv_core.c | 4 ++-- drivers/pci/switch/switchtec.c | 3 +-- drivers/scsi/ipr.c | 2 +- drivers/scsi/vmw_pvscsi.c | 2 +- include/linux/pci.h | 4 ++-- 20 files changed, 28 insertions(+), 34 deletions(-)
On Tue, Jun 02, 2020 at 11:16:17AM +0200, Piotr Stankiewicz wrote:
The primary objective of this patch series is to change the behaviour of pci_alloc_irq_vectors_affinity such that it forwards the MSI-X enable error code when appropriate. In the process, though, it was pointed out that there are multiple places in the kernel which check/ask for message signalled interrupts (MSI or MSI-X), which spawned the first patch adding PCI_IRQ_MSI_TYPES. Finally the rest of the chain converts all users to take advantage of PCI_IRQ_MSI_TYPES or PCI_IRQ_ALL_TYPES, as appropriate.
Piotr Stankiewicz (15): PCI: add shorthand define for message signalled interrupt types PCI/MSI: forward MSIx vector enable error code in pci_alloc_irq_vectors_affinity PCI: use PCI_IRQ_MSI_TYPES where appropriate ahci: use PCI_IRQ_MSI_TYPES where appropriate crypto: inside-secure - use PCI_IRQ_MSI_TYPES where appropriate dmaengine: dw-edma: use PCI_IRQ_MSI_TYPES where appropriate drm/amdgpu: use PCI_IRQ_MSI_TYPES where appropriate IB/qib: Use PCI_IRQ_MSI_TYPES where appropriate media: ddbridge: use PCI_IRQ_MSI_TYPES where appropriate vmw_vmci: use PCI_IRQ_ALL_TYPES where appropriate mmc: sdhci: use PCI_IRQ_MSI_TYPES where appropriate amd-xgbe: use PCI_IRQ_MSI_TYPES where appropriate aquantia: atlantic: use PCI_IRQ_ALL_TYPES where appropriate net: hns3: use PCI_IRQ_MSI_TYPES where appropriate scsi: use PCI_IRQ_MSI_TYPES and PCI_IRQ_ALL_TYPES where appropriate
Documentation/PCI/msi-howto.rst | 5 +++-- drivers/ata/ahci.c | 2 +- drivers/crypto/inside-secure/safexcel.c | 2 +- drivers/dma/dw-edma/dw-edma-pcie.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 8 ++++---- drivers/infiniband/hw/qib/qib_pcie.c | 2 +- drivers/media/pci/ddbridge/ddbridge-main.c | 2 +- drivers/misc/vmw_vmci/vmci_guest.c | 3 +-- drivers/mmc/host/sdhci-pci-gli.c | 3 +-- drivers/mmc/host/sdhci-pci-o2micro.c | 3 +-- drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 4 +--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +-- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +- drivers/pci/msi.c | 4 ++-- drivers/pci/pcie/portdrv_core.c | 4 ++-- drivers/pci/switch/switchtec.c | 3 +-- drivers/scsi/ipr.c | 2 +- drivers/scsi/vmw_pvscsi.c | 2 +- include/linux/pci.h | 4 ++-- 20 files changed, 28 insertions(+), 34 deletions(-)
I think I'm OK with this, and since they all depend on the first PCI patch, it will probably be easiest to merge them all through the PCI tree. I'm happy to do that, but can you please:
- Update the subject lines so they start with a capital letter to match the historical convention.
- Use "MSI-X" instead of "MSIx" so it matches the spec and other usage in the kernel.
- Add "()" after function names, e.g., "pci_alloc_irq_vectors_affinity()" instead of "pci_alloc_irq_vectors_affinity".
- Reorder them so the actual fix (02/15) is first and the cleanups later.
- Post them all to linux-pci (I only saw the drivers/pci patches).
- If possible, post them with all the patches as replies to the cover letter. These all appear to be unrelated messages, which makes it a bit of a hassle to collect them all up.
The primary objective of this patch series is to change the behaviour of pci_alloc_irq_vectors_affinity() such that it forwards the MSI-X enable error code when appropriate. In the process, though, it was pointed out that there are multiple places in the kernel which check/ask for message signalled interrupts (MSI or MSI-X), which spawned the first patch adding PCI_IRQ_MSI_TYPES. Finally the rest of the chain converts all users to take advantage of PCI_IRQ_MSI_TYPES or PCI_IRQ_ALL_TYPES, as appropriate.
Piotr Stankiewicz (15): PCI/MSI: Forward MSI-X vector enable error code in pci_alloc_irq_vectors_affinity() PCI: Add shorthand define for message signalled interrupt types PCI: Use PCI_IRQ_MSI_TYPES where appropriate ahci: Use PCI_IRQ_MSI_TYPES where appropriate crypto: inside-secure - Use PCI_IRQ_MSI_TYPES where appropriate dmaengine: dw-edma: Use PCI_IRQ_MSI_TYPES where appropriate drm/amdgpu: Use PCI_IRQ_MSI_TYPES where appropriate IB/qib: Use PCI_IRQ_MSI_TYPES where appropriate media: ddbridge: Use PCI_IRQ_MSI_TYPES where appropriate vmw_vmci: Use PCI_IRQ_ALL_TYPES where appropriate mmc: sdhci: Use PCI_IRQ_MSI_TYPES where appropriate amd-xgbe: Use PCI_IRQ_MSI_TYPES where appropriate aquantia: atlantic: Use PCI_IRQ_ALL_TYPES where appropriate net: hns3: Use PCI_IRQ_MSI_TYPES where appropriate scsi: Use PCI_IRQ_MSI_TYPES and PCI_IRQ_ALL_TYPES where appropriate
Documentation/PCI/msi-howto.rst | 5 +++-- drivers/ata/ahci.c | 2 +- drivers/crypto/inside-secure/safexcel.c | 2 +- drivers/dma/dw-edma/dw-edma-pcie.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 9 ++------- drivers/infiniband/hw/qib/qib_pcie.c | 6 ++++-- drivers/media/pci/ddbridge/ddbridge-main.c | 2 +- drivers/misc/vmw_vmci/vmci_guest.c | 3 +-- drivers/mmc/host/sdhci-pci-gli.c | 3 +-- drivers/mmc/host/sdhci-pci-o2micro.c | 3 +-- drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 4 +--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +-- .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 3 +-- drivers/pci/msi.c | 4 ++-- drivers/pci/pcie/portdrv_core.c | 4 ++-- drivers/pci/switch/switchtec.c | 3 +-- drivers/scsi/ipr.c | 5 +++-- drivers/scsi/vmw_pvscsi.c | 2 +- include/linux/pci.h | 4 ++-- 20 files changed, 31 insertions(+), 40 deletions(-)
There are several places in the kernel which check/ask for MSI or MSI-X interrupts. It would make sense to have a shorthand constant, similar to PCI_IRQ_ALL_TYPES, to use in these situations. So add PCI_IRQ_MSI_TYPES, for this purpose.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Suggested-by: Andy Shevchenko andriy.shevchenko@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com --- 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 83ce1cdf5676..b6c9bf70363e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1422,8 +1422,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() */
On 2020-06-03 5:45 a.m., 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 shorthand constant, similar to PCI_IRQ_ALL_TYPES, to use in these situations. So add PCI_IRQ_MSI_TYPES, for this purpose.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Suggested-by: Andy Shevchenko andriy.shevchenko@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com
Looks good to me,
Reviewed-by: Logan Gunthorpe logang@deltatee.com
Thanks,
Logan
That's a sensible change.
In your title you can use "macro" or "definition" or "macro definition". "Define" is a verb. "PCI: Add a macro for message-signalled interrupt types"
On 2020-06-03 7:45 a.m., 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 shorthand constant, similar to
"a shorthand constant" --> "a macro which defines all MSI-type of interrupt."
Regards, Luben
PCI_IRQ_ALL_TYPES, to use in these situations. So add PCI_IRQ_MSI_TYPES, for this purpose.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Suggested-by: Andy Shevchenko andriy.shevchenko@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com
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 83ce1cdf5676..b6c9bf70363e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1422,8 +1422,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() */
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 5ed4227f304b..2588dd1015db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -249,15 +249,10 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
if (amdgpu_msi_ok(adev)) { int nvec = pci_msix_vec_count(adev->pdev); - unsigned int flags;
- if (nvec <= 0) { - flags = PCI_IRQ_MSI; - } else { - flags = PCI_IRQ_MSI | PCI_IRQ_MSIX; - } /* we only need one vector */ - nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags); + nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, + PCI_IRQ_MSI_TYPES); if (nvec > 0) { adev->irq.msi_enabled = true; dev_dbg(adev->dev, "amdgpu: using MSI/MSI-X.\n");
On Wed, Jun 3, 2020 at 7:48 AM Piotr Stankiewicz piotr.stankiewicz@intel.com wrote:
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 5ed4227f304b..2588dd1015db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -249,15 +249,10 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
if (amdgpu_msi_ok(adev)) { int nvec = pci_msix_vec_count(adev->pdev);
I think you can drop pci_msix_vec_count() here. It's not used since we always request 1 vector.
Alex
unsigned int flags;
if (nvec <= 0) {
flags = PCI_IRQ_MSI;
} else {
flags = PCI_IRQ_MSI | PCI_IRQ_MSIX;
} /* we only need one vector */
nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags);
nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1,
PCI_IRQ_MSI_TYPES); if (nvec > 0) { adev->irq.msi_enabled = true; dev_dbg(adev->dev, "amdgpu: using MSI/MSI-X.\n");
-- 2.17.2
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
The primary objective of this patch series is to change the behaviour of pci_alloc_irq_vectors_affinity() such that it forwards the MSI-X enable error code when appropriate. In the process, though, it was pointed out that there are multiple places in the kernel which check/ask for message signalled interrupts (MSI or MSI-X), which spawned the first patch adding PCI_IRQ_MSI_TYPES. Finally the rest of the chain converts all users to take advantage of PCI_IRQ_MSI_TYPES or PCI_IRQ_ALL_TYPES, as appropriate.
Piotr Stankiewicz (15): PCI/MSI: Forward MSI-X vector enable error code in pci_alloc_irq_vectors_affinity() PCI: Add macro for message signalled interrupt types PCI: Use PCI_IRQ_MSI_TYPES where appropriate ahci: Use PCI_IRQ_MSI_TYPES where appropriate crypto: inside-secure - Use PCI_IRQ_MSI_TYPES where appropriate dmaengine: dw-edma: Use PCI_IRQ_MSI_TYPES where appropriate drm/amdgpu: Use PCI_IRQ_MSI_TYPES where appropriate IB/qib: Use PCI_IRQ_MSI_TYPES where appropriate media: ddbridge: Use PCI_IRQ_MSI_TYPES where appropriate vmw_vmci: Use PCI_IRQ_ALL_TYPES where appropriate mmc: sdhci: Use PCI_IRQ_MSI_TYPES where appropriate amd-xgbe: Use PCI_IRQ_MSI_TYPES where appropriate aquantia: atlantic: Use PCI_IRQ_ALL_TYPES where appropriate net: hns3: Use PCI_IRQ_MSI_TYPES where appropriate scsi: Use PCI_IRQ_MSI_TYPES and PCI_IRQ_ALL_TYPES where appropriate
Documentation/PCI/msi-howto.rst | 5 +++-- drivers/ata/ahci.c | 2 +- drivers/crypto/inside-secure/safexcel.c | 2 +- drivers/dma/dw-edma/dw-edma-pcie.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 11 +--------- drivers/infiniband/hw/qib/qib_pcie.c | 6 +++-- drivers/media/pci/ddbridge/ddbridge-main.c | 2 +- drivers/misc/vmw_vmci/vmci_guest.c | 3 +-- drivers/mmc/host/sdhci-pci-gli.c | 3 +-- drivers/mmc/host/sdhci-pci-o2micro.c | 3 +-- drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 2 +- .../ethernet/aquantia/atlantic/aq_pci_func.c | 4 +--- .../hisilicon/hns3/hns3pf/hclge_main.c | 3 +-- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 3 +-- drivers/pci/msi.c | 22 ++++++++----------- drivers/pci/pcie/portdrv_core.c | 4 ++-- drivers/pci/switch/switchtec.c | 3 +-- drivers/scsi/ipr.c | 5 +++-- drivers/scsi/vmw_pvscsi.c | 2 +- include/linux/pci.h | 4 ++-- 20 files changed, 37 insertions(+), 54 deletions(-)
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 piotr.stankiewicz@intel.com Suggested-by: Andy Shevchenko andriy.shevchenko@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com Reviewed-by: Logan Gunthorpe logang@deltatee.com --- 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() */
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 0cc4c67f95f7..97141aa81f32 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -248,17 +248,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev) adev->irq.msi_enabled = false;
if (amdgpu_msi_ok(adev)) { - int nvec = pci_msix_vec_count(adev->pdev); - unsigned int flags; - - if (nvec <= 0) { - flags = PCI_IRQ_MSI; - } else { - flags = PCI_IRQ_MSI | PCI_IRQ_MSIX; - } /* we only need one vector */ - nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags); - if (nvec > 0) { + if (pci_alloc_irq_vectors(adev->pdev, 1, 1, PCI_IRQ_MSI_TYPES) > 0) { adev->irq.msi_enabled = true; dev_dbg(adev->dev, "using MSI/MSI-X.\n"); }
On Tue, Jun 9, 2020 at 5:18 AM Piotr Stankiewicz piotr.stankiewicz@intel.com wrote:
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com
Acked-by: Alex Deucher alexander.deucher@amd.com
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 0cc4c67f95f7..97141aa81f32 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -248,17 +248,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev) adev->irq.msi_enabled = false;
if (amdgpu_msi_ok(adev)) {
int nvec = pci_msix_vec_count(adev->pdev);
unsigned int flags;
if (nvec <= 0) {
flags = PCI_IRQ_MSI;
} else {
flags = PCI_IRQ_MSI | PCI_IRQ_MSIX;
} /* we only need one vector */
nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags);
if (nvec > 0) {
if (pci_alloc_irq_vectors(adev->pdev, 1, 1, PCI_IRQ_MSI_TYPES) > 0) { adev->irq.msi_enabled = true; dev_dbg(adev->dev, "using MSI/MSI-X.\n"); }
-- 2.17.2
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
-----Original Message----- From: Alex Deucher alexdeucher@gmail.com Sent: Tuesday, June 9, 2020 10:24 PM
On Tue, Jun 9, 2020 at 5:18 AM Piotr Stankiewicz piotr.stankiewicz@intel.com wrote:
Seeing as there is shorthand available to use when asking for any type of interrupt, or any type of message signalled interrupt, leverage it.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com
Acked-by: Alex Deucher alexander.deucher@amd.com
Thanks. Adding PCI_IRQ_MSI_TYPES won't land upstream. But I'll send a patch with the other simplifications, just now.
pci_alloc_irq_vectors() will handle fallback from MSI-X to MSI internally, if necessary. So remove checks which determine if we are dealing with MSI or MSI-X and rely on pci_alloc_irq_vectors() to do the right thing.
Signed-off-by: Piotr Stankiewicz piotr.stankiewicz@intel.com Reviewed-by: Andy Shevchenko andriy.shevchenko@intel.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 0cc4c67f95f7..2d68ad7d45d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -248,17 +248,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev) adev->irq.msi_enabled = false;
if (amdgpu_msi_ok(adev)) { - int nvec = pci_msix_vec_count(adev->pdev); - unsigned int flags; - - if (nvec <= 0) { - flags = PCI_IRQ_MSI; - } else { - flags = PCI_IRQ_MSI | PCI_IRQ_MSIX; - } /* we only need one vector */ - nvec = pci_alloc_irq_vectors(adev->pdev, 1, 1, flags); - if (nvec > 0) { + if (pci_alloc_irq_vectors(adev->pdev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX) > 0) { adev->irq.msi_enabled = true; dev_dbg(adev->dev, "using MSI/MSI-X.\n"); }
dri-devel@lists.freedesktop.org