Skip to content

Commit 17105d9

Browse files
Dick Kennedymartinkpetersen
authored andcommitted
scsi: lpfc: Fix interrupt assignments when multiple vectors are supported on same CPU
With certain platforms its possible pci_alloc_irq_vectors() may affinitize irq vectors to multiple (all?) CPUs. The driver is currently assuming exclusivity and vectors being doled out to different CPUs and is assigning primary ownership of each vector to the first CPU in the mask. The code doesn't bother to check if the CPU already owns a vector and will unconditionally overwrite the CPU to vector mapping. This causes the relationships between eq's and cq's to get confused and gets worse when CPUs start to offline. The net results are interrupts are skipped resulting in mailbox timeouts and there are oopses in CPU offling flows. Fix this changing up the primary vector assignment. Now assign the eq to a CPU only if it is the CPU in the mask that does not have a prior assignment. And once the primary ownership is assigned, break from the loop. For CPUs that may have been set before but not the primary owner, the lpfc_cpu_affinity_check() routine will balance the CPU to eq assignment. Link: https://lore.kernel.org/r/20200706204230.130363-1-jsmart2021@gmail.com Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent df043c7 commit 17105d9

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

‎drivers/scsi/lpfc/lpfc_init.c‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11522,9 +11522,9 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba)
1152211522
char *name;
1152311523
const struct cpumask *aff_mask = NULL;
1152411524
unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids;
11525+
struct lpfc_vector_map_info *cpup;
1152511526
struct lpfc_hba_eq_hdl *eqhdl;
1152611527
const struct cpumask *maskp;
11527-
bool first;
1152811528
unsigned int flags = PCI_IRQ_MSIX;
1152911529

1153011530
/* Set up MSI-X multi-message vectors */
@@ -11597,18 +11597,28 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba)
1159711597
} else {
1159811598
maskp = pci_irq_get_affinity(phba->pcidev, index);
1159911599

11600-
first = true;
1160111600
/* Loop through all CPUs associated with vector index */
1160211601
for_each_cpu_and(cpu, maskp, cpu_present_mask) {
11602+
cpup = &phba->sli4_hba.cpu_map[cpu];
11603+
1160311604
/* If this is the first CPU thats assigned to
1160411605
* this vector, set LPFC_CPU_FIRST_IRQ.
11606+
*
11607+
* With certain platforms its possible that irq
11608+
* vectors are affinitized to all the cpu's.
11609+
* This can result in each cpu_map.eq to be set
11610+
* to the last vector, resulting in overwrite
11611+
* of all the previous cpu_map.eq. Ensure that
11612+
* each vector receives a place in cpu_map.
11613+
* Later call to lpfc_cpu_affinity_check will
11614+
* ensure we are nicely balanced out.
1160511615
*/
11616+
if (cpup->eq != LPFC_VECTOR_MAP_EMPTY)
11617+
continue;
1160611618
lpfc_assign_eq_map_info(phba, index,
11607-
first ?
11608-
LPFC_CPU_FIRST_IRQ : 0,
11619+
LPFC_CPU_FIRST_IRQ,
1160911620
cpu);
11610-
if (first)
11611-
first = false;
11621+
break;
1161211622
}
1161311623
}
1161411624
}

0 commit comments

Comments
 (0)