scsi: fnic: Fix missed link-up when a critical IRQ targets an offline CPU
Subsystems (2)
PATCH 1/1 scsi: fnic: Fix missed link-up when a critical IRQ targets an offline CPU
When CPU Hyper-Threading is disabled, sibling CPUs remain present but are reported offline. Managed MSI-X IRQs can still receive affinity masks that include those offline CPUs. If a driver-critical vector is managed, it can be parked on an offline CPU and the driver may miss critical events such as link-up.
Keep driver-critical vectors unmanaged so they can be migrated by the IRQ core when their target CPU is offlined.
Since HWQ-0 is unmanaged now, in some queue combinations there can be no mappings to it in mq_map. So without the blk-mq fix mentioned below, system may crash during cpu offline/online tests.
Depends-on: commit 10845a105bbc ("blk-mq: skip CPU offline notify on unmapped hctx")
--- drivers/scsi/fnic/fnic.h | 2 +- drivers/scsi/fnic/fnic_isr.c | 13 ++++++++--- drivers/scsi/fnic/fnic_main.c | 41 ++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 5 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
@@ -31,7 +31,7 @@#define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver" -#define DRV_VERSION "1.9.0.0" +#define DRV_VERSION "1.9.0.1"#define PFX DRV_NAME ": "#define DFX DRV_NAME "%d: "
drivers/scsi/fnic/fnic_isr.c +10 -3
@@ -245,7 +245,14 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)unsigned int m =ARRAY_SIZE (fnic->wq);unsigned int o =ARRAY_SIZE (fnic->hw_copy_wq);unsigned int min_irqs = n + m +1 +1 ;/*rq, raw wq, wq, err*/ - +/* +* Make driver critical vectors unmanaged, or else it can get tied +* to an offline CPU. This can happen when hyper-threading is off. +*/ +struct irq_affinity affd = { + .pre_vectors = n + m +1 ,/* rq, raw wq, 1 ioq */ + .post_vectors =1 ,/* err */ + };/* * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs * (last INTR is used for WQ/RQ errors and notification area)
@@ -263,8 +270,8 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)int vec_count =0 ;int vecs = fnic->rq_count + fnic->raw_wq_count + fnic->wq_copy_count +1 ; - vec_count =pci_alloc_irq_vectors (fnic->pdev, min_irqs, vecs, -PCI_IRQ_MSIX |PCI_IRQ_AFFINITY ); + vec_count =pci_alloc_irq_vectors_affinity (fnic->pdev, min_irqs, + vecs,PCI_IRQ_MSIX |PCI_IRQ_AFFINITY , &affd);FNIC_ISR_DBG (KERN_INFO , fnic,"allocated %d MSI-X vectors\n" , vec_count);
drivers/scsi/fnic/fnic_main.c +40 -1
55 lines not on this page · raw message
Signature · 1 line
2.55.0
Quoted 153 lines · Arun Easi
When CPU Hyper-Threading is disabled, sibling CPUs remain present but are reported offline. Managed MSI-X IRQs can still receive affinity masks that include those offline CPUs. If a driver-critical vector is managed, it can be parked on an offline CPU and the driver may miss critical events such as link-up.
Keep driver-critical vectors unmanaged so they can be migrated by the IRQ core when their target CPU is offlined.
Since HWQ-0 is unmanaged now, in some queue combinations there can be no
mappings to it inmq_map. So without the blk-mq fix mentioned below, system may crash during cpu offline/online tests.Fixes 8a8449ca5e33 ("scsi: fnic: Modify ISRs to support multiqueue(MQ)")
Cc: [email protected]
Depends-on: commit10845a105bbc("blk-mq: skip CPU offline notify on unmapped hctx")Reviewed-by Sesidhar Baddela <[email protected]>Reviewed-by Arulprabhu Ponnusamy <[email protected]>Reviewed-by Gian Carlo Boffa <[email protected]>Reviewed-by Karan Tilak Kumar <[email protected]>Signed-off-by Arun Easi <[email protected]>---
drivers/scsi/fnic/fnic.h | 2 +-
drivers/scsi/fnic/fnic_isr.c | 13 ++++++++---
drivers/scsi/fnic/fnic_main.c | 41
++++++++++++++++++++++++++++++++++-3 files changed, 51 insertions(+), 5 deletions(-)drivers/scsi/fnic/fnic.h +0
-0@@ -31,7 +31,7 @@
#defineDRV_NAME"fnic"
#defineDRV_DESCRIPTION"Cisco FCoE HBA Driver"drivers/scsi/fnic/fnic.h +1
-1-#define DRV_VERSION "1.9.0.0" +#define DRV_VERSION "1.9.0.1"#define PFX
DRV_NAME": "
#define DFXDRV_NAME"%d: "drivers/scsi/fnic/fnic_isr.c +0
-0@@ -245,7 +245,14 @@ int fnic_set_intr_mode_msix(struct fnic *fnic) unsigned int m = ARRAY_SIZE(fnic->wq); unsigned int o = ARRAY_SIZE(fnic->hw_copy_wq); unsigned int min_irqs = n + m + 1 + 1; /*rq, raw wq, wq,err*/
drivers/scsi/fnic/fnic_isr.c +2
-1- +/* +* Make driver critical vectors unmanaged, or else it can get tied
drivers/scsi/fnic/fnic_isr.c +1
-0+* to an offline CPU. This can happen when hyper-threading is off.
drivers/scsi/fnic/fnic_isr.c +5
-0+*/ +struct irq_affinity affd = { + .pre_vectors = n + m +1 ,/* rq, raw wq, 1 ioq */ + .post_vectors =1 ,/* err */ + };/*
* We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs
* (last INTR is used for WQ/RQ errors and notification area)drivers/scsi/fnic/fnic_isr.c +0
-0@@ -263,8 +270,8 @@ int fnic_set_intr_mode_msix(struct fnic *fnic) int vec_count = 0;int vecs =
fnic->rq_count+fnic->raw_wq_count+fnic->wq_copy_count+ 1;drivers/scsi/fnic/fnic_isr.c +0
-1- vec_count = pci_alloc_irq_vectors(fnic->pdev,
min_irqs, vecs,drivers/scsi/fnic/fnic_isr.c +0
-1- PCI_IRQ_MSIX |
PCI_IRQ_AFFINITY);drivers/scsi/fnic/fnic_isr.c +1
-0+ vec_count = pci_alloc_irq_vectors_affinity(fnic-Quoted 1 line
pdev,
min_irqs,drivers/scsi/fnic/fnic_isr.c +1
-0+ vecs, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY,&affd);
FNIC_ISR_DBG(KERN_INFO, fnic, "allocated %d MSI-X vectors\n",
vec_count);drivers/scsi/fnic/fnic_main.c +0
-0@@ -744,8 +744,19 @@ static int fnic_nvme_drv_init(struct fnic *fnic) return ret; }drivers/scsi/fnic/fnic_main.c +9
-0+static void fnic_mq_init_queue_map (struct fnic *fnic, +struct blk_mq_queue_map *qmap) +{ +unsigned int cpu; + +for_each_possible_cpu (cpu) + qmap->mq_map[cpu] =0 ; +} +void
fnic_mq_map_queues_cpus(struct Scsi_Host *host){drivers/scsi/fnic/fnic_main.c +2
-0+const struct cpumask *mask; +unsigned int queue, cpu;struct fnic *fnic = *((struct fnic **)
shost_priv(host)); structpci_dev*l_pdev=fnic->pdev;
intintr_mode=fnic->config.intr_mode;drivers/scsi/fnic/fnic_main.c +0
-0@@ -766,7 +777,35 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host) return; }drivers/scsi/fnic/fnic_main.c +5
-1-blk_mq_map_hw_queues (qmap, &l_pdev->dev,FNIC_PCI_OFFSET ); +fnic_mq_init_queue_map (fnic, qmap); + +/* +* Setup CPU to Queue mapping for all managed MSI-X IRQs. +* Q0 is driver critical and non-managed, hence start from Q1.
drivers/scsi/fnic/fnic_main.c +4
-0+*/ +for (queue =1 ; queue < qmap->nr_queues; queue++) { + int irq_num = pci_irq_vector(fnic->pdev, + queue +
FNIC_PCI_OFFSET);drivers/scsi/fnic/fnic_main.c +6
-0+ +if (irq_num <0 ) +continue ; + + mask = pci_irq_get_affinity(fnic->pdev, + queue +
FNIC_PCI_OFFSET);drivers/scsi/fnic/fnic_main.c +3
-0+if (!mask) { + shost_printk(KERN_ERR, host, + "failed to get irq_affinity map forqueue:%d\n",
irq_num);drivers/scsi/fnic/fnic_main.c +4
-0+continue ; + } + FNIC_MAIN_DBG(KERN_INFO, fnic, + "got irq_affinity map for %d:\n",
irq_num);drivers/scsi/fnic/fnic_main.c +2
-0+for_each_cpu (cpu, mask) { + qmap->mq_map[cpu] = qmap->queue_offset +queue;
drivers/scsi/fnic/fnic_main.c +5
-0+FNIC_MAIN_DBG (KERN_INFO , fnic, + "[Q%d] cpu:%d <=> irq:%d\n", + queue, cpu, irq_num); + } + }
Quoted 4 lines
}
static intfnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
This hit an actual customer who had the hyper CPUS showing but offline.
Patch looks OK to me, I understand how it prevents the original issue.
Thanks
Laurence
Quoted 10 lines · Arun Easi
When CPU Hyper-Threading is disabled, sibling CPUs remain present but are reported offline. Managed MSI-X IRQs can still receive affinity masks that include those offline CPUs. If a driver-critical vector is managed, it can be parked on an offline CPU and the driver may miss critical events such as link-up.
Keep driver-critical vectors unmanaged so they can be migrated by the IRQ core when their target CPU is offlined.
[...]
Applied to 7.3/scsi-fixes, thanks!
[1/1] scsi: fnic: Fix missed link-up when a critical IRQ targets an offline CPU
https://git.kernel.org/mkp/scsi/c/0cb1fd924126
Signature · 1 line
Martin K. Petersen