Browse code

linux kernel: Fix IRQ issues with NVMe on Azure

NVME driver allocates admin and IO vector using pci_alloc_irq_vectors().
In v4.9, if IO vector allocated using PCI_IRQ_AFFINITY,
then assignment of IO vector in vector_irq mismatches with actual assignment.
Due to which some IO INT fails to handle.

If IO vector allocated without using PCI_IRQ_AFFINITY,
then all IO INT scheduled on CPU 0 and no IO INT fails.

This problem only observed with Azure HyperV NVME,
so skipping PCI_IRQ_AFFINITY only in this case.

Change-Id: I9d511c8fb323345179643d9b3c4b2ca2c1bb00a4
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/6464
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Srivatsa S. Bhat <srivatsab@vmware.com>

Ajay Kaher authored on 2019/01/09 05:30:37
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,47 @@
0
+NVME driver allocates admin and IO vector using pci_alloc_irq_vectors(). 
1
+
2
+In v4.9, if IO vector allocated using PCI_IRQ_AFFINITY, 
3
+then assignment of IO vector in vector_irq mismatches with actual assignment. 
4
+Due to which some IO INT fails to handle.
5
+
6
+If IO vector allocated without using PCI_IRQ_AFFINITY, 
7
+then all IO INT scheduled on CPU 0 and no IO INT fails.
8
+
9
+This problem only observed with Azure HyperV NVME,
10
+so skipping PCI_IRQ_AFFINITY only in this case.
11
+
12
+diff -Nurp linux-4.9.140_modified/drivers/nvme/host/pci.c linux-4.9.140/drivers/nvme/host/pci.c
13
+--- linux-4.9.140_modified/drivers/nvme/host/pci.c	2018-11-23 17:27:41.000000000 +0530
14
+@@ -1450,8 +1450,18 @@ static int nvme_setup_io_queues(struct n
15
+ 	 * setting up the full range we need.
16
+ 	 */
17
+ 	pci_free_irq_vectors(pdev);
18
+-	nr_io_queues = pci_alloc_irq_vectors(pdev, 1, nr_io_queues,
19
+-			PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY);
20
++
21
++	if (pdev->vendor == PCI_VENDOR_ID_MICROSOFT &&
22
++			pdev->device == PCI_DEVICE_ID_MICROSOFT_NVME) {
23
++		nr_io_queues = pci_alloc_irq_vectors(pdev, 1, nr_io_queues,
24
++				PCI_IRQ_ALL_TYPES);
25
++		dev_warn(dev->ctrl.device, "detected MicroSoft NVMe controller, "
26
++			"skipping PCI_IRQ_AFFINITY from pci_alloc_irq_vectors\n");
27
++	} else {
28
++		nr_io_queues = pci_alloc_irq_vectors(pdev, 1, nr_io_queues,
29
++				PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY);
30
++	}
31
++
32
+ 	if (nr_io_queues <= 0)
33
+ 		return -EIO;
34
+ 	dev->max_qid = nr_io_queues;
35
+diff -Nurp linux-4.9.140_modified/include/linux/pci_ids.h linux-4.9.140/include/linux/pci_ids.h
36
+--- linux-4.9.140_modified/include/linux/pci_ids.h	2018-11-23 17:27:41.000000000 +0530
37
+@@ -3056,4 +3056,7 @@
38
+ 
39
+ #define PCI_VENDOR_ID_NCUBE		0x10ff
40
+ 
41
++#define PCI_VENDOR_ID_MICROSOFT		0x1414
42
++#define PCI_DEVICE_ID_MICROSOFT_NVME		0xb111
43
++
44
+ #endif /* _LINUX_PCI_IDS_H */
... ...
@@ -2,7 +2,7 @@
2 2
 Summary:        Kernel
3 3
 Name:           linux
4 4
 Version:        4.9.140
5
-Release:        4%{?kat_build:.%kat_build}%{?dist}
5
+Release:        5%{?kat_build:.%kat_build}%{?dist}
6 6
 License:    	GPLv2
7 7
 URL:        	http://www.kernel.org/
8 8
 Group:        	System Environment/Kernel
... ...
@@ -76,6 +76,9 @@ Patch51:        0001_PCI_hv_Allocate_physically_contiguous_hypercall_params_buff
76 76
 Patch52:        0002_PCI_hv_Add_vPCI_version_protocol_negotiation.patch
77 77
 Patch53:        0003_PCI_hv_Use_vPCI_protocol_version_1.2_v4.9.patch
78 78
 
79
+# NVME PCI patch
80
+Patch61:        0001_nvme_io_irq_without_affinity.patch
81
+
79 82
 # Out-of-tree patches from AppArmor:
80 83
 Patch71: 0001-UBUNTU-SAUCE-AppArmor-basic-networking-rules.patch
81 84
 Patch72: 0002-apparmor-Fix-quieting-of-audit-messages-for-network-.patch
... ...
@@ -198,6 +201,7 @@ This package contains the 'perf' performance analysis tools for Linux kernel.
198 198
 %patch51 -p1
199 199
 %patch52 -p1
200 200
 %patch53 -p1
201
+%patch61 -p1
201 202
 
202 203
 %patch71 -p1
203 204
 %patch72 -p1
... ...
@@ -372,6 +376,8 @@ ln -sf %{name}-%{uname_r}.cfg /boot/photon.cfg
372 372
 /usr/share/doc/*
373 373
 
374 374
 %changelog
375
+*   Thu Jan 17 2019 Ajay Kaher <akaher@vmware.com> 4.9.140-5
376
+-   Fix IRQ issues with NVMe on Azure.
375 377
 *   Tue Jan 15 2019 Alexey Makhalov <amakhalov@vmware.com> 4.9.140-4
376 378
 -   .config: disable CONFIG_FANOTIFY_ACCESS_PERMISSIONS
377 379
 *   Thu Dec 20 2018 Alexey Makhalov <amakhalov@vmware.com> 4.9.140-3