@@ -3288,6 +3288,25 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
32883288 ufshcd_release (hba );
32893289}
32903290
3291+ static int ufshcd_issue_dev_cmd (struct ufs_hba * hba , struct ufshcd_lrb * lrbp ,
3292+ const u32 tag , int timeout )
3293+ {
3294+ DECLARE_COMPLETION_ONSTACK (wait );
3295+ int err ;
3296+
3297+ hba -> dev_cmd .complete = & wait ;
3298+
3299+ ufshcd_add_query_upiu_trace (hba , UFS_QUERY_SEND , lrbp -> ucd_req_ptr );
3300+
3301+ ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
3302+ err = ufshcd_wait_for_dev_cmd (hba , lrbp , timeout );
3303+
3304+ ufshcd_add_query_upiu_trace (hba , err ? UFS_QUERY_ERR : UFS_QUERY_COMP ,
3305+ (struct utp_upiu_req * )lrbp -> ucd_rsp_ptr );
3306+
3307+ return err ;
3308+ }
3309+
32913310/**
32923311 * ufshcd_exec_dev_cmd - API for sending device management requests
32933312 * @hba: UFS hba
@@ -3302,31 +3321,18 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
33023321static int ufshcd_exec_dev_cmd (struct ufs_hba * hba ,
33033322 enum dev_cmd_type cmd_type , int timeout )
33043323{
3305- DECLARE_COMPLETION_ONSTACK (wait );
33063324 const u32 tag = hba -> reserved_slot ;
3307- struct ufshcd_lrb * lrbp ;
3325+ struct ufshcd_lrb * lrbp = & hba -> lrb [ tag ] ;
33083326 int err ;
33093327
33103328 /* Protects use of hba->reserved_slot. */
33113329 lockdep_assert_held (& hba -> dev_cmd .lock );
33123330
3313- lrbp = & hba -> lrb [tag ];
3314- lrbp -> cmd = NULL ;
33153331 err = ufshcd_compose_dev_cmd (hba , lrbp , cmd_type , tag );
33163332 if (unlikely (err ))
3317- goto out ;
3318-
3319- hba -> dev_cmd .complete = & wait ;
3320-
3321- ufshcd_add_query_upiu_trace (hba , UFS_QUERY_SEND , lrbp -> ucd_req_ptr );
3322-
3323- ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
3324- err = ufshcd_wait_for_dev_cmd (hba , lrbp , timeout );
3325- ufshcd_add_query_upiu_trace (hba , err ? UFS_QUERY_ERR : UFS_QUERY_COMP ,
3326- (struct utp_upiu_req * )lrbp -> ucd_rsp_ptr );
3333+ return err ;
33273334
3328- out :
3329- return err ;
3335+ return ufshcd_issue_dev_cmd (hba , lrbp , tag , timeout );
33303336}
33313337
33323338/**
@@ -7207,7 +7213,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
72077213 enum dev_cmd_type cmd_type ,
72087214 enum query_opcode desc_op )
72097215{
7210- DECLARE_COMPLETION_ONSTACK (wait );
72117216 const u32 tag = hba -> reserved_slot ;
72127217 struct ufshcd_lrb * lrbp ;
72137218 int err = 0 ;
@@ -7247,17 +7252,12 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
72477252
72487253 memset (lrbp -> ucd_rsp_ptr , 0 , sizeof (struct utp_upiu_rsp ));
72497254
7250- hba -> dev_cmd .complete = & wait ;
7251-
7252- ufshcd_add_query_upiu_trace (hba , UFS_QUERY_SEND , lrbp -> ucd_req_ptr );
7253-
7254- ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
72557255 /*
72567256 * ignore the returning value here - ufshcd_check_query_response is
72577257 * bound to fail since dev_cmd.query and dev_cmd.type were left empty.
72587258 * read the response directly ignoring all errors.
72597259 */
7260- ufshcd_wait_for_dev_cmd (hba , lrbp , QUERY_REQ_TIMEOUT );
7260+ ufshcd_issue_dev_cmd (hba , lrbp , tag , QUERY_REQ_TIMEOUT );
72617261
72627262 /* just copy the upiu response as it is */
72637263 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
73727372 struct ufs_ehs * rsp_ehs , int sg_cnt , struct scatterlist * sg_list ,
73737373 enum dma_data_direction dir )
73747374{
7375- DECLARE_COMPLETION_ONSTACK (wait );
73767375 const u32 tag = hba -> reserved_slot ;
73777376 struct ufshcd_lrb * lrbp ;
73787377 int err = 0 ;
@@ -7419,11 +7418,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
74197418
74207419 memset (lrbp -> ucd_rsp_ptr , 0 , sizeof (struct utp_upiu_rsp ));
74217420
7422- hba -> dev_cmd .complete = & wait ;
7423-
7424- ufshcd_send_command (hba , tag , hba -> dev_cmd_queue );
7425-
7426- err = ufshcd_wait_for_dev_cmd (hba , lrbp , ADVANCED_RPMB_REQ_TIMEOUT );
7421+ err = ufshcd_issue_dev_cmd (hba , lrbp , tag , ADVANCED_RPMB_REQ_TIMEOUT );
74277422
74287423 if (!err ) {
74297424 /* Just copy the upiu response as it is */
0 commit comments