Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: mpt3sas: save and use MSI-X index for posting RD

In the IO submission path _base_get_msix_index is called twice. Initially
while getting the smid and subsequently while posting the request
descriptor (RD).

Refactor code to query msix index only while posting the request
descriptor. Save determined msix index in msix_io field.

Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Suganath Prabu S and committed by
Martin K. Petersen
998c3001 5dd48a55

+35 -9
+33 -9
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 3399 3399 3400 3400 smid = tag + 1; 3401 3401 request->cb_idx = cb_idx; 3402 - request->msix_io = _base_get_msix_index(ioc, NULL); 3403 3402 request->smid = smid; 3403 + request->scmd = scmd; 3404 3404 INIT_LIST_HEAD(&request->chain_list); 3405 3405 return smid; 3406 3406 } ··· 3454 3454 return; 3455 3455 st->cb_idx = 0xFF; 3456 3456 st->direct_io = 0; 3457 + st->scmd = NULL; 3457 3458 atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0); 3458 3459 st->smid = 0; 3459 3460 } ··· 3554 3553 #endif 3555 3554 3556 3555 /** 3556 + * _base_set_and_get_msix_index - get the msix index and assign to msix_io 3557 + * variable of scsi tracker 3558 + * @ioc: per adapter object 3559 + * @smid: system request message index 3560 + * 3561 + * returns msix index. 3562 + */ 3563 + static u8 3564 + _base_set_and_get_msix_index(struct MPT3SAS_ADAPTER *ioc, u16 smid) 3565 + { 3566 + struct scsiio_tracker *st = NULL; 3567 + 3568 + if (smid < ioc->hi_priority_smid) 3569 + st = _get_st_from_smid(ioc, smid); 3570 + 3571 + if (st == NULL) 3572 + return _base_get_msix_index(ioc, NULL); 3573 + 3574 + st->msix_io = ioc->get_msix_index_for_smlio(ioc, st->scmd); 3575 + return st->msix_io; 3576 + } 3577 + 3578 + /** 3557 3579 * _base_put_smid_mpi_ep_scsi_io - send SCSI_IO request to firmware 3558 3580 * @ioc: per adapter object 3559 3581 * @smid: system request message index ··· 3597 3573 _base_clone_mpi_to_sys_mem(mpi_req_iomem, (void *)mfp, 3598 3574 ioc->request_sz); 3599 3575 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO; 3600 - descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc, NULL); 3576 + descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3601 3577 descriptor.SCSIIO.SMID = cpu_to_le16(smid); 3602 3578 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle); 3603 3579 descriptor.SCSIIO.LMID = 0; ··· 3619 3595 3620 3596 3621 3597 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO; 3622 - descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc, NULL); 3598 + descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3623 3599 descriptor.SCSIIO.SMID = cpu_to_le16(smid); 3624 3600 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle); 3625 3601 descriptor.SCSIIO.LMID = 0; ··· 3642 3618 3643 3619 descriptor.SCSIIO.RequestFlags = 3644 3620 MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO; 3645 - descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc, NULL); 3621 + descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3646 3622 descriptor.SCSIIO.SMID = cpu_to_le16(smid); 3647 3623 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle); 3648 3624 descriptor.SCSIIO.LMID = 0; ··· 3706 3682 3707 3683 descriptor.Default.RequestFlags = 3708 3684 MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED; 3709 - descriptor.Default.MSIxIndex = _base_get_msix_index(ioc, NULL); 3685 + descriptor.Default.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3710 3686 descriptor.Default.SMID = cpu_to_le16(smid); 3711 3687 descriptor.Default.LMID = 0; 3712 3688 descriptor.Default.DescriptorTypeDependent = 0; ··· 3738 3714 } 3739 3715 request = (u64 *)&descriptor; 3740 3716 descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; 3741 - descriptor.Default.MSIxIndex = _base_get_msix_index(ioc, NULL); 3717 + descriptor.Default.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3742 3718 descriptor.Default.SMID = cpu_to_le16(smid); 3743 3719 descriptor.Default.LMID = 0; 3744 3720 descriptor.Default.DescriptorTypeDependent = 0; ··· 3768 3744 u32 *request = (u32 *)&descriptor; 3769 3745 3770 3746 descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO; 3771 - descriptor.MSIxIndex = _base_get_msix_index(ioc, NULL); 3747 + descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3772 3748 descriptor.SMID = cpu_to_le16(smid); 3773 3749 3774 3750 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); ··· 3790 3766 u32 *request = (u32 *)&descriptor; 3791 3767 3792 3768 descriptor.RequestFlags = MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO; 3793 - descriptor.MSIxIndex = _base_get_msix_index(ioc, NULL); 3769 + descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3794 3770 descriptor.SMID = cpu_to_le16(smid); 3795 3771 3796 3772 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); ··· 3834 3810 u32 *request = (u32 *)&descriptor; 3835 3811 3836 3812 descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; 3837 - descriptor.MSIxIndex = _base_get_msix_index(ioc, NULL); 3813 + descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); 3838 3814 descriptor.SMID = cpu_to_le16(smid); 3839 3815 3840 3816 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
+1
drivers/scsi/mpt3sas/mpt3sas_base.h
··· 830 830 */ 831 831 struct scsiio_tracker { 832 832 u16 smid; 833 + struct scsi_cmnd *scmd; 833 834 u8 cb_idx; 834 835 u8 direct_io; 835 836 struct pcie_sg_list pcie_sg_list;
+1
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 5210 5210 ((ioc_status & MPI2_IOCSTATUS_MASK) 5211 5211 != MPI2_IOCSTATUS_SCSI_TASK_TERMINATED)) { 5212 5212 st->direct_io = 0; 5213 + st->scmd = scmd; 5213 5214 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); 5214 5215 mpi_request->DevHandle = 5215 5216 cpu_to_le16(sas_device_priv_data->sas_target->handle);