mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-07 06:15:23 +02:00
scsi: ufs: core: Reuse exec_dev_cmd
Move out the actual command issue from exec_dev_cmd it can be used elsewhere. While at it, remove a redundant "lrbp->cmd = NULL" assignment. Also, the device management commands that are originated from the ufs-bsg code path, are being traced now, which wasn't the case before. Signed-off-by: Avri Altman <avri.altman@wdc.com> Link: https://lore.kernel.org/r/20240309081104.5006-3-avri.altman@wdc.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Bean Huo <beanhuo@micron.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
ddfd7f051f
commit
71aabb747d
|
@ -3288,6 +3288,25 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
|
||||||
ufshcd_release(hba);
|
ufshcd_release(hba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
|
||||||
|
const u32 tag, int timeout)
|
||||||
|
{
|
||||||
|
DECLARE_COMPLETION_ONSTACK(wait);
|
||||||
|
int err;
|
||||||
|
|
||||||
|
hba->dev_cmd.complete = &wait;
|
||||||
|
|
||||||
|
ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
|
||||||
|
|
||||||
|
ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
|
||||||
|
err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout);
|
||||||
|
|
||||||
|
ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
|
||||||
|
(struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ufshcd_exec_dev_cmd - API for sending device management requests
|
* ufshcd_exec_dev_cmd - API for sending device management requests
|
||||||
* @hba: UFS hba
|
* @hba: UFS hba
|
||||||
|
@ -3302,31 +3321,18 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
|
||||||
static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
|
static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
|
||||||
enum dev_cmd_type cmd_type, int timeout)
|
enum dev_cmd_type cmd_type, int timeout)
|
||||||
{
|
{
|
||||||
DECLARE_COMPLETION_ONSTACK(wait);
|
|
||||||
const u32 tag = hba->reserved_slot;
|
const u32 tag = hba->reserved_slot;
|
||||||
struct ufshcd_lrb *lrbp;
|
struct ufshcd_lrb *lrbp = &hba->lrb[tag];
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* Protects use of hba->reserved_slot. */
|
/* Protects use of hba->reserved_slot. */
|
||||||
lockdep_assert_held(&hba->dev_cmd.lock);
|
lockdep_assert_held(&hba->dev_cmd.lock);
|
||||||
|
|
||||||
lrbp = &hba->lrb[tag];
|
|
||||||
lrbp->cmd = NULL;
|
|
||||||
err = ufshcd_compose_dev_cmd(hba, lrbp, cmd_type, tag);
|
err = ufshcd_compose_dev_cmd(hba, lrbp, cmd_type, tag);
|
||||||
if (unlikely(err))
|
if (unlikely(err))
|
||||||
goto out;
|
return err;
|
||||||
|
|
||||||
hba->dev_cmd.complete = &wait;
|
return ufshcd_issue_dev_cmd(hba, lrbp, tag, timeout);
|
||||||
|
|
||||||
ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
|
|
||||||
|
|
||||||
ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
|
|
||||||
err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout);
|
|
||||||
ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
|
|
||||||
(struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
|
|
||||||
|
|
||||||
out:
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7207,7 +7213,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
|
||||||
enum dev_cmd_type cmd_type,
|
enum dev_cmd_type cmd_type,
|
||||||
enum query_opcode desc_op)
|
enum query_opcode desc_op)
|
||||||
{
|
{
|
||||||
DECLARE_COMPLETION_ONSTACK(wait);
|
|
||||||
const u32 tag = hba->reserved_slot;
|
const u32 tag = hba->reserved_slot;
|
||||||
struct ufshcd_lrb *lrbp;
|
struct ufshcd_lrb *lrbp;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -7247,17 +7252,12 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
|
||||||
|
|
||||||
memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
|
memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
|
||||||
|
|
||||||
hba->dev_cmd.complete = &wait;
|
|
||||||
|
|
||||||
ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
|
|
||||||
|
|
||||||
ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
|
|
||||||
/*
|
/*
|
||||||
* ignore the returning value here - ufshcd_check_query_response is
|
* ignore the returning value here - ufshcd_check_query_response is
|
||||||
* bound to fail since dev_cmd.query and dev_cmd.type were left empty.
|
* bound to fail since dev_cmd.query and dev_cmd.type were left empty.
|
||||||
* read the response directly ignoring all errors.
|
* read the response directly ignoring all errors.
|
||||||
*/
|
*/
|
||||||
ufshcd_wait_for_dev_cmd(hba, lrbp, QUERY_REQ_TIMEOUT);
|
ufshcd_issue_dev_cmd(hba, lrbp, tag, QUERY_REQ_TIMEOUT);
|
||||||
|
|
||||||
/* just copy the upiu response as it is */
|
/* just copy the upiu response as it is */
|
||||||
memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));
|
memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));
|
||||||
|
@ -7372,7 +7372,6 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
|
||||||
struct ufs_ehs *rsp_ehs, int sg_cnt, struct scatterlist *sg_list,
|
struct ufs_ehs *rsp_ehs, int sg_cnt, struct scatterlist *sg_list,
|
||||||
enum dma_data_direction dir)
|
enum dma_data_direction dir)
|
||||||
{
|
{
|
||||||
DECLARE_COMPLETION_ONSTACK(wait);
|
|
||||||
const u32 tag = hba->reserved_slot;
|
const u32 tag = hba->reserved_slot;
|
||||||
struct ufshcd_lrb *lrbp;
|
struct ufshcd_lrb *lrbp;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -7419,11 +7418,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
|
||||||
|
|
||||||
memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
|
memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
|
||||||
|
|
||||||
hba->dev_cmd.complete = &wait;
|
err = ufshcd_issue_dev_cmd(hba, lrbp, tag, ADVANCED_RPMB_REQ_TIMEOUT);
|
||||||
|
|
||||||
ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
|
|
||||||
|
|
||||||
err = ufshcd_wait_for_dev_cmd(hba, lrbp, ADVANCED_RPMB_REQ_TIMEOUT);
|
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
/* Just copy the upiu response as it is */
|
/* Just copy the upiu response as it is */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user