* kill off pci_enable_msi_{exact,range}
@ 2017-01-09 20:37 Christoph Hellwig
2017-01-09 20:37 ` [PATCH 1/3] media/cobalt: use pci_irq_allocate_vectors Christoph Hellwig
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-09 20:37 UTC (permalink / raw)
To: linux-pci; +Cc: Mauro Carvalho Chehab, netdev, linux-media
I had hope that we could kill these old interfaces of for 4.10-rc,
but as of today Linus tree still has two users:
(1) the cobalt media driver, for which I sent a patch long time ago,
it got missed in the merge window.
(2) the new xgbe driver was merged in 4.10-rc but used the old interfaces
anyway
This series resend the patch for (1) and adds a new one for (2), as well
as having the final removal patch behind it. Maybe we should just queue
up all three together in the PCI tree for 4.11?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/3] media/cobalt: use pci_irq_allocate_vectors
2017-01-09 20:37 kill off pci_enable_msi_{exact,range} Christoph Hellwig
@ 2017-01-09 20:37 ` Christoph Hellwig
2017-01-09 20:37 ` [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors Christoph Hellwig
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-09 20:37 UTC (permalink / raw)
To: linux-pci; +Cc: Mauro Carvalho Chehab, netdev, linux-media
Simply the interrupt setup by using the new PCI layer helpers.
Despite using pci_enable_msi_range, this driver was only requesting a
single MSI vector anyway.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/media/pci/cobalt/cobalt-driver.c | 8 ++------
drivers/media/pci/cobalt/cobalt-driver.h | 2 --
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
index 9796340..d5c911c 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -308,9 +308,7 @@ static void cobalt_pci_iounmap(struct cobalt *cobalt, struct pci_dev *pci_dev)
static void cobalt_free_msi(struct cobalt *cobalt, struct pci_dev *pci_dev)
{
free_irq(pci_dev->irq, (void *)cobalt);
-
- if (cobalt->msi_enabled)
- pci_disable_msi(pci_dev);
+ pci_free_irq_vectors(pci_dev);
}
static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev,
@@ -387,14 +385,12 @@ static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev,
from being generated. */
cobalt_set_interrupt(cobalt, false);
- if (pci_enable_msi_range(pci_dev, 1, 1) < 1) {
+ if (pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_MSI) < 1) {
cobalt_err("Could not enable MSI\n");
- cobalt->msi_enabled = false;
ret = -EIO;
goto err_release;
}
msi_config_show(cobalt, pci_dev);
- cobalt->msi_enabled = true;
/* Register IRQ */
if (request_irq(pci_dev->irq, cobalt_irq_handler, IRQF_SHARED,
diff --git a/drivers/media/pci/cobalt/cobalt-driver.h b/drivers/media/pci/cobalt/cobalt-driver.h
index ed00dc9..00f773e 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.h
+++ b/drivers/media/pci/cobalt/cobalt-driver.h
@@ -287,8 +287,6 @@ struct cobalt {
u32 irq_none;
u32 irq_full_fifo;
- bool msi_enabled;
-
/* omnitek dma */
int dma_channels;
int first_fifo_channel;
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors
2017-01-09 20:37 kill off pci_enable_msi_{exact,range} Christoph Hellwig
2017-01-09 20:37 ` [PATCH 1/3] media/cobalt: use pci_irq_allocate_vectors Christoph Hellwig
@ 2017-01-09 20:37 ` Christoph Hellwig
2017-01-10 18:40 ` Tom Lendacky
2017-01-09 20:37 ` [PATCH 3/3] PCI/msi: remove pci_enable_msi_{exact,range} Christoph Hellwig
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-09 20:37 UTC (permalink / raw)
To: linux-pci; +Cc: Mauro Carvalho Chehab, netdev, linux-media
The newly added xgbe drivers uses the deprecated pci_enable_msi_exact
and pci_enable_msix_range interfaces. Switch it to use
pci_irq_alloc_vectors instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 47 +++++++++++++-------------------
drivers/net/ethernet/amd/xgbe/xgbe.h | 1 -
2 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
index e76b7f6..be2690e 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
@@ -133,12 +133,13 @@ static int xgbe_config_msi(struct xgbe_prv_data *pdata)
pdata->tx_ring_count);
msi_count = roundup_pow_of_two(msi_count);
- ret = pci_enable_msi_exact(pdata->pcidev, msi_count);
+ ret = pci_alloc_irq_vectors(pdata->pcidev, msi_count, msi_count,
+ PCI_IRQ_MSI);
if (ret < 0) {
dev_info(pdata->dev, "MSI request for %u interrupts failed\n",
msi_count);
- ret = pci_enable_msi(pdata->pcidev);
+ ret = pci_alloc_irq_vectors(pdata->pcidev, 1, 1, PCI_IRQ_MSI);
if (ret < 0) {
dev_info(pdata->dev, "MSI enablement failed\n");
return ret;
@@ -149,25 +150,26 @@ static int xgbe_config_msi(struct xgbe_prv_data *pdata)
pdata->irq_count = msi_count;
- pdata->dev_irq = pdata->pcidev->irq;
+ pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
if (msi_count > 1) {
- pdata->ecc_irq = pdata->pcidev->irq + 1;
- pdata->i2c_irq = pdata->pcidev->irq + 2;
- pdata->an_irq = pdata->pcidev->irq + 3;
+ pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 1);
+ pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 2);
+ pdata->an_irq = pci_irq_vector(pdata->pcidev, 3);
for (i = XGBE_MSIX_BASE_COUNT, j = 0;
(i < msi_count) && (j < XGBE_MAX_DMA_CHANNELS);
i++, j++)
- pdata->channel_irq[j] = pdata->pcidev->irq + i;
+ pdata->channel_irq[j] =
+ pci_irq_vector(pdata->pcidev, i);
pdata->channel_irq_count = j;
pdata->per_channel_irq = 1;
pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
} else {
- pdata->ecc_irq = pdata->pcidev->irq;
- pdata->i2c_irq = pdata->pcidev->irq;
- pdata->an_irq = pdata->pcidev->irq;
+ pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->an_irq = pci_irq_vector(pdata->pcidev, 0);
}
if (netif_msg_probe(pdata))
@@ -186,33 +188,22 @@ static int xgbe_config_msix(struct xgbe_prv_data *pdata)
msix_count += max(pdata->rx_ring_count,
pdata->tx_ring_count);
- pdata->msix_entries = devm_kcalloc(pdata->dev, msix_count,
- sizeof(struct msix_entry),
- GFP_KERNEL);
- if (!pdata->msix_entries)
- return -ENOMEM;
-
- for (i = 0; i < msix_count; i++)
- pdata->msix_entries[i].entry = i;
-
- ret = pci_enable_msix_range(pdata->pcidev, pdata->msix_entries,
- XGBE_MSIX_MIN_COUNT, msix_count);
+ ret = pci_alloc_irq_vectors(pdata->pcidev, XGBE_MSIX_MIN_COUNT,
+ msix_count, PCI_IRQ_MSIX);
if (ret < 0) {
dev_info(pdata->dev, "MSI-X enablement failed\n");
- devm_kfree(pdata->dev, pdata->msix_entries);
- pdata->msix_entries = NULL;
return ret;
}
pdata->irq_count = ret;
- pdata->dev_irq = pdata->msix_entries[0].vector;
- pdata->ecc_irq = pdata->msix_entries[1].vector;
- pdata->i2c_irq = pdata->msix_entries[2].vector;
- pdata->an_irq = pdata->msix_entries[3].vector;
+ pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 1);
+ pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 2);
+ pdata->an_irq = pci_irq_vector(pdata->pcidev, 3);
for (i = XGBE_MSIX_BASE_COUNT, j = 0; i < ret; i++, j++)
- pdata->channel_irq[j] = pdata->msix_entries[i].vector;
+ pdata->channel_irq[j] = pci_irq_vector(pdata->pcidev, i);
pdata->channel_irq_count = j;
pdata->per_channel_irq = 1;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index f52a9bd..3bcb6f5 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -980,7 +980,6 @@ struct xgbe_prv_data {
unsigned int desc_ded_count;
unsigned int desc_sec_count;
- struct msix_entry *msix_entries;
int dev_irq;
int ecc_irq;
int i2c_irq;
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/3] PCI/msi: remove pci_enable_msi_{exact,range}
2017-01-09 20:37 kill off pci_enable_msi_{exact,range} Christoph Hellwig
2017-01-09 20:37 ` [PATCH 1/3] media/cobalt: use pci_irq_allocate_vectors Christoph Hellwig
2017-01-09 20:37 ` [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors Christoph Hellwig
@ 2017-01-09 20:37 ` Christoph Hellwig
2017-01-11 1:20 ` kill off pci_enable_msi_{exact,range} David Miller
2017-01-12 21:29 ` Bjorn Helgaas
4 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-09 20:37 UTC (permalink / raw)
To: linux-pci; +Cc: Mauro Carvalho Chehab, netdev, linux-media
All multi-MSI allocations are now done through pci_irq_alloc_vectors,
so remove the old interface.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
Documentation/PCI/MSI-HOWTO.txt | 6 ++----
drivers/pci/msi.c | 26 +++++++++-----------------
include/linux/pci.h | 16 ++--------------
3 files changed, 13 insertions(+), 35 deletions(-)
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt
index cd9c9f6..b570a92 100644
--- a/Documentation/PCI/MSI-HOWTO.txt
+++ b/Documentation/PCI/MSI-HOWTO.txt
@@ -162,8 +162,6 @@ The following old APIs to enable and disable MSI or MSI-X interrupts should
not be used in new code:
pci_enable_msi() /* deprecated */
- pci_enable_msi_range() /* deprecated */
- pci_enable_msi_exact() /* deprecated */
pci_disable_msi() /* deprecated */
pci_enable_msix_range() /* deprecated */
pci_enable_msix_exact() /* deprecated */
@@ -268,5 +266,5 @@ or disabled (0). If 0 is found in any of the msi_bus files belonging
to bridges between the PCI root and the device, MSIs are disabled.
It is also worth checking the device driver to see whether it supports MSIs.
-For example, it may contain calls to pci_enable_msi_range() or
-pci_enable_msix_range().
+For example, it may contain calls to pci_irq_alloc_vectors with the
+PCI_IRQ_MSI or PCI_IRQ_MSIX flags.
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 50c5003..16dda43 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1109,23 +1109,15 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
}
}
-/**
- * pci_enable_msi_range - configure device's MSI capability structure
- * @dev: device to configure
- * @minvec: minimal number of interrupts to configure
- * @maxvec: maximum number of interrupts to configure
- *
- * This function tries to allocate a maximum possible number of interrupts in a
- * range between @minvec and @maxvec. It returns a negative errno if an error
- * occurs. If it succeeds, it returns the actual number of interrupts allocated
- * and updates the @dev's irq member to the lowest new interrupt number;
- * the other interrupt numbers allocated to this device are consecutive.
- **/
-int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
+/* deprecated, don't use */
+int pci_enable_msi(struct pci_dev *dev)
{
- return __pci_enable_msi_range(dev, minvec, maxvec, NULL);
+ int rc = __pci_enable_msi_range(dev, 1, 1, NULL);
+ if (rc < 0)
+ return rc;
+ return 0;
}
-EXPORT_SYMBOL(pci_enable_msi_range);
+EXPORT_SYMBOL(pci_enable_msi);
static int __pci_enable_msix_range(struct pci_dev *dev,
struct msix_entry *entries, int minvec,
@@ -1381,7 +1373,7 @@ int pci_msi_domain_check_cap(struct irq_domain *domain,
{
struct msi_desc *desc = first_pci_msi_entry(to_pci_dev(dev));
- /* Special handling to support pci_enable_msi_range() */
+ /* Special handling to support __pci_enable_msi_range() */
if (pci_msi_desc_is_multi_msi(desc) &&
!(info->flags & MSI_FLAG_MULTI_PCI_MSI))
return 1;
@@ -1394,7 +1386,7 @@ int pci_msi_domain_check_cap(struct irq_domain *domain,
static int pci_msi_domain_handle_error(struct irq_domain *domain,
struct msi_desc *desc, int error)
{
- /* Special handling to support pci_enable_msi_range() */
+ /* Special handling to support __pci_enable_msi_range() */
if (pci_msi_desc_is_multi_msi(desc) && error == -ENOSPC)
return 1;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e2d1a12..2159376 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1309,14 +1309,7 @@ void pci_msix_shutdown(struct pci_dev *dev);
void pci_disable_msix(struct pci_dev *dev);
void pci_restore_msi_state(struct pci_dev *dev);
int pci_msi_enabled(void);
-int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec);
-static inline int pci_enable_msi_exact(struct pci_dev *dev, int nvec)
-{
- int rc = pci_enable_msi_range(dev, nvec, nvec);
- if (rc < 0)
- return rc;
- return 0;
-}
+int pci_enable_msi(struct pci_dev *dev);
int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
int minvec, int maxvec);
static inline int pci_enable_msix_exact(struct pci_dev *dev,
@@ -1347,10 +1340,7 @@ static inline void pci_msix_shutdown(struct pci_dev *dev) { }
static inline void pci_disable_msix(struct pci_dev *dev) { }
static inline void pci_restore_msi_state(struct pci_dev *dev) { }
static inline int pci_msi_enabled(void) { return 0; }
-static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec,
- int maxvec)
-{ return -ENOSYS; }
-static inline int pci_enable_msi_exact(struct pci_dev *dev, int nvec)
+static inline int pci_enable_msi(struct pci_dev *dev)
{ return -ENOSYS; }
static inline int pci_enable_msix_range(struct pci_dev *dev,
struct msix_entry *entries, int minvec, int maxvec)
@@ -1426,8 +1416,6 @@ static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
static inline void pcie_ecrc_get_policy(char *str) { }
#endif
-#define pci_enable_msi(pdev) pci_enable_msi_exact(pdev, 1)
-
#ifdef CONFIG_HT_IRQ
/* The functions a driver should call */
int ht_create_irq(struct pci_dev *dev, int idx);
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors
2017-01-09 20:37 ` [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors Christoph Hellwig
@ 2017-01-10 18:40 ` Tom Lendacky
2017-01-11 9:03 ` Christoph Hellwig
0 siblings, 1 reply; 14+ messages in thread
From: Tom Lendacky @ 2017-01-10 18:40 UTC (permalink / raw)
To: Christoph Hellwig, linux-pci; +Cc: Mauro Carvalho Chehab, netdev, linux-media
On 1/9/2017 2:37 PM, Christoph Hellwig wrote:
> The newly added xgbe drivers uses the deprecated pci_enable_msi_exact
> and pci_enable_msix_range interfaces. Switch it to use
> pci_irq_alloc_vectors instead.
I was just working on switching over to this API with some additional
changes / simplification. I'm ok with using this patch so that you get
the API removal accomplished. Going through the PCI tree just means
it will probably be easier for me to hold off on the additional changes
I wanted to make until later.
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 47 +++++++++++++-------------------
> drivers/net/ethernet/amd/xgbe/xgbe.h | 1 -
> 2 files changed, 19 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
> index e76b7f6..be2690e 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
> @@ -133,12 +133,13 @@ static int xgbe_config_msi(struct xgbe_prv_data *pdata)
> pdata->tx_ring_count);
> msi_count = roundup_pow_of_two(msi_count);
>
> - ret = pci_enable_msi_exact(pdata->pcidev, msi_count);
> + ret = pci_alloc_irq_vectors(pdata->pcidev, msi_count, msi_count,
> + PCI_IRQ_MSI);
> if (ret < 0) {
> dev_info(pdata->dev, "MSI request for %u interrupts failed\n",
> msi_count);
>
> - ret = pci_enable_msi(pdata->pcidev);
> + ret = pci_alloc_irq_vectors(pdata->pcidev, 1, 1, PCI_IRQ_MSI);
> if (ret < 0) {
> dev_info(pdata->dev, "MSI enablement failed\n");
> return ret;
> @@ -149,25 +150,26 @@ static int xgbe_config_msi(struct xgbe_prv_data *pdata)
>
> pdata->irq_count = msi_count;
>
> - pdata->dev_irq = pdata->pcidev->irq;
> + pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
>
> if (msi_count > 1) {
> - pdata->ecc_irq = pdata->pcidev->irq + 1;
> - pdata->i2c_irq = pdata->pcidev->irq + 2;
> - pdata->an_irq = pdata->pcidev->irq + 3;
> + pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 1);
> + pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 2);
> + pdata->an_irq = pci_irq_vector(pdata->pcidev, 3);
>
> for (i = XGBE_MSIX_BASE_COUNT, j = 0;
> (i < msi_count) && (j < XGBE_MAX_DMA_CHANNELS);
> i++, j++)
> - pdata->channel_irq[j] = pdata->pcidev->irq + i;
> + pdata->channel_irq[j] =
> + pci_irq_vector(pdata->pcidev, i);
> pdata->channel_irq_count = j;
>
> pdata->per_channel_irq = 1;
> pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
> } else {
> - pdata->ecc_irq = pdata->pcidev->irq;
> - pdata->i2c_irq = pdata->pcidev->irq;
> - pdata->an_irq = pdata->pcidev->irq;
> + pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->an_irq = pci_irq_vector(pdata->pcidev, 0);
> }
>
> if (netif_msg_probe(pdata))
> @@ -186,33 +188,22 @@ static int xgbe_config_msix(struct xgbe_prv_data *pdata)
> msix_count += max(pdata->rx_ring_count,
> pdata->tx_ring_count);
>
> - pdata->msix_entries = devm_kcalloc(pdata->dev, msix_count,
> - sizeof(struct msix_entry),
> - GFP_KERNEL);
> - if (!pdata->msix_entries)
> - return -ENOMEM;
> -
> - for (i = 0; i < msix_count; i++)
> - pdata->msix_entries[i].entry = i;
> -
> - ret = pci_enable_msix_range(pdata->pcidev, pdata->msix_entries,
> - XGBE_MSIX_MIN_COUNT, msix_count);
> + ret = pci_alloc_irq_vectors(pdata->pcidev, XGBE_MSIX_MIN_COUNT,
> + msix_count, PCI_IRQ_MSIX);
> if (ret < 0) {
> dev_info(pdata->dev, "MSI-X enablement failed\n");
> - devm_kfree(pdata->dev, pdata->msix_entries);
> - pdata->msix_entries = NULL;
> return ret;
> }
>
> pdata->irq_count = ret;
>
> - pdata->dev_irq = pdata->msix_entries[0].vector;
> - pdata->ecc_irq = pdata->msix_entries[1].vector;
> - pdata->i2c_irq = pdata->msix_entries[2].vector;
> - pdata->an_irq = pdata->msix_entries[3].vector;
> + pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 1);
> + pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 2);
> + pdata->an_irq = pci_irq_vector(pdata->pcidev, 3);
>
> for (i = XGBE_MSIX_BASE_COUNT, j = 0; i < ret; i++, j++)
> - pdata->channel_irq[j] = pdata->msix_entries[i].vector;
> + pdata->channel_irq[j] = pci_irq_vector(pdata->pcidev, i);
> pdata->channel_irq_count = j;
>
> pdata->per_channel_irq = 1;
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
> index f52a9bd..3bcb6f5 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe.h
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
> @@ -980,7 +980,6 @@ struct xgbe_prv_data {
> unsigned int desc_ded_count;
> unsigned int desc_sec_count;
>
> - struct msix_entry *msix_entries;
> int dev_irq;
> int ecc_irq;
> int i2c_irq;
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-09 20:37 kill off pci_enable_msi_{exact,range} Christoph Hellwig
` (2 preceding siblings ...)
2017-01-09 20:37 ` [PATCH 3/3] PCI/msi: remove pci_enable_msi_{exact,range} Christoph Hellwig
@ 2017-01-11 1:20 ` David Miller
2017-01-12 21:29 ` Bjorn Helgaas
4 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2017-01-11 1:20 UTC (permalink / raw)
To: hch; +Cc: linux-pci, mchehab, netdev, linux-media
From: Christoph Hellwig <hch@lst.de>
Date: Mon, 9 Jan 2017 21:37:37 +0100
> I had hope that we could kill these old interfaces of for 4.10-rc,
> but as of today Linus tree still has two users:
>
> (1) the cobalt media driver, for which I sent a patch long time ago,
> it got missed in the merge window.
> (2) the new xgbe driver was merged in 4.10-rc but used the old interfaces
> anyway
>
> This series resend the patch for (1) and adds a new one for (2), as well
> as having the final removal patch behind it. Maybe we should just queue
> up all three together in the PCI tree for 4.11?
Feel free to toss this into the PCI tree.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors
2017-01-10 18:40 ` Tom Lendacky
@ 2017-01-11 9:03 ` Christoph Hellwig
2017-01-11 16:46 ` Tom Lendacky
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-11 9:03 UTC (permalink / raw)
To: Tom Lendacky
Cc: Christoph Hellwig, linux-pci, Mauro Carvalho Chehab, netdev,
linux-media
On Tue, Jan 10, 2017 at 12:40:10PM -0600, Tom Lendacky wrote:
> On 1/9/2017 2:37 PM, Christoph Hellwig wrote:
> > The newly added xgbe drivers uses the deprecated pci_enable_msi_exact
> > and pci_enable_msix_range interfaces. Switch it to use
> > pci_irq_alloc_vectors instead.
>
> I was just working on switching over to this API with some additional
> changes / simplification. I'm ok with using this patch so that you get
> the API removal accomplished. Going through the PCI tree just means
> it will probably be easier for me to hold off on the additional changes
> I wanted to make until later.
Hi Tom,
if you have a better patch I'd be more than happy to use that one instead,
this one was intended as a stupid search and replace. The important
part for me is to get the two conversions and the interface removal
in together.
E.g. I've alreayd wondered why the driver requires the exact vector
number for MSI and a variable one for MSI-X, and there certainly is
all kinds of opportunity for cosmetic cleanup.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors
2017-01-11 9:03 ` Christoph Hellwig
@ 2017-01-11 16:46 ` Tom Lendacky
0 siblings, 0 replies; 14+ messages in thread
From: Tom Lendacky @ 2017-01-11 16:46 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-pci, Mauro Carvalho Chehab, netdev, linux-media
On 1/11/2017 3:03 AM, Christoph Hellwig wrote:
> On Tue, Jan 10, 2017 at 12:40:10PM -0600, Tom Lendacky wrote:
>> On 1/9/2017 2:37 PM, Christoph Hellwig wrote:
>>> The newly added xgbe drivers uses the deprecated pci_enable_msi_exact
>>> and pci_enable_msix_range interfaces. Switch it to use
>>> pci_irq_alloc_vectors instead.
>>
>> I was just working on switching over to this API with some additional
>> changes / simplification. I'm ok with using this patch so that you get
>> the API removal accomplished. Going through the PCI tree just means
>> it will probably be easier for me to hold off on the additional changes
>> I wanted to make until later.
>
> Hi Tom,
Hi Christoph,
>
> if you have a better patch I'd be more than happy to use that one instead,
> this one was intended as a stupid search and replace. The important
> part for me is to get the two conversions and the interface removal
> in together.
That sounds good, I'll send the patch to you in a separate email for use
in your series.
Thanks,
Tom
>
> E.g. I've alreayd wondered why the driver requires the exact vector
> number for MSI and a variable one for MSI-X, and there certainly is
> all kinds of opportunity for cosmetic cleanup.
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-09 20:37 kill off pci_enable_msi_{exact,range} Christoph Hellwig
` (3 preceding siblings ...)
2017-01-11 1:20 ` kill off pci_enable_msi_{exact,range} David Miller
@ 2017-01-12 21:29 ` Bjorn Helgaas
2017-01-13 7:55 ` Christoph Hellwig
4 siblings, 1 reply; 14+ messages in thread
From: Bjorn Helgaas @ 2017-01-12 21:29 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-pci, Mauro Carvalho Chehab, netdev, linux-media,
Tom Lendacky
On Mon, Jan 09, 2017 at 09:37:37PM +0100, Christoph Hellwig wrote:
> I had hope that we could kill these old interfaces of for 4.10-rc,
> but as of today Linus tree still has two users:
>
> (1) the cobalt media driver, for which I sent a patch long time ago,
> it got missed in the merge window.
> (2) the new xgbe driver was merged in 4.10-rc but used the old interfaces
> anyway
>
> This series resend the patch for (1) and adds a new one for (2), as well
> as having the final removal patch behind it. Maybe we should just queue
> up all three together in the PCI tree for 4.11?
Applied all three (with Tom's ack on the amd-xgbe patch) to pci/msi for
v4.11, thanks!
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-12 21:29 ` Bjorn Helgaas
@ 2017-01-13 7:55 ` Christoph Hellwig
2017-01-13 8:05 ` Christoph Hellwig
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-13 7:55 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Christoph Hellwig, linux-pci, Mauro Carvalho Chehab, netdev,
linux-media, Tom Lendacky
On Thu, Jan 12, 2017 at 03:29:00PM -0600, Bjorn Helgaas wrote:
> Applied all three (with Tom's ack on the amd-xgbe patch) to pci/msi for
> v4.11, thanks!
Tom had just send me an event better version of the xgbe patch. Tom,
maybe you can resend that relative to the PCI tree [1], so that we don't
lose it for next merge window?
[1] https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-13 7:55 ` Christoph Hellwig
@ 2017-01-13 8:05 ` Christoph Hellwig
2017-01-13 17:13 ` Bjorn Helgaas
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-13 8:05 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Christoph Hellwig, linux-pci, Mauro Carvalho Chehab, netdev,
linux-media, Tom Lendacky
On Fri, Jan 13, 2017 at 08:55:03AM +0100, Christoph Hellwig wrote:
> On Thu, Jan 12, 2017 at 03:29:00PM -0600, Bjorn Helgaas wrote:
> > Applied all three (with Tom's ack on the amd-xgbe patch) to pci/msi for
> > v4.11, thanks!
>
> Tom had just send me an event better version of the xgbe patch. Tom,
> maybe you can resend that relative to the PCI tree [1], so that we don't
> lose it for next merge window?
Actually - Bjorn, your msi branch contains an empty commit from this
thread:
https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=pci/msi&id=7a8191de43faa9869b421a1b06075d8126ce7c0b
Maybe we should rebase it after all to avoid that? In that case please
pick up the xgbe patch from Tom below:
---
From: Tom Lendacky <thomas.lendacky@amd.com>
Subject: [PATCH] amd-xgbe: Update PCI support to use new IRQ functions
Some of the PCI MSI/MSI-X functions have been deprecated and it is
recommended to use the new pci_alloc_irq_vectors() function. Convert
the code over to use the new function. Also, modify the way in which
the IRQs are requested - try for multiple MSI-X/MSI first, then a
single MSI/legacy interrupt.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 128 +++++++++---------------------
drivers/net/ethernet/amd/xgbe/xgbe.h | 8 +-
2 files changed, 41 insertions(+), 95 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
index e76b7f6..e436902 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
@@ -122,104 +122,40 @@
#include "xgbe.h"
#include "xgbe-common.h"
-static int xgbe_config_msi(struct xgbe_prv_data *pdata)
+static int xgbe_config_multi_msi(struct xgbe_prv_data *pdata)
{
- unsigned int msi_count;
+ unsigned int vector_count;
unsigned int i, j;
int ret;
- msi_count = XGBE_MSIX_BASE_COUNT;
- msi_count += max(pdata->rx_ring_count,
- pdata->tx_ring_count);
- msi_count = roundup_pow_of_two(msi_count);
+ vector_count = XGBE_MSI_BASE_COUNT;
+ vector_count += max(pdata->rx_ring_count,
+ pdata->tx_ring_count);
- ret = pci_enable_msi_exact(pdata->pcidev, msi_count);
+ ret = pci_alloc_irq_vectors(pdata->pcidev, XGBE_MSI_MIN_COUNT,
+ vector_count, PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (ret < 0) {
- dev_info(pdata->dev, "MSI request for %u interrupts failed\n",
- msi_count);
-
- ret = pci_enable_msi(pdata->pcidev);
- if (ret < 0) {
- dev_info(pdata->dev, "MSI enablement failed\n");
- return ret;
- }
-
- msi_count = 1;
- }
-
- pdata->irq_count = msi_count;
-
- pdata->dev_irq = pdata->pcidev->irq;
-
- if (msi_count > 1) {
- pdata->ecc_irq = pdata->pcidev->irq + 1;
- pdata->i2c_irq = pdata->pcidev->irq + 2;
- pdata->an_irq = pdata->pcidev->irq + 3;
-
- for (i = XGBE_MSIX_BASE_COUNT, j = 0;
- (i < msi_count) && (j < XGBE_MAX_DMA_CHANNELS);
- i++, j++)
- pdata->channel_irq[j] = pdata->pcidev->irq + i;
- pdata->channel_irq_count = j;
-
- pdata->per_channel_irq = 1;
- pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
- } else {
- pdata->ecc_irq = pdata->pcidev->irq;
- pdata->i2c_irq = pdata->pcidev->irq;
- pdata->an_irq = pdata->pcidev->irq;
- }
-
- if (netif_msg_probe(pdata))
- dev_dbg(pdata->dev, "MSI interrupts enabled\n");
-
- return 0;
-}
-
-static int xgbe_config_msix(struct xgbe_prv_data *pdata)
-{
- unsigned int msix_count;
- unsigned int i, j;
- int ret;
-
- msix_count = XGBE_MSIX_BASE_COUNT;
- msix_count += max(pdata->rx_ring_count,
- pdata->tx_ring_count);
-
- pdata->msix_entries = devm_kcalloc(pdata->dev, msix_count,
- sizeof(struct msix_entry),
- GFP_KERNEL);
- if (!pdata->msix_entries)
- return -ENOMEM;
-
- for (i = 0; i < msix_count; i++)
- pdata->msix_entries[i].entry = i;
-
- ret = pci_enable_msix_range(pdata->pcidev, pdata->msix_entries,
- XGBE_MSIX_MIN_COUNT, msix_count);
- if (ret < 0) {
- dev_info(pdata->dev, "MSI-X enablement failed\n");
- devm_kfree(pdata->dev, pdata->msix_entries);
- pdata->msix_entries = NULL;
+ dev_info(pdata->dev, "multi MSI/MSI-X enablement failed\n");
return ret;
}
pdata->irq_count = ret;
- pdata->dev_irq = pdata->msix_entries[0].vector;
- pdata->ecc_irq = pdata->msix_entries[1].vector;
- pdata->i2c_irq = pdata->msix_entries[2].vector;
- pdata->an_irq = pdata->msix_entries[3].vector;
+ pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 1);
+ pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 2);
+ pdata->an_irq = pci_irq_vector(pdata->pcidev, 3);
- for (i = XGBE_MSIX_BASE_COUNT, j = 0; i < ret; i++, j++)
- pdata->channel_irq[j] = pdata->msix_entries[i].vector;
+ for (i = XGBE_MSI_BASE_COUNT, j = 0; i < ret; i++, j++)
+ pdata->channel_irq[j] = pci_irq_vector(pdata->pcidev, i);
pdata->channel_irq_count = j;
pdata->per_channel_irq = 1;
pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
if (netif_msg_probe(pdata))
- dev_dbg(pdata->dev, "MSI-X interrupts enabled\n");
+ dev_dbg(pdata->dev, "multi %s interrupts enabled\n",
+ pdata->pcidev->msix_enabled ? "MSI-X" : "MSI");
return 0;
}
@@ -228,21 +164,28 @@ static int xgbe_config_irqs(struct xgbe_prv_data *pdata)
{
int ret;
- ret = xgbe_config_msix(pdata);
+ ret = xgbe_config_multi_msi(pdata);
if (!ret)
goto out;
- ret = xgbe_config_msi(pdata);
- if (!ret)
- goto out;
+ ret = pci_alloc_irq_vectors(pdata->pcidev, 1, 1,
+ PCI_IRQ_LEGACY | PCI_IRQ_MSI);
+ if (ret < 0) {
+ dev_info(pdata->dev, "single IRQ enablement failed\n");
+ return ret;
+ }
pdata->irq_count = 1;
- pdata->irq_shared = 1;
+ pdata->channel_irq_count = 1;
+
+ pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 0);
+ pdata->an_irq = pci_irq_vector(pdata->pcidev, 0);
- pdata->dev_irq = pdata->pcidev->irq;
- pdata->ecc_irq = pdata->pcidev->irq;
- pdata->i2c_irq = pdata->pcidev->irq;
- pdata->an_irq = pdata->pcidev->irq;
+ if (netif_msg_probe(pdata))
+ dev_dbg(pdata->dev, "single %s interrupt enabled\n",
+ pdata->pcidev->msi_enabled ? "MSI" : "legacy");
out:
if (netif_msg_probe(pdata)) {
@@ -412,12 +355,15 @@ static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* Configure the netdev resource */
ret = xgbe_config_netdev(pdata);
if (ret)
- goto err_pci_enable;
+ goto err_irq_vectors;
netdev_notice(pdata->netdev, "net device enabled\n");
return 0;
+err_irq_vectors:
+ pci_free_irq_vectors(pdata->pcidev);
+
err_pci_enable:
xgbe_free_pdata(pdata);
@@ -433,6 +379,8 @@ static void xgbe_pci_remove(struct pci_dev *pdev)
xgbe_deconfig_netdev(pdata);
+ pci_free_irq_vectors(pdata->pcidev);
+
xgbe_free_pdata(pdata);
}
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index f52a9bd..99f1c87 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -211,9 +211,9 @@
#define XGBE_MAC_PROP_OFFSET 0x1d000
#define XGBE_I2C_CTRL_OFFSET 0x1e000
-/* PCI MSIx support */
-#define XGBE_MSIX_BASE_COUNT 4
-#define XGBE_MSIX_MIN_COUNT (XGBE_MSIX_BASE_COUNT + 1)
+/* PCI MSI/MSIx support */
+#define XGBE_MSI_BASE_COUNT 4
+#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1)
/* PCI clock frequencies */
#define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */
@@ -980,14 +980,12 @@ struct xgbe_prv_data {
unsigned int desc_ded_count;
unsigned int desc_sec_count;
- struct msix_entry *msix_entries;
int dev_irq;
int ecc_irq;
int i2c_irq;
int channel_irq[XGBE_MAX_DMA_CHANNELS];
unsigned int per_channel_irq;
- unsigned int irq_shared;
unsigned int irq_count;
unsigned int channel_irq_count;
unsigned int channel_irq_mode;
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-13 8:05 ` Christoph Hellwig
@ 2017-01-13 17:13 ` Bjorn Helgaas
2017-01-13 17:15 ` Christoph Hellwig
0 siblings, 1 reply; 14+ messages in thread
From: Bjorn Helgaas @ 2017-01-13 17:13 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-pci, Mauro Carvalho Chehab, netdev, linux-media,
Tom Lendacky
On Fri, Jan 13, 2017 at 09:05:53AM +0100, Christoph Hellwig wrote:
> On Fri, Jan 13, 2017 at 08:55:03AM +0100, Christoph Hellwig wrote:
> > On Thu, Jan 12, 2017 at 03:29:00PM -0600, Bjorn Helgaas wrote:
> > > Applied all three (with Tom's ack on the amd-xgbe patch) to pci/msi for
> > > v4.11, thanks!
> >
> > Tom had just send me an event better version of the xgbe patch. Tom,
> > maybe you can resend that relative to the PCI tree [1], so that we don't
> > lose it for next merge window?
>
> Actually - Bjorn, your msi branch contains an empty commit from this
> thread:
>
> https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=pci/msi&id=7a8191de43faa9869b421a1b06075d8126ce7c0b
Yep, I botched that. Thought I'd fixed it, but guess I got distracted.
> Maybe we should rebase it after all to avoid that? In that case please
> pick up the xgbe patch from Tom below:
I dropped the empty commit and replaced the xgbe patch with the one below.
Can you take a look at [1] and make sure it's what you expected?
[1] https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/msi
Thanks!
> ---
> From: Tom Lendacky <thomas.lendacky@amd.com>
> Subject: [PATCH] amd-xgbe: Update PCI support to use new IRQ functions
>
> Some of the PCI MSI/MSI-X functions have been deprecated and it is
> recommended to use the new pci_alloc_irq_vectors() function. Convert
> the code over to use the new function. Also, modify the way in which
> the IRQs are requested - try for multiple MSI-X/MSI first, then a
> single MSI/legacy interrupt.
>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/net/ethernet/amd/xgbe/xgbe-pci.c | 128 +++++++++---------------------
> drivers/net/ethernet/amd/xgbe/xgbe.h | 8 +-
> 2 files changed, 41 insertions(+), 95 deletions(-)
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
> index e76b7f6..e436902 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-pci.c
> @@ -122,104 +122,40 @@
> #include "xgbe.h"
> #include "xgbe-common.h"
>
> -static int xgbe_config_msi(struct xgbe_prv_data *pdata)
> +static int xgbe_config_multi_msi(struct xgbe_prv_data *pdata)
> {
> - unsigned int msi_count;
> + unsigned int vector_count;
> unsigned int i, j;
> int ret;
>
> - msi_count = XGBE_MSIX_BASE_COUNT;
> - msi_count += max(pdata->rx_ring_count,
> - pdata->tx_ring_count);
> - msi_count = roundup_pow_of_two(msi_count);
> + vector_count = XGBE_MSI_BASE_COUNT;
> + vector_count += max(pdata->rx_ring_count,
> + pdata->tx_ring_count);
>
> - ret = pci_enable_msi_exact(pdata->pcidev, msi_count);
> + ret = pci_alloc_irq_vectors(pdata->pcidev, XGBE_MSI_MIN_COUNT,
> + vector_count, PCI_IRQ_MSI | PCI_IRQ_MSIX);
> if (ret < 0) {
> - dev_info(pdata->dev, "MSI request for %u interrupts failed\n",
> - msi_count);
> -
> - ret = pci_enable_msi(pdata->pcidev);
> - if (ret < 0) {
> - dev_info(pdata->dev, "MSI enablement failed\n");
> - return ret;
> - }
> -
> - msi_count = 1;
> - }
> -
> - pdata->irq_count = msi_count;
> -
> - pdata->dev_irq = pdata->pcidev->irq;
> -
> - if (msi_count > 1) {
> - pdata->ecc_irq = pdata->pcidev->irq + 1;
> - pdata->i2c_irq = pdata->pcidev->irq + 2;
> - pdata->an_irq = pdata->pcidev->irq + 3;
> -
> - for (i = XGBE_MSIX_BASE_COUNT, j = 0;
> - (i < msi_count) && (j < XGBE_MAX_DMA_CHANNELS);
> - i++, j++)
> - pdata->channel_irq[j] = pdata->pcidev->irq + i;
> - pdata->channel_irq_count = j;
> -
> - pdata->per_channel_irq = 1;
> - pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
> - } else {
> - pdata->ecc_irq = pdata->pcidev->irq;
> - pdata->i2c_irq = pdata->pcidev->irq;
> - pdata->an_irq = pdata->pcidev->irq;
> - }
> -
> - if (netif_msg_probe(pdata))
> - dev_dbg(pdata->dev, "MSI interrupts enabled\n");
> -
> - return 0;
> -}
> -
> -static int xgbe_config_msix(struct xgbe_prv_data *pdata)
> -{
> - unsigned int msix_count;
> - unsigned int i, j;
> - int ret;
> -
> - msix_count = XGBE_MSIX_BASE_COUNT;
> - msix_count += max(pdata->rx_ring_count,
> - pdata->tx_ring_count);
> -
> - pdata->msix_entries = devm_kcalloc(pdata->dev, msix_count,
> - sizeof(struct msix_entry),
> - GFP_KERNEL);
> - if (!pdata->msix_entries)
> - return -ENOMEM;
> -
> - for (i = 0; i < msix_count; i++)
> - pdata->msix_entries[i].entry = i;
> -
> - ret = pci_enable_msix_range(pdata->pcidev, pdata->msix_entries,
> - XGBE_MSIX_MIN_COUNT, msix_count);
> - if (ret < 0) {
> - dev_info(pdata->dev, "MSI-X enablement failed\n");
> - devm_kfree(pdata->dev, pdata->msix_entries);
> - pdata->msix_entries = NULL;
> + dev_info(pdata->dev, "multi MSI/MSI-X enablement failed\n");
> return ret;
> }
>
> pdata->irq_count = ret;
>
> - pdata->dev_irq = pdata->msix_entries[0].vector;
> - pdata->ecc_irq = pdata->msix_entries[1].vector;
> - pdata->i2c_irq = pdata->msix_entries[2].vector;
> - pdata->an_irq = pdata->msix_entries[3].vector;
> + pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 1);
> + pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 2);
> + pdata->an_irq = pci_irq_vector(pdata->pcidev, 3);
>
> - for (i = XGBE_MSIX_BASE_COUNT, j = 0; i < ret; i++, j++)
> - pdata->channel_irq[j] = pdata->msix_entries[i].vector;
> + for (i = XGBE_MSI_BASE_COUNT, j = 0; i < ret; i++, j++)
> + pdata->channel_irq[j] = pci_irq_vector(pdata->pcidev, i);
> pdata->channel_irq_count = j;
>
> pdata->per_channel_irq = 1;
> pdata->channel_irq_mode = XGBE_IRQ_MODE_LEVEL;
>
> if (netif_msg_probe(pdata))
> - dev_dbg(pdata->dev, "MSI-X interrupts enabled\n");
> + dev_dbg(pdata->dev, "multi %s interrupts enabled\n",
> + pdata->pcidev->msix_enabled ? "MSI-X" : "MSI");
>
> return 0;
> }
> @@ -228,21 +164,28 @@ static int xgbe_config_irqs(struct xgbe_prv_data *pdata)
> {
> int ret;
>
> - ret = xgbe_config_msix(pdata);
> + ret = xgbe_config_multi_msi(pdata);
> if (!ret)
> goto out;
>
> - ret = xgbe_config_msi(pdata);
> - if (!ret)
> - goto out;
> + ret = pci_alloc_irq_vectors(pdata->pcidev, 1, 1,
> + PCI_IRQ_LEGACY | PCI_IRQ_MSI);
> + if (ret < 0) {
> + dev_info(pdata->dev, "single IRQ enablement failed\n");
> + return ret;
> + }
>
> pdata->irq_count = 1;
> - pdata->irq_shared = 1;
> + pdata->channel_irq_count = 1;
> +
> + pdata->dev_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->ecc_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->i2c_irq = pci_irq_vector(pdata->pcidev, 0);
> + pdata->an_irq = pci_irq_vector(pdata->pcidev, 0);
>
> - pdata->dev_irq = pdata->pcidev->irq;
> - pdata->ecc_irq = pdata->pcidev->irq;
> - pdata->i2c_irq = pdata->pcidev->irq;
> - pdata->an_irq = pdata->pcidev->irq;
> + if (netif_msg_probe(pdata))
> + dev_dbg(pdata->dev, "single %s interrupt enabled\n",
> + pdata->pcidev->msi_enabled ? "MSI" : "legacy");
>
> out:
> if (netif_msg_probe(pdata)) {
> @@ -412,12 +355,15 @@ static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> /* Configure the netdev resource */
> ret = xgbe_config_netdev(pdata);
> if (ret)
> - goto err_pci_enable;
> + goto err_irq_vectors;
>
> netdev_notice(pdata->netdev, "net device enabled\n");
>
> return 0;
>
> +err_irq_vectors:
> + pci_free_irq_vectors(pdata->pcidev);
> +
> err_pci_enable:
> xgbe_free_pdata(pdata);
>
> @@ -433,6 +379,8 @@ static void xgbe_pci_remove(struct pci_dev *pdev)
>
> xgbe_deconfig_netdev(pdata);
>
> + pci_free_irq_vectors(pdata->pcidev);
> +
> xgbe_free_pdata(pdata);
> }
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
> index f52a9bd..99f1c87 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe.h
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
> @@ -211,9 +211,9 @@
> #define XGBE_MAC_PROP_OFFSET 0x1d000
> #define XGBE_I2C_CTRL_OFFSET 0x1e000
>
> -/* PCI MSIx support */
> -#define XGBE_MSIX_BASE_COUNT 4
> -#define XGBE_MSIX_MIN_COUNT (XGBE_MSIX_BASE_COUNT + 1)
> +/* PCI MSI/MSIx support */
> +#define XGBE_MSI_BASE_COUNT 4
> +#define XGBE_MSI_MIN_COUNT (XGBE_MSI_BASE_COUNT + 1)
>
> /* PCI clock frequencies */
> #define XGBE_V2_DMA_CLOCK_FREQ 500000000 /* 500 MHz */
> @@ -980,14 +980,12 @@ struct xgbe_prv_data {
> unsigned int desc_ded_count;
> unsigned int desc_sec_count;
>
> - struct msix_entry *msix_entries;
> int dev_irq;
> int ecc_irq;
> int i2c_irq;
> int channel_irq[XGBE_MAX_DMA_CHANNELS];
>
> unsigned int per_channel_irq;
> - unsigned int irq_shared;
> unsigned int irq_count;
> unsigned int channel_irq_count;
> unsigned int channel_irq_mode;
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-13 17:13 ` Bjorn Helgaas
@ 2017-01-13 17:15 ` Christoph Hellwig
2017-01-13 21:28 ` Tom Lendacky
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2017-01-13 17:15 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Christoph Hellwig, linux-pci, Mauro Carvalho Chehab, netdev,
linux-media, Tom Lendacky
On Fri, Jan 13, 2017 at 11:13:21AM -0600, Bjorn Helgaas wrote:
> I dropped the empty commit and replaced the xgbe patch with the one below.
> Can you take a look at [1] and make sure it's what you expected?
This looks great, thanks!
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: kill off pci_enable_msi_{exact,range}
2017-01-13 17:15 ` Christoph Hellwig
@ 2017-01-13 21:28 ` Tom Lendacky
0 siblings, 0 replies; 14+ messages in thread
From: Tom Lendacky @ 2017-01-13 21:28 UTC (permalink / raw)
To: Christoph Hellwig, Bjorn Helgaas
Cc: linux-pci, Mauro Carvalho Chehab, netdev, linux-media
On 1/13/2017 11:15 AM, Christoph Hellwig wrote:
> On Fri, Jan 13, 2017 at 11:13:21AM -0600, Bjorn Helgaas wrote:
>> I dropped the empty commit and replaced the xgbe patch with the one below.
>> Can you take a look at [1] and make sure it's what you expected?
>
> This looks great, thanks!
>
Christoph and Bjorn, thanks for taking care of this!
Tom
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-01-13 21:28 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-09 20:37 kill off pci_enable_msi_{exact,range} Christoph Hellwig
2017-01-09 20:37 ` [PATCH 1/3] media/cobalt: use pci_irq_allocate_vectors Christoph Hellwig
2017-01-09 20:37 ` [PATCH 2/3] xgbe: switch to pci_irq_alloc_vectors Christoph Hellwig
2017-01-10 18:40 ` Tom Lendacky
2017-01-11 9:03 ` Christoph Hellwig
2017-01-11 16:46 ` Tom Lendacky
2017-01-09 20:37 ` [PATCH 3/3] PCI/msi: remove pci_enable_msi_{exact,range} Christoph Hellwig
2017-01-11 1:20 ` kill off pci_enable_msi_{exact,range} David Miller
2017-01-12 21:29 ` Bjorn Helgaas
2017-01-13 7:55 ` Christoph Hellwig
2017-01-13 8:05 ` Christoph Hellwig
2017-01-13 17:13 ` Bjorn Helgaas
2017-01-13 17:15 ` Christoph Hellwig
2017-01-13 21:28 ` Tom Lendacky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).