Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: ufs: core: Move code out of ufshcd_wait_for_dev_cmd()

The ufshcd_dev_cmd_completion() call is useful for some but not for all
ufshcd_wait_for_dev_cmd() callers. Hence, remove the
ufshcd_dev_cmd_completion() call from ufshcd_wait_for_dev_cmd() and move
it past the ufshcd_issue_dev_cmd() calls where appropriate. This makes
it easier to detect timeout errors for UPIU frames submitted through the
BSG interface.

Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251031204029.2883185-28-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
a11c015c 4b6c0d9c

+12 -9
+12 -9
drivers/ufs/core/ufshcd.c
··· 3265 3265 3266 3266 if (likely(time_left)) { 3267 3267 err = ufshcd_get_tr_ocs(lrbp, NULL); 3268 - if (!err) 3269 - err = ufshcd_dev_cmd_completion(hba, lrbp); 3270 3268 } else { 3271 3269 err = -ETIMEDOUT; 3272 3270 dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n", ··· 3374 3376 { 3375 3377 const u32 tag = hba->reserved_slot; 3376 3378 struct scsi_cmnd *cmd = ufshcd_tag_to_cmd(hba, tag); 3379 + struct ufshcd_lrb *lrbp = scsi_cmd_priv(cmd); 3377 3380 int err; 3378 3381 3379 3382 /* Protects use of hba->reserved_slot. */ ··· 3384 3385 if (unlikely(err)) 3385 3386 return err; 3386 3387 3387 - return ufshcd_issue_dev_cmd(hba, cmd, tag, timeout); 3388 + err = ufshcd_issue_dev_cmd(hba, cmd, tag, timeout); 3389 + if (err) 3390 + return err; 3391 + 3392 + return ufshcd_dev_cmd_completion(hba, lrbp); 3388 3393 } 3389 3394 3390 3395 /** ··· 7415 7412 7416 7413 memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); 7417 7414 7418 - /* 7419 - * ignore the returning value here - ufshcd_check_query_response is 7420 - * bound to fail since dev_cmd.query and dev_cmd.type were left empty. 7421 - * read the response directly ignoring all errors. 7422 - */ 7423 - ufshcd_issue_dev_cmd(hba, cmd, tag, dev_cmd_timeout); 7415 + err = ufshcd_issue_dev_cmd(hba, cmd, tag, dev_cmd_timeout); 7416 + if (err) 7417 + return err; 7424 7418 7425 7419 /* just copy the upiu response as it is */ 7426 7420 memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu)); ··· 7563 7563 memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); 7564 7564 7565 7565 err = ufshcd_issue_dev_cmd(hba, cmd, tag, ADVANCED_RPMB_REQ_TIMEOUT); 7566 + if (err) 7567 + return err; 7566 7568 7569 + err = ufshcd_dev_cmd_completion(hba, lrbp); 7567 7570 if (!err) { 7568 7571 /* Just copy the upiu response as it is */ 7569 7572 memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));