Skip to content

Commit 17a51f1

Browse files
Christoph Hellwightejun
authored andcommitted
ahci: only try to use multi-MSI mode if there is more than 1 port
We should only try to allocate multiple MSI or MSI-X vectors if the device actually has multiple ports. Otherwise pci_alloc_irq_vectors will return a single vector due to n_ports = 1, in which case we shouldn't set the AHCI_HFLAG_MULTI_MSI flag. Signed-off-by: Christoph Hellwig <hch@lst.de> Fixes: 0b9e298 ("ahci: use pci_alloc_irq_vectors") Reported-by: Emmanuel Benisty <benisty.e@gmail.com> Tested-by: Emmanuel Benisty <benisty.e@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 1001354 commit 17a51f1

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

drivers/ata/ahci.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,21 +1418,24 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
14181418
* Message mode could be enforced. In this case assume that advantage
14191419
* of multipe MSIs is negated and use single MSI mode instead.
14201420
*/
1421-
nvec = pci_alloc_irq_vectors(pdev, n_ports, INT_MAX,
1422-
PCI_IRQ_MSIX | PCI_IRQ_MSI);
1423-
if (nvec > 0) {
1424-
if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) {
1425-
hpriv->get_irq_vector = ahci_get_irq_vector;
1426-
hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
1427-
return nvec;
1428-
}
1421+
if (n_ports > 1) {
1422+
nvec = pci_alloc_irq_vectors(pdev, n_ports, INT_MAX,
1423+
PCI_IRQ_MSIX | PCI_IRQ_MSI);
1424+
if (nvec > 0) {
1425+
if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) {
1426+
hpriv->get_irq_vector = ahci_get_irq_vector;
1427+
hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
1428+
return nvec;
1429+
}
14291430

1430-
/*
1431-
* Fallback to single MSI mode if the controller enforced MRSM
1432-
* mode.
1433-
*/
1434-
printk(KERN_INFO "ahci: MRSM is on, fallback to single MSI\n");
1435-
pci_free_irq_vectors(pdev);
1431+
/*
1432+
* Fallback to single MSI mode if the controller
1433+
* enforced MRSM mode.
1434+
*/
1435+
printk(KERN_INFO
1436+
"ahci: MRSM is on, fallback to single MSI\n");
1437+
pci_free_irq_vectors(pdev);
1438+
}
14361439
}
14371440

14381441
/*

0 commit comments

Comments
 (0)