Skip to content

Commit 15cfb0f

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: "Twelve minor fixes, all in drivers or doc. Most of the fixes are pretty obvious (although we had two goes to get the UFS sysfs doc right) and the biggest change is in the ufs driver which they've extensively tested" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: ibmvfc: Set default timeout to avoid crash during migration scsi: target: tcmu: Fix use-after-free of se_cmd->priv scsi: fnic: Fix memleak in vnic_dev_init_devcmd2 scsi: libfc: Avoid invoking response handler twice if ep is already completed scsi: scsi_transport_srp: Don't block target in failfast state scsi: docs: ABI: sysfs-driver-ufs: Rectify table formatting scsi: ufs: Fix tm request when non-fatal error happens scsi: ufs: Fix livelock of ufshcd_clear_ua_wluns() scsi: ibmvfc: Fix missing cast of ibmvfc_event pointer to u64 handle scsi: ufs: ufshcd-pltfrm depends on HAS_IOMEM scsi: megaraid_sas: Fix MEGASAS_IOC_FIRMWARE regression scsi: docs: ABI: sysfs-driver-ufs: Add DeepSleep power mode
2 parents 929b979 + 7649072 commit 15cfb0f

9 files changed

Lines changed: 90 additions & 42 deletions

File tree

Documentation/ABI/testing/sysfs-driver-ufs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -916,21 +916,25 @@ Date: September 2014
916916
Contact: Subhash Jadavani <subhashj@codeaurora.org>
917917
Description: This entry could be used to set or show the UFS device
918918
runtime power management level. The current driver
919-
implementation supports 6 levels with next target states:
919+
implementation supports 7 levels with next target states:
920920

921921
== ====================================================
922-
0 an UFS device will stay active, an UIC link will
922+
0 UFS device will stay active, UIC link will
923923
stay active
924-
1 an UFS device will stay active, an UIC link will
924+
1 UFS device will stay active, UIC link will
925925
hibernate
926-
2 an UFS device will moved to sleep, an UIC link will
926+
2 UFS device will be moved to sleep, UIC link will
927927
stay active
928-
3 an UFS device will moved to sleep, an UIC link will
928+
3 UFS device will be moved to sleep, UIC link will
929929
hibernate
930-
4 an UFS device will be powered off, an UIC link will
930+
4 UFS device will be powered off, UIC link will
931931
hibernate
932-
5 an UFS device will be powered off, an UIC link will
932+
5 UFS device will be powered off, UIC link will
933933
be powered off
934+
6 UFS device will be moved to deep sleep, UIC link
935+
will be powered off. Note, deep sleep might not be
936+
supported in which case this value will not be
937+
accepted
934938
== ====================================================
935939

936940
What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_dev_state
@@ -954,21 +958,25 @@ Date: September 2014
954958
Contact: Subhash Jadavani <subhashj@codeaurora.org>
955959
Description: This entry could be used to set or show the UFS device
956960
system power management level. The current driver
957-
implementation supports 6 levels with next target states:
961+
implementation supports 7 levels with next target states:
958962

959963
== ====================================================
960-
0 an UFS device will stay active, an UIC link will
964+
0 UFS device will stay active, UIC link will
961965
stay active
962-
1 an UFS device will stay active, an UIC link will
966+
1 UFS device will stay active, UIC link will
963967
hibernate
964-
2 an UFS device will moved to sleep, an UIC link will
968+
2 UFS device will be moved to sleep, UIC link will
965969
stay active
966-
3 an UFS device will moved to sleep, an UIC link will
970+
3 UFS device will be moved to sleep, UIC link will
967971
hibernate
968-
4 an UFS device will be powered off, an UIC link will
972+
4 UFS device will be powered off, UIC link will
969973
hibernate
970-
5 an UFS device will be powered off, an UIC link will
974+
5 UFS device will be powered off, UIC link will
971975
be powered off
976+
6 UFS device will be moved to deep sleep, UIC link
977+
will be powered off. Note, deep sleep might not be
978+
supported in which case this value will not be
979+
accepted
972980
== ====================================================
973981

974982
What: /sys/bus/platform/drivers/ufshcd/*/spm_target_dev_state

drivers/scsi/fnic/vnic_dev.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
444444
fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index);
445445
if (fetch_index == 0xFFFFFFFF) { /* check for hardware gone */
446446
pr_err("error in devcmd2 init");
447-
return -ENODEV;
447+
err = -ENODEV;
448+
goto err_free_wq;
448449
}
449450

450451
/*
@@ -460,7 +461,7 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
460461
err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring,
461462
DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE);
462463
if (err)
463-
goto err_free_wq;
464+
goto err_disable_wq;
464465

465466
vdev->devcmd2->result =
466467
(struct devcmd2_result *) vdev->devcmd2->results_ring.descs;
@@ -481,8 +482,9 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
481482

482483
err_free_desc_ring:
483484
vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring);
484-
err_free_wq:
485+
err_disable_wq:
485486
vnic_wq_disable(&vdev->devcmd2->wq);
487+
err_free_wq:
486488
vnic_wq_free(&vdev->devcmd2->wq);
487489
err_free_devcmd2:
488490
kfree(vdev->devcmd2);

drivers/scsi/ibmvscsi/ibmvfc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ static int ibmvfc_queuecommand_lck(struct scsi_cmnd *cmnd,
17441744
iu->pri_task_attr = IBMVFC_SIMPLE_TASK;
17451745
}
17461746

1747-
vfc_cmd->correlation = cpu_to_be64(evt);
1747+
vfc_cmd->correlation = cpu_to_be64((u64)evt);
17481748

17491749
if (likely(!(rc = ibmvfc_map_sg_data(cmnd, evt, vfc_cmd, vhost->dev))))
17501750
return ibmvfc_send_event(evt, vhost, 0);
@@ -2418,7 +2418,7 @@ static int ibmvfc_abort_task_set(struct scsi_device *sdev)
24182418
tmf->flags = cpu_to_be16((IBMVFC_NO_MEM_DESC | IBMVFC_TMF));
24192419
evt->sync_iu = &rsp_iu;
24202420

2421-
tmf->correlation = cpu_to_be64(evt);
2421+
tmf->correlation = cpu_to_be64((u64)evt);
24222422

24232423
init_completion(&evt->comp);
24242424
rsp_rc = ibmvfc_send_event(evt, vhost, default_timeout);
@@ -3007,8 +3007,10 @@ static int ibmvfc_slave_configure(struct scsi_device *sdev)
30073007
unsigned long flags = 0;
30083008

30093009
spin_lock_irqsave(shost->host_lock, flags);
3010-
if (sdev->type == TYPE_DISK)
3010+
if (sdev->type == TYPE_DISK) {
30113011
sdev->allow_restart = 1;
3012+
blk_queue_rq_timeout(sdev->request_queue, 120 * HZ);
3013+
}
30123014
spin_unlock_irqrestore(shost->host_lock, flags);
30133015
return 0;
30143016
}

drivers/scsi/libfc/fc_exch.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,8 +1623,13 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
16231623
rc = fc_exch_done_locked(ep);
16241624
WARN_ON(fc_seq_exch(sp) != ep);
16251625
spin_unlock_bh(&ep->ex_lock);
1626-
if (!rc)
1626+
if (!rc) {
16271627
fc_exch_delete(ep);
1628+
} else {
1629+
FC_EXCH_DBG(ep, "ep is completed already,"
1630+
"hence skip calling the resp\n");
1631+
goto skip_resp;
1632+
}
16281633
}
16291634

16301635
/*
@@ -1643,6 +1648,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
16431648
if (!fc_invoke_resp(ep, sp, fp))
16441649
fc_frame_free(fp);
16451650

1651+
skip_resp:
16461652
fc_exch_release(ep);
16471653
return;
16481654
rel:
@@ -1899,10 +1905,16 @@ static void fc_exch_reset(struct fc_exch *ep)
18991905

19001906
fc_exch_hold(ep);
19011907

1902-
if (!rc)
1908+
if (!rc) {
19031909
fc_exch_delete(ep);
1910+
} else {
1911+
FC_EXCH_DBG(ep, "ep is completed already,"
1912+
"hence skip calling the resp\n");
1913+
goto skip_resp;
1914+
}
19041915

19051916
fc_invoke_resp(ep, sp, ERR_PTR(-FC_EX_CLOSED));
1917+
skip_resp:
19061918
fc_seq_set_resp(sp, NULL, ep->arg);
19071919
fc_exch_release(ep);
19081920
}

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8244,11 +8244,9 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
82448244
goto out;
82458245
}
82468246

8247+
/* always store 64 bits regardless of addressing */
82478248
sense_ptr = (void *)cmd->frame + ioc->sense_off;
8248-
if (instance->consistent_mask_64bit)
8249-
put_unaligned_le64(sense_handle, sense_ptr);
8250-
else
8251-
put_unaligned_le32(sense_handle, sense_ptr);
8249+
put_unaligned_le64(sense_handle, sense_ptr);
82528250
}
82538251

82548252
/*

drivers/scsi/scsi_transport_srp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,14 @@ int srp_reconnect_rport(struct srp_rport *rport)
541541
res = mutex_lock_interruptible(&rport->mutex);
542542
if (res)
543543
goto out;
544-
scsi_target_block(&shost->shost_gendev);
544+
if (rport->state != SRP_RPORT_FAIL_FAST)
545+
/*
546+
* sdev state must be SDEV_TRANSPORT_OFFLINE, transition
547+
* to SDEV_BLOCK is illegal. Calling scsi_target_unblock()
548+
* later is ok though, scsi_internal_device_unblock_nowait()
549+
* treats SDEV_TRANSPORT_OFFLINE like SDEV_BLOCK.
550+
*/
551+
scsi_target_block(&shost->shost_gendev);
545552
res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV;
546553
pr_debug("%s (state %d): transport.reconnect() returned %d\n",
547554
dev_name(&shost->shost_gendev), rport->state, res);

drivers/scsi/ufs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ config SCSI_UFS_DWC_TC_PCI
7272
config SCSI_UFSHCD_PLATFORM
7373
tristate "Platform bus based UFS Controller support"
7474
depends on SCSI_UFSHCD
75+
depends on HAS_IOMEM
7576
help
7677
This selects the UFS host controller support. Select this if
7778
you have an UFS controller on Platform bus.

drivers/scsi/ufs/ufshcd.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,6 +3996,8 @@ int ufshcd_link_recovery(struct ufs_hba *hba)
39963996
if (ret)
39973997
dev_err(hba->dev, "%s: link recovery failed, err %d",
39983998
__func__, ret);
3999+
else
4000+
ufshcd_clear_ua_wluns(hba);
39994001

40004002
return ret;
40014003
}
@@ -4992,7 +4994,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
49924994
break;
49934995
} /* end of switch */
49944996

4995-
if ((host_byte(result) != DID_OK) && !hba->silence_err_logs)
4997+
if ((host_byte(result) != DID_OK) &&
4998+
(host_byte(result) != DID_REQUEUE) && !hba->silence_err_logs)
49964999
ufshcd_print_trs(hba, 1 << lrbp->task_tag, true);
49975000
return result;
49985001
}
@@ -6001,6 +6004,9 @@ static void ufshcd_err_handler(struct work_struct *work)
60016004
ufshcd_scsi_unblock_requests(hba);
60026005
ufshcd_err_handling_unprepare(hba);
60036006
up(&hba->eh_sem);
6007+
6008+
if (!err && needs_reset)
6009+
ufshcd_clear_ua_wluns(hba);
60046010
}
60056011

60066012
/**
@@ -6295,9 +6301,13 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
62956301
intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
62966302
}
62976303

6298-
if (enabled_intr_status && retval == IRQ_NONE) {
6299-
dev_err(hba->dev, "%s: Unhandled interrupt 0x%08x\n",
6300-
__func__, intr_status);
6304+
if (enabled_intr_status && retval == IRQ_NONE &&
6305+
!ufshcd_eh_in_progress(hba)) {
6306+
dev_err(hba->dev, "%s: Unhandled interrupt 0x%08x (0x%08x, 0x%08x)\n",
6307+
__func__,
6308+
intr_status,
6309+
hba->ufs_stats.last_intr_status,
6310+
enabled_intr_status);
63016311
ufshcd_dump_regs(hba, 0, UFSHCI_REG_SPACE_SIZE, "host_regs: ");
63026312
}
63036313

@@ -6341,7 +6351,10 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
63416351
* Even though we use wait_event() which sleeps indefinitely,
63426352
* the maximum wait time is bounded by %TM_CMD_TIMEOUT.
63436353
*/
6344-
req = blk_get_request(q, REQ_OP_DRV_OUT, BLK_MQ_REQ_RESERVED);
6354+
req = blk_get_request(q, REQ_OP_DRV_OUT, 0);
6355+
if (IS_ERR(req))
6356+
return PTR_ERR(req);
6357+
63456358
req->end_io_data = &wait;
63466359
free_slot = req->tag;
63476360
WARN_ON_ONCE(free_slot < 0 || free_slot >= hba->nutmrs);
@@ -6938,14 +6951,11 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
69386951
ufshcd_set_clk_freq(hba, true);
69396952

69406953
err = ufshcd_hba_enable(hba);
6941-
if (err)
6942-
goto out;
69436954

69446955
/* Establish the link again and restore the device */
6945-
err = ufshcd_probe_hba(hba, false);
69466956
if (!err)
6947-
ufshcd_clear_ua_wluns(hba);
6948-
out:
6957+
err = ufshcd_probe_hba(hba, false);
6958+
69496959
if (err)
69506960
dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err);
69516961
ufshcd_update_evt_hist(hba, UFS_EVT_HOST_RESET, (u32)err);
@@ -7716,6 +7726,8 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
77167726
if (ret)
77177727
goto out;
77187728

7729+
ufshcd_clear_ua_wluns(hba);
7730+
77197731
/* Initialize devfreq after UFS device is detected */
77207732
if (ufshcd_is_clkscaling_supported(hba)) {
77217733
memcpy(&hba->clk_scaling.saved_pwr_info.info,
@@ -7917,8 +7929,6 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
79177929
pm_runtime_put_sync(hba->dev);
79187930
ufshcd_exit_clk_scaling(hba);
79197931
ufshcd_hba_exit(hba);
7920-
} else {
7921-
ufshcd_clear_ua_wluns(hba);
79227932
}
79237933
}
79247934

@@ -8775,6 +8785,7 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
87758785
ufshcd_resume_clkscaling(hba);
87768786
hba->clk_gating.is_suspended = false;
87778787
hba->dev_info.b_rpm_dev_flush_capable = false;
8788+
ufshcd_clear_ua_wluns(hba);
87788789
ufshcd_release(hba);
87798790
out:
87808791
if (hba->dev_info.b_rpm_dev_flush_capable) {
@@ -8885,6 +8896,8 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
88858896
cancel_delayed_work(&hba->rpm_dev_flush_recheck_work);
88868897
}
88878898

8899+
ufshcd_clear_ua_wluns(hba);
8900+
88888901
/* Schedule clock gating in case of no access to UFS device yet */
88898902
ufshcd_release(hba);
88908903

drivers/target/target_core_user.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,6 @@ tcmu_get_block_page(struct tcmu_dev *udev, uint32_t dbi)
562562

563563
static inline void tcmu_free_cmd(struct tcmu_cmd *tcmu_cmd)
564564
{
565-
if (tcmu_cmd->se_cmd)
566-
tcmu_cmd->se_cmd->priv = NULL;
567565
kfree(tcmu_cmd->dbi);
568566
kmem_cache_free(tcmu_cmd_cache, tcmu_cmd);
569567
}
@@ -1174,11 +1172,12 @@ tcmu_queue_cmd(struct se_cmd *se_cmd)
11741172
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
11751173

11761174
mutex_lock(&udev->cmdr_lock);
1177-
se_cmd->priv = tcmu_cmd;
11781175
if (!(se_cmd->transport_state & CMD_T_ABORTED))
11791176
ret = queue_cmd_ring(tcmu_cmd, &scsi_ret);
11801177
if (ret < 0)
11811178
tcmu_free_cmd(tcmu_cmd);
1179+
else
1180+
se_cmd->priv = tcmu_cmd;
11821181
mutex_unlock(&udev->cmdr_lock);
11831182
return scsi_ret;
11841183
}
@@ -1241,6 +1240,7 @@ tcmu_tmr_notify(struct se_device *se_dev, enum tcm_tmreq_table tmf,
12411240

12421241
list_del_init(&cmd->queue_entry);
12431242
tcmu_free_cmd(cmd);
1243+
se_cmd->priv = NULL;
12441244
target_complete_cmd(se_cmd, SAM_STAT_TASK_ABORTED);
12451245
unqueued = true;
12461246
}
@@ -1332,6 +1332,7 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
13321332
}
13331333

13341334
done:
1335+
se_cmd->priv = NULL;
13351336
if (read_len_valid) {
13361337
pr_debug("read_len = %d\n", read_len);
13371338
target_complete_cmd_with_length(cmd->se_cmd,
@@ -1478,6 +1479,7 @@ static void tcmu_check_expired_queue_cmd(struct tcmu_cmd *cmd)
14781479
se_cmd = cmd->se_cmd;
14791480
tcmu_free_cmd(cmd);
14801481

1482+
se_cmd->priv = NULL;
14811483
target_complete_cmd(se_cmd, SAM_STAT_TASK_SET_FULL);
14821484
}
14831485

@@ -1592,6 +1594,7 @@ static void run_qfull_queue(struct tcmu_dev *udev, bool fail)
15921594
* removed then LIO core will do the right thing and
15931595
* fail the retry.
15941596
*/
1597+
tcmu_cmd->se_cmd->priv = NULL;
15951598
target_complete_cmd(tcmu_cmd->se_cmd, SAM_STAT_BUSY);
15961599
tcmu_free_cmd(tcmu_cmd);
15971600
continue;
@@ -1605,6 +1608,7 @@ static void run_qfull_queue(struct tcmu_dev *udev, bool fail)
16051608
* Ignore scsi_ret for now. target_complete_cmd
16061609
* drops it.
16071610
*/
1611+
tcmu_cmd->se_cmd->priv = NULL;
16081612
target_complete_cmd(tcmu_cmd->se_cmd,
16091613
SAM_STAT_CHECK_CONDITION);
16101614
tcmu_free_cmd(tcmu_cmd);
@@ -2212,6 +2216,7 @@ static void tcmu_reset_ring(struct tcmu_dev *udev, u8 err_level)
22122216
if (!test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags)) {
22132217
WARN_ON(!cmd->se_cmd);
22142218
list_del_init(&cmd->queue_entry);
2219+
cmd->se_cmd->priv = NULL;
22152220
if (err_level == 1) {
22162221
/*
22172222
* Userspace was not able to start the

0 commit comments

Comments
 (0)