@@ -724,14 +724,39 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
724
724
}
725
725
EXPORT_SYMBOL_GPL (nvme_setup_cmd );
726
726
727
+ static void nvme_end_sync_rq (struct request * rq , blk_status_t error )
728
+ {
729
+ struct completion * waiting = rq -> end_io_data ;
730
+
731
+ rq -> end_io_data = NULL ;
732
+ complete (waiting );
733
+ }
734
+
735
+ static void nvme_execute_rq_polled (struct request_queue * q ,
736
+ struct gendisk * bd_disk , struct request * rq , int at_head )
737
+ {
738
+ DECLARE_COMPLETION_ONSTACK (wait );
739
+
740
+ WARN_ON_ONCE (!test_bit (QUEUE_FLAG_POLL , & q -> queue_flags ));
741
+
742
+ rq -> cmd_flags |= REQ_HIPRI ;
743
+ rq -> end_io_data = & wait ;
744
+ blk_execute_rq_nowait (q , bd_disk , rq , at_head , nvme_end_sync_rq );
745
+
746
+ while (!completion_done (& wait )) {
747
+ blk_poll (q , request_to_qc_t (rq -> mq_hctx , rq ), true);
748
+ cond_resched ();
749
+ }
750
+ }
751
+
727
752
/*
728
753
* Returns 0 on success. If the result is negative, it's a Linux error code;
729
754
* if the result is positive, it's an NVM Express status code
730
755
*/
731
756
int __nvme_submit_sync_cmd (struct request_queue * q , struct nvme_command * cmd ,
732
757
union nvme_result * result , void * buffer , unsigned bufflen ,
733
758
unsigned timeout , int qid , int at_head ,
734
- blk_mq_req_flags_t flags )
759
+ blk_mq_req_flags_t flags , bool poll )
735
760
{
736
761
struct request * req ;
737
762
int ret ;
@@ -748,7 +773,10 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
748
773
goto out ;
749
774
}
750
775
751
- blk_execute_rq (req -> q , NULL , req , at_head );
776
+ if (poll )
777
+ nvme_execute_rq_polled (req -> q , NULL , req , at_head );
778
+ else
779
+ blk_execute_rq (req -> q , NULL , req , at_head );
752
780
if (result )
753
781
* result = nvme_req (req )-> result ;
754
782
if (nvme_req (req )-> flags & NVME_REQ_CANCELLED )
@@ -765,7 +793,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
765
793
void * buffer , unsigned bufflen )
766
794
{
767
795
return __nvme_submit_sync_cmd (q , cmd , NULL , buffer , bufflen , 0 ,
768
- NVME_QID_ANY , 0 , 0 );
796
+ NVME_QID_ANY , 0 , 0 , false );
769
797
}
770
798
EXPORT_SYMBOL_GPL (nvme_submit_sync_cmd );
771
799
@@ -1084,7 +1112,7 @@ static int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword
1084
1112
c .features .dword11 = cpu_to_le32 (dword11 );
1085
1113
1086
1114
ret = __nvme_submit_sync_cmd (dev -> admin_q , & c , & res ,
1087
- buffer , buflen , 0 , NVME_QID_ANY , 0 , 0 );
1115
+ buffer , buflen , 0 , NVME_QID_ANY , 0 , 0 , false );
1088
1116
if (ret >= 0 && result )
1089
1117
* result = le32_to_cpu (res .u32 );
1090
1118
return ret ;
@@ -1727,7 +1755,7 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
1727
1755
cmd .common .cdw11 = cpu_to_le32 (len );
1728
1756
1729
1757
return __nvme_submit_sync_cmd (ctrl -> admin_q , & cmd , NULL , buffer , len ,
1730
- ADMIN_TIMEOUT , NVME_QID_ANY , 1 , 0 );
1758
+ ADMIN_TIMEOUT , NVME_QID_ANY , 1 , 0 , false );
1731
1759
}
1732
1760
EXPORT_SYMBOL_GPL (nvme_sec_submit );
1733
1761
#endif /* CONFIG_BLK_SED_OPAL */
0 commit comments