Skip to content

Commit 102c16a

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: "Small ufs fixes and a core change to clear the command private area on every retry (which fixes a reported bug in virtio_scsi)" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: ufs: core: bsg: Fix crash when arpmb command fails scsi: ufs: core: Set default runtime/system PM levels before ufshcd_hba_init() scsi: core: Clear driver private data when retrying request scsi: ufs: core: Fix ufshcd_is_ufs_dev_busy() and ufshcd_eh_timed_out()
2 parents f4ce1f3 + f27a958 commit 102c16a

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,13 +1669,6 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
16691669
if (in_flight)
16701670
__set_bit(SCMD_STATE_INFLIGHT, &cmd->state);
16711671

1672-
/*
1673-
* Only clear the driver-private command data if the LLD does not supply
1674-
* a function to initialize that data.
1675-
*/
1676-
if (!shost->hostt->init_cmd_priv)
1677-
memset(cmd + 1, 0, shost->hostt->cmd_size);
1678-
16791672
cmd->prot_op = SCSI_PROT_NORMAL;
16801673
if (blk_rq_bytes(req))
16811674
cmd->sc_data_direction = rq_dma_dir(req);
@@ -1842,6 +1835,13 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
18421835
if (!scsi_host_queue_ready(q, shost, sdev, cmd))
18431836
goto out_dec_target_busy;
18441837

1838+
/*
1839+
* Only clear the driver-private command data if the LLD does not supply
1840+
* a function to initialize that data.
1841+
*/
1842+
if (shost->hostt->cmd_size && !shost->hostt->init_cmd_priv)
1843+
memset(cmd + 1, 0, shost->hostt->cmd_size);
1844+
18451845
if (!(req->rq_flags & RQF_DONTPREP)) {
18461846
ret = scsi_prepare_cmd(req);
18471847
if (ret != BLK_STS_OK)

drivers/ufs/core/ufs_bsg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,12 @@ static int ufs_bsg_request(struct bsg_job *job)
194194
ufshcd_rpm_put_sync(hba);
195195
kfree(buff);
196196
bsg_reply->result = ret;
197-
job->reply_len = !rpmb ? sizeof(struct ufs_bsg_reply) : sizeof(struct ufs_rpmb_reply);
198197
/* complete the job here only if no error */
199-
if (ret == 0)
198+
if (ret == 0) {
199+
job->reply_len = rpmb ? sizeof(struct ufs_rpmb_reply) :
200+
sizeof(struct ufs_bsg_reply);
200201
bsg_job_done(job, ret, bsg_reply->reply_payload_rcv_len);
202+
}
201203

202204
return ret;
203205
}

drivers/ufs/core/ufshcd.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static bool ufshcd_has_pending_tasks(struct ufs_hba *hba)
266266

267267
static bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba)
268268
{
269-
return hba->outstanding_reqs || ufshcd_has_pending_tasks(hba);
269+
return scsi_host_busy(hba->host) || ufshcd_has_pending_tasks(hba);
270270
}
271271

272272
static const struct ufs_dev_quirk ufs_fixups[] = {
@@ -628,8 +628,8 @@ static void ufshcd_print_host_state(struct ufs_hba *hba)
628628
const struct scsi_device *sdev_ufs = hba->ufs_device_wlun;
629629

630630
dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);
631-
dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n",
632-
hba->outstanding_reqs, hba->outstanding_tasks);
631+
dev_err(hba->dev, "%d outstanding reqs, tasks=0x%lx\n",
632+
scsi_host_busy(hba->host), hba->outstanding_tasks);
633633
dev_err(hba->dev, "saved_err=0x%x, saved_uic_err=0x%x\n",
634634
hba->saved_err, hba->saved_uic_err);
635635
dev_err(hba->dev, "Device power mode=%d, UIC link state=%d\n",
@@ -8882,7 +8882,7 @@ static enum scsi_timeout_action ufshcd_eh_timed_out(struct scsi_cmnd *scmd)
88828882
dev_info(hba->dev, "%s() finished; outstanding_tasks = %#lx.\n",
88838883
__func__, hba->outstanding_tasks);
88848884

8885-
return hba->outstanding_reqs ? SCSI_EH_RESET_TIMER : SCSI_EH_DONE;
8885+
return scsi_host_busy(hba->host) ? SCSI_EH_RESET_TIMER : SCSI_EH_DONE;
88868886
}
88878887

88888888
static const struct attribute_group *ufshcd_driver_groups[] = {
@@ -10431,6 +10431,21 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1043110431
*/
1043210432
spin_lock_init(&hba->clk_gating.lock);
1043310433

10434+
/*
10435+
* Set the default power management level for runtime and system PM.
10436+
* Host controller drivers can override them in their
10437+
* 'ufs_hba_variant_ops::init' callback.
10438+
*
10439+
* Default power saving mode is to keep UFS link in Hibern8 state
10440+
* and UFS device in sleep state.
10441+
*/
10442+
hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10443+
UFS_SLEEP_PWR_MODE,
10444+
UIC_LINK_HIBERN8_STATE);
10445+
hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10446+
UFS_SLEEP_PWR_MODE,
10447+
UIC_LINK_HIBERN8_STATE);
10448+
1043410449
err = ufshcd_hba_init(hba);
1043510450
if (err)
1043610451
goto out_error;
@@ -10544,21 +10559,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1054410559
goto out_disable;
1054510560
}
1054610561

10547-
/*
10548-
* Set the default power management level for runtime and system PM if
10549-
* not set by the host controller drivers.
10550-
* Default power saving mode is to keep UFS link in Hibern8 state
10551-
* and UFS device in sleep state.
10552-
*/
10553-
if (!hba->rpm_lvl)
10554-
hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10555-
UFS_SLEEP_PWR_MODE,
10556-
UIC_LINK_HIBERN8_STATE);
10557-
if (!hba->spm_lvl)
10558-
hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10559-
UFS_SLEEP_PWR_MODE,
10560-
UIC_LINK_HIBERN8_STATE);
10561-
1056210562
INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, ufshcd_rpm_dev_flush_recheck_work);
1056310563
INIT_DELAYED_WORK(&hba->ufs_rtc_update_work, ufshcd_rtc_work);
1056410564

0 commit comments

Comments
 (0)