Skip to content

Commit 23025cb

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Ten small fixes (less the one that cleaned up a reverted removal), nine in drivers of which the ufs one is the most critical. The single core patch is a minor speedup to error handling" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: libsas: Grab the ATA port lock in sas_ata_device_link_abort() scsi: hisi_sas: Fix tag freeing for reserved tags scsi: ufs: core: WLUN suspend SSU/enter hibern8 fail recovery scsi: scsi_debug: Delete unreachable code in inquiry_vpd_b0() scsi: mpi3mr: Refer CONFIG_SCSI_MPI3MR in Makefile scsi: core: scsi_error: Do not queue pointless abort workqueue functions scsi: storvsc: Fix swiotlb bounce buffer leak in confidential VM scsi: iscsi: Fix multiple iSCSI session unbind events sent to userspace scsi: mpi3mr: Remove usage of dma_get_required_mask() API scsi: mpt3sas: Remove usage of dma_get_required_mask() API
2 parents e8f60cd + a67aad5 commit 23025cb

File tree

11 files changed

+95
-13
lines changed

11 files changed

+95
-13
lines changed

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
162162
static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx)
163163
{
164164
if (hisi_hba->hw->slot_index_alloc ||
165-
slot_idx >= HISI_SAS_UNRESERVED_IPTT) {
165+
slot_idx < HISI_SAS_RESERVED_IPTT) {
166166
spin_lock(&hisi_hba->lock);
167167
hisi_sas_slot_index_clear(hisi_hba, slot_idx);
168168
spin_unlock(&hisi_hba->lock);

drivers/scsi/libsas/sas_ata.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,14 +889,17 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset)
889889
{
890890
struct ata_port *ap = device->sata_dev.ap;
891891
struct ata_link *link = &ap->link;
892+
unsigned long flags;
892893

894+
spin_lock_irqsave(ap->lock, flags);
893895
device->sata_dev.fis[2] = ATA_ERR | ATA_DRDY; /* tf status */
894896
device->sata_dev.fis[3] = ATA_ABORTED; /* tf error */
895897

896898
link->eh_info.err_mask |= AC_ERR_DEV;
897899
if (force_reset)
898900
link->eh_info.action |= ATA_EH_RESET;
899901
ata_link_abort(link);
902+
spin_unlock_irqrestore(ap->lock, flags);
900903
}
901904
EXPORT_SYMBOL_GPL(sas_ata_device_link_abort);
902905

drivers/scsi/mpi3mr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mpi3mr makefile
2-
obj-m += mpi3mr.o
2+
obj-$(CONFIG_SCSI_MPI3MR) += mpi3mr.o
33
mpi3mr-y += mpi3mr_os.o \
44
mpi3mr_fw.o \
55
mpi3mr_app.o \

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,8 +3633,7 @@ int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc)
36333633
int i, retval = 0, capb = 0;
36343634
u16 message_control;
36353635
u64 dma_mask = mrioc->dma_mask ? mrioc->dma_mask :
3636-
(((dma_get_required_mask(&pdev->dev) > DMA_BIT_MASK(32)) &&
3637-
(sizeof(dma_addr_t) > 4)) ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));
3636+
((sizeof(dma_addr_t) > 4) ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));
36383637

36393638
if (pci_enable_device_mem(pdev)) {
36403639
ioc_err(mrioc, "pci_enable_device_mem: failed\n");

drivers/scsi/mpt3sas/mpt3sas_base.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,8 +2992,7 @@ _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev)
29922992
struct sysinfo s;
29932993
u64 coherent_dma_mask, dma_mask;
29942994

2995-
if (ioc->is_mcpu_endpoint || sizeof(dma_addr_t) == 4 ||
2996-
dma_get_required_mask(&pdev->dev) <= DMA_BIT_MASK(32)) {
2995+
if (ioc->is_mcpu_endpoint || sizeof(dma_addr_t) == 4) {
29972996
ioc->dma_mask = 32;
29982997
coherent_dma_mask = dma_mask = DMA_BIT_MASK(32);
29992998
/* Set 63 bit DMA mask for all SAS3 and SAS35 controllers */

drivers/scsi/scsi_debug.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,8 +1511,6 @@ static int inquiry_vpd_b0(unsigned char *arr)
15111511
put_unaligned_be64(sdebug_write_same_length, &arr[32]);
15121512

15131513
return 0x3c; /* Mandatory page length for Logical Block Provisioning */
1514-
1515-
return sizeof(vpdb0_data);
15161514
}
15171515

15181516
/* Block device characteristics VPD page (SBC-3) */

drivers/scsi/scsi_error.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ scsi_abort_command(struct scsi_cmnd *scmd)
231231
struct Scsi_Host *shost = sdev->host;
232232
unsigned long flags;
233233

234+
if (!shost->hostt->eh_abort_handler) {
235+
/* No abort handler, fail command directly */
236+
return FAILED;
237+
}
238+
234239
if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) {
235240
/*
236241
* Retry after abort failed, escalate to next level.

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,13 @@ static const char *iscsi_session_state_name(int state)
16771677
return name;
16781678
}
16791679

1680+
static char *iscsi_session_target_state_name[] = {
1681+
[ISCSI_SESSION_TARGET_UNBOUND] = "UNBOUND",
1682+
[ISCSI_SESSION_TARGET_ALLOCATED] = "ALLOCATED",
1683+
[ISCSI_SESSION_TARGET_SCANNED] = "SCANNED",
1684+
[ISCSI_SESSION_TARGET_UNBINDING] = "UNBINDING",
1685+
};
1686+
16801687
int iscsi_session_chkready(struct iscsi_cls_session *session)
16811688
{
16821689
int err;
@@ -1786,9 +1793,13 @@ static int iscsi_user_scan_session(struct device *dev, void *data)
17861793
if ((scan_data->channel == SCAN_WILD_CARD ||
17871794
scan_data->channel == 0) &&
17881795
(scan_data->id == SCAN_WILD_CARD ||
1789-
scan_data->id == id))
1796+
scan_data->id == id)) {
17901797
scsi_scan_target(&session->dev, 0, id,
17911798
scan_data->lun, scan_data->rescan);
1799+
spin_lock_irqsave(&session->lock, flags);
1800+
session->target_state = ISCSI_SESSION_TARGET_SCANNED;
1801+
spin_unlock_irqrestore(&session->lock, flags);
1802+
}
17921803
}
17931804

17941805
user_scan_exit:
@@ -1961,31 +1972,41 @@ static void __iscsi_unbind_session(struct work_struct *work)
19611972
struct iscsi_cls_host *ihost = shost->shost_data;
19621973
unsigned long flags;
19631974
unsigned int target_id;
1975+
bool remove_target = true;
19641976

19651977
ISCSI_DBG_TRANS_SESSION(session, "Unbinding session\n");
19661978

19671979
/* Prevent new scans and make sure scanning is not in progress */
19681980
mutex_lock(&ihost->mutex);
19691981
spin_lock_irqsave(&session->lock, flags);
1970-
if (session->target_id == ISCSI_MAX_TARGET) {
1982+
if (session->target_state == ISCSI_SESSION_TARGET_ALLOCATED) {
1983+
remove_target = false;
1984+
} else if (session->target_state != ISCSI_SESSION_TARGET_SCANNED) {
19711985
spin_unlock_irqrestore(&session->lock, flags);
19721986
mutex_unlock(&ihost->mutex);
1973-
goto unbind_session_exit;
1987+
ISCSI_DBG_TRANS_SESSION(session,
1988+
"Skipping target unbinding: Session is unbound/unbinding.\n");
1989+
return;
19741990
}
19751991

1992+
session->target_state = ISCSI_SESSION_TARGET_UNBINDING;
19761993
target_id = session->target_id;
19771994
session->target_id = ISCSI_MAX_TARGET;
19781995
spin_unlock_irqrestore(&session->lock, flags);
19791996
mutex_unlock(&ihost->mutex);
19801997

1981-
scsi_remove_target(&session->dev);
1998+
if (remove_target)
1999+
scsi_remove_target(&session->dev);
19822000

19832001
if (session->ida_used)
19842002
ida_free(&iscsi_sess_ida, target_id);
19852003

1986-
unbind_session_exit:
19872004
iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION);
19882005
ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n");
2006+
2007+
spin_lock_irqsave(&session->lock, flags);
2008+
session->target_state = ISCSI_SESSION_TARGET_UNBOUND;
2009+
spin_unlock_irqrestore(&session->lock, flags);
19892010
}
19902011

19912012
static void __iscsi_destroy_session(struct work_struct *work)
@@ -2062,6 +2083,9 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
20622083
session->ida_used = true;
20632084
} else
20642085
session->target_id = target_id;
2086+
spin_lock_irqsave(&session->lock, flags);
2087+
session->target_state = ISCSI_SESSION_TARGET_ALLOCATED;
2088+
spin_unlock_irqrestore(&session->lock, flags);
20652089

20662090
dev_set_name(&session->dev, "session%u", session->sid);
20672091
err = device_add(&session->dev);
@@ -4369,6 +4393,19 @@ iscsi_session_attr(def_taskmgmt_tmo, ISCSI_PARAM_DEF_TASKMGMT_TMO, 0);
43694393
iscsi_session_attr(discovery_parent_idx, ISCSI_PARAM_DISCOVERY_PARENT_IDX, 0);
43704394
iscsi_session_attr(discovery_parent_type, ISCSI_PARAM_DISCOVERY_PARENT_TYPE, 0);
43714395

4396+
static ssize_t
4397+
show_priv_session_target_state(struct device *dev, struct device_attribute *attr,
4398+
char *buf)
4399+
{
4400+
struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent);
4401+
4402+
return sysfs_emit(buf, "%s\n",
4403+
iscsi_session_target_state_name[session->target_state]);
4404+
}
4405+
4406+
static ISCSI_CLASS_ATTR(priv_sess, target_state, S_IRUGO,
4407+
show_priv_session_target_state, NULL);
4408+
43724409
static ssize_t
43734410
show_priv_session_state(struct device *dev, struct device_attribute *attr,
43744411
char *buf)
@@ -4471,6 +4508,7 @@ static struct attribute *iscsi_session_attrs[] = {
44714508
&dev_attr_sess_boot_target.attr,
44724509
&dev_attr_priv_sess_recovery_tmo.attr,
44734510
&dev_attr_priv_sess_state.attr,
4511+
&dev_attr_priv_sess_target_state.attr,
44744512
&dev_attr_priv_sess_creator.attr,
44754513
&dev_attr_sess_chap_out_idx.attr,
44764514
&dev_attr_sess_chap_in_idx.attr,
@@ -4584,6 +4622,8 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj,
45844622
return S_IRUGO | S_IWUSR;
45854623
else if (attr == &dev_attr_priv_sess_state.attr)
45864624
return S_IRUGO;
4625+
else if (attr == &dev_attr_priv_sess_target_state.attr)
4626+
return S_IRUGO;
45874627
else if (attr == &dev_attr_priv_sess_creator.attr)
45884628
return S_IRUGO;
45894629
else if (attr == &dev_attr_priv_sess_target_id.attr)

drivers/scsi/storvsc_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,9 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
18231823
ret = storvsc_do_io(dev, cmd_request, get_cpu());
18241824
put_cpu();
18251825

1826+
if (ret)
1827+
scsi_dma_unmap(scmnd);
1828+
18261829
if (ret == -EAGAIN) {
18271830
/* no more space */
18281831
ret = SCSI_MLQUEUE_DEVICE_BUSY;

drivers/ufs/core/ufshcd.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6056,6 +6056,14 @@ void ufshcd_schedule_eh_work(struct ufs_hba *hba)
60566056
}
60576057
}
60586058

6059+
static void ufshcd_force_error_recovery(struct ufs_hba *hba)
6060+
{
6061+
spin_lock_irq(hba->host->host_lock);
6062+
hba->force_reset = true;
6063+
ufshcd_schedule_eh_work(hba);
6064+
spin_unlock_irq(hba->host->host_lock);
6065+
}
6066+
60596067
static void ufshcd_clk_scaling_allow(struct ufs_hba *hba, bool allow)
60606068
{
60616069
down_write(&hba->clk_scaling_lock);
@@ -9083,6 +9091,15 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
90839091

90849092
if (!hba->dev_info.b_rpm_dev_flush_capable) {
90859093
ret = ufshcd_set_dev_pwr_mode(hba, req_dev_pwr_mode);
9094+
if (ret && pm_op != UFS_SHUTDOWN_PM) {
9095+
/*
9096+
* If return err in suspend flow, IO will hang.
9097+
* Trigger error handler and break suspend for
9098+
* error recovery.
9099+
*/
9100+
ufshcd_force_error_recovery(hba);
9101+
ret = -EBUSY;
9102+
}
90869103
if (ret)
90879104
goto enable_scaling;
90889105
}
@@ -9094,6 +9111,15 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
90949111
*/
90959112
check_for_bkops = !ufshcd_is_ufs_dev_deepsleep(hba);
90969113
ret = ufshcd_link_state_transition(hba, req_link_state, check_for_bkops);
9114+
if (ret && pm_op != UFS_SHUTDOWN_PM) {
9115+
/*
9116+
* If return err in suspend flow, IO will hang.
9117+
* Trigger error handler and break suspend for
9118+
* error recovery.
9119+
*/
9120+
ufshcd_force_error_recovery(hba);
9121+
ret = -EBUSY;
9122+
}
90979123
if (ret)
90989124
goto set_dev_active;
90999125

0 commit comments

Comments
 (0)