* [PATCH] ahci: only try to use multi-MSI mode if there is more than 1 port
@ 2016-10-18 7:00 Christoph Hellwig
2016-10-19 17:19 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2016-10-18 7:00 UTC (permalink / raw)
To: tj; +Cc: benisty.e, linux-ide
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: 0b9e2988 ("ahci: use pci_alloc_irq_vectors")
Reported-by: Emmanuel Benisty <benisty.e@gmail.com>
Tested-by: Emmanuel Benisty <benisty.e@gmail.com>
---
drivers/ata/ahci.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index ba5f11c..ed311a0 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1418,21 +1418,24 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
* Message mode could be enforced. In this case assume that advantage
* of multipe MSIs is negated and use single MSI mode instead.
*/
- nvec = pci_alloc_irq_vectors(pdev, n_ports, INT_MAX,
- PCI_IRQ_MSIX | PCI_IRQ_MSI);
- if (nvec > 0) {
- if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) {
- hpriv->get_irq_vector = ahci_get_irq_vector;
- hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
- return nvec;
- }
+ if (n_ports > 1) {
+ nvec = pci_alloc_irq_vectors(pdev, n_ports, INT_MAX,
+ PCI_IRQ_MSIX | PCI_IRQ_MSI);
+ if (nvec > 0) {
+ if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) {
+ hpriv->get_irq_vector = ahci_get_irq_vector;
+ hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
+ return nvec;
+ }
- /*
- * Fallback to single MSI mode if the controller enforced MRSM
- * mode.
- */
- printk(KERN_INFO "ahci: MRSM is on, fallback to single MSI\n");
- pci_free_irq_vectors(pdev);
+ /*
+ * Fallback to single MSI mode if the controller
+ * enforced MRSM mode.
+ */
+ printk(KERN_INFO
+ "ahci: MRSM is on, fallback to single MSI\n");
+ pci_free_irq_vectors(pdev);
+ }
}
/*
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ahci: only try to use multi-MSI mode if there is more than 1 port
2016-10-18 7:00 [PATCH] ahci: only try to use multi-MSI mode if there is more than 1 port Christoph Hellwig
@ 2016-10-19 17:19 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2016-10-19 17:19 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: benisty.e, linux-ide
On Tue, Oct 18, 2016 at 09:00:52AM +0200, Christoph Hellwig wrote:
> 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: 0b9e2988 ("ahci: use pci_alloc_irq_vectors")
> Reported-by: Emmanuel Benisty <benisty.e@gmail.com>
> Tested-by: Emmanuel Benisty <benisty.e@gmail.com>
Applied to libata/for-4.9-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-19 17:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-18 7:00 [PATCH] ahci: only try to use multi-MSI mode if there is more than 1 port Christoph Hellwig
2016-10-19 17:19 ` Tejun Heo
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).