aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/gdth.c8
-rw-r--r--drivers/scsi/libsas/sas_ata.c1
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c1
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c24
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c64
-rw-r--r--drivers/scsi/pmcraid.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c6
-rw-r--r--drivers/scsi/qla4xxx/ql4_nx.c1
-rw-r--r--drivers/scsi/scsi_lib.c6
-rw-r--r--drivers/scsi/scsi_sysfs.c3
-rw-r--r--drivers/scsi/sd.c24
15 files changed, 117 insertions, 30 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index b860d650a563..4cf7ffa2dad3 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4175,6 +4175,14 @@ static int ioc_general(void __user *arg, char *cmnd)
4175 ha = gdth_find_ha(gen.ionode); 4175 ha = gdth_find_ha(gen.ionode);
4176 if (!ha) 4176 if (!ha)
4177 return -EFAULT; 4177 return -EFAULT;
4178
4179 if (gen.data_len > INT_MAX)
4180 return -EINVAL;
4181 if (gen.sense_len > INT_MAX)
4182 return -EINVAL;
4183 if (gen.data_len + gen.sense_len > INT_MAX)
4184 return -EINVAL;
4185
4178 if (gen.data_len + gen.sense_len != 0) { 4186 if (gen.data_len + gen.sense_len != 0) {
4179 if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len, 4187 if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len,
4180 FALSE, &paddr))) 4188 FALSE, &paddr)))
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 042153cbbde1..ddbade7beec9 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -347,6 +347,7 @@ static int sas_ata_scr_read(struct ata_link *link, unsigned int sc_reg_in,
347static struct ata_port_operations sas_sata_ops = { 347static struct ata_port_operations sas_sata_ops = {
348 .phy_reset = sas_ata_phy_reset, 348 .phy_reset = sas_ata_phy_reset,
349 .post_internal_cmd = sas_ata_post_internal, 349 .post_internal_cmd = sas_ata_post_internal,
350 .qc_defer = ata_std_qc_defer,
350 .qc_prep = ata_noop_qc_prep, 351 .qc_prep = ata_noop_qc_prep,
351 .qc_issue = sas_ata_qc_issue, 352 .qc_issue = sas_ata_qc_issue,
352 .qc_fill_rtf = sas_ata_qc_fill_rtf, 353 .qc_fill_rtf = sas_ata_qc_fill_rtf,
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index f0cfba9a1fc8..baf2b6039952 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -649,6 +649,7 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
649 649
650 spin_lock_irqsave(shost->host_lock, flags); 650 spin_lock_irqsave(shost->host_lock, flags);
651 list_splice_init(&shost->eh_cmd_q, &eh_work_q); 651 list_splice_init(&shost->eh_cmd_q, &eh_work_q);
652 shost->host_eh_scheduled = 0;
652 spin_unlock_irqrestore(shost->host_lock, flags); 653 spin_unlock_irqrestore(shost->host_lock, flags);
653 654
654 SAS_DPRINTK("Enter %s\n", __func__); 655 SAS_DPRINTK("Enter %s\n", __func__);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 57bcd5c9dcff..9e590265a020 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -2057,9 +2057,9 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2057 /* adjust hba_queue_depth, reply_free_queue_depth, 2057 /* adjust hba_queue_depth, reply_free_queue_depth,
2058 * and queue_size 2058 * and queue_size
2059 */ 2059 */
2060 ioc->hba_queue_depth -= queue_diff; 2060 ioc->hba_queue_depth -= (queue_diff / 2);
2061 ioc->reply_free_queue_depth -= queue_diff; 2061 ioc->reply_free_queue_depth -= (queue_diff / 2);
2062 queue_size -= queue_diff; 2062 queue_size = facts->MaxReplyDescriptorPostQueueDepth;
2063 } 2063 }
2064 ioc->reply_post_queue_depth = queue_size; 2064 ioc->reply_post_queue_depth = queue_size;
2065 2065
@@ -3662,6 +3662,11 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3662 ioc->scsih_cmds.status = MPT2_CMD_NOT_USED; 3662 ioc->scsih_cmds.status = MPT2_CMD_NOT_USED;
3663 mutex_init(&ioc->scsih_cmds.mutex); 3663 mutex_init(&ioc->scsih_cmds.mutex);
3664 3664
3665 /* scsih internal command bits */
3666 ioc->scsih_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3667 ioc->scsih_cmds.status = MPT2_CMD_NOT_USED;
3668 mutex_init(&ioc->scsih_cmds.mutex);
3669
3665 /* task management internal command bits */ 3670 /* task management internal command bits */
3666 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); 3671 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3667 ioc->tm_cmds.status = MPT2_CMD_NOT_USED; 3672 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
@@ -3786,6 +3791,8 @@ mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc)
3786static void 3791static void
3787_base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) 3792_base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
3788{ 3793{
3794 mpt2sas_scsih_reset_handler(ioc, reset_phase);
3795 mpt2sas_ctl_reset_handler(ioc, reset_phase);
3789 switch (reset_phase) { 3796 switch (reset_phase) {
3790 case MPT2_IOC_PRE_RESET: 3797 case MPT2_IOC_PRE_RESET:
3791 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: " 3798 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: "
@@ -3816,8 +3823,6 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
3816 "MPT2_IOC_DONE_RESET\n", ioc->name, __func__)); 3823 "MPT2_IOC_DONE_RESET\n", ioc->name, __func__));
3817 break; 3824 break;
3818 } 3825 }
3819 mpt2sas_scsih_reset_handler(ioc, reset_phase);
3820 mpt2sas_ctl_reset_handler(ioc, reset_phase);
3821} 3826}
3822 3827
3823/** 3828/**
@@ -3871,6 +3876,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3871{ 3876{
3872 int r; 3877 int r;
3873 unsigned long flags; 3878 unsigned long flags;
3879 u8 pe_complete = ioc->wait_for_port_enable_to_complete;
3874 3880
3875 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: enter\n", ioc->name, 3881 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: enter\n", ioc->name,
3876 __func__)); 3882 __func__));
@@ -3913,6 +3919,14 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3913 if (r) 3919 if (r)
3914 goto out; 3920 goto out;
3915 _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET); 3921 _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET);
3922
3923 /* If this hard reset is called while port enable is active, then
3924 * there is no reason to call make_ioc_operational
3925 */
3926 if (pe_complete) {
3927 r = -EFAULT;
3928 goto out;
3929 }
3916 r = _base_make_ioc_operational(ioc, sleep_flag); 3930 r = _base_make_ioc_operational(ioc, sleep_flag);
3917 if (!r) 3931 if (!r)
3918 _base_reset_handler(ioc, MPT2_IOC_DONE_RESET); 3932 _base_reset_handler(ioc, MPT2_IOC_DONE_RESET);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 16e99b686354..794d927f70c1 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -819,7 +819,7 @@ _scsih_is_end_device(u32 device_info)
819} 819}
820 820
821/** 821/**
822 * mptscsih_get_scsi_lookup - returns scmd entry 822 * _scsih_scsi_lookup_get - returns scmd entry
823 * @ioc: per adapter object 823 * @ioc: per adapter object
824 * @smid: system request message index 824 * @smid: system request message index
825 * 825 *
@@ -832,6 +832,28 @@ _scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid)
832} 832}
833 833
834/** 834/**
835 * _scsih_scsi_lookup_get_clear - returns scmd entry
836 * @ioc: per adapter object
837 * @smid: system request message index
838 *
839 * Returns the smid stored scmd pointer.
840 * Then will derefrence the stored scmd pointer.
841 */
842static inline struct scsi_cmnd *
843_scsih_scsi_lookup_get_clear(struct MPT2SAS_ADAPTER *ioc, u16 smid)
844{
845 unsigned long flags;
846 struct scsi_cmnd *scmd;
847
848 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
849 scmd = ioc->scsi_lookup[smid - 1].scmd;
850 ioc->scsi_lookup[smid - 1].scmd = NULL;
851 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
852
853 return scmd;
854}
855
856/**
835 * _scsih_scsi_lookup_find_by_scmd - scmd lookup 857 * _scsih_scsi_lookup_find_by_scmd - scmd lookup
836 * @ioc: per adapter object 858 * @ioc: per adapter object
837 * @smid: system request message index 859 * @smid: system request message index
@@ -2957,9 +2979,6 @@ _scsih_check_topo_delete_events(struct MPT2SAS_ADAPTER *ioc,
2957 u16 handle; 2979 u16 handle;
2958 2980
2959 for (i = 0 ; i < event_data->NumEntries; i++) { 2981 for (i = 0 ; i < event_data->NumEntries; i++) {
2960 if (event_data->PHY[i].PhyStatus &
2961 MPI2_EVENT_SAS_TOPO_PHYSTATUS_VACANT)
2962 continue;
2963 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); 2982 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
2964 if (!handle) 2983 if (!handle)
2965 continue; 2984 continue;
@@ -3186,7 +3205,7 @@ _scsih_flush_running_cmds(struct MPT2SAS_ADAPTER *ioc)
3186 u16 count = 0; 3205 u16 count = 0;
3187 3206
3188 for (smid = 1; smid <= ioc->scsiio_depth; smid++) { 3207 for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
3189 scmd = _scsih_scsi_lookup_get(ioc, smid); 3208 scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
3190 if (!scmd) 3209 if (!scmd)
3191 continue; 3210 continue;
3192 count++; 3211 count++;
@@ -3778,7 +3797,7 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
3778 u32 response_code = 0; 3797 u32 response_code = 0;
3779 3798
3780 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 3799 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
3781 scmd = _scsih_scsi_lookup_get(ioc, smid); 3800 scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
3782 if (scmd == NULL) 3801 if (scmd == NULL)
3783 return 1; 3802 return 1;
3784 3803
@@ -4940,6 +4959,12 @@ _scsih_sas_device_status_change_event(struct MPT2SAS_ADAPTER *ioc,
4940 event_data); 4959 event_data);
4941#endif 4960#endif
4942 4961
4962 /* In MPI Revision K (0xC), the internal device reset complete was
4963 * implemented, so avoid setting tm_busy flag for older firmware.
4964 */
4965 if ((ioc->facts.HeaderVersion >> 8) < 0xC)
4966 return;
4967
4943 if (event_data->ReasonCode != 4968 if (event_data->ReasonCode !=
4944 MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET && 4969 MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET &&
4945 event_data->ReasonCode != 4970 event_data->ReasonCode !=
@@ -5034,6 +5059,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
5034 struct fw_event_work *fw_event) 5059 struct fw_event_work *fw_event)
5035{ 5060{
5036 struct scsi_cmnd *scmd; 5061 struct scsi_cmnd *scmd;
5062 struct scsi_device *sdev;
5037 u16 smid, handle; 5063 u16 smid, handle;
5038 u32 lun; 5064 u32 lun;
5039 struct MPT2SAS_DEVICE *sas_device_priv_data; 5065 struct MPT2SAS_DEVICE *sas_device_priv_data;
@@ -5044,12 +5070,17 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
5044 Mpi2EventDataSasBroadcastPrimitive_t *event_data = fw_event->event_data; 5070 Mpi2EventDataSasBroadcastPrimitive_t *event_data = fw_event->event_data;
5045#endif 5071#endif
5046 u16 ioc_status; 5072 u16 ioc_status;
5073 unsigned long flags;
5074 int r;
5075
5047 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "broadcast primative: " 5076 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "broadcast primative: "
5048 "phy number(%d), width(%d)\n", ioc->name, event_data->PhyNum, 5077 "phy number(%d), width(%d)\n", ioc->name, event_data->PhyNum,
5049 event_data->PortWidth)); 5078 event_data->PortWidth));
5050 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: enter\n", ioc->name, 5079 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: enter\n", ioc->name,
5051 __func__)); 5080 __func__));
5052 5081
5082 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
5083 ioc->broadcast_aen_busy = 0;
5053 termination_count = 0; 5084 termination_count = 0;
5054 query_count = 0; 5085 query_count = 0;
5055 mpi_reply = ioc->tm_cmds.reply; 5086 mpi_reply = ioc->tm_cmds.reply;
@@ -5057,7 +5088,8 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
5057 scmd = _scsih_scsi_lookup_get(ioc, smid); 5088 scmd = _scsih_scsi_lookup_get(ioc, smid);
5058 if (!scmd) 5089 if (!scmd)
5059 continue; 5090 continue;
5060 sas_device_priv_data = scmd->device->hostdata; 5091 sdev = scmd->device;
5092 sas_device_priv_data = sdev->hostdata;
5061 if (!sas_device_priv_data || !sas_device_priv_data->sas_target) 5093 if (!sas_device_priv_data || !sas_device_priv_data->sas_target)
5062 continue; 5094 continue;
5063 /* skip hidden raid components */ 5095 /* skip hidden raid components */
@@ -5073,6 +5105,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
5073 lun = sas_device_priv_data->lun; 5105 lun = sas_device_priv_data->lun;
5074 query_count++; 5106 query_count++;
5075 5107
5108 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
5076 mpt2sas_scsih_issue_tm(ioc, handle, 0, 0, lun, 5109 mpt2sas_scsih_issue_tm(ioc, handle, 0, 0, lun,
5077 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, smid, 30, NULL); 5110 MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, smid, 30, NULL);
5078 ioc->tm_cmds.status = MPT2_CMD_NOT_USED; 5111 ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
@@ -5082,14 +5115,20 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
5082 (mpi_reply->ResponseCode == 5115 (mpi_reply->ResponseCode ==
5083 MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED || 5116 MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED ||
5084 mpi_reply->ResponseCode == 5117 mpi_reply->ResponseCode ==
5085 MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC)) 5118 MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC)) {
5119 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
5086 continue; 5120 continue;
5087 5121 }
5088 mpt2sas_scsih_issue_tm(ioc, handle, 0, 0, lun, 5122 r = mpt2sas_scsih_issue_tm(ioc, handle, sdev->channel, sdev->id,
5089 MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, 0, 30, NULL); 5123 sdev->lun, MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK, smid, 30,
5124 scmd);
5125 if (r == FAILED)
5126 sdev_printk(KERN_WARNING, sdev, "task abort: FAILED "
5127 "scmd(%p)\n", scmd);
5090 termination_count += le32_to_cpu(mpi_reply->TerminationCount); 5128 termination_count += le32_to_cpu(mpi_reply->TerminationCount);
5129 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
5091 } 5130 }
5092 ioc->broadcast_aen_busy = 0; 5131 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
5093 5132
5094 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT 5133 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT
5095 "%s - exit, query_count = %d termination_count = %d\n", 5134 "%s - exit, query_count = %d termination_count = %d\n",
@@ -6685,6 +6724,7 @@ _scsih_remove(struct pci_dev *pdev)
6685 destroy_workqueue(wq); 6724 destroy_workqueue(wq);
6686 6725
6687 /* release all the volumes */ 6726 /* release all the volumes */
6727 _scsih_ir_shutdown(ioc);
6688 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, 6728 list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list,
6689 list) { 6729 list) {
6690 if (raid_device->starget) { 6730 if (raid_device->starget) {
diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
index 6cfa0145a1d7..dd78f9e8eb9b 100644
--- a/drivers/scsi/pmcraid.h
+++ b/drivers/scsi/pmcraid.h
@@ -568,7 +568,6 @@ struct pmcraid_cmd {
568 struct pmcraid_control_block *ioa_cb; 568 struct pmcraid_control_block *ioa_cb;
569 dma_addr_t ioa_cb_bus_addr; 569 dma_addr_t ioa_cb_bus_addr;
570 dma_addr_t dma_handle; 570 dma_addr_t dma_handle;
571 u8 *sense_buffer;
572 571
573 /* pointer to mid layer structure of SCSI commands */ 572 /* pointer to mid layer structure of SCSI commands */
574 struct scsi_cmnd *scsi_cmd; 573 struct scsi_cmnd *scsi_cmd;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 1a1b281cea33..16df82ac1b26 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -92,6 +92,7 @@ extern int ql2xshiftctondsd;
92extern int ql2xdbwr; 92extern int ql2xdbwr;
93extern int ql2xdontresethba; 93extern int ql2xdontresethba;
94extern int ql2xasynctmfenable; 94extern int ql2xasynctmfenable;
95extern int ql2xgffidenable;
95extern int ql2xenabledif; 96extern int ql2xenabledif;
96extern int ql2xenablehba_err_chk; 97extern int ql2xenablehba_err_chk;
97extern int ql2xtargetreset; 98extern int ql2xtargetreset;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 9c383baebe27..49e7b0916364 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3258,8 +3258,9 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
3258 continue; 3258 continue;
3259 3259
3260 /* Bypass ports whose FCP-4 type is not FCP_SCSI */ 3260 /* Bypass ports whose FCP-4 type is not FCP_SCSI */
3261 if (new_fcport->fc4_type != FC4_TYPE_FCP_SCSI && 3261 if (ql2xgffidenable &&
3262 new_fcport->fc4_type != FC4_TYPE_UNKNOWN) 3262 (new_fcport->fc4_type != FC4_TYPE_FCP_SCSI &&
3263 new_fcport->fc4_type != FC4_TYPE_UNKNOWN))
3263 continue; 3264 continue;
3264 3265
3265 /* Locate matching device in database. */ 3266 /* Locate matching device in database. */
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 579f02854665..de844996743c 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -1061,6 +1061,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
1061 fcp_cmnd->additional_cdb_len |= 2; 1061 fcp_cmnd->additional_cdb_len |= 2;
1062 1062
1063 int_to_scsilun(sp->cmd->device->lun, &fcp_cmnd->lun); 1063 int_to_scsilun(sp->cmd->device->lun, &fcp_cmnd->lun);
1064 host_to_fcp_swap((uint8_t *)&fcp_cmnd->lun, sizeof(fcp_cmnd->lun));
1064 memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); 1065 memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len);
1065 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len); 1066 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len);
1066 cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32( 1067 cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32(
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 0a71cc71eab2..424cf189af27 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -2740,6 +2740,7 @@ sufficient_dsds:
2740 goto queuing_error_fcp_cmnd; 2740 goto queuing_error_fcp_cmnd;
2741 2741
2742 int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun); 2742 int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun);
2743 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun));
2743 2744
2744 /* build FCP_CMND IU */ 2745 /* build FCP_CMND IU */
2745 memset(ctx->fcp_cmnd, 0, sizeof(struct fcp_cmnd)); 2746 memset(ctx->fcp_cmnd, 0, sizeof(struct fcp_cmnd));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 1e4bff695254..202a31ab2f18 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -160,6 +160,11 @@ MODULE_PARM_DESC(ql2xtargetreset,
160 "Enable target reset." 160 "Enable target reset."
161 "Default is 1 - use hw defaults."); 161 "Default is 1 - use hw defaults.");
162 162
163int ql2xgffidenable;
164module_param(ql2xgffidenable, int, S_IRUGO|S_IRUSR);
165MODULE_PARM_DESC(ql2xgffidenable,
166 "Enables GFF_ID checks of port type. "
167 "Default is 0 - Do not use GFF_ID information.");
163 168
164int ql2xasynctmfenable; 169int ql2xasynctmfenable;
165module_param(ql2xasynctmfenable, int, S_IRUGO|S_IRUSR); 170module_param(ql2xasynctmfenable, int, S_IRUGO|S_IRUSR);
@@ -2090,6 +2095,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2090 ha->init_cb_size = sizeof(struct mid_init_cb_81xx); 2095 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
2091 ha->gid_list_info_size = 8; 2096 ha->gid_list_info_size = 8;
2092 ha->optrom_size = OPTROM_SIZE_82XX; 2097 ha->optrom_size = OPTROM_SIZE_82XX;
2098 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
2093 ha->isp_ops = &qla82xx_isp_ops; 2099 ha->isp_ops = &qla82xx_isp_ops;
2094 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; 2100 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
2095 ha->flash_data_off = FARX_ACCESS_FLASH_DATA; 2101 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 5d4a3822382d..449256f2c5f8 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -5,6 +5,7 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/io.h>
8#include <linux/pci.h> 9#include <linux/pci.h>
9#include "ql4_def.h" 10#include "ql4_def.h"
10#include "ql4_glbl.h" 11#include "ql4_glbl.h"
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ee02d3838a0a..5bff8a2396e4 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1632,9 +1632,8 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
1632 1632
1633 blk_queue_max_segment_size(q, dma_get_max_seg_size(dev)); 1633 blk_queue_max_segment_size(q, dma_get_max_seg_size(dev));
1634 1634
1635 /* New queue, no concurrency on queue_flags */
1636 if (!shost->use_clustering) 1635 if (!shost->use_clustering)
1637 queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q); 1636 q->limits.cluster = 0;
1638 1637
1639 /* 1638 /*
1640 * set a reasonable default alignment on word boundaries: the 1639 * set a reasonable default alignment on word boundaries: the
@@ -2428,7 +2427,8 @@ scsi_internal_device_unblock(struct scsi_device *sdev)
2428 sdev->sdev_state = SDEV_RUNNING; 2427 sdev->sdev_state = SDEV_RUNNING;
2429 else if (sdev->sdev_state == SDEV_CREATED_BLOCK) 2428 else if (sdev->sdev_state == SDEV_CREATED_BLOCK)
2430 sdev->sdev_state = SDEV_CREATED; 2429 sdev->sdev_state = SDEV_CREATED;
2431 else 2430 else if (sdev->sdev_state != SDEV_CANCEL &&
2431 sdev->sdev_state != SDEV_OFFLINE)
2432 return -EINVAL; 2432 return -EINVAL;
2433 2433
2434 spin_lock_irqsave(q->queue_lock, flags); 2434 spin_lock_irqsave(q->queue_lock, flags);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index c3f67373a4f8..7a0ca6fdbd79 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -962,10 +962,11 @@ static void __scsi_remove_target(struct scsi_target *starget)
962 list_for_each_entry(sdev, &shost->__devices, siblings) { 962 list_for_each_entry(sdev, &shost->__devices, siblings) {
963 if (sdev->channel != starget->channel || 963 if (sdev->channel != starget->channel ||
964 sdev->id != starget->id || 964 sdev->id != starget->id ||
965 sdev->sdev_state == SDEV_DEL) 965 scsi_device_get(sdev))
966 continue; 966 continue;
967 spin_unlock_irqrestore(shost->host_lock, flags); 967 spin_unlock_irqrestore(shost->host_lock, flags);
968 scsi_remove_device(sdev); 968 scsi_remove_device(sdev);
969 scsi_device_put(sdev);
969 spin_lock_irqsave(shost->host_lock, flags); 970 spin_lock_irqsave(shost->host_lock, flags);
970 goto restart; 971 goto restart;
971 } 972 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index ffa0689ee840..c52273c1327a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1153,6 +1153,12 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
1153 u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512); 1153 u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
1154 u64 bad_lba; 1154 u64 bad_lba;
1155 int info_valid; 1155 int info_valid;
1156 /*
1157 * resid is optional but mostly filled in. When it's unused,
1158 * its value is zero, so we assume the whole buffer transferred
1159 */
1160 unsigned int transferred = scsi_bufflen(scmd) - scsi_get_resid(scmd);
1161 unsigned int good_bytes;
1156 1162
1157 if (scmd->request->cmd_type != REQ_TYPE_FS) 1163 if (scmd->request->cmd_type != REQ_TYPE_FS)
1158 return 0; 1164 return 0;
@@ -1186,7 +1192,8 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
1186 /* This computation should always be done in terms of 1192 /* This computation should always be done in terms of
1187 * the resolution of the device's medium. 1193 * the resolution of the device's medium.
1188 */ 1194 */
1189 return (bad_lba - start_lba) * scmd->device->sector_size; 1195 good_bytes = (bad_lba - start_lba) * scmd->device->sector_size;
1196 return min(good_bytes, transferred);
1190} 1197}
1191 1198
1192/** 1199/**
@@ -2252,11 +2259,10 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
2252 index = sdkp->index; 2259 index = sdkp->index;
2253 dev = &sdp->sdev_gendev; 2260 dev = &sdp->sdev_gendev;
2254 2261
2255 if (index < SD_MAX_DISKS) { 2262 gd->major = sd_major((index & 0xf0) >> 4);
2256 gd->major = sd_major((index & 0xf0) >> 4); 2263 gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
2257 gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); 2264 gd->minors = SD_MINORS;
2258 gd->minors = SD_MINORS; 2265
2259 }
2260 gd->fops = &sd_fops; 2266 gd->fops = &sd_fops;
2261 gd->private_data = &sdkp->driver; 2267 gd->private_data = &sdkp->driver;
2262 gd->queue = sdkp->device->request_queue; 2268 gd->queue = sdkp->device->request_queue;
@@ -2346,6 +2352,12 @@ static int sd_probe(struct device *dev)
2346 if (error) 2352 if (error)
2347 goto out_put; 2353 goto out_put;
2348 2354
2355 if (index >= SD_MAX_DISKS) {
2356 error = -ENODEV;
2357 sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name space exhausted.\n");
2358 goto out_free_index;
2359 }
2360
2349 error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); 2361 error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN);
2350 if (error) 2362 if (error)
2351 goto out_free_index; 2363 goto out_free_index;