Bug 187821

Summary: MSI is no longer enabled for many/most Intel SATA controllers in 4.9
Product: IO/Storage Reporter: Michael Marley (michael)
Component: Serial ATAAssignee: Tejun Heo (tj)
Severity: normal CC: hch, michael, tj
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.9.0-rc5 Subsystem:
Regression: No Bisected commit-id:

Description Michael Marley 2016-11-16 05:13:42 UTC
After installing kernel 4.9.0-rc5 x86_64 on a few different computers, it seems that Message-Signaled Interrupts are no longer being enabled for (at least) the AHCI controllers in Intel chipsets.  With 4.8, MSI was enabled as it should be.  With 4.9, legacy interrupts are used for the AHCI controllers in an Ivybridge laptop, a Broadwell NUC, a Skylake NUC, and a Skylake desktop.

If I revert commit https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/ata/ahci.c?h=v4.9-rc5&id=0b9e2988ab2261fd6d4a0039edf81ed1e3662be8 (along with https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/ata/ahci.c?h=v4.9-rc5&id=17a51f12cfbd2814fd35966a069b242569c53e27, https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/ata/ahci.c?h=v4.9-rc5&id=a478b097474cd9f2268ab1beaca74ff09e652b9b, and https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/ata/ahci.c?h=v4.9-rc5&id=0ce57f8af1782fd12d3a81872a4ab97244989802, which depend on it), the AHCI driver uses MSI interrupts correctly again.
Comment 1 Tejun Heo 2016-11-17 17:06:19 UTC
Christoph, can you please take a look at this? Thanks!
Comment 2 Christoph Hellwig 2016-11-17 21:03:24 UTC
On Thu, Nov 17, 2016 at 05:06:19PM +0000, bugzilla-daemon@bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=187821
> --- Comment #1 from Tejun Heo <tj@kernel.org> ---
> Christoph, can you please take a look at this? Thanks!

The only sensible explanation would be that the multi-vector
pci_alloc_irq_vectors returns something else than -ENOSPC.
Please try the patch below, which I think would make sense anyway
as robustness masure:

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 9669fc7..74f4c66 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1436,13 +1436,6 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
 				"ahci: MRSM is on, fallback to single MSI\n");
-		/*
-		 * -ENOSPC indicated we don't have enough vectors.  Don't bother
-		 * trying a single vectors for any other error:
-		 */
-		if (nvec < 0 && nvec != -ENOSPC)
-			return nvec;
Comment 3 Michael Marley 2016-11-17 23:01:21 UTC
I applied the patch and I can confirm that it causes the AHCI driver to use MSI correctly.  Thanks!
Comment 4 Michael Marley 2019-11-14 18:12:44 UTC
This was fixed at some point before the final 4.9 release.