Skip to content

Commit a09bd81

Browse files
caildavem330
authored andcommitted
net: aquantia: Limit number of vectors to actually allocated irqs
Driver should use pci_alloc_irq_vectors return value to correct number of allocated vectors and napi instances. Otherwise it'll panic later in pci_irq_vector. Driver also should allow more than one MSI vectors to be allocated. Error return path from pci_alloc_irq_vectors is also fixed to revert resources in a correct sequence when error happens. Reported-by: Long, Nicholas <[email protected]> Fixes: 23ee07a ("net: aquantia: Cleanup pci functions module") Signed-off-by: Igor Russkikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8c61ab7 commit a09bd81

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_nic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ void aq_nic_cfg_start(struct aq_nic_s *self)
9595
/*rss rings */
9696
cfg->vecs = min(cfg->aq_hw_caps->vecs, AQ_CFG_VECS_DEF);
9797
cfg->vecs = min(cfg->vecs, num_online_cpus());
98+
cfg->vecs = min(cfg->vecs, self->irqvecs);
9899
/* cfg->vecs should be power of 2 for RSS */
99100
if (cfg->vecs >= 8U)
100101
cfg->vecs = 8U;

drivers/net/ethernet/aquantia/atlantic/aq_nic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct aq_nic_s {
8080

8181
struct pci_dev *pdev;
8282
unsigned int msix_entry_mask;
83+
u32 irqvecs;
8384
};
8485

8586
static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)

drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,16 @@ static int aq_pci_probe(struct pci_dev *pdev,
267267
numvecs = min(numvecs, num_online_cpus());
268268
/*enable interrupts */
269269
#if !AQ_CFG_FORCE_LEGACY_INT
270-
err = pci_alloc_irq_vectors(self->pdev, numvecs, numvecs,
271-
PCI_IRQ_MSIX);
272-
273-
if (err < 0) {
274-
err = pci_alloc_irq_vectors(self->pdev, 1, 1,
275-
PCI_IRQ_MSI | PCI_IRQ_LEGACY);
276-
if (err < 0)
277-
goto err_hwinit;
270+
numvecs = pci_alloc_irq_vectors(self->pdev, 1, numvecs,
271+
PCI_IRQ_MSIX | PCI_IRQ_MSI |
272+
PCI_IRQ_LEGACY);
273+
274+
if (numvecs < 0) {
275+
err = numvecs;
276+
goto err_hwinit;
278277
}
279278
#endif
279+
self->irqvecs = numvecs;
280280

281281
/* net device init */
282282
aq_nic_cfg_start(self);
@@ -298,9 +298,9 @@ static int aq_pci_probe(struct pci_dev *pdev,
298298
kfree(self->aq_hw);
299299
err_ioremap:
300300
free_netdev(ndev);
301-
err_pci_func:
302-
pci_release_regions(pdev);
303301
err_ndev:
302+
pci_release_regions(pdev);
303+
err_pci_func:
304304
pci_disable_device(pdev);
305305
return err;
306306
}

0 commit comments

Comments
 (0)