@@ -168,24 +168,6 @@ static bool mtip_check_surprise_removal(struct pci_dev *pdev)
168168 return false; /* device present */
169169}
170170
171- /* we have to use runtime tag to setup command header */
172- static void mtip_init_cmd_header (struct request * rq )
173- {
174- struct driver_data * dd = rq -> q -> queuedata ;
175- struct mtip_cmd * cmd = blk_mq_rq_to_pdu (rq );
176-
177- /* Point the command headers at the command tables. */
178- cmd -> command_header = dd -> port -> command_list +
179- (sizeof (struct mtip_cmd_hdr ) * rq -> tag );
180- cmd -> command_header_dma = dd -> port -> command_list_dma +
181- (sizeof (struct mtip_cmd_hdr ) * rq -> tag );
182-
183- if (test_bit (MTIP_PF_HOST_CAP_64 , & dd -> port -> flags ))
184- cmd -> command_header -> ctbau = cpu_to_le32 ((cmd -> command_dma >> 16 ) >> 16 );
185-
186- cmd -> command_header -> ctba = cpu_to_le32 (cmd -> command_dma & 0xFFFFFFFF );
187- }
188-
189171static struct mtip_cmd * mtip_get_int_command (struct driver_data * dd )
190172{
191173 struct request * rq ;
@@ -197,9 +179,6 @@ static struct mtip_cmd *mtip_get_int_command(struct driver_data *dd)
197179 if (IS_ERR (rq ))
198180 return NULL ;
199181
200- /* Internal cmd isn't submitted via .queue_rq */
201- mtip_init_cmd_header (rq );
202-
203182 return blk_mq_rq_to_pdu (rq );
204183}
205184
@@ -2179,6 +2158,8 @@ static void mtip_hw_submit_io(struct driver_data *dd, struct request *rq,
21792158 struct mtip_cmd * command ,
21802159 struct blk_mq_hw_ctx * hctx )
21812160{
2161+ struct mtip_cmd_hdr * hdr =
2162+ dd -> port -> command_list + sizeof (struct mtip_cmd_hdr ) * rq -> tag ;
21822163 struct host_to_dev_fis * fis ;
21832164 struct mtip_port * port = dd -> port ;
21842165 int dma_dir = rq_data_dir (rq ) == READ ? DMA_FROM_DEVICE : DMA_TO_DEVICE ;
@@ -2228,9 +2209,11 @@ static void mtip_hw_submit_io(struct driver_data *dd, struct request *rq,
22282209 fis -> device |= 1 << 7 ;
22292210
22302211 /* Populate the command header */
2231- command -> command_header -> opts =
2232- cpu_to_le32 ((nents << 16 ) | 5 | AHCI_CMD_PREFETCH );
2233- command -> command_header -> byte_count = 0 ;
2212+ hdr -> ctba = cpu_to_le32 (command -> command_dma & 0xFFFFFFFF );
2213+ if (test_bit (MTIP_PF_HOST_CAP_64 , & dd -> port -> flags ))
2214+ hdr -> ctbau = cpu_to_le32 ((command -> command_dma >> 16 ) >> 16 );
2215+ hdr -> opts = cpu_to_le32 ((nents << 16 ) | 5 | AHCI_CMD_PREFETCH );
2216+ hdr -> byte_count = 0 ;
22342217
22352218 command -> direction = dma_dir ;
22362219
@@ -3577,13 +3560,18 @@ static blk_status_t mtip_issue_reserved_cmd(struct blk_mq_hw_ctx *hctx,
35773560 struct driver_data * dd = hctx -> queue -> queuedata ;
35783561 struct mtip_int_cmd * icmd = rq -> special ;
35793562 struct mtip_cmd * cmd = blk_mq_rq_to_pdu (rq );
3563+ struct mtip_cmd_hdr * hdr =
3564+ dd -> port -> command_list + sizeof (struct mtip_cmd_hdr ) * rq -> tag ;
35803565 struct mtip_cmd_sg * command_sg ;
35813566
35823567 if (mtip_commands_active (dd -> port ))
35833568 return BLK_STS_RESOURCE ;
35843569
3570+ hdr -> ctba = cpu_to_le32 (cmd -> command_dma & 0xFFFFFFFF );
3571+ if (test_bit (MTIP_PF_HOST_CAP_64 , & dd -> port -> flags ))
3572+ hdr -> ctbau = cpu_to_le32 ((cmd -> command_dma >> 16 ) >> 16 );
35853573 /* Populate the SG list */
3586- cmd -> command_header -> opts = cpu_to_le32 (icmd -> opts | icmd -> fis_len );
3574+ hdr -> opts = cpu_to_le32 (icmd -> opts | icmd -> fis_len );
35873575 if (icmd -> buf_len ) {
35883576 command_sg = cmd -> command + AHCI_CMD_TBL_HDR_SZ ;
35893577
@@ -3592,11 +3580,11 @@ static blk_status_t mtip_issue_reserved_cmd(struct blk_mq_hw_ctx *hctx,
35923580 command_sg -> dba_upper =
35933581 cpu_to_le32 ((icmd -> buffer >> 16 ) >> 16 );
35943582
3595- cmd -> command_header -> opts |= cpu_to_le32 ((1 << 16 ));
3583+ hdr -> opts |= cpu_to_le32 ((1 << 16 ));
35963584 }
35973585
35983586 /* Populate the command header */
3599- cmd -> command_header -> byte_count = 0 ;
3587+ hdr -> byte_count = 0 ;
36003588
36013589 blk_mq_start_request (rq );
36023590 mtip_issue_non_ncq_command (dd -> port , rq -> tag );
@@ -3610,8 +3598,6 @@ static blk_status_t mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
36103598 struct request * rq = bd -> rq ;
36113599 struct mtip_cmd * cmd = blk_mq_rq_to_pdu (rq );
36123600
3613- mtip_init_cmd_header (rq );
3614-
36153601 if (blk_rq_is_passthrough (rq ))
36163602 return mtip_issue_reserved_cmd (hctx , rq );
36173603
0 commit comments