* remove pci_enable_msix()
@ 2017-03-27 8:29 Christoph Hellwig
2017-03-27 8:29 ` [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors Christoph Hellwig
` (4 more replies)
0 siblings, 5 replies; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 8:29 UTC (permalink / raw)
To: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
Hi all,
this series removes the remaining callers of the pci_enable_msix()
function and then the function itself. All remaining users in in network
drivers, so if Bjorn is fine with it I'd like to handle it entirely
through the netdev tree.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors
2017-03-27 8:29 remove pci_enable_msix() Christoph Hellwig
@ 2017-03-27 8:29 ` Christoph Hellwig
2017-03-27 16:03 ` Sunil Kovvuri
2017-03-27 8:29 ` [PATCH 2/5] net: thunderxvf: " Christoph Hellwig
` (3 subsequent siblings)
4 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 8:29 UTC (permalink / raw)
To: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
Remove the deprecated pci_enable_msix API in favour of it's successor.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/net/ethernet/cavium/thunder/nic_main.c | 75 ++++++--------------------
1 file changed, 15 insertions(+), 60 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c
index 767234e2e8f9..205569db9093 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
@@ -65,10 +65,7 @@ struct nicpf {
bool mbx_lock[MAX_NUM_VFS_SUPPORTED];
/* MSI-X */
- bool msix_enabled;
u8 num_vec;
- struct msix_entry *msix_entries;
- bool irq_allocated[NIC_PF_MSIX_VECTORS];
char irq_name[NIC_PF_MSIX_VECTORS][20];
};
@@ -1088,7 +1085,7 @@ static irqreturn_t nic_mbx_intr_handler(int irq, void *nic_irq)
u64 intr;
u8 vf, vf_per_mbx_reg = 64;
- if (irq == nic->msix_entries[NIC_PF_INTR_ID_MBOX0].vector)
+ if (irq == pci_irq_vector(nic->pdev, NIC_PF_INTR_ID_MBOX0))
mbx = 0;
else
mbx = 1;
@@ -1107,76 +1104,30 @@ static irqreturn_t nic_mbx_intr_handler(int irq, void *nic_irq)
return IRQ_HANDLED;
}
-static int nic_enable_msix(struct nicpf *nic)
+static int nic_register_interrupts(struct nicpf *nic)
{
int i, ret;
- nic->num_vec = pci_msix_vec_count(nic->pdev);
-
- nic->msix_entries = kmalloc_array(nic->num_vec,
- sizeof(struct msix_entry),
- GFP_KERNEL);
- if (!nic->msix_entries)
- return -ENOMEM;
-
- for (i = 0; i < nic->num_vec; i++)
- nic->msix_entries[i].entry = i;
-
- ret = pci_enable_msix(nic->pdev, nic->msix_entries, nic->num_vec);
- if (ret) {
+ /* Enable MSI-X */
+ ret = pci_alloc_irq_vectors(nic->pdev, nic->num_vec, nic->num_vec,
+ PCI_IRQ_MSIX);
+ if (ret < 0) {
dev_err(&nic->pdev->dev,
"Request for #%d msix vectors failed, returned %d\n",
nic->num_vec, ret);
- kfree(nic->msix_entries);
return ret;
}
- nic->msix_enabled = 1;
- return 0;
-}
-
-static void nic_disable_msix(struct nicpf *nic)
-{
- if (nic->msix_enabled) {
- pci_disable_msix(nic->pdev);
- kfree(nic->msix_entries);
- nic->msix_enabled = 0;
- nic->num_vec = 0;
- }
-}
-
-static void nic_free_all_interrupts(struct nicpf *nic)
-{
- int irq;
-
- for (irq = 0; irq < nic->num_vec; irq++) {
- if (nic->irq_allocated[irq])
- free_irq(nic->msix_entries[irq].vector, nic);
- nic->irq_allocated[irq] = false;
- }
-}
-
-static int nic_register_interrupts(struct nicpf *nic)
-{
- int i, ret;
-
- /* Enable MSI-X */
- ret = nic_enable_msix(nic);
- if (ret)
- return ret;
-
/* Register mailbox interrupt handler */
for (i = NIC_PF_INTR_ID_MBOX0; i < nic->num_vec; i++) {
sprintf(nic->irq_name[i],
"NICPF Mbox%d", (i - NIC_PF_INTR_ID_MBOX0));
- ret = request_irq(nic->msix_entries[i].vector,
+ ret = request_irq(pci_irq_vector(nic->pdev, i),
nic_mbx_intr_handler, 0,
nic->irq_name[i], nic);
if (ret)
goto fail;
-
- nic->irq_allocated[i] = true;
}
/* Enable mailbox interrupt */
@@ -1185,15 +1136,19 @@ static int nic_register_interrupts(struct nicpf *nic)
fail:
dev_err(&nic->pdev->dev, "Request irq failed\n");
- nic_free_all_interrupts(nic);
- nic_disable_msix(nic);
+ while (--i >= 0)
+ free_irq(pci_irq_vector(nic->pdev, i), nic);
+ pci_free_irq_vectors(nic->pdev);
return ret;
}
static void nic_unregister_interrupts(struct nicpf *nic)
{
- nic_free_all_interrupts(nic);
- nic_disable_msix(nic);
+ int i;
+
+ for (i = 0; i < nic->num_vec; i++)
+ free_irq(pci_irq_vector(nic->pdev, i), nic);
+ pci_free_irq_vectors(nic->pdev);
}
static int nic_num_sqs_en(struct nicpf *nic, int vf_en)
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/5] net: thunderxvf: switch to pci_alloc_irq_vectors
2017-03-27 8:29 remove pci_enable_msix() Christoph Hellwig
2017-03-27 8:29 ` [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors Christoph Hellwig
@ 2017-03-27 8:29 ` Christoph Hellwig
2017-03-27 8:29 ` [PATCH 3/5] net: alx: " Christoph Hellwig
` (2 subsequent siblings)
4 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 8:29 UTC (permalink / raw)
To: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
Remove the deprecated pci_enable_msix API in favour of it's successor.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/net/ethernet/cavium/thunder/nic.h | 2 -
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 70 ++++++++----------------
2 files changed, 24 insertions(+), 48 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h
index 2269ff562d95..6fb44218bf55 100644
--- a/drivers/net/ethernet/cavium/thunder/nic.h
+++ b/drivers/net/ethernet/cavium/thunder/nic.h
@@ -319,9 +319,7 @@ struct nicvf {
struct bgx_stats bgx_stats;
/* MSI-X */
- bool msix_enabled;
u8 num_vec;
- struct msix_entry msix_entries[NIC_VF_MSIX_VECTORS];
char irq_name[NIC_VF_MSIX_VECTORS][IFNAMSIZ + 15];
bool irq_allocated[NIC_VF_MSIX_VECTORS];
cpumask_var_t affinity_mask[NIC_VF_MSIX_VECTORS];
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 24017588f531..183782ce9581 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -882,38 +882,9 @@ static irqreturn_t nicvf_qs_err_intr_handler(int irq, void *nicvf_irq)
return IRQ_HANDLED;
}
-static int nicvf_enable_msix(struct nicvf *nic)
-{
- int ret, vec;
-
- nic->num_vec = NIC_VF_MSIX_VECTORS;
-
- for (vec = 0; vec < nic->num_vec; vec++)
- nic->msix_entries[vec].entry = vec;
-
- ret = pci_enable_msix(nic->pdev, nic->msix_entries, nic->num_vec);
- if (ret) {
- netdev_err(nic->netdev,
- "Req for #%d msix vectors failed\n", nic->num_vec);
- return 0;
- }
- nic->msix_enabled = 1;
- return 1;
-}
-
-static void nicvf_disable_msix(struct nicvf *nic)
-{
- if (nic->msix_enabled) {
- pci_disable_msix(nic->pdev);
- nic->msix_enabled = 0;
- nic->num_vec = 0;
- }
-}
-
static void nicvf_set_irq_affinity(struct nicvf *nic)
{
int vec, cpu;
- int irqnum;
for (vec = 0; vec < nic->num_vec; vec++) {
if (!nic->irq_allocated[vec])
@@ -930,15 +901,14 @@ static void nicvf_set_irq_affinity(struct nicvf *nic)
cpumask_set_cpu(cpumask_local_spread(cpu, nic->node),
nic->affinity_mask[vec]);
- irqnum = nic->msix_entries[vec].vector;
- irq_set_affinity_hint(irqnum, nic->affinity_mask[vec]);
+ irq_set_affinity_hint(pci_irq_vector(nic->pdev, vec),
+ nic->affinity_mask[vec]);
}
}
static int nicvf_register_interrupts(struct nicvf *nic)
{
int irq, ret = 0;
- int vector;
for_each_cq_irq(irq)
sprintf(nic->irq_name[irq], "%s-rxtx-%d",
@@ -957,8 +927,8 @@ static int nicvf_register_interrupts(struct nicvf *nic)
/* Register CQ interrupts */
for (irq = 0; irq < nic->qs->cq_cnt; irq++) {
- vector = nic->msix_entries[irq].vector;
- ret = request_irq(vector, nicvf_intr_handler,
+ ret = request_irq(pci_irq_vector(nic->pdev, irq),
+ nicvf_intr_handler,
0, nic->irq_name[irq], nic->napi[irq]);
if (ret)
goto err;
@@ -968,8 +938,8 @@ static int nicvf_register_interrupts(struct nicvf *nic)
/* Register RBDR interrupt */
for (irq = NICVF_INTR_ID_RBDR;
irq < (NICVF_INTR_ID_RBDR + nic->qs->rbdr_cnt); irq++) {
- vector = nic->msix_entries[irq].vector;
- ret = request_irq(vector, nicvf_rbdr_intr_handler,
+ ret = request_irq(pci_irq_vector(nic->pdev, irq),
+ nicvf_rbdr_intr_handler,
0, nic->irq_name[irq], nic);
if (ret)
goto err;
@@ -981,7 +951,7 @@ static int nicvf_register_interrupts(struct nicvf *nic)
nic->pnicvf->netdev->name,
nic->sqs_mode ? (nic->sqs_id + 1) : 0);
irq = NICVF_INTR_ID_QS_ERR;
- ret = request_irq(nic->msix_entries[irq].vector,
+ ret = request_irq(pci_irq_vector(nic->pdev, irq),
nicvf_qs_err_intr_handler,
0, nic->irq_name[irq], nic);
if (ret)
@@ -1001,6 +971,7 @@ static int nicvf_register_interrupts(struct nicvf *nic)
static void nicvf_unregister_interrupts(struct nicvf *nic)
{
+ struct pci_dev *pdev = nic->pdev;
int irq;
/* Free registered interrupts */
@@ -1008,19 +979,20 @@ static void nicvf_unregister_interrupts(struct nicvf *nic)
if (!nic->irq_allocated[irq])
continue;
- irq_set_affinity_hint(nic->msix_entries[irq].vector, NULL);
+ irq_set_affinity_hint(pci_irq_vector(pdev, irq), NULL);
free_cpumask_var(nic->affinity_mask[irq]);
if (irq < NICVF_INTR_ID_SQ)
- free_irq(nic->msix_entries[irq].vector, nic->napi[irq]);
+ free_irq(pci_irq_vector(pdev, irq), nic->napi[irq]);
else
- free_irq(nic->msix_entries[irq].vector, nic);
+ free_irq(pci_irq_vector(pdev, irq), nic);
nic->irq_allocated[irq] = false;
}
/* Disable MSI-X */
- nicvf_disable_msix(nic);
+ pci_free_irq_vectors(pdev);
+ nic->num_vec = 0;
}
/* Initialize MSIX vectors and register MISC interrupt.
@@ -1032,16 +1004,22 @@ static int nicvf_register_misc_interrupt(struct nicvf *nic)
int irq = NICVF_INTR_ID_MISC;
/* Return if mailbox interrupt is already registered */
- if (nic->msix_enabled)
+ if (nic->pdev->msix_enabled)
return 0;
/* Enable MSI-X */
- if (!nicvf_enable_msix(nic))
+ nic->num_vec = NIC_VF_MSIX_VECTORS;
+ ret = pci_alloc_irq_vectors(nic->pdev, nic->num_vec, nic->num_vec,
+ PCI_IRQ_MSIX);
+ if (ret < 0) {
+ netdev_err(nic->netdev,
+ "Req for #%d msix vectors failed\n", nic->num_vec);
return 1;
+ }
sprintf(nic->irq_name[irq], "%s Mbox", "NICVF");
/* Register Misc interrupt */
- ret = request_irq(nic->msix_entries[irq].vector,
+ ret = request_irq(pci_irq_vector(nic->pdev, irq),
nicvf_misc_intr_handler, 0, nic->irq_name[irq], nic);
if (ret)
@@ -1164,7 +1142,7 @@ int nicvf_stop(struct net_device *netdev)
/* Wait for pending IRQ handlers to finish */
for (irq = 0; irq < nic->num_vec; irq++)
- synchronize_irq(nic->msix_entries[irq].vector);
+ synchronize_irq(pci_irq_vector(nic->pdev, irq));
tasklet_kill(&nic->rbdr_task);
tasklet_kill(&nic->qs_err_task);
@@ -1365,7 +1343,7 @@ static int nicvf_set_mac_address(struct net_device *netdev, void *p)
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
- if (nic->msix_enabled) {
+ if (nic->pdev->msix_enabled) {
if (nicvf_hw_set_mac_addr(nic, netdev))
return -EBUSY;
} else {
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 3/5] net: alx: switch to pci_alloc_irq_vectors
2017-03-27 8:29 remove pci_enable_msix() Christoph Hellwig
2017-03-27 8:29 ` [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors Christoph Hellwig
2017-03-27 8:29 ` [PATCH 2/5] net: thunderxvf: " Christoph Hellwig
@ 2017-03-27 8:29 ` Christoph Hellwig
2017-03-27 8:29 ` [PATCH 4/5] net/ena: " Christoph Hellwig
2017-03-27 8:29 ` [PATCH 5/5] PCI: remove pci_enable_msix Christoph Hellwig
4 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 8:29 UTC (permalink / raw)
To: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
Remove the deprecated pci_enable_msix API in favour of it's successor,
and make sure to handle errors during IRQ setup properly.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/net/ethernet/atheros/alx/alx.h | 6 --
drivers/net/ethernet/atheros/alx/main.c | 128 ++++++++++++++------------------
2 files changed, 54 insertions(+), 80 deletions(-)
diff --git a/drivers/net/ethernet/atheros/alx/alx.h b/drivers/net/ethernet/atheros/alx/alx.h
index d4a409139ea2..78c5de467426 100644
--- a/drivers/net/ethernet/atheros/alx/alx.h
+++ b/drivers/net/ethernet/atheros/alx/alx.h
@@ -102,9 +102,6 @@ struct alx_napi {
#define ALX_MAX_NAPIS 8
-#define ALX_FLAG_USING_MSIX BIT(0)
-#define ALX_FLAG_USING_MSI BIT(1)
-
struct alx_priv {
struct net_device *dev;
@@ -112,7 +109,6 @@ struct alx_priv {
/* msi-x vectors */
int num_vec;
- struct msix_entry *msix_entries;
/* all descriptor memory */
struct {
@@ -139,8 +135,6 @@ struct alx_priv {
u16 msg_enable;
- int flags;
-
/* protects hw.stats */
spinlock_t stats_lock;
};
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 6a27c2662675..a8c2db881b75 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -314,7 +314,7 @@ static int alx_poll(struct napi_struct *napi, int budget)
napi_complete_done(&np->napi, work);
/* enable interrupt */
- if (alx->flags & ALX_FLAG_USING_MSIX) {
+ if (alx->hw.pdev->msix_enabled) {
alx_mask_msix(hw, np->vec_idx, false);
} else {
spin_lock_irqsave(&alx->irq_lock, flags);
@@ -811,7 +811,7 @@ static void alx_config_vector_mapping(struct alx_priv *alx)
u32 tbl[2] = {0, 0};
int i, vector, idx, shift;
- if (alx->flags & ALX_FLAG_USING_MSIX) {
+ if (alx->hw.pdev->msix_enabled) {
/* tx mappings */
for (i = 0, vector = 1; i < alx->num_txq; i++, vector++) {
idx = txq_vec_mapping_shift[i * 2];
@@ -828,29 +828,19 @@ static void alx_config_vector_mapping(struct alx_priv *alx)
alx_write_mem32(hw, ALX_MSI_ID_MAP, 0);
}
-static bool alx_enable_msix(struct alx_priv *alx)
+static int alx_enable_msix(struct alx_priv *alx)
{
- int i, err, num_vec, num_txq, num_rxq;
+ int err, num_vec, num_txq, num_rxq;
num_txq = min_t(int, num_online_cpus(), ALX_MAX_TX_QUEUES);
num_rxq = 1;
num_vec = max_t(int, num_txq, num_rxq) + 1;
- alx->msix_entries = kcalloc(num_vec, sizeof(struct msix_entry),
- GFP_KERNEL);
- if (!alx->msix_entries) {
- netdev_warn(alx->dev, "Allocation of msix entries failed!\n");
- return false;
- }
-
- for (i = 0; i < num_vec; i++)
- alx->msix_entries[i].entry = i;
-
- err = pci_enable_msix(alx->hw.pdev, alx->msix_entries, num_vec);
+ err = pci_alloc_irq_vectors(alx->hw.pdev, num_vec, num_vec,
+ PCI_IRQ_MSIX);
if (err) {
- kfree(alx->msix_entries);
netdev_warn(alx->dev, "Enabling MSI-X interrupts failed!\n");
- return false;
+ return err;
}
alx->num_vec = num_vec;
@@ -858,7 +848,7 @@ static bool alx_enable_msix(struct alx_priv *alx)
alx->num_txq = num_txq;
alx->num_rxq = num_rxq;
- return true;
+ return err;
}
static int alx_request_msix(struct alx_priv *alx)
@@ -866,7 +856,7 @@ static int alx_request_msix(struct alx_priv *alx)
struct net_device *netdev = alx->dev;
int i, err, vector = 0, free_vector = 0;
- err = request_irq(alx->msix_entries[0].vector, alx_intr_msix_misc,
+ err = request_irq(pci_irq_vector(alx->hw.pdev, 0), alx_intr_msix_misc,
0, netdev->name, alx);
if (err)
goto out_err;
@@ -889,7 +879,7 @@ static int alx_request_msix(struct alx_priv *alx)
sprintf(np->irq_lbl, "%s-unused", netdev->name);
np->vec_idx = vector;
- err = request_irq(alx->msix_entries[vector].vector,
+ err = request_irq(pci_irq_vector(alx->hw.pdev, vector),
alx_intr_msix_ring, 0, np->irq_lbl, np);
if (err)
goto out_free;
@@ -897,47 +887,31 @@ static int alx_request_msix(struct alx_priv *alx)
return 0;
out_free:
- free_irq(alx->msix_entries[free_vector++].vector, alx);
+ free_irq(pci_irq_vector(alx->hw.pdev, free_vector++), alx);
vector--;
for (i = 0; i < vector; i++)
- free_irq(alx->msix_entries[free_vector++].vector,
+ free_irq(pci_irq_vector(alx->hw.pdev,free_vector++),
alx->qnapi[i]);
out_err:
return err;
}
-static void alx_init_intr(struct alx_priv *alx, bool msix)
+static int alx_init_intr(struct alx_priv *alx)
{
- if (msix) {
- if (alx_enable_msix(alx))
- alx->flags |= ALX_FLAG_USING_MSIX;
- }
+ int ret;
- if (!(alx->flags & ALX_FLAG_USING_MSIX)) {
- alx->num_vec = 1;
- alx->num_napi = 1;
- alx->num_txq = 1;
- alx->num_rxq = 1;
-
- if (!pci_enable_msi(alx->hw.pdev))
- alx->flags |= ALX_FLAG_USING_MSI;
- }
-}
-
-static void alx_disable_advanced_intr(struct alx_priv *alx)
-{
- if (alx->flags & ALX_FLAG_USING_MSIX) {
- kfree(alx->msix_entries);
- pci_disable_msix(alx->hw.pdev);
- alx->flags &= ~ALX_FLAG_USING_MSIX;
- }
+ ret = pci_alloc_irq_vectors(alx->hw.pdev, 1, 1,
+ PCI_IRQ_MSI | PCI_IRQ_LEGACY);
+ if (ret)
+ return ret;
- if (alx->flags & ALX_FLAG_USING_MSI) {
- pci_disable_msi(alx->hw.pdev);
- alx->flags &= ~ALX_FLAG_USING_MSI;
- }
+ alx->num_vec = 1;
+ alx->num_napi = 1;
+ alx->num_txq = 1;
+ alx->num_rxq = 1;
+ return 0;
}
static void alx_irq_enable(struct alx_priv *alx)
@@ -950,10 +924,11 @@ static void alx_irq_enable(struct alx_priv *alx)
alx_write_mem32(hw, ALX_IMR, alx->int_mask);
alx_post_write(hw);
- if (alx->flags & ALX_FLAG_USING_MSIX)
+ if (alx->hw.pdev->msix_enabled) {
/* enable all msix irqs */
for (i = 0; i < alx->num_vec; i++)
alx_mask_msix(hw, i, false);
+ }
}
static void alx_irq_disable(struct alx_priv *alx)
@@ -965,13 +940,13 @@ static void alx_irq_disable(struct alx_priv *alx)
alx_write_mem32(hw, ALX_IMR, 0);
alx_post_write(hw);
- if (alx->flags & ALX_FLAG_USING_MSIX) {
+ if (alx->hw.pdev->msix_enabled) {
for (i = 0; i < alx->num_vec; i++) {
alx_mask_msix(hw, i, true);
- synchronize_irq(alx->msix_entries[i].vector);
+ synchronize_irq(pci_irq_vector(alx->hw.pdev, i));
}
} else {
- synchronize_irq(alx->hw.pdev->irq);
+ synchronize_irq(pci_irq_vector(alx->hw.pdev, 0));
}
}
@@ -981,8 +956,11 @@ static int alx_realloc_resources(struct alx_priv *alx)
alx_free_rings(alx);
alx_free_napis(alx);
- alx_disable_advanced_intr(alx);
- alx_init_intr(alx, false);
+ pci_free_irq_vectors(alx->hw.pdev);
+
+ err = alx_init_intr(alx);
+ if (err)
+ return err;
err = alx_alloc_napis(alx);
if (err)
@@ -1004,7 +982,7 @@ static int alx_request_irq(struct alx_priv *alx)
msi_ctrl = (hw->imt >> 1) << ALX_MSI_RETRANS_TM_SHIFT;
- if (alx->flags & ALX_FLAG_USING_MSIX) {
+ if (alx->hw.pdev->msix_enabled) {
alx_write_mem32(hw, ALX_MSI_RETRANS_TIMER, msi_ctrl);
err = alx_request_msix(alx);
if (!err)
@@ -1016,20 +994,20 @@ static int alx_request_irq(struct alx_priv *alx)
goto out;
}
- if (alx->flags & ALX_FLAG_USING_MSI) {
+ if (alx->hw.pdev->msi_enabled) {
alx_write_mem32(hw, ALX_MSI_RETRANS_TIMER,
msi_ctrl | ALX_MSI_MASK_SEL_LINE);
- err = request_irq(pdev->irq, alx_intr_msi, 0,
+ err = request_irq(pci_irq_vector(pdev, 0), alx_intr_msi, 0,
alx->dev->name, alx);
if (!err)
goto out;
+
/* fall back to legacy interrupt */
- alx->flags &= ~ALX_FLAG_USING_MSI;
- pci_disable_msi(alx->hw.pdev);
+ pci_free_irq_vectors(alx->hw.pdev);
}
alx_write_mem32(hw, ALX_MSI_RETRANS_TIMER, 0);
- err = request_irq(pdev->irq, alx_intr_legacy, IRQF_SHARED,
+ err = request_irq(pci_irq_vector(pdev, 0), alx_intr_legacy, IRQF_SHARED,
alx->dev->name, alx);
out:
if (!err)
@@ -1042,18 +1020,15 @@ static int alx_request_irq(struct alx_priv *alx)
static void alx_free_irq(struct alx_priv *alx)
{
struct pci_dev *pdev = alx->hw.pdev;
- int i, vector = 0;
+ int i;
- if (alx->flags & ALX_FLAG_USING_MSIX) {
- free_irq(alx->msix_entries[vector++].vector, alx);
+ free_irq(pci_irq_vector(pdev, 0), alx);
+ if (alx->hw.pdev->msix_enabled) {
for (i = 0; i < alx->num_napi; i++)
- free_irq(alx->msix_entries[vector++].vector,
- alx->qnapi[i]);
- } else {
- free_irq(pdev->irq, alx);
+ free_irq(pci_irq_vector(pdev, i + 1), alx->qnapi[i]);
}
- alx_disable_advanced_intr(alx);
+ pci_free_irq_vectors(pdev);
}
static int alx_identify_hw(struct alx_priv *alx)
@@ -1221,7 +1196,12 @@ static int __alx_open(struct alx_priv *alx, bool resume)
{
int err;
- alx_init_intr(alx, true);
+ err = alx_enable_msix(alx);
+ if (err < 0) {
+ err = alx_init_intr(alx);
+ if (err)
+ return err;
+ }
if (!resume)
netif_carrier_off(alx->dev);
@@ -1264,7 +1244,7 @@ static int __alx_open(struct alx_priv *alx, bool resume)
alx_free_rings(alx);
alx_free_napis(alx);
out_disable_adv_intr:
- alx_disable_advanced_intr(alx);
+ pci_free_irq_vectors(alx->hw.pdev);
return err;
}
@@ -1637,11 +1617,11 @@ static void alx_poll_controller(struct net_device *netdev)
struct alx_priv *alx = netdev_priv(netdev);
int i;
- if (alx->flags & ALX_FLAG_USING_MSIX) {
+ if (alx->hw.pdev->msix_enabled) {
alx_intr_msix_misc(0, alx);
for (i = 0; i < alx->num_txq; i++)
alx_intr_msix_ring(0, alx->qnapi[i]);
- } else if (alx->flags & ALX_FLAG_USING_MSI)
+ } else if (alx->hw.pdev->msi_enabled)
alx_intr_msi(0, alx);
else
alx_intr_legacy(0, alx);
@@ -1783,7 +1763,7 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->netdev_ops = &alx_netdev_ops;
netdev->ethtool_ops = &alx_ethtool_ops;
- netdev->irq = pdev->irq;
+ netdev->irq = pci_irq_vector(pdev, 0);
netdev->watchdog_timeo = ALX_WATCHDOG_TIME;
if (ent->driver_data & ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG)
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 4/5] net/ena: switch to pci_alloc_irq_vectors
2017-03-27 8:29 remove pci_enable_msix() Christoph Hellwig
` (2 preceding siblings ...)
2017-03-27 8:29 ` [PATCH 3/5] net: alx: " Christoph Hellwig
@ 2017-03-27 8:29 ` Christoph Hellwig
2017-03-27 8:29 ` [PATCH 5/5] PCI: remove pci_enable_msix Christoph Hellwig
4 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 8:29 UTC (permalink / raw)
To: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
Remove the deprecated pci_enable_msix API in favour of it's successor.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 55 ++++++----------------------
drivers/net/ethernet/amazon/ena/ena_netdev.h | 2 -
2 files changed, 12 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 35f19430c84a..7c1214d78855 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -133,7 +133,7 @@ static int ena_init_rx_cpu_rmap(struct ena_adapter *adapter)
int irq_idx = ENA_IO_IRQ_IDX(i);
rc = irq_cpu_rmap_add(adapter->netdev->rx_cpu_rmap,
- adapter->msix_entries[irq_idx].vector);
+ pci_irq_vector(adapter->pdev, irq_idx));
if (rc) {
free_irq_cpu_rmap(adapter->netdev->rx_cpu_rmap);
adapter->netdev->rx_cpu_rmap = NULL;
@@ -1208,13 +1208,7 @@ static irqreturn_t ena_intr_msix_io(int irq, void *data)
static int ena_enable_msix(struct ena_adapter *adapter, int num_queues)
{
- int i, msix_vecs, rc;
-
- if (test_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags)) {
- netif_err(adapter, probe, adapter->netdev,
- "Error, MSI-X is already enabled\n");
- return -EPERM;
- }
+ int msix_vecs, rc;
/* Reserved the max msix vectors we might need */
msix_vecs = ENA_MAX_MSIX_VEC(num_queues);
@@ -1222,16 +1216,9 @@ static int ena_enable_msix(struct ena_adapter *adapter, int num_queues)
netif_dbg(adapter, probe, adapter->netdev,
"trying to enable MSI-X, vectors %d\n", msix_vecs);
- adapter->msix_entries = vzalloc(msix_vecs * sizeof(struct msix_entry));
-
- if (!adapter->msix_entries)
- return -ENOMEM;
-
- for (i = 0; i < msix_vecs; i++)
- adapter->msix_entries[i].entry = i;
-
- rc = pci_enable_msix(adapter->pdev, adapter->msix_entries, msix_vecs);
- if (rc != 0) {
+ rc = pci_alloc_irq_vectors(adapter->pdev, msix_vecs, msix_vecs,
+ PCI_IRQ_MSIX);
+ if (rc < 0) {
netif_err(adapter, probe, adapter->netdev,
"Failed to enable MSI-X, vectors %d rc %d\n",
msix_vecs, rc);
@@ -1248,7 +1235,6 @@ static int ena_enable_msix(struct ena_adapter *adapter, int num_queues)
}
adapter->msix_vecs = msix_vecs;
- set_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags);
return 0;
}
@@ -1264,7 +1250,7 @@ static void ena_setup_mgmnt_intr(struct ena_adapter *adapter)
ena_intr_msix_mgmnt;
adapter->irq_tbl[ENA_MGMNT_IRQ_IDX].data = adapter;
adapter->irq_tbl[ENA_MGMNT_IRQ_IDX].vector =
- adapter->msix_entries[ENA_MGMNT_IRQ_IDX].vector;
+ pci_irq_vector(adapter->pdev, ENA_MGMNT_IRQ_IDX);
cpu = cpumask_first(cpu_online_mask);
adapter->irq_tbl[ENA_MGMNT_IRQ_IDX].cpu = cpu;
cpumask_set_cpu(cpu,
@@ -1287,7 +1273,7 @@ static void ena_setup_io_intr(struct ena_adapter *adapter)
adapter->irq_tbl[irq_idx].handler = ena_intr_msix_io;
adapter->irq_tbl[irq_idx].data = &adapter->ena_napi[i];
adapter->irq_tbl[irq_idx].vector =
- adapter->msix_entries[irq_idx].vector;
+ pci_irq_vector(adapter->pdev, irq_idx);
adapter->irq_tbl[irq_idx].cpu = cpu;
cpumask_set_cpu(cpu,
@@ -1325,12 +1311,6 @@ static int ena_request_io_irq(struct ena_adapter *adapter)
struct ena_irq *irq;
int rc = 0, i, k;
- if (!test_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags)) {
- netif_err(adapter, ifup, adapter->netdev,
- "Failed to request I/O IRQ: MSI-X is not enabled\n");
- return -EINVAL;
- }
-
for (i = ENA_IO_IRQ_FIRST_IDX; i < adapter->msix_vecs; i++) {
irq = &adapter->irq_tbl[i];
rc = request_irq(irq->vector, irq->handler, flags, irq->name,
@@ -1389,16 +1369,6 @@ static void ena_free_io_irq(struct ena_adapter *adapter)
}
}
-static void ena_disable_msix(struct ena_adapter *adapter)
-{
- if (test_and_clear_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags))
- pci_disable_msix(adapter->pdev);
-
- if (adapter->msix_entries)
- vfree(adapter->msix_entries);
- adapter->msix_entries = NULL;
-}
-
static void ena_disable_io_intr_sync(struct ena_adapter *adapter)
{
int i;
@@ -2479,8 +2449,7 @@ static int ena_enable_msix_and_set_admin_interrupts(struct ena_adapter *adapter,
return 0;
err_disable_msix:
- ena_disable_msix(adapter);
-
+ pci_free_irq_vectors(adapter->pdev);
return rc;
}
@@ -2518,7 +2487,7 @@ static void ena_fw_reset_device(struct work_struct *work)
ena_free_mgmnt_irq(adapter);
- ena_disable_msix(adapter);
+ pci_free_irq_vectors(adapter->pdev);
ena_com_abort_admin_commands(ena_dev);
@@ -2569,7 +2538,7 @@ static void ena_fw_reset_device(struct work_struct *work)
return;
err_disable_msix:
ena_free_mgmnt_irq(adapter);
- ena_disable_msix(adapter);
+ pci_free_irq_vectors(adapter->pdev);
err_device_destroy:
ena_com_admin_destroy(ena_dev);
err:
@@ -3103,7 +3072,7 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_free_msix:
ena_com_dev_reset(ena_dev);
ena_free_mgmnt_irq(adapter);
- ena_disable_msix(adapter);
+ pci_free_irq_vectors(adapter->pdev);
err_worker_destroy:
ena_com_destroy_interrupt_moderation(ena_dev);
del_timer(&adapter->timer_service);
@@ -3188,7 +3157,7 @@ static void ena_remove(struct pci_dev *pdev)
ena_free_mgmnt_irq(adapter);
- ena_disable_msix(adapter);
+ pci_free_irq_vectors(adapter->pdev);
free_netdev(netdev);
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index ed62d8e231a1..0e22bce6239d 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -248,7 +248,6 @@ enum ena_flags_t {
ENA_FLAG_DEVICE_RUNNING,
ENA_FLAG_DEV_UP,
ENA_FLAG_LINK_UP,
- ENA_FLAG_MSIX_ENABLED,
ENA_FLAG_TRIGGER_RESET
};
@@ -267,7 +266,6 @@ struct ena_adapter {
int num_queues;
- struct msix_entry *msix_entries;
int msix_vecs;
u32 tx_usecs, rx_usecs; /* interrupt moderation */
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 8:29 remove pci_enable_msix() Christoph Hellwig
` (3 preceding siblings ...)
2017-03-27 8:29 ` [PATCH 4/5] net/ena: " Christoph Hellwig
@ 2017-03-27 8:29 ` Christoph Hellwig
2017-03-27 14:06 ` David Laight
` (2 more replies)
4 siblings, 3 replies; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 8:29 UTC (permalink / raw)
To: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
Unused now that all callers switched to pci_alloc_irq_vectors.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/pci/msi.c | 21 ---------------------
include/linux/pci.h | 4 ----
2 files changed, 25 deletions(-)
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index d571bc330686..0042c365b29b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -973,27 +973,6 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
return msix_capability_init(dev, entries, nvec, affd);
}
-/**
- * pci_enable_msix - configure device's MSI-X capability structure
- * @dev: pointer to the pci_dev data structure of MSI-X device function
- * @entries: pointer to an array of MSI-X entries (optional)
- * @nvec: number of MSI-X irqs requested for allocation by device driver
- *
- * Setup the MSI-X capability structure of device function with the number
- * of requested irqs upon its software driver call to request for
- * MSI-X mode enabled on its hardware device function. A return of zero
- * indicates the successful configuration of MSI-X capability structure
- * with new allocated MSI-X irqs. A return of < 0 indicates a failure.
- * Or a return of > 0 indicates that driver request is exceeding the number
- * of irqs or MSI-X vectors available. Driver should use the returned value to
- * re-send its request.
- **/
-int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
-{
- return __pci_enable_msix(dev, entries, nvec, NULL);
-}
-EXPORT_SYMBOL(pci_enable_msix);
-
void pci_msix_shutdown(struct pci_dev *dev)
{
struct msi_desc *entry;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index eb3da1a04e6c..82dec36845e6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1300,7 +1300,6 @@ int pci_msi_vec_count(struct pci_dev *dev);
void pci_msi_shutdown(struct pci_dev *dev);
void pci_disable_msi(struct pci_dev *dev);
int pci_msix_vec_count(struct pci_dev *dev);
-int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
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);
@@ -1330,9 +1329,6 @@ static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
static inline void pci_msi_shutdown(struct pci_dev *dev) { }
static inline void pci_disable_msi(struct pci_dev *dev) { }
static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
-static inline int pci_enable_msix(struct pci_dev *dev,
- struct msix_entry *entries, int nvec)
-{ return -ENOSYS; }
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) { }
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* RE: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 8:29 ` [PATCH 5/5] PCI: remove pci_enable_msix Christoph Hellwig
@ 2017-03-27 14:06 ` David Laight
2017-03-27 14:51 ` 'Christoph Hellwig'
2017-03-27 16:59 ` David Daney
2017-03-30 23:09 ` Bjorn Helgaas
2 siblings, 1 reply; 21+ messages in thread
From: David Laight @ 2017-03-27 14:06 UTC (permalink / raw)
To: 'Christoph Hellwig',
bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric
Cc: netdev, linux-pci
From: Christoph Hellwig
> Sent: 27 March 2017 09:30
>
> Unused now that all callers switched to pci_alloc_irq_vectors.
Apart from all the 'out of tree' drivers that will need
fixing and a conditional compile added.
At least give us a couple of kernel versions to get it sorted.
David
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 14:06 ` David Laight
@ 2017-03-27 14:51 ` 'Christoph Hellwig'
2017-03-27 15:03 ` David Laight
0 siblings, 1 reply; 21+ messages in thread
From: 'Christoph Hellwig' @ 2017-03-27 14:51 UTC (permalink / raw)
To: David Laight
Cc: 'Christoph Hellwig',
bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
On Mon, Mar 27, 2017 at 02:06:45PM +0000, David Laight wrote:
> Apart from all the 'out of tree' drivers that will need
> fixing and a conditional compile added.
That has never been a reason for stopping linux kernel changes.
Never mind that your out of tree drivers should probably never have used
this function anyway, but pci_enable_msix_{exact,range} which would have
been the better choice even before pci_alloc_irq_vectors.
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 14:51 ` 'Christoph Hellwig'
@ 2017-03-27 15:03 ` David Laight
2017-03-27 17:10 ` 'Christoph Hellwig'
0 siblings, 1 reply; 21+ messages in thread
From: David Laight @ 2017-03-27 15:03 UTC (permalink / raw)
To: 'Christoph Hellwig'
Cc: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
From: 'Christoph Hellwig'
> Sent: 27 March 2017 15:52
> On Mon, Mar 27, 2017 at 02:06:45PM +0000, David Laight wrote:
> > Apart from all the 'out of tree' drivers that will need
> > fixing and a conditional compile added.
>
> That has never been a reason for stopping linux kernel changes.
I'm aware of that, but sometimes you just make life hard.
> Never mind that your out of tree drivers should probably never have used
> this function anyway, but pci_enable_msix_{exact,range} which would have
> been the better choice even before pci_alloc_irq_vectors.
Indeed, but pci_enable_msix_range() only appeared in 3.14.
We have to support a wide range of kernels.
I think we've finally managed to get most of our customers off 2.6.18.
David
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors
2017-03-27 8:29 ` [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors Christoph Hellwig
@ 2017-03-27 16:03 ` Sunil Kovvuri
2017-03-27 17:12 ` Christoph Hellwig
0 siblings, 1 reply; 21+ messages in thread
From: Sunil Kovvuri @ 2017-03-27 16:03 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Bjorn Helgaas, David S. Miller, netanel, jcliburn, chris.snook,
Sunil Goutham, Robert Richter, Linux Netdev List, linux-pci
On Mon, Mar 27, 2017 at 1:59 PM, Christoph Hellwig <hch@lst.de> wrote:
> Remove the deprecated pci_enable_msix API in favour of it's successor.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/net/ethernet/cavium/thunder/nic_main.c | 75 ++++++--------------------
> 1 file changed, 15 insertions(+), 60 deletions(-)
> - nic->num_vec = pci_msix_vec_count(nic->pdev);
> -
> - ret = pci_enable_msix(nic->pdev, nic->msix_entries, nic->num_vec);
> - if (ret) {
> + /* Enable MSI-X */
> + ret = pci_alloc_irq_vectors(nic->pdev, nic->num_vec, nic->num_vec,
> + PCI_IRQ_MSIX);
nic->num_vec will always be zero here.
> + while (--i >= 0)
> + free_irq(pci_irq_vector(nic->pdev, i), nic);
> + pci_free_irq_vectors(nic->pdev);
> return ret;
IRQ handlers are not registered for all vectors to free them unconditionally
> + int i;
> +
> + for (i = 0; i < nic->num_vec; i++)
> + free_irq(pci_irq_vector(nic->pdev, i), nic);
> + pci_free_irq_vectors(nic->pdev);
> }
Same as here.
How urgent is this ?
Can we comeup with a proper patch to fix this in couple of weeks, instead of
going with these untested patches ?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 8:29 ` [PATCH 5/5] PCI: remove pci_enable_msix Christoph Hellwig
2017-03-27 14:06 ` David Laight
@ 2017-03-27 16:59 ` David Daney
2017-03-27 17:11 ` Christoph Hellwig
2017-03-30 23:09 ` Bjorn Helgaas
2 siblings, 1 reply; 21+ messages in thread
From: David Daney @ 2017-03-27 16:59 UTC (permalink / raw)
To: Christoph Hellwig, bhelgaas, davem, netanel, jcliburn,
chris.snook, sgoutham, rric
Cc: netdev, linux-pci
On 03/27/2017 01:29 AM, Christoph Hellwig wrote:
> Unused now that all callers switched to pci_alloc_irq_vectors.
>
And you are aware that the ThunderX GPIO driver that I am attempting to
merge uses this interface.
If this patch gets merged, should I ask to revert it when the GPIO
driver goes in?
You offer no solution for drivers that would benefit from using a sparse
sub set of the available MSI-X vectors.
David Daney
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/pci/msi.c | 21 ---------------------
> include/linux/pci.h | 4 ----
> 2 files changed, 25 deletions(-)
>
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index d571bc330686..0042c365b29b 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -973,27 +973,6 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
> return msix_capability_init(dev, entries, nvec, affd);
> }
>
> -/**
> - * pci_enable_msix - configure device's MSI-X capability structure
> - * @dev: pointer to the pci_dev data structure of MSI-X device function
> - * @entries: pointer to an array of MSI-X entries (optional)
> - * @nvec: number of MSI-X irqs requested for allocation by device driver
> - *
> - * Setup the MSI-X capability structure of device function with the number
> - * of requested irqs upon its software driver call to request for
> - * MSI-X mode enabled on its hardware device function. A return of zero
> - * indicates the successful configuration of MSI-X capability structure
> - * with new allocated MSI-X irqs. A return of < 0 indicates a failure.
> - * Or a return of > 0 indicates that driver request is exceeding the number
> - * of irqs or MSI-X vectors available. Driver should use the returned value to
> - * re-send its request.
> - **/
> -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
> -{
> - return __pci_enable_msix(dev, entries, nvec, NULL);
> -}
> -EXPORT_SYMBOL(pci_enable_msix);
> -
> void pci_msix_shutdown(struct pci_dev *dev)
> {
> struct msi_desc *entry;
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index eb3da1a04e6c..82dec36845e6 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1300,7 +1300,6 @@ int pci_msi_vec_count(struct pci_dev *dev);
> void pci_msi_shutdown(struct pci_dev *dev);
> void pci_disable_msi(struct pci_dev *dev);
> int pci_msix_vec_count(struct pci_dev *dev);
> -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
> 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);
> @@ -1330,9 +1329,6 @@ static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
> static inline void pci_msi_shutdown(struct pci_dev *dev) { }
> static inline void pci_disable_msi(struct pci_dev *dev) { }
> static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
> -static inline int pci_enable_msix(struct pci_dev *dev,
> - struct msix_entry *entries, int nvec)
> -{ return -ENOSYS; }
> 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) { }
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 15:03 ` David Laight
@ 2017-03-27 17:10 ` 'Christoph Hellwig'
0 siblings, 0 replies; 21+ messages in thread
From: 'Christoph Hellwig' @ 2017-03-27 17:10 UTC (permalink / raw)
To: David Laight
Cc: 'Christoph Hellwig',
bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
On Mon, Mar 27, 2017 at 03:03:30PM +0000, David Laight wrote:
> Indeed, but pci_enable_msix_range() only appeared in 3.14.
> We have to support a wide range of kernels.
> I think we've finally managed to get most of our customers off 2.6.18.
That's your problem, not that of upstream kernel developers.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 16:59 ` David Daney
@ 2017-03-27 17:11 ` Christoph Hellwig
2017-03-27 17:30 ` David Daney
0 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 17:11 UTC (permalink / raw)
To: David Daney
Cc: Christoph Hellwig, bhelgaas, davem, netanel, jcliburn,
chris.snook, sgoutham, rric, netdev, linux-pci
On Mon, Mar 27, 2017 at 09:59:35AM -0700, David Daney wrote:
> On 03/27/2017 01:29 AM, Christoph Hellwig wrote:
>> Unused now that all callers switched to pci_alloc_irq_vectors.
>>
>
> And you are aware that the ThunderX GPIO driver that I am attempting to
> merge uses this interface.
>
> If this patch gets merged, should I ask to revert it when the GPIO driver
> goes in?
No. You should not use pci_enable_msix in your new driver as I told
you before.
> You offer no solution for drivers that would benefit from using a sparse
> sub set of the available MSI-X vectors.
Use pci_enable_msix_{exact,range} for now, as I told you before.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors
2017-03-27 16:03 ` Sunil Kovvuri
@ 2017-03-27 17:12 ` Christoph Hellwig
0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-27 17:12 UTC (permalink / raw)
To: Sunil Kovvuri
Cc: Christoph Hellwig, Bjorn Helgaas, David S. Miller, netanel,
jcliburn, chris.snook, Sunil Goutham, Robert Richter,
Linux Netdev List, linux-pci
On Mon, Mar 27, 2017 at 09:33:32PM +0530, Sunil Kovvuri wrote:
> How urgent is this ?
I would like to get this into 4.12 to stop people from adding new users of
pci_enable_msix.
> Can we comeup with a proper patch to fix this in couple of weeks, instead of
> going with these untested patches ?
Sure.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 17:11 ` Christoph Hellwig
@ 2017-03-27 17:30 ` David Daney
2017-03-28 6:41 ` Christoph Hellwig
2017-03-28 9:07 ` David Laight
0 siblings, 2 replies; 21+ messages in thread
From: David Daney @ 2017-03-27 17:30 UTC (permalink / raw)
To: Christoph Hellwig
Cc: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
On 03/27/2017 10:11 AM, Christoph Hellwig wrote:
> On Mon, Mar 27, 2017 at 09:59:35AM -0700, David Daney wrote:
>> On 03/27/2017 01:29 AM, Christoph Hellwig wrote:
>>> Unused now that all callers switched to pci_alloc_irq_vectors.
>>>
>>
>> And you are aware that the ThunderX GPIO driver that I am attempting to
>> merge uses this interface.
>>
>> If this patch gets merged, should I ask to revert it when the GPIO driver
>> goes in?
>
> No. You should not use pci_enable_msix in your new driver as I told
> you before.
>
>> You offer no solution for drivers that would benefit from using a sparse
>> sub set of the available MSI-X vectors.
>
> Use pci_enable_msix_{exact,range} for now, as I told you before.
>
That still results in twice as many MSI-X being provisioned than are needed.
For drivers that use a contiguous range of MSI-X, your suggestion is
usable, but for others you are forcing resources to be wasted. For what
end?
David Daney
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 17:30 ` David Daney
@ 2017-03-28 6:41 ` Christoph Hellwig
2017-03-28 16:24 ` David Daney
2017-03-28 9:07 ` David Laight
1 sibling, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2017-03-28 6:41 UTC (permalink / raw)
To: David Daney
Cc: Christoph Hellwig, bhelgaas, davem, netanel, jcliburn,
chris.snook, sgoutham, rric, netdev, linux-pci
On Mon, Mar 27, 2017 at 10:30:46AM -0700, David Daney wrote:
>> Use pci_enable_msix_{exact,range} for now, as I told you before.
>>
>
> That still results in twice as many MSI-X being provisioned than are needed.
How so? Except for the return value, a pci_enable_msix_exact call with the
same arguments as your previous pci_enable_msix will work exactly the
same.
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 17:30 ` David Daney
2017-03-28 6:41 ` Christoph Hellwig
@ 2017-03-28 9:07 ` David Laight
1 sibling, 0 replies; 21+ messages in thread
From: David Laight @ 2017-03-28 9:07 UTC (permalink / raw)
To: 'David Daney', Christoph Hellwig
Cc: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
From: David Daney
> Sent: 27 March 2017 18:31
> On 03/27/2017 10:11 AM, Christoph Hellwig wrote:
> > On Mon, Mar 27, 2017 at 09:59:35AM -0700, David Daney wrote:
> >> On 03/27/2017 01:29 AM, Christoph Hellwig wrote:
> >>> Unused now that all callers switched to pci_alloc_irq_vectors.
> >>>
> >>
> >> And you are aware that the ThunderX GPIO driver that I am attempting to
> >> merge uses this interface.
> >>
> >> If this patch gets merged, should I ask to revert it when the GPIO driver
> >> goes in?
> >
> > No. You should not use pci_enable_msix in your new driver as I told
> > you before.
> >
> >> You offer no solution for drivers that would benefit from using a sparse
> >> sub set of the available MSI-X vectors.
> >
> > Use pci_enable_msix_{exact,range} for now, as I told you before.
> >
>
> That still results in twice as many MSI-X being provisioned than are needed.
>
> For drivers that use a contiguous range of MSI-X, your suggestion is
> usable, but for others you are forcing resources to be wasted. For what
> end?
There are also drivers that only need some interrupts after a specific
device is opened, and could free them when closed.
This could even be network devices with lots of queues, or a driver
realising that the workload is high and per-cpu interrupts make sense.
So any real change to the interface should allow drivers to allocate
and free individual MSI-X vectors.
I remember a lot of discussions when pci_enable_msix_range() was added,
but almost nothing about this change.
David
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-28 6:41 ` Christoph Hellwig
@ 2017-03-28 16:24 ` David Daney
2017-03-30 22:56 ` Bjorn Helgaas
0 siblings, 1 reply; 21+ messages in thread
From: David Daney @ 2017-03-28 16:24 UTC (permalink / raw)
To: Christoph Hellwig
Cc: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
On 03/27/2017 11:41 PM, Christoph Hellwig wrote:
> On Mon, Mar 27, 2017 at 10:30:46AM -0700, David Daney wrote:
>>> Use pci_enable_msix_{exact,range} for now, as I told you before.
>>>
>>
>> That still results in twice as many MSI-X being provisioned than are needed.
>
> How so? Except for the return value, a pci_enable_msix_exact call with the
> same arguments as your previous pci_enable_msix will work exactly the
> same.
>
Sorry, I think it was my misunderstanding. I didn't realize that we had
essentially renamed the function, but left the functionality mostly
unchanged.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-28 16:24 ` David Daney
@ 2017-03-30 22:56 ` Bjorn Helgaas
2017-03-30 23:00 ` David Daney
0 siblings, 1 reply; 21+ messages in thread
From: Bjorn Helgaas @ 2017-03-30 22:56 UTC (permalink / raw)
To: David Daney
Cc: Christoph Hellwig, bhelgaas, davem, netanel, jcliburn,
chris.snook, sgoutham, rric, netdev, linux-pci
On Tue, Mar 28, 2017 at 09:24:15AM -0700, David Daney wrote:
> On 03/27/2017 11:41 PM, Christoph Hellwig wrote:
> >On Mon, Mar 27, 2017 at 10:30:46AM -0700, David Daney wrote:
> >>>Use pci_enable_msix_{exact,range} for now, as I told you before.
> >>>
> >>
> >>That still results in twice as many MSI-X being provisioned than are needed.
> >
> >How so? Except for the return value, a pci_enable_msix_exact call with the
> >same arguments as your previous pci_enable_msix will work exactly the
> >same.
> >
>
> Sorry, I think it was my misunderstanding. I didn't realize that we
> had essentially renamed the function, but left the functionality
> mostly unchanged.
Does this mean you're OK with this patch? I know it may require some
work on out-of-tree drivers and so on, but if that work is possible
and you don't actually lose functionality, I'm OK with this patch.
Bjorn
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-30 22:56 ` Bjorn Helgaas
@ 2017-03-30 23:00 ` David Daney
0 siblings, 0 replies; 21+ messages in thread
From: David Daney @ 2017-03-30 23:00 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Christoph Hellwig, bhelgaas, davem, netanel, jcliburn,
chris.snook, sgoutham, rric, netdev, linux-pci
On 03/30/2017 03:56 PM, Bjorn Helgaas wrote:
> On Tue, Mar 28, 2017 at 09:24:15AM -0700, David Daney wrote:
>> On 03/27/2017 11:41 PM, Christoph Hellwig wrote:
>>> On Mon, Mar 27, 2017 at 10:30:46AM -0700, David Daney wrote:
>>>>> Use pci_enable_msix_{exact,range} for now, as I told you before.
>>>>>
>>>>
>>>> That still results in twice as many MSI-X being provisioned than are needed.
>>>
>>> How so? Except for the return value, a pci_enable_msix_exact call with the
>>> same arguments as your previous pci_enable_msix will work exactly the
>>> same.
>>>
>>
>> Sorry, I think it was my misunderstanding. I didn't realize that we
>> had essentially renamed the function, but left the functionality
>> mostly unchanged.
>
> Does this mean you're OK with this patch?
Yes. I have re-written my GPIO driver to use the newer functions, so I
withdraw my objections to the patch.
Thanks,
David Daney
> I know it may require some
> work on out-of-tree drivers and so on, but if that work is possible
> and you don't actually lose functionality, I'm OK with this patch.
>
> Bjorn
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] PCI: remove pci_enable_msix
2017-03-27 8:29 ` [PATCH 5/5] PCI: remove pci_enable_msix Christoph Hellwig
2017-03-27 14:06 ` David Laight
2017-03-27 16:59 ` David Daney
@ 2017-03-30 23:09 ` Bjorn Helgaas
2 siblings, 0 replies; 21+ messages in thread
From: Bjorn Helgaas @ 2017-03-30 23:09 UTC (permalink / raw)
To: Christoph Hellwig
Cc: bhelgaas, davem, netanel, jcliburn, chris.snook, sgoutham, rric,
netdev, linux-pci
On Mon, Mar 27, 2017 at 10:29:36AM +0200, Christoph Hellwig wrote:
> Unused now that all callers switched to pci_alloc_irq_vectors.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
I assume this will be merged with the rest via the netdev tree.
> ---
> drivers/pci/msi.c | 21 ---------------------
> include/linux/pci.h | 4 ----
> 2 files changed, 25 deletions(-)
>
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index d571bc330686..0042c365b29b 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -973,27 +973,6 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
> return msix_capability_init(dev, entries, nvec, affd);
> }
>
> -/**
> - * pci_enable_msix - configure device's MSI-X capability structure
> - * @dev: pointer to the pci_dev data structure of MSI-X device function
> - * @entries: pointer to an array of MSI-X entries (optional)
> - * @nvec: number of MSI-X irqs requested for allocation by device driver
> - *
> - * Setup the MSI-X capability structure of device function with the number
> - * of requested irqs upon its software driver call to request for
> - * MSI-X mode enabled on its hardware device function. A return of zero
> - * indicates the successful configuration of MSI-X capability structure
> - * with new allocated MSI-X irqs. A return of < 0 indicates a failure.
> - * Or a return of > 0 indicates that driver request is exceeding the number
> - * of irqs or MSI-X vectors available. Driver should use the returned value to
> - * re-send its request.
> - **/
> -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
> -{
> - return __pci_enable_msix(dev, entries, nvec, NULL);
> -}
> -EXPORT_SYMBOL(pci_enable_msix);
> -
> void pci_msix_shutdown(struct pci_dev *dev)
> {
> struct msi_desc *entry;
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index eb3da1a04e6c..82dec36845e6 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1300,7 +1300,6 @@ int pci_msi_vec_count(struct pci_dev *dev);
> void pci_msi_shutdown(struct pci_dev *dev);
> void pci_disable_msi(struct pci_dev *dev);
> int pci_msix_vec_count(struct pci_dev *dev);
> -int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
> 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);
> @@ -1330,9 +1329,6 @@ static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
> static inline void pci_msi_shutdown(struct pci_dev *dev) { }
> static inline void pci_disable_msi(struct pci_dev *dev) { }
> static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
> -static inline int pci_enable_msix(struct pci_dev *dev,
> - struct msix_entry *entries, int nvec)
> -{ return -ENOSYS; }
> 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) { }
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2017-03-30 23:09 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 8:29 remove pci_enable_msix() Christoph Hellwig
2017-03-27 8:29 ` [PATCH 1/5] net: thunderx: switch to pci_alloc_irq_vectors Christoph Hellwig
2017-03-27 16:03 ` Sunil Kovvuri
2017-03-27 17:12 ` Christoph Hellwig
2017-03-27 8:29 ` [PATCH 2/5] net: thunderxvf: " Christoph Hellwig
2017-03-27 8:29 ` [PATCH 3/5] net: alx: " Christoph Hellwig
2017-03-27 8:29 ` [PATCH 4/5] net/ena: " Christoph Hellwig
2017-03-27 8:29 ` [PATCH 5/5] PCI: remove pci_enable_msix Christoph Hellwig
2017-03-27 14:06 ` David Laight
2017-03-27 14:51 ` 'Christoph Hellwig'
2017-03-27 15:03 ` David Laight
2017-03-27 17:10 ` 'Christoph Hellwig'
2017-03-27 16:59 ` David Daney
2017-03-27 17:11 ` Christoph Hellwig
2017-03-27 17:30 ` David Daney
2017-03-28 6:41 ` Christoph Hellwig
2017-03-28 16:24 ` David Daney
2017-03-30 22:56 ` Bjorn Helgaas
2017-03-30 23:00 ` David Daney
2017-03-28 9:07 ` David Laight
2017-03-30 23:09 ` Bjorn Helgaas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.