Skip to content

Commit c718a19

Browse files
shivasharan-sgregkh
authored andcommitted
scsi: megaraid_sas: Load balance completions across all MSI-X
[ Upstream commit 1d15d90 ] Driver will use "reply descriptor post queues" in round robin fashion when the combined MSI-X mode is not enabled. With this IO completions are distributed and load balanced across all the available reply descriptor post queues equally. This is enabled only if combined MSI-X mode is not enabled in firmware. This improves performance and also fixes soft lockups. When load balancing is enabled, IRQ affinity from driver needs to be disabled. Signed-off-by: Kashyap Desai <[email protected]> Signed-off-by: Shivasharan S <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Stable-dep-of: 0b0747d ("scsi: megaraid_sas: Fix deadlock on firmware crashdump") Signed-off-by: Sasha Levin <[email protected]>
1 parent 75d6b6b commit c718a19

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

drivers/scsi/megaraid/megaraid_sas.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,7 @@ struct megasas_instance {
21932193
u32 secure_jbod_support;
21942194
u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
21952195
bool use_seqnum_jbod_fp; /* Added for PD sequence */
2196+
bool smp_affinity_enable;
21962197
spinlock_t crashdump_lock;
21972198

21982199
struct megasas_register_set __iomem *reg_set;
@@ -2210,6 +2211,7 @@ struct megasas_instance {
22102211
u16 ldio_threshold;
22112212
u16 cur_can_queue;
22122213
u32 max_sectors_per_req;
2214+
bool msix_load_balance;
22132215
struct megasas_aen_event *ev;
22142216

22152217
struct megasas_cmd **cmd_list;
@@ -2246,6 +2248,7 @@ struct megasas_instance {
22462248
atomic_t sge_holes_type1;
22472249
atomic_t sge_holes_type2;
22482250
atomic_t sge_holes_type3;
2251+
atomic64_t total_io_count;
22492252

22502253
struct megasas_instance_template *instancet;
22512254
struct tasklet_struct isr_tasklet;

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5101,6 +5101,7 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
51015101
&instance->irq_context[j]);
51025102
/* Retry irq register for IO_APIC*/
51035103
instance->msix_vectors = 0;
5104+
instance->msix_load_balance = false;
51045105
if (is_probe) {
51055106
pci_free_irq_vectors(instance->pdev);
51065107
return megasas_setup_irqs_ioapic(instance);
@@ -5109,6 +5110,7 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
51095110
}
51105111
}
51115112
}
5113+
51125114
return 0;
51135115
}
51145116

@@ -5364,6 +5366,12 @@ static int megasas_init_fw(struct megasas_instance *instance)
53645366
if (rdpq_enable)
53655367
instance->is_rdpq = (scratch_pad_2 & MR_RDPQ_MODE_OFFSET) ?
53665368
1 : 0;
5369+
5370+
if (!instance->msix_combined) {
5371+
instance->msix_load_balance = true;
5372+
instance->smp_affinity_enable = false;
5373+
}
5374+
53675375
fw_msix_count = instance->msix_vectors;
53685376
/* Save 1-15 reply post index address to local memory
53695377
* Index 0 is already saved from reg offset
@@ -5382,17 +5390,20 @@ static int megasas_init_fw(struct megasas_instance *instance)
53825390
instance->msix_vectors);
53835391
} else /* MFI adapters */
53845392
instance->msix_vectors = 1;
5393+
53855394
/* Don't bother allocating more MSI-X vectors than cpus */
53865395
instance->msix_vectors = min(instance->msix_vectors,
53875396
(unsigned int)num_online_cpus());
5388-
if (smp_affinity_enable)
5397+
if (instance->smp_affinity_enable)
53895398
irq_flags |= PCI_IRQ_AFFINITY;
53905399
i = pci_alloc_irq_vectors(instance->pdev, 1,
53915400
instance->msix_vectors, irq_flags);
5392-
if (i > 0)
5401+
if (i > 0) {
53935402
instance->msix_vectors = i;
5394-
else
5403+
} else {
53955404
instance->msix_vectors = 0;
5405+
instance->msix_load_balance = false;
5406+
}
53965407
}
53975408
/*
53985409
* MSI-X host index 0 is common for all adapter.
@@ -6447,6 +6458,7 @@ static inline void megasas_init_ctrl_params(struct megasas_instance *instance)
64476458
INIT_LIST_HEAD(&instance->internal_reset_pending_q);
64486459

64496460
atomic_set(&instance->fw_outstanding, 0);
6461+
atomic64_set(&instance->total_io_count, 0);
64506462

64516463
init_waitqueue_head(&instance->int_cmd_wait_q);
64526464
init_waitqueue_head(&instance->abort_cmd_wait_q);
@@ -6469,6 +6481,8 @@ static inline void megasas_init_ctrl_params(struct megasas_instance *instance)
64696481
instance->last_time = 0;
64706482
instance->disableOnlineCtrlReset = 1;
64716483
instance->UnevenSpanSupport = 0;
6484+
instance->smp_affinity_enable = smp_affinity_enable ? true : false;
6485+
instance->msix_load_balance = false;
64726486

64736487
if (instance->adapter_type != MFI_SERIES) {
64746488
INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq);
@@ -6818,7 +6832,7 @@ megasas_resume(struct pci_dev *pdev)
68186832
/* Now re-enable MSI-X */
68196833
if (instance->msix_vectors) {
68206834
irq_flags = PCI_IRQ_MSIX;
6821-
if (smp_affinity_enable)
6835+
if (instance->smp_affinity_enable)
68226836
irq_flags |= PCI_IRQ_AFFINITY;
68236837
}
68246838
rval = pci_alloc_irq_vectors(instance->pdev, 1,

drivers/scsi/megaraid/megaraid_sas_fusion.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,8 +2641,13 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
26412641
fp_possible = (io_info.fpOkForIo > 0) ? true : false;
26422642
}
26432643

2644-
cmd->request_desc->SCSIIO.MSIxIndex =
2645-
instance->reply_map[raw_smp_processor_id()];
2644+
if (instance->msix_load_balance)
2645+
cmd->request_desc->SCSIIO.MSIxIndex =
2646+
(mega_mod64(atomic64_add_return(1, &instance->total_io_count),
2647+
instance->msix_vectors));
2648+
else
2649+
cmd->request_desc->SCSIIO.MSIxIndex =
2650+
instance->reply_map[raw_smp_processor_id()];
26462651

26472652
praid_context = &io_request->RaidContext;
26482653

@@ -2969,8 +2974,13 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
29692974

29702975
cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
29712976

2972-
cmd->request_desc->SCSIIO.MSIxIndex =
2973-
instance->reply_map[raw_smp_processor_id()];
2977+
if (instance->msix_load_balance)
2978+
cmd->request_desc->SCSIIO.MSIxIndex =
2979+
(mega_mod64(atomic64_add_return(1, &instance->total_io_count),
2980+
instance->msix_vectors));
2981+
else
2982+
cmd->request_desc->SCSIIO.MSIxIndex =
2983+
instance->reply_map[raw_smp_processor_id()];
29742984

29752985
if (!fp_possible) {
29762986
/* system pd firmware path */

0 commit comments

Comments
 (0)