Skip to content

Commit 9dc704d

Browse files
Sagar Biradarmartinkpetersen
authored andcommitted
scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity
Fix the I/O hang that arises because of the MSIx vector not having a mapped online CPU upon receiving completion. SCSI cmds take the blk_mq route, which is setup during init. Reserved cmds fetch the vector_no from mq_map after init is complete. Before init, they have to use 0 - as per the norm. Reviewed-by: Gilbert Wu <gilbert.wu@microchip.com> Signed-off-by: Sagar Biradar <Sagar.Biradar@microchip.com> Reviewed-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20230519230834.27436-1-sagar.biradar@microchip.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6d074ce commit 9dc704d

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

drivers/scsi/aacraid/aacraid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ struct aac_dev
16781678
u32 handle_pci_error;
16791679
bool init_reset;
16801680
u8 soft_reset_support;
1681+
u8 use_map_queue;
16811682
};
16821683

16831684
#define aac_adapter_interrupt(dev) \

drivers/scsi/aacraid/commsup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,12 @@ int aac_fib_setup(struct aac_dev * dev)
223223
struct fib *aac_fib_alloc_tag(struct aac_dev *dev, struct scsi_cmnd *scmd)
224224
{
225225
struct fib *fibptr;
226+
u32 blk_tag;
227+
int i;
226228

227-
fibptr = &dev->fibs[scsi_cmd_to_rq(scmd)->tag];
229+
blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
230+
i = blk_mq_unique_tag_to_tag(blk_tag);
231+
fibptr = &dev->fibs[i];
228232
/*
229233
* Null out fields that depend on being zero at the start of
230234
* each I/O

drivers/scsi/aacraid/linit.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <linux/compat.h>
2121
#include <linux/blkdev.h>
22+
#include <linux/blk-mq-pci.h>
2223
#include <linux/completion.h>
2324
#include <linux/init.h>
2425
#include <linux/interrupt.h>
@@ -504,6 +505,15 @@ static int aac_slave_configure(struct scsi_device *sdev)
504505
return 0;
505506
}
506507

508+
static void aac_map_queues(struct Scsi_Host *shost)
509+
{
510+
struct aac_dev *aac = (struct aac_dev *)shost->hostdata;
511+
512+
blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
513+
aac->pdev, 0);
514+
aac->use_map_queue = true;
515+
}
516+
507517
/**
508518
* aac_change_queue_depth - alter queue depths
509519
* @sdev: SCSI device we are considering
@@ -1488,6 +1498,7 @@ static const struct scsi_host_template aac_driver_template = {
14881498
.bios_param = aac_biosparm,
14891499
.shost_groups = aac_host_groups,
14901500
.slave_configure = aac_slave_configure,
1501+
.map_queues = aac_map_queues,
14911502
.change_queue_depth = aac_change_queue_depth,
14921503
.sdev_groups = aac_dev_groups,
14931504
.eh_abort_handler = aac_eh_abort,
@@ -1775,6 +1786,8 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
17751786
shost->max_lun = AAC_MAX_LUN;
17761787

17771788
pci_set_drvdata(pdev, shost);
1789+
shost->nr_hw_queues = aac->max_msix;
1790+
shost->host_tagset = 1;
17781791

17791792
error = scsi_add_host(shost, &pdev->dev);
17801793
if (error)
@@ -1906,6 +1919,7 @@ static void aac_remove_one(struct pci_dev *pdev)
19061919
struct aac_dev *aac = (struct aac_dev *)shost->hostdata;
19071920

19081921
aac_cancel_rescan_worker(aac);
1922+
aac->use_map_queue = false;
19091923
scsi_remove_host(shost);
19101924

19111925
__aac_shutdown(aac);

drivers/scsi/aacraid/src.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,10 @@ static int aac_src_deliver_message(struct fib *fib)
493493
#endif
494494

495495
u16 vector_no;
496+
struct scsi_cmnd *scmd;
497+
u32 blk_tag;
498+
struct Scsi_Host *shost = dev->scsi_host_ptr;
499+
struct blk_mq_queue_map *qmap;
496500

497501
atomic_inc(&q->numpending);
498502

@@ -505,8 +509,25 @@ static int aac_src_deliver_message(struct fib *fib)
505509
if ((dev->comm_interface == AAC_COMM_MESSAGE_TYPE3)
506510
&& dev->sa_firmware)
507511
vector_no = aac_get_vector(dev);
508-
else
509-
vector_no = fib->vector_no;
512+
else {
513+
if (!fib->vector_no || !fib->callback_data) {
514+
if (shost && dev->use_map_queue) {
515+
qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
516+
vector_no = qmap->mq_map[raw_smp_processor_id()];
517+
}
518+
/*
519+
* We hardcode the vector_no for
520+
* reserved commands as a valid shost is
521+
* absent during the init
522+
*/
523+
else
524+
vector_no = 0;
525+
} else {
526+
scmd = (struct scsi_cmnd *)fib->callback_data;
527+
blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
528+
vector_no = blk_mq_unique_tag_to_hwq(blk_tag);
529+
}
530+
}
510531

511532
if (native_hba) {
512533
if (fib->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF) {

0 commit comments

Comments
 (0)