[PATCH v4 14/14] mpt3sas: Fix sparse warning
From: root 1) Used data type __le64/__le32 whichever required in building NVME PRP, which is passed to LE Controller. 2) Remove unused function, Declared functions which are used only in mpt3sas_scsih.c as static. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 23 +++--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 37 +--- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 3e571ef..9ec7f0e 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -1437,8 +1437,8 @@ _base_build_nvme_prp(struct MPT3SAS_ADAPTER *ioc, u16 smid, size_t data_in_sz) { int prp_size = NVME_PRP_SIZE; - u64 *prp_entry, *prp1_entry, *prp2_entry, *prp_entry_phys; - u64 *prp_page, *prp_page_phys; + __le64 *prp_entry, *prp1_entry, *prp2_entry, *prp_entry_phys; + __le64 *prp_page, *prp_page_phys; u32 offset, entry_len; u32 page_mask_result, page_mask; dma_addr_t paddr; @@ -1455,17 +1455,17 @@ _base_build_nvme_prp(struct MPT3SAS_ADAPTER *ioc, u16 smid, * PRP1 is located at a 24 byte offset from the start of the NVMe * command. Then set the current PRP entry pointer to PRP1. */ - prp1_entry = (u64 *)(nvme_encap_request->NVMe_Command + + prp1_entry = (__le64 *)(nvme_encap_request->NVMe_Command + NVME_CMD_PRP1_OFFSET); - prp2_entry = (u64 *)(nvme_encap_request->NVMe_Command + + prp2_entry = (__le64 *)(nvme_encap_request->NVMe_Command + NVME_CMD_PRP2_OFFSET); prp_entry = prp1_entry; /* * For the PRP entries, use the specially allocated buffer of * contiguous memory. */ - prp_page = (u64 *)mpt3sas_base_get_pcie_sgl(ioc, smid); - prp_page_phys = (u64 *)mpt3sas_base_get_pcie_sgl_dma(ioc, smid); + prp_page = (__le64 *)mpt3sas_base_get_pcie_sgl(ioc, smid); + prp_page_phys = (__le64 *)mpt3sas_base_get_pcie_sgl_dma(ioc, smid); /* * Check if we are within 1 entry of a page boundary we don't @@ -1475,8 +1475,8 @@ _base_build_nvme_prp(struct MPT3SAS_ADAPTER *ioc, u16 smid, page_mask_result = (uintptr_t)((u8 *)prp_page + prp_size) & page_mask; if (!page_mask_result) { /* Bump up to next page boundary. */ - prp_page = (u64 *)((u8 *)prp_page + prp_size); - prp_page_phys = (u64 *)((u8 *)prp_page_phys + prp_size); + prp_page = (__le64 *)((u8 *)prp_page + prp_size); + prp_page_phys = (__le64 *)((u8 *)prp_page_phys + prp_size); } /* @@ -1604,7 +1604,7 @@ _base_build_nvme_prp(struct MPT3SAS_ADAPTER *ioc, u16 smid, * Returns:true: PRPs are built * false: IEEE SGLs needs to be built */ -void +static void base_make_prp_nvme(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, Mpi25SCSIIORequest_t *mpi_request, @@ -1612,7 +1612,7 @@ base_make_prp_nvme(struct MPT3SAS_ADAPTER *ioc, { int sge_len, offset, num_prp_in_chain = 0; Mpi25IeeeSgeChain64_t *main_chain_element, *ptr_first_sgl; - u64 *curr_buff; + __le64 *curr_buff; dma_addr_t msg_phys; u64 sge_addr; u32 page_mask, page_mask_result; @@ -1736,7 +1736,6 @@ static bool base_is_prp_possible(struct MPT3SAS_ADAPTER *ioc, struct _pcie_device *pcie_device, struct scsi_cmnd *scmd, int sge_count) { - u32 i; u32 data_length = 0; struct scatterlist *sg_scmd; bool build_prp = false; @@ -1746,7 +1745,7 @@ base_is_prp_possible(struct MPT3SAS_ADAPTER *ioc, nvme_pg_size = max_t(u32, ioc->page_size, NVME_PRP_PAGE_SIZE); - data_length = cpu_to_le32(scsi_bufflen(scmd)); + data_length = scsi_bufflen(scmd); sg_scmd = scsi_sglist(scmd); /* Create page_mask (to get offset within page) */ diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 49e1943..f8990d9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -600,7 +600,7 @@ __mpt3sas_get_pdev_from_target(struct MPT3SAS_ADAPTER *ioc, * * This searches for pcie_device from target, then return pcie_device object. */ -struct _pcie_device * +static struct _pcie_device * mpt3sas_get_pdev_from_target(struct MPT3SAS_ADAPTER *ioc, struct MPT3SAS_TARGET *tgt_priv) { @@ -908,7 +908,7 @@ _scsih_sas_device_init_add(struct MPT3SAS_ADAPTER *ioc, } -struct _pcie_device * +static struct _pcie_device * __mpt3sas_get_pdev_by_wwid(struct MPT3SAS_ADAPTER *ioc, u64 wwid) { struct _pcie_device *pcie_device; @@ -941,7 +941,7 @
[PATCH v4 13/14] mpt3sas: Update mpt3sas driver version.
From: root Updated mpt3sas driver version to 15.101.00.00 Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 51d2668..2cd1550 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -74,9 +74,9 @@ #define MPT3SAS_DRIVER_NAME"mpt3sas" #define MPT3SAS_AUTHOR "Avago Technologies " #define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver" -#define MPT3SAS_DRIVER_VERSION "15.100.00.00" +#define MPT3SAS_DRIVER_VERSION "15.101.00.00" #define MPT3SAS_MAJOR_VERSION 15 -#define MPT3SAS_MINOR_VERSION 100 +#define MPT3SAS_MINOR_VERSION 101 #define MPT3SAS_BUILD_VERSION 0 #define MPT3SAS_RELEASE_VERSION00 -- 2.5.5
[PATCH v4 12/14] mpt3sas: Fix nvme drives checking for tlr.
From: root Check for NVMe drives before enabling or checking tlr. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index ff77850..49e1943 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2014,6 +2014,14 @@ scsih_is_raid(struct device *dev) return (sdev->channel == RAID_CHANNEL) ? 1 : 0; } +static int +scsih_is_nvme(struct device *dev) +{ + struct scsi_device *sdev = to_scsi_device(dev); + + return (sdev->channel == PCIE_CHANNEL) ? 1 : 0; +} + /** * scsih_get_resync - get raid volume resync percent complete * @dev the device struct object @@ -4818,8 +4826,9 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) /* Make sure Device is not raid volume. * We do not expose raid functionality to upper layer for warpdrive. */ - if (!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev) - && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) + if (((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)) + && !scsih_is_nvme(&scmd->device->sdev_gendev)) + && sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32) mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON; smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd); @@ -4864,8 +4873,8 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) raid_device = sas_target_priv_data->raid_device; if (raid_device && raid_device->direct_io_enabled) - mpt3sas_setup_direct_io(ioc, scmd, raid_device, mpi_request, - smid); + mpt3sas_setup_direct_io(ioc, scmd, + raid_device, mpi_request, smid); if (likely(mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST)) { if (sas_target_priv_data->flags & MPT_TARGET_FASTPATH_IO) { @@ -5413,9 +5422,10 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) le32_to_cpu(mpi_reply->ResponseInfo) & 0xFF; if (!sas_device_priv_data->tlr_snoop_check) { sas_device_priv_data->tlr_snoop_check++; - if (!ioc->is_warpdrive && + if ((!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev) && - sas_is_tlr_enabled(scmd->device) && + !scsih_is_nvme(&scmd->device->sdev_gendev)) + && sas_is_tlr_enabled(scmd->device) && response_code == MPI2_SCSITASKMGMT_RSP_INVALID_FRAME) { sas_disable_tlr(scmd->device); sdev_printk(KERN_INFO, scmd->device, "TLR disabled\n"); -- 2.5.5
[PATCH v4 11/14] mpt3sas: NVMe drive support for BTDHMAPPING ioctl command and log info
From: root * Added debug prints for pcie devices in ioctl debug path. Which will be helpful for debugging. * Added PCIe device support for ioctl BTDHMAPPING ioctl. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 88 +- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 6362d60..99147ad 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -79,32 +79,6 @@ enum block_state { }; /** - * _ctl_sas_device_find_by_handle - sas device search - * @ioc: per adapter object - * @handle: sas device handle (assigned by firmware) - * Context: Calling function should acquire ioc->sas_device_lock - * - * This searches for sas_device based on sas_address, then return sas_device - * object. - */ -static struct _sas_device * -_ctl_sas_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) -{ - struct _sas_device *sas_device, *r; - - r = NULL; - list_for_each_entry(sas_device, &ioc->sas_device_list, list) { - if (sas_device->handle != handle) - continue; - r = sas_device; - goto out; - } - - out: - return r; -} - -/** * _ctl_display_some_debug - debug routine * @ioc: per adapter object * @smid: system request message index @@ -229,10 +203,9 @@ _ctl_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid, Mpi2SCSIIOReply_t *scsi_reply = (Mpi2SCSIIOReply_t *)mpi_reply; struct _sas_device *sas_device = NULL; - unsigned long flags; + struct _pcie_device *pcie_device = NULL; - spin_lock_irqsave(&ioc->sas_device_lock, flags); - sas_device = _ctl_sas_device_find_by_handle(ioc, + sas_device = mpt3sas_get_sdev_by_handle(ioc, le16_to_cpu(scsi_reply->DevHandle)); if (sas_device) { pr_warn(MPT3SAS_FMT "\tsas_address(0x%016llx), phy(%d)\n", @@ -242,8 +215,25 @@ _ctl_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid, "\tenclosure_logical_id(0x%016llx), slot(%d)\n", ioc->name, (unsigned long long) sas_device->enclosure_logical_id, sas_device->slot); + sas_device_put(sas_device); + } + if (!sas_device) { + pcie_device = mpt3sas_get_pdev_by_handle(ioc, + le16_to_cpu(scsi_reply->DevHandle)); + if (pcie_device) { + pr_warn(MPT3SAS_FMT + "\tWWID(0x%016llx), port(%d)\n", ioc->name, + (unsigned long long)pcie_device->wwid, + pcie_device->port_num); + if (pcie_device->enclosure_handle != 0) + pr_warn(MPT3SAS_FMT + "\tenclosure_logical_id(0x%016llx), slot(%d)\n", + ioc->name, (unsigned long long) + pcie_device->enclosure_logical_id, + pcie_device->slot); + pcie_device_put(pcie_device); + } } - spin_unlock_irqrestore(&ioc->sas_device_lock, flags); if (scsi_reply->SCSIState || scsi_reply->SCSIStatus) pr_info(MPT3SAS_FMT "\tscsi_state(0x%02x), scsi_status" @@ -1353,6 +1343,42 @@ _ctl_btdh_search_sas_device(struct MPT3SAS_ADAPTER *ioc, } /** + * _ctl_btdh_search_pcie_device - searching for pcie device + * @ioc: per adapter object + * @btdh: btdh ioctl payload + */ +static int +_ctl_btdh_search_pcie_device(struct MPT3SAS_ADAPTER *ioc, + struct mpt3_ioctl_btdh_mapping *btdh) +{ + struct _pcie_device *pcie_device; + unsigned long flags; + int rc = 0; + + if (list_empty(&ioc->pcie_device_list)) + return rc; + + spin_lock_irqsave(&ioc->pcie_device_lock, flags); + list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { + if (btdh->bus == 0x && btdh->id == 0x && + btdh->handle == pcie_device->handle) { + btdh->bus = pcie_device->channel; + btdh->id = pcie_device->id; + rc = 1; + goto out; + } else if (btdh->bus == pcie_device->channel && btdh->id == + pcie_device->id && btdh->handle == 0x) { + btdh->handle = pcie_device->handl
[PATCH v4 10/14] mpt3as: Add-Task-management-debug-info-for-NVMe-drives.
From: root Added debug information for NVMe/PCIe drives in target rest path. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 83 ++-- 1 file changed, 70 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 2242edb..ff77850 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2900,6 +2900,7 @@ _scsih_tm_display_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd) struct scsi_target *starget = scmd->device->sdev_target; struct MPT3SAS_TARGET *priv_target = starget->hostdata; struct _sas_device *sas_device = NULL; + struct _pcie_device *pcie_device = NULL; unsigned long flags; char *device_str = NULL; @@ -2916,6 +2917,31 @@ _scsih_tm_display_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd) "%s handle(0x%04x), %s wwid(0x%016llx)\n", device_str, priv_target->handle, device_str, (unsigned long long)priv_target->sas_address); + + } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { + spin_lock_irqsave(&ioc->pcie_device_lock, flags); + pcie_device = __mpt3sas_get_pdev_from_target(ioc, priv_target); + if (pcie_device) { + starget_printk(KERN_INFO, starget, + "handle(0x%04x), wwid(0x%016llx), port(%d)\n", + pcie_device->handle, + (unsigned long long)pcie_device->wwid, + pcie_device->port_num); + if (pcie_device->enclosure_handle != 0) + starget_printk(KERN_INFO, starget, + "enclosure logical id(0x%016llx), slot(%d)\n", + (unsigned long long) + pcie_device->enclosure_logical_id, + pcie_device->slot); + if (pcie_device->connector_name[0] != '\0') + starget_printk(KERN_INFO, starget, + "enclosure level(0x%04x), connector name( %s)\n", + pcie_device->enclosure_level, + pcie_device->connector_name); + pcie_device_put(pcie_device); + } + spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + } else { spin_lock_irqsave(&ioc->sas_device_lock, flags); sas_device = __mpt3sas_get_sdev_from_target(ioc, priv_target); @@ -3659,6 +3685,7 @@ _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) Mpi2SCSITaskManagementRequest_t *mpi_request; u16 smid; struct _sas_device *sas_device = NULL; + struct _pcie_device *pcie_device = NULL; struct MPT3SAS_TARGET *sas_target_priv_data = NULL; u64 sas_address = 0; unsigned long flags; @@ -3701,24 +3728,52 @@ _scsih_tm_tr_send(struct MPT3SAS_ADAPTER *ioc, u16 handle) sas_address = sas_device->sas_address; } spin_unlock_irqrestore(&ioc->sas_device_lock, flags); - + if (!sas_device) { + spin_lock_irqsave(&ioc->pcie_device_lock, flags); + pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); + if (pcie_device && pcie_device->starget && + pcie_device->starget->hostdata) { + sas_target_priv_data = pcie_device->starget->hostdata; + sas_target_priv_data->deleted = 1; + sas_address = pcie_device->wwid; + } + spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + } if (sas_target_priv_data) { dewtprintk(ioc, pr_info(MPT3SAS_FMT "setting delete flag: handle(0x%04x), sas_addr(0x%016llx)\n", ioc->name, handle, (unsigned long long)sas_address)); - if (sas_device->enclosure_handle != 0) - dewtprintk(ioc, pr_info(MPT3SAS_FMT -"setting delete flag:enclosure logical id(0x%016llx)," -" slot(%d)\n", ioc->name, (unsigned long long) - sas_device->enclosure_logical_id, - sas_device->slot)); - if (sas_device->connector_name[0] != '\0') - dewtprintk(ioc, pr_info(MPT3SAS_FMT -"setting delete flag: enclosure level(0x%04x)," -" connector name( %s)\n", ioc->name, - sas_device->enclosure_level, -
[PATCH v4 09/14] mpt3sas: scan and add nvme device after controller reset
From: root After Controller reset, Scan and add nvme device back to the topology. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 194 ++- 1 file changed, 190 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 35b472f..2242edb 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -4876,6 +4876,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, char *desc_scsi_state = ioc->tmp_string; u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo); struct _sas_device *sas_device = NULL; + struct _pcie_device *pcie_device = NULL; struct scsi_target *starget = scmd->device->sdev_target; struct MPT3SAS_TARGET *priv_target = starget->hostdata; char *device_str = NULL; @@ -5008,6 +5009,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) { pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name, device_str, (unsigned long long)priv_target->sas_address); + } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { + pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target); + if (pcie_device) { + pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n", + ioc->name, + (unsigned long long)pcie_device->wwid, + pcie_device->port_num); + if (pcie_device->enclosure_handle != 0) + pr_info(MPT3SAS_FMT + "\tenclosure logical id(0x%016llx), " + "slot(%d)\n", ioc->name, + (unsigned long long) + pcie_device->enclosure_logical_id, + pcie_device->slot); + if (pcie_device->connector_name[0]) + pr_info(MPT3SAS_FMT + "\tenclosure level(0x%04x)," + "connector name( %s)\n", + ioc->name, pcie_device->enclosure_level, + pcie_device->connector_name); + pcie_device_put(pcie_device); + } } else { sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target); if (sas_device) { @@ -5054,11 +5077,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, struct sense_info data; _scsih_normalize_sense(scmd->sense_buffer, &data); pr_warn(MPT3SAS_FMT - "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n", - ioc->name, data.skey, - data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount)); + "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n", + ioc->name, data.skey, + data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount)); } - if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) { response_info = le32_to_cpu(mpi_reply->ResponseInfo); response_bytes = (u8 *)&response_info; @@ -8519,6 +8541,130 @@ _scsih_search_responding_sas_devices(struct MPT3SAS_ADAPTER *ioc) } /** + * _scsih_mark_responding_pcie_device - mark a pcie_device as responding + * @ioc: per adapter object + * @pcie_device_pg0: PCIe Device page 0 + * + * After host reset, find out whether devices are still responding. + * Used in _scsih_remove_unresponding_devices. + * + * Return nothing. + */ +static void +_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc, + Mpi26PCIeDevicePage0_t *pcie_device_pg0) +{ + struct MPT3SAS_TARGET *sas_target_priv_data = NULL; + struct scsi_target *starget; + struct _pcie_device *pcie_device; + unsigned long flags; + + spin_lock_irqsave(&ioc->pcie_device_lock, flags); + list_for_each_entry(pcie_device, &ioc->pcie_device_list, list) { + if ((pcie_device->wwid == pcie_device_pg0->WWID) && + (pcie_device->slot == pcie_device_pg0->Slot)) { + pcie_device->responding = 1; + starget = pcie_device->starget; + if (starget && starget->hostdata) { + sas_target_priv_data = starget->hostdata; + sas_target_priv_data->tm_busy = 0; + sas_target_priv_data->deleted = 0; + } else + sas_target_priv_da
[PATCH v4 08/14] mpt3sas: Set NVMe device queue depth as 128
From: root Sets nvme device queue depth, name and displays device capabilities Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 47 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 09ad823..51d2668 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -115,7 +115,7 @@ #define MPT3SAS_RAID_MAX_SECTORS 8192 #define MPT3SAS_HOST_PAGE_SIZE_4K 12 - +#define MPT3SAS_NVME_QUEUE_DEPTH 128 #define MPT_NAME_LENGTH32 /* generic length of strings */ #define MPT_STRING_LENGTH 64 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 344f946..35b472f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2290,6 +2290,7 @@ scsih_slave_configure(struct scsi_device *sdev) struct MPT3SAS_DEVICE *sas_device_priv_data; struct MPT3SAS_TARGET *sas_target_priv_data; struct _sas_device *sas_device; + struct _pcie_device *pcie_device; struct _raid_device *raid_device; unsigned long flags; int qdepth; @@ -2420,6 +2421,52 @@ scsih_slave_configure(struct scsi_device *sdev) } } + /* PCIe handling */ + if (sas_target_priv_data->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) { + spin_lock_irqsave(&ioc->pcie_device_lock, flags); + pcie_device = __mpt3sas_get_pdev_by_wwid(ioc, + sas_device_priv_data->sas_target->sas_address); + if (!pcie_device) { + spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + dfailprintk(ioc, pr_warn(MPT3SAS_FMT + "failure at %s:%d/%s()!\n", ioc->name, __FILE__, + __LINE__, __func__)); + return 1; + } + + qdepth = MPT3SAS_NVME_QUEUE_DEPTH; + ds = "NVMe"; + sdev_printk(KERN_INFO, sdev, + "%s: handle(0x%04x), wwid(0x%016llx), port(%d)\n", + ds, handle, (unsigned long long)pcie_device->wwid, + pcie_device->port_num); + if (pcie_device->enclosure_handle != 0) + sdev_printk(KERN_INFO, sdev, + "%s: enclosure logical id(0x%016llx), slot(%d)\n", + ds, + (unsigned long long)pcie_device->enclosure_logical_id, + pcie_device->slot); + if (pcie_device->connector_name[0] != '\0') + sdev_printk(KERN_INFO, sdev, + "%s: enclosure level(0x%04x)," + "connector name( %s)\n", ds, + pcie_device->enclosure_level, + pcie_device->connector_name); + pcie_device_put(pcie_device); + spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + scsih_change_queue_depth(sdev, qdepth); + + /* Enable QUEUE_FLAG_NOMERGES flag, so that IOs won't be +** merged and can eliminate holes created during merging +** operation. +**/ + queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, + sdev->request_queue); + blk_queue_virt_boundary(sdev->request_queue, + ioc->page_size - 1); + return 0; + } + spin_lock_irqsave(&ioc->sas_device_lock, flags); sas_device = __mpt3sas_get_sdev_by_addr(ioc, sas_device_priv_data->sas_target->sas_address); -- 2.5.5
[PATCH v4 07/14] mpt3sas: Handle NVMe PCIe device related events generated from firmware.
From: root * The controller firmware sends separate events for NVMe devices and PCIe switches similar to existing SAS events. * NVMe device detection, addition and removal are reported by the firmware through PCIe Topology Change list events. * The PCIe device state change events are sent when the firmware detects any abnormal conditions with a NVMe device or switch. * The enumeration event are sent when the firmware starts PCIe device enumeration and stops. * This patch has the code change to handle the events and add/remove NVMe devices in driver's inventory. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.c | 30 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 471 ++- 2 files changed, 495 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 2ffcac2..3e571ef 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -663,6 +663,26 @@ _base_display_event_data(struct MPT3SAS_ADAPTER *ioc, case MPI2_EVENT_ACTIVE_CABLE_EXCEPTION: desc = "Active cable exception"; break; + case MPI2_EVENT_PCIE_DEVICE_STATUS_CHANGE: + desc = "PCIE Device Status Change"; + break; + case MPI2_EVENT_PCIE_ENUMERATION: + { + Mpi26EventDataPCIeEnumeration_t *event_data = + (Mpi26EventDataPCIeEnumeration_t *)mpi_reply->EventData; + pr_info(MPT3SAS_FMT "PCIE Enumeration: (%s)", ioc->name, + (event_data->ReasonCode == + MPI26_EVENT_PCIE_ENUM_RC_STARTED) ? + "start" : "stop"); + if (event_data->EnumerationStatus) + pr_info("enumeration_status(0x%08x)", + le32_to_cpu(event_data->EnumerationStatus)); + pr_info("\n"); + return; + } + case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST: + desc = "PCIE Topology Change List"; + break; } if (!desc) @@ -6165,8 +6185,16 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); _base_unmask_events(ioc, MPI2_EVENT_TEMP_THRESHOLD); - if (ioc->hba_mpi_version_belonged == MPI26_VERSION) + if (ioc->hba_mpi_version_belonged == MPI26_VERSION) { _base_unmask_events(ioc, MPI2_EVENT_ACTIVE_CABLE_EXCEPTION); + if (ioc->is_gen35_ioc) { + _base_unmask_events(ioc, + MPI2_EVENT_PCIE_DEVICE_STATUS_CHANGE); + _base_unmask_events(ioc, MPI2_EVENT_PCIE_ENUMERATION); + _base_unmask_events(ioc, + MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST); + } + } r = _base_make_ioc_operational(ioc); if (r) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 710ea63..344f946 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -75,6 +75,8 @@ static int _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, static int _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle); static void _scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc, struct _pcie_device *pcie_device); +static void +_scsih_pcie_check_device(struct MPT3SAS_ADAPTER *ioc, u16 handle); static u8 _scsih_check_for_pending_tm(struct MPT3SAS_ADAPTER *ioc, u16 smid); /* global parameters */ @@ -3458,8 +3460,6 @@ _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) struct _sas_device *sas_device; sas_device = mpt3sas_get_sdev_by_handle(ioc, handle); - if (!sas_device) - return; shost_for_each_device(sdev, ioc->shost) { sas_device_priv_data = sdev->hostdata; @@ -3469,7 +3469,7 @@ _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) continue; if (sas_device_priv_data->block) continue; - if (sas_device->pend_sas_rphy_add) + if (sas_device && sas_device->pend_sas_rphy_add) continue; if (sas_device_priv_data->ignore_delay_remove) { sdev_printk(KERN_INFO, sdev, @@ -3480,7 +3480,8 @@ _scsih_block_io_device(struct MPT3SAS_ADAPTER *ioc, u16 handle) _scsih_internal_device_block(sdev, sas_device_priv_data); } - sas_device_put(sas_device); + if (sas_device) + sas_device_put(sas_device); } /** @@ -3564,6 +3565,33 @@ _scsih_block_io_to_children_attached_directly(struc
[PATCH v4 06/14] mpt3sas: API's to remove nvme drive from sml
From: root Below API's are included in nvme drive remove path. _scsih_pcie_device_remove_by_handle _scsih_pcie_device_remove_from_sml Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 148 ++- 1 file changed, 145 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 2f257e1..710ea63 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -73,6 +73,8 @@ static void _scsih_remove_device(struct MPT3SAS_ADAPTER *ioc, static int _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 retry_count, u8 is_pd); static int _scsih_pcie_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle); +static void _scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc, + struct _pcie_device *pcie_device); static u8 _scsih_check_for_pending_tm(struct MPT3SAS_ADAPTER *ioc, u16 smid); /* global parameters */ @@ -1092,6 +1094,41 @@ _scsih_pcie_device_remove(struct MPT3SAS_ADAPTER *ioc, pcie_device_put(pcie_device); } } + + +/** + * _scsih_pcie_device_remove_by_handle - removing pcie device object by handle + * @ioc: per adapter object + * @handle: device handle + * + * Return nothing. + */ +static void +_scsih_pcie_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle) +{ + struct _pcie_device *pcie_device; + unsigned long flags; + int was_on_pcie_device_list = 0; + + if (ioc->shost_recovery) + return; + + spin_lock_irqsave(&ioc->pcie_device_lock, flags); + pcie_device = __mpt3sas_get_pdev_by_handle(ioc, handle); + if (pcie_device) { + if (!list_empty(&pcie_device->list)) { + list_del_init(&pcie_device->list); + was_on_pcie_device_list = 1; + pcie_device_put(pcie_device); + } + } + spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + if (was_on_pcie_device_list) { + _scsih_pcie_device_remove_from_sml(ioc, pcie_device); + pcie_device_put(pcie_device); + } +} + /** * _scsih_pcie_device_add - add pcie_device object * @ioc: per adapter object @@ -6533,6 +6570,83 @@ _scsih_check_pcie_access_status(struct MPT3SAS_ADAPTER *ioc, u64 wwid, (unsigned long long)wwid, handle); return rc; } + +/** + * _scsih_pcie_device_remove_from_sml - removing pcie device + * from SML and free up associated memory + * @ioc: per adapter object + * @pcie_device: the pcie_device object + * + * Return nothing. + */ +static void +_scsih_pcie_device_remove_from_sml(struct MPT3SAS_ADAPTER *ioc, + struct _pcie_device *pcie_device) +{ + struct MPT3SAS_TARGET *sas_target_priv_data; + + dewtprintk(ioc, pr_info(MPT3SAS_FMT + "%s: enter: handle(0x%04x), wwid(0x%016llx)\n", ioc->name, __func__, + pcie_device->handle, (unsigned long long) + pcie_device->wwid)); + if (pcie_device->enclosure_handle != 0) + dewtprintk(ioc, pr_info(MPT3SAS_FMT + "%s: enter: enclosure logical id(0x%016llx), slot(%d)\n", + ioc->name, __func__, + (unsigned long long)pcie_device->enclosure_logical_id, + pcie_device->slot)); + if (pcie_device->connector_name[0] != '\0') + dewtprintk(ioc, pr_info(MPT3SAS_FMT + "%s: enter: enclosure level(0x%04x), connector name( %s)\n", + ioc->name, __func__, + pcie_device->enclosure_level, + pcie_device->connector_name)); + + if (pcie_device->starget && pcie_device->starget->hostdata) { + sas_target_priv_data = pcie_device->starget->hostdata; + sas_target_priv_data->deleted = 1; + _scsih_ublock_io_device(ioc, pcie_device->wwid); + sas_target_priv_data->handle = MPT3SAS_INVALID_DEVICE_HANDLE; + } + + pr_info(MPT3SAS_FMT + "removing handle(0x%04x), wwid (0x%016llx)\n", + ioc->name, pcie_device->handle, + (unsigned long long) pcie_device->wwid); + if (pcie_device->enclosure_handle != 0) + pr_info(MPT3SAS_FMT + "removing : enclosure logical id(0x%016llx), slot(%d)\n", + ioc->name, + (unsigned long long)pcie_device->enclosure_logical_id, + pcie_device->slot); + if (pcie_device->connector_name[0] != '\0') + pr_info(MPT3SAS_FMT + "removing: enclosure level(0x%04x), connector name( %s)\n", + ioc->name, pcie_device->enclosure_level, + pcie_device->connector_name); + + if (pcie_device->starget) + scsi_remove_target(&
[PATCH v4 05/14] mpt3sas: API 's to support NVMe drive addition to SML
From: root Below Functions are added in various paths to support NVMe drive addition. _scsih_pcie_add_device _scsih_pcie_device_add _scsih_pcie_device_init_add _scsih_check_pcie_access_status _scsih_pcie_check_device mpt3sas_get_pdev_by_handle mpt3sas_config_get_pcie_device_pg0 mpt3sas_config_get_pcie_device_pg2 Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.h | 10 + drivers/scsi/mpt3sas/mpt3sas_config.c | 100 +++ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 473 +- 3 files changed, 575 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index c4be9ad..09ad823 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1458,6 +1458,10 @@ struct _sas_device *mpt3sas_get_sdev_by_addr( struct MPT3SAS_ADAPTER *ioc, u64 sas_address); struct _sas_device *__mpt3sas_get_sdev_by_addr( struct MPT3SAS_ADAPTER *ioc, u64 sas_address); +struct _sas_device *mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc, + u16 handle); +struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc, + u16 handle); void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc); struct _raid_device * @@ -1496,6 +1500,12 @@ int mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER *ioc, int mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle); +int mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page, + u32 form, u32 handle); +int mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage2_t *config_page, + u32 form, u32 handle); int mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz); diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c b/drivers/scsi/mpt3sas/mpt3sas_config.c index dd62701..1c747cf 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_config.c +++ b/drivers/scsi/mpt3sas/mpt3sas_config.c @@ -150,6 +150,24 @@ _config_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid, case MPI2_CONFIG_EXTPAGETYPE_DRIVER_MAPPING: desc = "driver_mapping"; break; + case MPI2_CONFIG_EXTPAGETYPE_SAS_PORT: + desc = "sas_port"; + break; + case MPI2_CONFIG_EXTPAGETYPE_EXT_MANUFACTURING: + desc = "ext_manufacturing"; + break; + case MPI2_CONFIG_EXTPAGETYPE_PCIE_IO_UNIT: + desc = "pcie_io_unit"; + break; + case MPI2_CONFIG_EXTPAGETYPE_PCIE_SWITCH: + desc = "pcie_switch"; + break; + case MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE: + desc = "pcie_device"; + break; + case MPI2_CONFIG_EXTPAGETYPE_PCIE_LINK: + desc = "pcie_link"; + break; } break; } @@ -1053,6 +1071,88 @@ mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc, } /** + * mpt3sas_config_get_pcie_device_pg0 - obtain pcie device page 0 + * @ioc: per adapter object + * @mpi_reply: reply mf payload returned from firmware + * @config_page: contents of the config page + * @form: GET_NEXT_HANDLE or HANDLE + * @handle: device handle + * Context: sleep. + * + * Returns 0 for success, non-zero for failure. + */ +int +mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc, + Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page, + u32 form, u32 handle) +{ + Mpi2ConfigRequest_t mpi_request; + int r; + + memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); + mpi_request.Function = MPI2_FUNCTION_CONFIG; + mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; + mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED; + mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_PCIE_DEVICE; + mpi_request.Header.PageVersion = MPI26_PCIEDEVICE0_PAGEVERSION; + mpi_request.Header.PageNumber = 0; + ioc->build_zero_len_sge_mpi(ioc, &mpi_request.PageBufferSGE); + r = _config_request(ioc, &mpi_request, mpi_reply, + MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0); + if (r) + goto out; + + mpi_request.PageAddress = cpu_to_le32(form | handle); + mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT; + r = _config_request(ioc, &mpi_request, mpi_reply, + MPT
[PATCH v4 03/14] mpt3sas: SGL to PRP Translation for I/Os to NVMe devices
From: root * Added support for translating the SGLs associated with incoming commands either to IEE SGL or NVMe PRPs for NVMe devices. * The hardware translation of IEEE SGL to NVMe PRPs has limitation and if a command cannot be translated by hardware then it will go to firmware and the firmware needs to translate it. And this will have a performance reduction. To avoid that driver proactively checks whether the translation will be done in hardware or not, if not then driver try to translate inside the driver. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 601 ++- drivers/scsi/mpt3sas/mpt3sas_base.h | 44 ++- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 1 + drivers/scsi/mpt3sas/mpt3sas_scsih.c | 14 +- drivers/scsi/mpt3sas/mpt3sas_warpdrive.c | 2 +- 5 files changed, 646 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 18039bb..1e9086a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -59,6 +59,7 @@ #include #include #include +#include /* To get host page size per arch */ #include @@ -1347,6 +1348,480 @@ _base_build_sg(struct MPT3SAS_ADAPTER *ioc, void *psge, /* IEEE format sgls */ /** + * _base_build_nvme_prp - This function is called for NVMe end devices to build + * a native SGL (NVMe PRP). The native SGL is built starting in the first PRP + * entry of the NVMe message (PRP1). If the data buffer is small enough to be + * described entirely using PRP1, then PRP2 is not used. If needed, PRP2 is + * used to describe a larger data buffer. If the data buffer is too large to + * describe using the two PRP entriess inside the NVMe message, then PRP1 + * describes the first data memory segment, and PRP2 contains a pointer to a PRP + * list located elsewhere in memory to describe the remaining data memory + * segments. The PRP list will be contiguous. + + * The native SGL for NVMe devices is a Physical Region Page (PRP). A PRP + * consists of a list of PRP entries to describe a number of noncontigous + * physical memory segments as a single memory buffer, just as a SGL does. Note + * however, that this function is only used by the IOCTL call, so the memory + * given will be guaranteed to be contiguous. There is no need to translate + * non-contiguous SGL into a PRP in this case. All PRPs will describe + * contiguous space that is one page size each. + * + * Each NVMe message contains two PRP entries. The first (PRP1) either contains + * a PRP list pointer or a PRP element, depending upon the command. PRP2 + * contains the second PRP element if the memory being described fits within 2 + * PRP entries, or a PRP list pointer if the PRP spans more than two entries. + * + * A PRP list pointer contains the address of a PRP list, structured as a linear + * array of PRP entries. Each PRP entry in this list describes a segment of + * physical memory. + * + * Each 64-bit PRP entry comprises an address and an offset field. The address + * always points at the beginning of a 4KB physical memory page, and the offset + * describes where within that 4KB page the memory segment begins. Only the + * first element in a PRP list may contain a non-zero offest, implying that all + * memory segments following the first begin at the start of a 4KB page. + * + * Each PRP element normally describes 4KB of physical memory, with exceptions + * for the first and last elements in the list. If the memory being described + * by the list begins at a non-zero offset within the first 4KB page, then the + * first PRP element will contain a non-zero offset indicating where the region + * begins within the 4KB page. The last memory segment may end before the end + * of the 4KB segment, depending upon the overall size of the memory being + * described by the PRP list. + * + * Since PRP entries lack any indication of size, the overall data buffer length + * is used to determine where the end of the data memory buffer is located, and + * how many PRP entries are required to describe it. + * + * @ioc: per adapter object + * @smid: system request message index for getting asscociated SGL + * @nvme_encap_request: the NVMe request msg frame pointer + * @data_out_dma: physical address for WRITES + * @data_out_sz: data xfer size for WRITES + * @data_in_dma: physical address for READS + * @data_in_sz: data xfer size for READS + * + * Returns nothing. + */ +static void +_base_build_nvme_prp(struct MPT3SAS_ADAPTER *ioc, u16 smid, + Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request, + dma_addr_t data_out_dma, size_t data_out_sz, dma_addr_t data_in_dma, + size_t data_in_sz) +{ + int prp_size = NVME_PRP_SIZE; + u64 *prp_entry, *prp1_entry, *prp2_entry, *prp_entry_phys; + u64 *prp_page, *prp_page_phys; + u32
[PATCH v4 04/14] mpt3sas: Added support for nvme encapsulated request message.
From: root * Mpt3sas driver uses the NVMe Encapsulated Request message to send an NVMe command to an NVMe device attached to the IOC. * Normal I/O commands like reads and writes are passed to the controller as SCSI commands and the controller has the ability to translate the commands to NVMe equivalent. * This encapsulated NVMe command is used by applications to send direct NVMe commands to NVMe drives or for handling unmap where the translation at controller/firmware level is having performance issues. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.c | 56 +- drivers/scsi/mpt3sas/mpt3sas_base.h | 1 + drivers/scsi/mpt3sas/mpt3sas_ctl.c | 69 + 3 files changed, 119 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 1e9086a..2ffcac2 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -557,6 +557,11 @@ _base_sas_ioc_info(struct MPT3SAS_ADAPTER *ioc, MPI2DefaultReply_t *mpi_reply, frame_sz = sizeof(Mpi2SmpPassthroughRequest_t) + ioc->sge_size; func_str = "smp_passthru"; break; + case MPI2_FUNCTION_NVME_ENCAPSULATED: + frame_sz = sizeof(Mpi26NVMeEncapsulatedRequest_t) + + ioc->sge_size; + func_str = "nvme_encapsulated"; + break; default: frame_sz = 32; func_str = "unknown"; @@ -985,7 +990,9 @@ _base_interrupt(int irq, void *bus_id) if (request_desript_type == MPI25_RPY_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO_SUCCESS || request_desript_type == - MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS) { + MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS || + request_desript_type == + MPI26_RPY_DESCRIPT_FLAGS_PCIE_ENCAPSULATED_SUCCESS) { cb_idx = _base_get_cb_idx(ioc, smid); if ((likely(cb_idx < MPT_MAX_CALLBACKS)) && (likely(mpt_callbacks[cb_idx] != NULL))) { @@ -3057,6 +3064,30 @@ _base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid, } /** + * _base_put_smid_nvme_encap - send NVMe encapsulated request to + * firmware + * @ioc: per adapter object + * @smid: system request message index + * + * Return nothing. + */ +static void +_base_put_smid_nvme_encap(struct MPT3SAS_ADAPTER *ioc, u16 smid) +{ + Mpi2RequestDescriptorUnion_t descriptor; + u64 *request = (u64 *)&descriptor; + + descriptor.Default.RequestFlags = + MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED; + descriptor.Default.MSIxIndex = _base_get_msix_index(ioc); + descriptor.Default.SMID = cpu_to_le16(smid); + descriptor.Default.LMID = 0; + descriptor.Default.DescriptorTypeDependent = 0; + _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow, + &ioc->scsi_lookup_lock); +} + +/** * _base_put_smid_default - Default, primarily used for config pages * @ioc: per adapter object * @smid: system request message index @@ -3147,6 +3178,27 @@ _base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, } /** + * _base_put_smid_nvme_encap_atomic - send NVMe encapsulated request to + * firmware using Atomic Request Descriptor + * @ioc: per adapter object + * @smid: system request message index + * + * Return nothing. + */ +static void +_base_put_smid_nvme_encap_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid) +{ + Mpi26AtomicRequestDescriptor_t descriptor; + u32 *request = (u32 *)&descriptor; + + descriptor.RequestFlags = MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED; + descriptor.MSIxIndex = _base_get_msix_index(ioc); + descriptor.SMID = cpu_to_le16(smid); + + writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); +} + +/** * _base_put_smid_default - Default, primarily used for config pages * use Atomic Request Descriptor * @ioc: per adapter object @@ -5979,11 +6031,13 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) ioc->put_smid_scsi_io = &_base_put_smid_scsi_io_atomic; ioc->put_smid_fast_path = &_base_put_smid_fast_path_atomic; ioc->put_smid_hi_priority = &_base_put_smid_hi_priority_atomic; + ioc->put_smid_nvme_encap = &_base_put_smid_nvme_encap_atomic; } else { ioc->put_smid_default = &_base_put_smid_default; ioc->put_smid_scsi_io = &_base_put_smid_scsi_io; ioc->put_smid_fast_path = &_base_put_smid_fast_path; ioc->put_smid_hi_priority = &_base_put_smid_hi_priority; + ioc->put_smid_nvme_encap = &_base_put_smid_nvme_encap; } diff --git a/drivers/scsi/
[PATCH v4 02/14] mpt3sas: Add nvme device support in slave alloc, target alloc and probe
From: root 1) Added support for probing pcie device and adding NVMe drives to SML and driver's internal list pcie_device_list. 2) Added support for determing NVMe as boot device. 3) Added nvme device support for call back functions scan_finished target_alloc,slave_alloc,target destroy and slave destroy. a) During scan, pcie devices are probed and added to SML to drivers internal list. b) target_alloc & slave alloc API's allocates resources for (MPT3SAS_TARGET & MPT3SAS_DEVICE) private datas and holds information like handle, target_id etc. c) slave_destroy & target_destroy are called when driver unregisters or removes device. Also frees allocated resources and info. Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.h | 110 - drivers/scsi/mpt3sas/mpt3sas_scsih.c | 431 --- 2 files changed, 507 insertions(+), 34 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 099ab4c..c522057 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -159,6 +159,7 @@ #define MPT_TARGET_FLAGS_VOLUME0x02 #define MPT_TARGET_FLAGS_DELETED 0x04 #define MPT_TARGET_FASTPATH_IO 0x08 +#define MPT_TARGET_FLAGS_PCIE_DEVICE 0x10 #define SAS2_PCI_DEVICE_B0_REVISION(0x01) #define SAS3_PCI_DEVICE_C0_REVISION(0x02) @@ -357,7 +358,8 @@ struct Mpi2ManufacturingPage11_t { * @flags: MPT_TARGET_FLAGS_XXX flags * @deleted: target flaged for deletion * @tm_busy: target is busy with TM request. - * @sdev: The sas_device associated with this target + * @sas_dev: The sas_device associated with this target + * @pcie_dev: The pcie device associated with this target */ struct MPT3SAS_TARGET { struct scsi_target *starget; @@ -368,7 +370,8 @@ struct MPT3SAS_TARGET { u32 flags; u8 deleted; u8 tm_busy; - struct _sas_device *sdev; + struct _sas_device *sas_dev; + struct _pcie_device *pcie_dev; }; @@ -508,6 +511,89 @@ static inline void sas_device_put(struct _sas_device *s) kref_put(&s->refcount, sas_device_free); } +/* + * struct _pcie_device - attached PCIe device information + * @list: pcie device list + * @starget: starget object + * @wwid: device WWID + * @handle: device handle + * @device_info: bitfield provides detailed info about the device + * @id: target id + * @channel: target channel + * @slot: slot number + * @port_num: port number + * @responding: used in _scsih_pcie_device_mark_responding + * @fast_path: fast path feature enable bit + * @nvme_mdts: MaximumDataTransferSize from PCIe Device Page 2 for + * NVMe device only + * @enclosure_handle: enclosure handle + * @enclosure_logical_id: enclosure logical identifier + * @enclosure_level: The level of device's enclosure from the controller + * @connector_name: ASCII value of the Connector's name + * @serial_number: pointer of serial number string allocated runtime + * @refcount: reference count for deletion + */ +struct _pcie_device { + struct list_head list; + struct scsi_target *starget; + u64 wwid; + u16 handle; + u32 device_info; + int id; + int channel; + u16 slot; + u8 port_num; + u8 responding; + u8 fast_path; + u32 nvme_mdts; + u16 enclosure_handle; + u64 enclosure_logical_id; + u8 enclosure_level; + u8 connector_name[4]; + u8 *serial_number; + struct kref refcount; +}; +/** + * pcie_device_get - Increment the pcie device reference count + * + * @p: pcie_device object + * + * When ever this function called it will increment the + * reference count of the pcie device for which this function called. + * + */ +static inline void pcie_device_get(struct _pcie_device *p) +{ + kref_get(&p->refcount); +} + +/** + * pcie_device_free - Release the pcie device object + * @r - kref object + * + * Free's the pcie device object. It will be called when reference count + * reaches to zero. + */ +static inline void pcie_device_free(struct kref *r) +{ + kfree(container_of(r, struct _pcie_device, refcount)); +} + +/** + * pcie_device_put - Decrement the pcie device reference count + * + * @p: pcie_device object + * + * When ever this function called it will decrement the + * reference count of the pcie device for which this function called. + * + * When refernce count reaches to Zero, this will call pcie_device_free to the + * pcie_device object. + */ +static inline void pcie_device_put(struct _pcie_device *p) +{ + kref_put(&p->refcount, pcie_device_free); +} /** * struct _raid_device - raid volume link list * @list: sas device list @@ -556,12 +642,13 @@ struct _raid_device { /** * struct _boot_device - boot device info - * @is_raid: flag to indicate whether this is volu
[PATCH v4 01/14] mpt3sas: Update MPI Header
From: root Update MPI Files for NVMe support Signed-off-by: Chaitra P B Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpi/mpi2.h | 43 ++- drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 564 +-- drivers/scsi/mpt3sas/mpi/mpi2_init.h | 11 +- drivers/scsi/mpt3sas/mpi/mpi2_ioc.h | 282 +- drivers/scsi/mpt3sas/mpi/mpi2_pci.h | 112 +++ drivers/scsi/mpt3sas/mpi/mpi2_tool.h | 14 +- 6 files changed, 992 insertions(+), 34 deletions(-) create mode 100644 drivers/scsi/mpt3sas/mpi/mpi2_pci.h diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h index a9a659f..bc59058 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2.h @@ -8,7 +8,7 @@ * scatter/gather formats. * Creation Date: June 21, 2006 * - * mpi2.h Version: 02.00.42 + * mpi2.h Version: 02.00.48 * * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25 * prefix are for use only on MPI v2.5 products, and must not be used @@ -103,6 +103,16 @@ * 08-25-15 02.00.40 Bumped MPI2_HEADER_VERSION_UNIT. * 12-15-15 02.00.41 Bumped MPI_HEADER_VERSION_UNIT * 01-01-16 02.00.42 Bumped MPI_HEADER_VERSION_UNIT + * 04-05-16 02.00.43 Modified MPI26_DIAG_BOOT_DEVICE_SELECT defines + * to be unique within first 32 characters. + * Removed AHCI support. + * Removed SOP support. + * Bumped MPI2_HEADER_VERSION_UNIT. + * 04-10-16 02.00.44 Bumped MPI2_HEADER_VERSION_UNIT. + * 07-06-16 02.00.45 Bumped MPI2_HEADER_VERSION_UNIT. + * 09-02-16 02.00.46 Bumped MPI2_HEADER_VERSION_UNIT. + * 11-23-16 02.00.47 Bumped MPI2_HEADER_VERSION_UNIT. + * 02-03-17 02.00.48 Bumped MPI2_HEADER_VERSION_UNIT. * -- */ @@ -142,7 +152,7 @@ #define MPI2_VERSION_02_06 (0x0206) /*Unit and Dev versioning for this MPI header set */ -#define MPI2_HEADER_VERSION_UNIT(0x2A) +#define MPI2_HEADER_VERSION_UNIT(0x30) #define MPI2_HEADER_VERSION_DEV (0x00) #define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00) #define MPI2_HEADER_VERSION_UNIT_SHIFT (8) @@ -249,6 +259,12 @@ typedef volatile struct _MPI2_SYSTEM_INTERFACE_REGS { #define MPI2_DIAG_BOOT_DEVICE_SELECT_DEFAULT(0x) #define MPI2_DIAG_BOOT_DEVICE_SELECT_HCDW (0x0800) +/* Defines for V7A/V7R HostDiagnostic Register */ +#define MPI26_DIAG_BOOT_DEVICE_SEL_64FLASH (0x) +#define MPI26_DIAG_BOOT_DEVICE_SEL_64HCDW (0x0800) +#define MPI26_DIAG_BOOT_DEVICE_SEL_32FLASH (0x1000) +#define MPI26_DIAG_BOOT_DEVICE_SEL_32HCDW (0x1800) + #define MPI2_DIAG_CLEAR_FLASH_BAD_SIG (0x0400) #define MPI2_DIAG_FORCE_HCB_ON_RESET(0x0200) #define MPI2_DIAG_HCB_MODE (0x0100) @@ -367,6 +383,7 @@ typedef struct _MPI2_DEFAULT_REQUEST_DESCRIPTOR { #define MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE(0x08) #define MPI2_REQ_DESCRIPT_FLAGS_RAID_ACCELERATOR(0x0A) #define MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO (0x0C) +#define MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED (0x10) #define MPI2_REQ_DESCRIPT_FLAGS_IOC_FIFO_MARKER (0x01) @@ -425,6 +442,13 @@ typedef MPI2_SCSI_IO_REQUEST_DESCRIPTOR Mpi25FastPathSCSIIORequestDescriptor_t, *pMpi25FastPathSCSIIORequestDescriptor_t; +/*PCIe Encapsulated Request Descriptor */ +typedef MPI2_SCSI_IO_REQUEST_DESCRIPTOR + MPI26_PCIE_ENCAPSULATED_REQUEST_DESCRIPTOR, + *PTR_MPI26_PCIE_ENCAPSULATED_REQUEST_DESCRIPTOR, + Mpi26PCIeEncapsulatedRequestDescriptor_t, + *pMpi26PCIeEncapsulatedRequestDescriptor_t; + /*union of Request Descriptors */ typedef union _MPI2_REQUEST_DESCRIPTOR_UNION { MPI2_DEFAULT_REQUEST_DESCRIPTOR Default; @@ -433,6 +457,7 @@ typedef union _MPI2_REQUEST_DESCRIPTOR_UNION { MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR SCSITarget; MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR RAIDAccelerator; MPI25_FP_SCSI_IO_REQUEST_DESCRIPTOR FastPathSCSIIO; + MPI26_PCIE_ENCAPSULATED_REQUEST_DESCRIPTOR PCIeEncapsulated; U64 Words; } MPI2_REQUEST_DESCRIPTOR_UNION, *PTR_MPI2_REQUEST_DESCRIPTOR_UNION, @@ -450,6 +475,7 @@ typedef union _MPI2_REQUEST_DESCRIPTOR_UNION { * Atomic SCSI Target Request Descriptor * Atomic RAID Accelerator Request Descriptor * Atomic Fast Path SCSI IO Request Descriptor + * Atomic PCIe Encapsulated Request Descriptor */ /*Atomic Request Descriptor */ @@ -487,6 +513,7 @@ typedef struct _MPI2_DEFAULT_REPLY_DESCRIPTOR { #define MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER (0x03) #define MPI2_RPY_DESCRIPT_FLAGS_RAID_ACCELERATOR_SUCCESS(0x05) #define MPI25_RPY_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO_SUCCESS (0x06) +#define MPI26_RPY_DESCRIPT_FLAGS_PCIE_ENCAP
[PATCH v4 00/14] mpt3sas driver NVMe support:
Ventura Series controller are Tri-mode. The controller and firmware are capable of supporting NVMe devices and PCIe switches to be connected with the controller. This patch set adds driver level support for NVMe devices and PCIe switches. mpt3sas v4 patset: 1) Removed code which detects gaps/holes in IO data buffers. 2) Added Patch 14, This has sparse warning fixes. mpt3sas v3 patset: Posting version v3. This accommodates below changes over v2 patch. 1. In the MPI header files patch, Reformatted headers to have type and variable on one line as suggested. 2. As suggested, started using blk_queue_virt_boundary() API for NVMe drives and simplified the PRP formation. 3. Removed 'TODO' comments. Suganath Prabu S (14): mpt3sas: Update MPI Header mpt3sas: Add nvme device support in slave alloc, target alloc and probe mpt3sas: SGL to PRP Translation for I/Os to NVMe devices mpt3sas: Added support for nvme encapsulated request message. mpt3sas: API 's to support NVMe drive addition to SML mpt3sas: API's to remove nvme drive from sml mpt3sas: Handle NVMe PCIe device related events generated from firmware. mpt3sas: Set NVMe device queue depth as 128 mpt3sas: scan and add nvme device after controller reset mpt3as: Add-Task-management-debug-info-for-NVMe-drives. mpt3sas: NVMe drive support for BTDHMAPPING ioctl command and log info mpt3sas: Fix nvme drives checking for tlr. mpt3sas: Update mpt3sas driver version. mpt3sas: Fix sparse warning drivers/scsi/mpt3sas/mpi/mpi2.h | 43 +- drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 564 +++- drivers/scsi/mpt3sas/mpi/mpi2_init.h | 11 +- drivers/scsi/mpt3sas/mpi/mpi2_ioc.h | 282 +++- drivers/scsi/mpt3sas/mpi/mpi2_pci.h | 112 ++ drivers/scsi/mpt3sas/mpi/mpi2_tool.h | 14 +- drivers/scsi/mpt3sas/mpt3sas_base.c | 686 +- drivers/scsi/mpt3sas/mpt3sas_base.h | 171 ++- drivers/scsi/mpt3sas/mpt3sas_config.c| 100 ++ drivers/scsi/mpt3sas/mpt3sas_ctl.c | 158 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2076 +++--- drivers/scsi/mpt3sas/mpt3sas_warpdrive.c |2 +- 12 files changed, 3945 insertions(+), 274 deletions(-) create mode 100644 drivers/scsi/mpt3sas/mpi/mpi2_pci.h Thanks, Suganath Prabu S -- 2.5.5
Re: [PATCH] scsi: sd_zbc: Disable zoned block devices with scsi-mq
On Thu, Aug 17, 2017 at 03:01:51PM +, Bart Van Assche wrote: > Another possible approach is to fix the ipr driver and to resubmit the > "scsi-mq: Always unprepare before requeuing a request" and "scsi: sd_zbc: > Write unlock zone from sd_uninit_cmnd()" patches. We should absolutely take that broader approach. But it seems like we need to refne the always unprepare patch first, to make sure we only release resources, but don't clear the scmd->retries field. The NVMe driver already works that way, so we have an example to follow.
Re: [Regression 4.13-rc1] Resume does not work on Lenovo X60t
Hi Paul, with 4.13-rc6 we're not using blk-mq by default any more, do you still see the issue with that one?
RE: [PATCH] sd: preserve sysfs updates to max_sectors_kb
> -Original Message- > From: Bart Van Assche [mailto:bart.vanass...@wdc.com] > Sent: Friday, August 18, 2017 4:47 PM > To: h...@infradead.org; Viswas G ; Gerry > Morong ; Mahesh Rajashekhara > ; posw...@suse.com; Scott > Benesh ; Don Brace > ; Bader Ali - Saleh > ; Kevin Barnett > ; joseph.szczy...@hpe.com; Scott Teel > ; j...@linux.vnet.ibm.com; Justin Lindley > ; John Hall > Cc: linux-scsi@vger.kernel.org > Subject: Re: [PATCH] sd: preserve sysfs updates to max_sectors_kb > > EXTERNAL EMAIL > > > On Fri, 2017-08-18 at 21:29 +, Don Brace wrote: > > As far as I can see, udev looks for file access in sysfs. > > I am not exactly sure which rule changes this. It was added in more recent > > distros. Can someone help me out? > > Hello Don, > > Can you check on your test system which udev rule changes > max_sectors_kb? I > have checked two recent Linux distro's but haven't been able to find such a > udev rule: > $ grep -rw max_sectors_kb /usr/lib/udev/rules.d /etc/udev/rules.d | wc -l > 0 > > Thanks, > > Bart. On my system it is 60-block.rules, and it is the last rule in that rule file. -- # do not edit this file, it will be overwritten on update # enable in-kernel media-presence polling ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", \ ATTR{parameters/events_dfl_poll_msecs}="2000" # forward scsi device event to corresponding block device ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change" # watch metadata changes, caused by tools closing the device node which was opened for writing ACTION!="remove", SUBSYSTEM=="block", KERNEL=="loop*|nvme*|sd*|vd*|xvd*|pmem*", OPTIONS+="watch"
Re: [PATCH] sd: preserve sysfs updates to max_sectors_kb
On Mon, 2017-08-21 at 19:12 +, Don Brace wrote: > On Friday Bart Van Assche wrote: > > Can you check on your test system which udev rule changes > > max_sectors_kb? I > > have checked two recent Linux distro's but haven't been able to find > > such a udev rule: > > $ grep -rw max_sectors_kb /usr/lib/udev/rules.d /etc/udev/rules.d | wc > > -l > > 0 > > > > Thanks, > > > > Bart. > > On my system it is 60-block.rules, and it is the last rule in that rule > file. > -- > # do not edit this file, it will be overwritten on update > > # enable in-kernel media-presence polling > ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", > ATTR{parameters/events_dfl_poll_msecs}=="0", \ > ATTR{parameters/events_dfl_poll_msecs}="2000" > > # forward scsi device event to corresponding block device > ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", > TEST=="block", ATTR{block/*/uevent}="change" > > # watch metadata changes, caused by tools closing the device node which > was opened for writing > ACTION!="remove", SUBSYSTEM=="block", > KERNEL=="loop*|nvme*|sd*|vd*|xvd*|pmem*", OPTIONS+="watch" Hello Don, Can you have another look at the udev rules on your test system? The last rule in 60-block.rules looks like a watch rule to me. The same holds for the upstream version of that file (https://github.com/systemd/systemd/blob/maste r/rules/60-block.rules). Bart.
Re: [PATCH 06/15] mtd: make device_type const
Le Sat, 19 Aug 2017 13:52:17 +0530, Bhumika Goyal a écrit : > Make this const as it is only stored in the type field of a device > structure, which is const. > Done using Coccinelle. > Applied to l2-mtd/master. Thanks, Boris > Signed-off-by: Bhumika Goyal > --- > drivers/mtd/mtdcore.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index f872a99..e7ea842 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -340,7 +340,7 @@ static ssize_t mtd_bbtblocks_show(struct device *dev, > }; > ATTRIBUTE_GROUPS(mtd); > > -static struct device_type mtd_devtype = { > +static const struct device_type mtd_devtype = { > .name = "mtd", > .groups = mtd_groups, > .release= mtd_release,
RE: [PATCH] sd: preserve sysfs updates to max_sectors_kb
> -Original Message- > From: Bart Van Assche [mailto:bart.vanass...@wdc.com] > Sent: Monday, August 21, 2017 2:53 PM > To: h...@infradead.org; Viswas G ; Gerry > Morong ; Mahesh Rajashekhara > ; posw...@suse.com; Scott > Benesh ; Don Brace > ; Bader Ali - Saleh > ; Kevin Barnett > ; joseph.szczy...@hpe.com; Scott Teel > ; j...@linux.vnet.ibm.com; Justin Lindley > ; John Hall > Cc: linux-scsi@vger.kernel.org > Subject: Re: [PATCH] sd: preserve sysfs updates to max_sectors_kb > > EXTERNAL EMAIL > > > On Mon, 2017-08-21 at 19:12 +, Don Brace wrote: > > On Friday Bart Van Assche wrote: > > > Can you check on your test system which udev rule changes > > > max_sectors_kb? I > > > have checked two recent Linux distro's but haven't been able to find > > > such a udev rule: > > > $ grep -rw max_sectors_kb /usr/lib/udev/rules.d /etc/udev/rules.d | wc > > > -l > > > 0 > > > > > > Thanks, > > > > > > Bart. > > > > On my system it is 60-block.rules, and it is the last rule in that rule > > file. > > -- > > # do not edit this file, it will be overwritten on update > > > > # enable in-kernel media-presence polling > > ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", > > ATTR{parameters/events_dfl_poll_msecs}=="0", \ > > ATTR{parameters/events_dfl_poll_msecs}="2000" > > > > # forward scsi device event to corresponding block device > > ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", > > TEST=="block", ATTR{block/*/uevent}="change" > > > > # watch metadata changes, caused by tools closing the device node which > > was opened for writing > > ACTION!="remove", SUBSYSTEM=="block", > > KERNEL=="loop*|nvme*|sd*|vd*|xvd*|pmem*", OPTIONS+="watch" > > Hello Don, > > Can you have another look at the udev rules on your test system? The last > rule in 60-block.rules looks like a watch rule to me. The same holds for the > upstream version of that file > (https://github.com/systemd/systemd/blob/maste > r/rules/60-block.rules). > > Bart. It is a watch rule. systemd/src/udev/udevd.c manager_new manager->fd_inotify = udev_watch_init(manager->udev); sd_event_add_io(manager->event, &manager->inotify_event, manager->fd_inotify, EPOLLIN, on_inotify, manager); on_inotify (systemd source code: src/udev/udevd.c) synthesize_change ioctl --> BLKRRPART This rule ends up calling BLKRRPART. Thanks, Don Brace ESC - Smart Storage Microsemi Corporation
Re: [PATCH] ipr: Set no_report_opcodes for RAID arrays
Brian, > Since ipr RAID arrays do not support the MAINTENANCE_IN / > MI_REPORT_SUPPORTED_OPERATION_CODES, set no_report_opcodes to prevent > it from being sent. Applied to 4.13/scsi-fixes. Thank you! -- Martin K. Petersen Oracle Linux Engineering
Re: [BUG][bisected 270065e] linux-next fails to boot on powerpc
Brian, >> Thanks for the detailed analysis. This is very helpful. Have you >> considered to change the ipr driver such that it terminates REPORT >> SUPPORTED OPERATION CODES commands with the appropriate check >> condition code instead of DID_ERROR? > > Yes. That data is actually in the sense buffer, but since I'm also > setting DID_ERROR, scsi_decide_disposition isn't using it. I've got a > patch to do just as you suggest, to stop setting DID_ERROR when there > is more detailed error data available, but it will need some > additional testing before I submit, as it will impact much more than > just this case. I agree. In this case where a command is not supported, a check condition would be a better way to signal the failure to the SCSI midlayer. -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH] scsi: sd_zbc: Disable zoned block devices with scsi-mq
Christoph, > But it seems like we need to refne the always unprepare patch first, > to make sure we only release resources, but don't clear the > scmd->retries field. The NVMe driver already works that way, so > we have an example to follow. Agree! -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 0/4] constify scsi/tty parisc_device_id
On 19.08.2017 19:54, Arvind Yadav wrote: > parisc_device_id are not supposed to change at runtime. All functions > working with parisc_device_id provided by work with > const parisc_device_id. So mark the non-const structs as const. > > Arvind Yadav (4): > [PATCH 1/4] scsi: lasi700: constify parisc_device_id > [PATCH 2/4] scsi: zalon: constify parisc_device_id > [PATCH 3/4] tty: 8250: constify parisc_device_id > [PATCH 4/4] tty: mux: constify parisc_device_id NAK. Please don't apply. I have other patches in my tree which will move those consts into __init sections instead. Thanks, Helge > drivers/scsi/lasi700.c | 2 +- > drivers/scsi/zalon.c | 2 +- > drivers/tty/serial/8250/8250_gsc.c | 4 ++-- > drivers/tty/serial/mux.c | 4 ++-- > 4 files changed, 6 insertions(+), 6 deletions(-) >
[PATCH 0/2] Allow scsi_prep_fn to occur for retried commands
The following two patches address the hang issue being observed with Bart's patch on powerpc. The first patch moves the initialization of jiffies_at_alloc from scsi_init_command to scsi_init_rq, and ensures we don't zero jiffies_at_alloc in scsi_init_command. The second patch saves / restores the retry counter in scsi_init_command which lets us go through scsi_init_command for retries and not forget why we were there. These patches have only been boot tested on my Power machine with ipr to ensure they fix the issue I was seeing. -Brian -- Brian King Power Linux I/O IBM Linux Technology Center
[PATCH 1/2] scsi: Move scsi_cmd->jiffies_at_alloc initialization to allocation time
Move the initialization of scsi_cmd->jiffies_at_alloc to allocation time rather than prep time. Also ensure that jiffies_at_alloc is preserved when we go through prep. This lets us send retries through prep again and not break the overall retry timer logic in scsi_softirq_done. Suggested-by: Bart Van Assche Signed-off-by: Brian King --- Index: linux-2.6.git/drivers/scsi/scsi_lib.c === --- linux-2.6.git.orig/drivers/scsi/scsi_lib.c +++ linux-2.6.git/drivers/scsi/scsi_lib.c @@ -1154,6 +1154,7 @@ void scsi_init_command(struct scsi_devic void *buf = cmd->sense_buffer; void *prot = cmd->prot_sdb; unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA; + unsigned long jiffies_at_alloc = cmd->jiffies_at_alloc; /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, @@ -1164,7 +1165,7 @@ void scsi_init_command(struct scsi_devic cmd->prot_sdb = prot; cmd->flags = unchecked_isa_dma; INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); - cmd->jiffies_at_alloc = jiffies; + cmd->jiffies_at_alloc = jiffies_at_alloc; scsi_add_cmd_to_list(cmd); } @@ -2119,6 +2120,7 @@ static int scsi_init_rq(struct request_q if (!cmd->sense_buffer) goto fail; cmd->req.sense = cmd->sense_buffer; + cmd->jiffies_at_alloc = jiffies; if (scsi_host_get_prot(shost) >= SHOST_DIX_TYPE0_PROTECTION) { cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp);
[PATCH 2/2] scsi: Preserve retry counter through scsi_prep_fn
Save / restore the retry counter in scsi_cmd in scsi_init_command. This allows us to go back through scsi_init_command for retries and not forget we are doing a retry. Signed-off-by: Brian King --- Index: linux-2.6.git/drivers/scsi/scsi_lib.c === --- linux-2.6.git.orig/drivers/scsi/scsi_lib.c +++ linux-2.6.git/drivers/scsi/scsi_lib.c @@ -1155,6 +1155,7 @@ void scsi_init_command(struct scsi_devic void *prot = cmd->prot_sdb; unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA; unsigned long jiffies_at_alloc = cmd->jiffies_at_alloc; + int retries = cmd->retries; /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, @@ -1166,6 +1167,7 @@ void scsi_init_command(struct scsi_devic cmd->flags = unchecked_isa_dma; INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); cmd->jiffies_at_alloc = jiffies_at_alloc; + cmd->retries = retries; scsi_add_cmd_to_list(cmd); }
Re: [PATCH 1/2] scsi: Move scsi_cmd->jiffies_at_alloc initialization to allocation time
Scratch this one... Version 2 on the way with the corresponding changes in scsi_init_request... -Brian -- Brian King Power Linux I/O IBM Linux Technology Center
[PATCHv2 1/2] scsi: Move scsi_cmd->jiffies_at_alloc initialization to allocation time
This second version also sets up jiffies_at_alloc in scsi_init_request. This has been tested without the second patch in the series and I've confirmed I now see the following in the logs after booting: [ 121.718088] sd 1:2:0:0: timing out command, waited 120s [ 121.798081] sd 1:2:1:0: timing out command, waited 120s Without this patch I was never seeing these messages, indicating the retry timer code wasn't working. Also, after seeing these messages, I've confirmed there are no longer any hung tasks in the kernel with sysrq-w, while before, without this patch, I would see hung tasks for the scsi_report_opcodes calls which were getting retried forever. 8< Move the initialization of scsi_cmd->jiffies_at_alloc to allocation time rather than prep time. Also ensure that jiffies_at_alloc is preserved when we go through prep. This lets us send retries through prep again and not break the overall retry timer logic in scsi_softirq_done. Suggested-by: Bart Van Assche Signed-off-by: Brian King --- Index: linux-2.6.git/drivers/scsi/scsi_lib.c === --- linux-2.6.git.orig/drivers/scsi/scsi_lib.c +++ linux-2.6.git/drivers/scsi/scsi_lib.c @@ -1154,6 +1154,7 @@ void scsi_init_command(struct scsi_devic void *buf = cmd->sense_buffer; void *prot = cmd->prot_sdb; unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA; + unsigned long jiffies_at_alloc = cmd->jiffies_at_alloc; /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, @@ -1164,7 +1165,7 @@ void scsi_init_command(struct scsi_devic cmd->prot_sdb = prot; cmd->flags = unchecked_isa_dma; INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); - cmd->jiffies_at_alloc = jiffies; + cmd->jiffies_at_alloc = jiffies_at_alloc; scsi_add_cmd_to_list(cmd); } @@ -2016,6 +2017,7 @@ static int scsi_init_request(struct blk_ if (!cmd->sense_buffer) return -ENOMEM; cmd->req.sense = cmd->sense_buffer; + cmd->jiffies_at_alloc = jiffies; if (scsi_host_get_prot(shost)) { sg = (void *)cmd + sizeof(struct scsi_cmnd) + @@ -2119,6 +2121,7 @@ static int scsi_init_rq(struct request_q if (!cmd->sense_buffer) goto fail; cmd->req.sense = cmd->sense_buffer; + cmd->jiffies_at_alloc = jiffies; if (scsi_host_get_prot(shost) >= SHOST_DIX_TYPE0_PROTECTION) { cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp);
[PATCH] storvsc: do not assume SG list is continuous when doing bounce buffers (for 4.1 stable only)
From: Long Li This patch is for linux-stable 4.1 branch only. storvsc checks the SG list for gaps before passing them to Hyper-v device. If there are gaps, data is copied to a bounce buffer and a continuous data buffer is passed to Hyper-V. The check on gaps assumes SG list is continuous, and not chained. This is not always true. Failing the check may result in incorrect I/O data passed to the Hyper-v device. This code path is not used post Linux 4.1. Signed-off-by: Long Li --- drivers/scsi/storvsc_drv.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 6c52d14..14dc5c6 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -584,17 +584,18 @@ static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count) for (i = 0; i < sg_count; i++) { if (i == 0) { /* make sure 1st one does not have hole */ - if (sgl[i].offset + sgl[i].length != PAGE_SIZE) + if (sgl->offset + sgl->length != PAGE_SIZE) return i; } else if (i == sg_count - 1) { /* make sure last one does not have hole */ - if (sgl[i].offset != 0) + if (sgl->offset != 0) return i; } else { /* make sure no hole in the middle */ - if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0) + if (sgl->length != PAGE_SIZE || sgl->offset != 0) return i; } + sgl = sg_next(sgl); } return -1; } -- 2.7.4
Re: [PATCH] storvsc: do not assume SG list is continuous when doing bounce buffers (for 4.1 stable only)
Wouldn't it make sense to backport the changes to set the virt_boundary (which probably still is the SG_GAPS flag in such an old kernel)?
Re: [Regression 4.13-rc1] Resume does not work on Lenovo X60t
Dear Christoph, On 2017-08-21 20:41, Christoph Hellwig wrote: with 4.13-rc6 we're not using blk-mq by default any more, do you still see the issue with that one? Yes, I do see it this commit 6470812e2226 (Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc). ``` 00.831: [ 575.945132] BUG: unable to handle kernel NULL pointer dereference at 00f4 00.830: [ 575.948009] IP: blk_set_runtime_active+0x27/0x60 00.830: [ 575.948009] *pde = 00.831: [ 575.948009] 00.831: [ 575.948009] Oops: 0002 [#1] SMP 00.831: [ 575.948009] Modules linked in: joydev wacom_w8001 serport cpufreq_powersave cpufreq_conservative cpufreq_userspace binfmt_misc iTCO_wdt iTCO_vendor_support arc4 coretemp snd_hda_codec_analog snd_hda_codec_generic iwl3945 snd_hda_intel pcmcia iwlegacy snd_hda_codec kvm mac80211 snd_hda_core irqbypass yenta_socket snd_pcsp lpc_ich snd_hwdep thinkpad_acpi pcmcia_rsrc mfd_core serio_raw snd_pcm sg pcmcia_core nvram cfg80211 snd_timer rng_core snd rfkill battery soundcore shpchp evdev ac acpi_cpufreq parport_pc ppdev lp parport ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 fscrypto ecb cbc algif_skcipher af_alg dm_crypt dm_mod sr_mod cdrom sd_mod ata_generic ahci libahci sdhci_pci firewire_ohci ata_piix sdhci firewire_core libata e1000e i2c_i801 psmouse mmc_core crc_itu_t ptp scsi_mod i915 pps_core 00.831: [ 575.948009] ehci_pci video button uhci_hcd i2c_algo_bit ehci_hcd drm_kms_helper thermal usbcore syscopyarea sysfillrect sysimgblt fb_sys_fops drm 00.831: [ 575.948009] CPU: 0 PID: 1126 Comm: kworker/u4:36 Not tainted 4.13.0-rc6+ #110 00.831: [ 575.948009] Hardware name: LENOVO 636338U/636338U, BIOS CBET4000 TIMELESS 01/01/1970 00.831: [ 575.948009] Workqueue: events_unbound async_run_entry_fn 00.831: [ 575.948009] task: f2ed8bc0 task.stack: f2ecc000 00.831: [ 575.948009] EIP: blk_set_runtime_active+0x27/0x60 00.831: [ 575.948009] EFLAGS: 00010046 CPU: 0 00.831: [ 575.948009] EAX: EBX: f5f3f820 ECX: f5f3f918 EDX: 00010d7b 00.831: [ 575.948009] ESI: f8ac3cc0 EDI: 0010 EBP: 0010 ESP: f2ecdea4 00.831: [ 575.948009] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 00.831: [ 575.948009] CR0: 80050033 CR2: 00f4 CR3: 0e3a9000 CR4: 06d0 00.831: [ 575.948009] Call Trace: 00.831: [ 575.948009] ? scsi_bus_resume_common+0x6e/0x110 [scsi_mod] 00.831: [ 575.948009] ? dpm_run_callback+0x4f/0x150 00.831: [ 575.948009] ? wait_for_completion+0x29/0x140 00.831: [ 575.948009] ? scsi_bus_thaw+0x10/0x10 [scsi_mod] 00.831: [ 575.948009] ? device_resume+0x8e/0x180 00.831: [ 575.948009] ? async_resume+0x1b/0x40 00.831: [ 575.948009] ? async_run_entry_fn+0x3f/0x1a0 00.831: [ 575.948009] ? process_one_work+0x136/0x310 00.831: [ 575.948009] ? worker_thread+0x39/0x3b0 00.831: [ 575.948009] ? kthread+0xd7/0x110 00.831: [ 575.948009] ? process_one_work+0x310/0x310 00.831: [ 575.948009] ? kthread_create_on_node+0x30/0x30 00.831: [ 575.948009] ? ret_from_fork+0x19/0x24 00.831: [ 575.948009] Code: 8d 74 26 00 3e 8d 74 26 00 53 89 c3 8b 80 fc 00 00 00 e8 2d 48 32 00 31 c0 8b 15 20 9e 24 ce 89 83 54 01 00 00 8b 83 50 01 00 00 <89> 90 f4 00 00 00 ba 09 00 00 00 8b 83 50 01 00 00 e8 f3 f2 16 00.831: [ 575.948009] EIP: blk_set_runtime_active+0x27/0x60 SS:ESP: 0068:f2ecdea4 00.831: [ 575.948009] CR2: 00f4 00.831: [ 575.948009] ---[ end trace b3f1ac10115418ab ]--- 00.831: [ 576.195662] pciehp :00:1c.0:pcie004: Timeout on hotplug command 0x1038 (issued 574920 msec ago) 00.831: [ 576.204847] pciehp :00:1c.0:pcie004: Device :01:00.0 already exists at :01:00, cannot hot-add 00.832: [ 576.214460] pciehp :00:1c.0:pcie004: Cannot add device at :01:00 00.834: [ 576.223117] atkbd serio0: Spurious ACK on isa0060/serio0. Some program might be trying to access hardware directly. 00.834: [ 576.233968] ata1.00: configured for UDMA/33 00.927: [ 576.328159] pciehp :00:1c.0:pcie004: Device :01:00.0 already exists at :01:00, cannot hot-add 00.929: [ 576.340348] pciehp :00:1c.0:pcie004: Cannot add device at :01:00 01.002: [ 576.420139] usb 5-6: reset high-speed USB device number 2 using ehci-pci 01.372: [ 576.796072] firewire_core :05:00.1: rediscovered device fw0 03.010: [ 578.440083] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300) 05.274: [ 580.710027] ata3.00: ATA Identify Device Log not supported 05.276: [ 580.718136] ata3.00: Security Log not supported 05.279: [ 580.725856] ata3.00: ATA Identify Device Log not supported 05.282: [ 580.733887] ata3.00: Security Log not supported 05.284: [ 580.740838] ata3.00: configured for UDMA/100 ``` Kind regards, Paul
Re: [PATCH 0/2] Allow scsi_prep_fn to occur for retried commands
On Mon, 2017-08-21 at 17:11 -0500, Brian King wrote: > The following two patches address the hang issue being observed > with Bart's patch on powerpc. The first patch moves the initialization > of jiffies_at_alloc from scsi_init_command to scsi_init_rq, and ensures > we don't zero jiffies_at_alloc in scsi_init_command. The second patch > saves / restores the retry counter in scsi_init_command which lets us > go through scsi_init_command for retries and not forget why we were > there. > > These patches have only been boot tested on my Power machine with ipr > to ensure they fix the issue I was seeing. > > -Brian > Thank you Brian and Bart, for your efforts to fix this bug. I tested these patches on my PowerPC machine and system booted fine. [PATCHv2 1/2] scsi: Move scsi_cmd->jiffies_at_alloc initialization to allocation time [PATCH 2/2] scsi: Preserve retry counter through scsi_prep_fn Reported-and-Tested-by: Abdul Haleem -- Regard's Abdul Haleem IBM Linux Technology Centre
Re: [PATCH 1/2] scsi: Move scsi_cmd->jiffies_at_alloc initialization to allocation time
On Mon, Aug 21, 2017 at 05:13:20PM -0500, Brian King wrote: > Move the initialization of scsi_cmd->jiffies_at_alloc to allocation > time rather than prep time. Also ensure that jiffies_at_alloc > is preserved when we go through prep. This lets us send retries > through prep again and not break the overall retry timer logic > in scsi_softirq_done. > > Suggested-by: Bart Van Assche > Signed-off-by: Brian King As far as I can tell this will never set jiffies_at_alloc for the blk-mq path.
Re: [PATCH 2/2] scsi: Preserve retry counter through scsi_prep_fn
On Mon, Aug 21, 2017 at 05:14:00PM -0500, Brian King wrote: > Save / restore the retry counter in scsi_cmd in scsi_init_command. > This allows us to go back through scsi_init_command for retries > and not forget we are doing a retry. So where will we initialize it to zero now?