--- zzzz-none-000/linux-3.10.107/drivers/message/fusion/mptsas.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/message/fusion/mptsas.c 2021-02-04 17:41:59.000000000 +0000 @@ -990,11 +990,10 @@ MpiEventDataSasDeviceStatusChange_t *sas_event_data) { struct fw_event_work *fw_event; - int sz; - sz = offsetof(struct fw_event_work, event_data) + - sizeof(MpiEventDataSasDeviceStatusChange_t); - fw_event = kzalloc(sz, GFP_ATOMIC); + fw_event = kzalloc(sizeof(*fw_event) + + sizeof(MpiEventDataSasDeviceStatusChange_t), + GFP_ATOMIC); if (!fw_event) { printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, __func__, __LINE__); @@ -1011,10 +1010,8 @@ mptsas_queue_rescan(MPT_ADAPTER *ioc) { struct fw_event_work *fw_event; - int sz; - sz = offsetof(struct fw_event_work, event_data); - fw_event = kzalloc(sz, GFP_ATOMIC); + fw_event = kzalloc(sizeof(*fw_event), GFP_ATOMIC); if (!fw_event) { printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, __func__, __LINE__); @@ -1206,27 +1203,28 @@ "(mf = %p, mr = %p)\n", ioc->name, mf, mr)); pScsiTmReply = (SCSITaskMgmtReply_t *)mr; - if (pScsiTmReply) { - dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT - "\tTaskMgmt completed: fw_channel = %d, fw_id = %d,\n" - "\ttask_type = 0x%02X, iocstatus = 0x%04X " - "loginfo = 0x%08X,\n\tresponse_code = 0x%02X, " - "term_cmnds = %d\n", ioc->name, - pScsiTmReply->Bus, pScsiTmReply->TargetID, - pScsiTmReply->TaskType, - le16_to_cpu(pScsiTmReply->IOCStatus), - le32_to_cpu(pScsiTmReply->IOCLogInfo), - pScsiTmReply->ResponseCode, - le32_to_cpu(pScsiTmReply->TerminationCount))); - - if (pScsiTmReply->ResponseCode) - mptscsih_taskmgmt_response_code(ioc, - pScsiTmReply->ResponseCode); - } + if (!pScsiTmReply) + return 0; - if (pScsiTmReply && (pScsiTmReply->TaskType == + dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT + "\tTaskMgmt completed: fw_channel = %d, fw_id = %d,\n" + "\ttask_type = 0x%02X, iocstatus = 0x%04X " + "loginfo = 0x%08X,\n\tresponse_code = 0x%02X, " + "term_cmnds = %d\n", ioc->name, + pScsiTmReply->Bus, pScsiTmReply->TargetID, + pScsiTmReply->TaskType, + le16_to_cpu(pScsiTmReply->IOCStatus), + le32_to_cpu(pScsiTmReply->IOCLogInfo), + pScsiTmReply->ResponseCode, + le32_to_cpu(pScsiTmReply->TerminationCount))); + + if (pScsiTmReply->ResponseCode) + mptscsih_taskmgmt_response_code(ioc, + pScsiTmReply->ResponseCode); + + if (pScsiTmReply->TaskType == MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK || pScsiTmReply->TaskType == - MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET)) { + MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET) { ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_RF_VALID; memcpy(ioc->taskmgmt_cmds.reply, mr, @@ -1575,7 +1573,7 @@ mptsas_port_delete(ioc, phy_info->port_details); } -struct mptsas_phyinfo * +static struct mptsas_phyinfo * mptsas_refreshing_device_handles(MPT_ADAPTER *ioc, struct mptsas_devinfo *sas_device) { @@ -1896,7 +1894,7 @@ } static int -mptsas_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) +mptsas_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt) { MPT_SCSI_HOST *hd; MPT_ADAPTER *ioc; @@ -1904,11 +1902,11 @@ if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) { SCpnt->result = DID_NO_CONNECT << 16; - done(SCpnt); + SCpnt->scsi_done(SCpnt); return 0; } - hd = shost_priv(SCpnt->device->host); + hd = shost_priv(shost); ioc = hd->ioc; if (ioc->sas_discovery_quiesce_io) @@ -1917,11 +1915,9 @@ if (ioc->debug_level & MPT_DEBUG_SCSI) scsi_print_command(SCpnt); - return mptscsih_qcmd(SCpnt,done); + return mptscsih_qcmd(SCpnt); } -static DEF_SCSI_QCMD(mptsas_qcmd) - /** * mptsas_mptsas_eh_timed_out - resets the scsi_cmnd timeout * if the device under question is currently in the @@ -2235,10 +2231,10 @@ } /* do we need to support multiple segments? */ - if (bio_segments(req->bio) > 1 || bio_segments(rsp->bio) > 1) { - printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n", - ioc->name, __func__, bio_segments(req->bio), blk_rq_bytes(req), - bio_segments(rsp->bio), blk_rq_bytes(rsp)); + if (bio_multiple_segments(req->bio) || + bio_multiple_segments(rsp->bio)) { + printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u, rsp %u\n", + ioc->name, __func__, blk_rq_bytes(req), blk_rq_bytes(rsp)); return -EINVAL; } @@ -3650,7 +3646,7 @@ * @handle: * */ -struct mptsas_portinfo * +static struct mptsas_portinfo * mptsas_expander_add(MPT_ADAPTER *ioc, u16 handle) { struct mptsas_portinfo buffer, *port_info; @@ -3765,7 +3761,7 @@ printk(MYIOC_s_DEBUG_FMT "SDEV OUTSTANDING CMDS" "%d\n", ioc->name, - sdev->device_busy)); + atomic_read(&sdev->device_busy))); } } @@ -3858,10 +3854,8 @@ phy_info = mptsas_find_phyinfo_by_sas_address(ioc, sas_info->sas_address); - if (phy_info) { - mptsas_del_end_device(ioc, phy_info); - goto redo_device_scan; - } + mptsas_del_end_device(ioc, phy_info); + goto redo_device_scan; } else mptsas_volume_delete(ioc, sas_info->fw.id); } @@ -3872,9 +3866,8 @@ redo_expander_scan: list_for_each_entry(port_info, &ioc->sas_topology, list) { - if (port_info->phy_info && - (!(port_info->phy_info[0].identify.device_info & - MPI_SAS_DEVICE_INFO_SMP_TARGET))) + if (!(port_info->phy_info[0].identify.device_info & + MPI_SAS_DEVICE_INFO_SMP_TARGET)) continue; found_expander = 0; handle = 0xFFFF; @@ -4096,7 +4089,7 @@ continue; } depth = scsi_track_queue_full(sdev, - current_depth - 1); + sdev->queue_depth - 1); if (depth > 0) sdev_printk(KERN_INFO, sdev, "Queue depth reduced to (%d)\n", @@ -4106,7 +4099,7 @@ "Tagged Command Queueing is being " "disabled\n"); else if (depth == 0) - sdev_printk(KERN_INFO, sdev, + sdev_printk(KERN_DEBUG, sdev, "Queue depth not changed yet\n"); } } @@ -4985,7 +4978,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply) { u32 event = le32_to_cpu(reply->Event); - int sz, event_data_sz; + int event_data_sz; struct fw_event_work *fw_event; unsigned long delay; @@ -5095,8 +5088,7 @@ event_data_sz = ((reply->MsgLength * 4) - offsetof(EventNotificationReply_t, Data)); - sz = offsetof(struct fw_event_work, event_data) + event_data_sz; - fw_event = kzalloc(sz, GFP_ATOMIC); + fw_event = kzalloc(sizeof(*fw_event) + event_data_sz, GFP_ATOMIC); if (!fw_event) { printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, __func__, __LINE__); @@ -5323,7 +5315,7 @@ return error; } -void +static void mptsas_shutdown(struct pci_dev *pdev) { MPT_ADAPTER *ioc = pci_get_drvdata(pdev);