@@ -430,7 +430,6 @@ static int resp_rsup_opcodes(struct scsi_cmnd *, struct sdebug_dev_info *);
430430static int resp_rsup_tmfs (struct scsi_cmnd * , struct sdebug_dev_info * );
431431static int resp_write_same_10 (struct scsi_cmnd * , struct sdebug_dev_info * );
432432static int resp_write_same_16 (struct scsi_cmnd * , struct sdebug_dev_info * );
433- static int resp_xdwriteread_10 (struct scsi_cmnd * , struct sdebug_dev_info * );
434433static int resp_comp_write (struct scsi_cmnd * , struct sdebug_dev_info * );
435434static int resp_write_buffer (struct scsi_cmnd * , struct sdebug_dev_info * );
436435static int resp_sync_cache (struct scsi_cmnd * , struct sdebug_dev_info * );
@@ -600,9 +599,6 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEMENT + 1] = {
600599 {0 , 0x42 , 0 , F_D_OUT | FF_MEDIA_IO , resp_unmap , NULL , /* UNMAP */
601600 {10 , 0x1 , 0 , 0 , 0 , 0 , 0x3f , 0xff , 0xff , 0xc7 , 0 , 0 , 0 , 0 , 0 , 0 } },
602601/* 25 */
603- {0 , 0x53 , 0 , F_D_IN | F_D_OUT | FF_MEDIA_IO , resp_xdwriteread_10 ,
604- NULL , {10 , 0xff , 0xff , 0xff , 0xff , 0xff , 0x3f , 0xff , 0xff , 0xc7 ,
605- 0 , 0 , 0 , 0 , 0 , 0 } }, /* XDWRITEREAD(10) */
606602 {0 , 0x3b , 0 , F_D_OUT_MAYBE , resp_write_buffer , NULL ,
607603 {10 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xc7 , 0 , 0 ,
608604 0 , 0 , 0 , 0 } }, /* WRITE_BUFFER */
@@ -1010,11 +1006,11 @@ static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
10101006 int arr_len )
10111007{
10121008 int act_len ;
1013- struct scsi_data_buffer * sdb = scsi_in ( scp ) ;
1009+ struct scsi_data_buffer * sdb = & scp -> sdb ;
10141010
10151011 if (!sdb -> length )
10161012 return 0 ;
1017- if (!( scsi_bidi_cmnd ( scp ) || scp -> sc_data_direction == DMA_FROM_DEVICE ) )
1013+ if (scp -> sc_data_direction != DMA_FROM_DEVICE )
10181014 return DID_ERROR << 16 ;
10191015
10201016 act_len = sg_copy_from_buffer (sdb -> table .sgl , sdb -> table .nents ,
@@ -1033,12 +1029,12 @@ static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr,
10331029 int arr_len , unsigned int off_dst )
10341030{
10351031 int act_len , n ;
1036- struct scsi_data_buffer * sdb = scsi_in ( scp ) ;
1032+ struct scsi_data_buffer * sdb = & scp -> sdb ;
10371033 off_t skip = off_dst ;
10381034
10391035 if (sdb -> length <= off_dst )
10401036 return 0 ;
1041- if (!( scsi_bidi_cmnd ( scp ) || scp -> sc_data_direction == DMA_FROM_DEVICE ) )
1037+ if (scp -> sc_data_direction != DMA_FROM_DEVICE )
10421038 return DID_ERROR << 16 ;
10431039
10441040 act_len = sg_pcopy_from_buffer (sdb -> table .sgl , sdb -> table .nents ,
@@ -1058,7 +1054,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
10581054{
10591055 if (!scsi_bufflen (scp ))
10601056 return 0 ;
1061- if (!( scsi_bidi_cmnd ( scp ) || scp -> sc_data_direction == DMA_TO_DEVICE ) )
1057+ if (scp -> sc_data_direction != DMA_TO_DEVICE )
10621058 return -1 ;
10631059
10641060 return scsi_sg_copy_to_buffer (scp , arr , arr_len );
@@ -2477,21 +2473,19 @@ static int do_device_access(struct scsi_cmnd *scmd, u32 sg_skip, u64 lba,
24772473{
24782474 int ret ;
24792475 u64 block , rest = 0 ;
2480- struct scsi_data_buffer * sdb ;
2476+ struct scsi_data_buffer * sdb = & scmd -> sdb ;
24812477 enum dma_data_direction dir ;
24822478
24832479 if (do_write ) {
2484- sdb = scsi_out (scmd );
24852480 dir = DMA_TO_DEVICE ;
24862481 write_since_sync = true;
24872482 } else {
2488- sdb = scsi_in (scmd );
24892483 dir = DMA_FROM_DEVICE ;
24902484 }
24912485
24922486 if (!sdb -> length )
24932487 return 0 ;
2494- if (!( scsi_bidi_cmnd ( scmd ) || scmd -> sc_data_direction == dir ) )
2488+ if (scmd -> sc_data_direction != dir )
24952489 return -1 ;
24962490
24972491 block = do_div (lba , sdebug_store_sectors );
@@ -2774,7 +2768,7 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
27742768 if (unlikely (ret == -1 ))
27752769 return DID_ERROR << 16 ;
27762770
2777- scsi_in ( scp ) -> resid = scsi_bufflen (scp ) - ret ;
2771+ scp -> sdb . resid = scsi_bufflen (scp ) - ret ;
27782772
27792773 if (unlikely (sqcp )) {
27802774 if (sqcp -> inj_recovered ) {
@@ -3718,68 +3712,6 @@ static int resp_report_luns(struct scsi_cmnd *scp,
37183712 return res ;
37193713}
37203714
3721- static int resp_xdwriteread (struct scsi_cmnd * scp , unsigned long long lba ,
3722- unsigned int num , struct sdebug_dev_info * devip )
3723- {
3724- int j ;
3725- unsigned char * kaddr , * buf ;
3726- unsigned int offset ;
3727- struct scsi_data_buffer * sdb = scsi_in (scp );
3728- struct sg_mapping_iter miter ;
3729-
3730- /* better not to use temporary buffer. */
3731- buf = kzalloc (scsi_bufflen (scp ), GFP_ATOMIC );
3732- if (!buf ) {
3733- mk_sense_buffer (scp , ILLEGAL_REQUEST , INSUFF_RES_ASC ,
3734- INSUFF_RES_ASCQ );
3735- return check_condition_result ;
3736- }
3737-
3738- scsi_sg_copy_to_buffer (scp , buf , scsi_bufflen (scp ));
3739-
3740- offset = 0 ;
3741- sg_miter_start (& miter , sdb -> table .sgl , sdb -> table .nents ,
3742- SG_MITER_ATOMIC | SG_MITER_TO_SG );
3743-
3744- while (sg_miter_next (& miter )) {
3745- kaddr = miter .addr ;
3746- for (j = 0 ; j < miter .length ; j ++ )
3747- * (kaddr + j ) ^= * (buf + offset + j );
3748-
3749- offset += miter .length ;
3750- }
3751- sg_miter_stop (& miter );
3752- kfree (buf );
3753-
3754- return 0 ;
3755- }
3756-
3757- static int resp_xdwriteread_10 (struct scsi_cmnd * scp ,
3758- struct sdebug_dev_info * devip )
3759- {
3760- u8 * cmd = scp -> cmnd ;
3761- u64 lba ;
3762- u32 num ;
3763- int errsts ;
3764-
3765- if (!scsi_bidi_cmnd (scp )) {
3766- mk_sense_buffer (scp , ILLEGAL_REQUEST , INSUFF_RES_ASC ,
3767- INSUFF_RES_ASCQ );
3768- return check_condition_result ;
3769- }
3770- errsts = resp_read_dt0 (scp , devip );
3771- if (errsts )
3772- return errsts ;
3773- if (!(cmd [1 ] & 0x4 )) { /* DISABLE_WRITE is not set */
3774- errsts = resp_write_dt0 (scp , devip );
3775- if (errsts )
3776- return errsts ;
3777- }
3778- lba = get_unaligned_be32 (cmd + 2 );
3779- num = get_unaligned_be16 (cmd + 7 );
3780- return resp_xdwriteread (scp , lba , num , devip );
3781- }
3782-
37833715static struct sdebug_queue * get_queue (struct scsi_cmnd * cmnd )
37843716{
37853717 u32 tag = blk_mq_unique_tag (cmnd -> request );
@@ -3953,7 +3885,6 @@ static int scsi_debug_slave_alloc(struct scsi_device *sdp)
39533885 if (sdebug_verbose )
39543886 pr_info ("slave_alloc <%u %u %u %llu>\n" ,
39553887 sdp -> host -> host_no , sdp -> channel , sdp -> id , sdp -> lun );
3956- blk_queue_flag_set (QUEUE_FLAG_BIDI , sdp -> request_queue );
39573888 return 0 ;
39583889}
39593890
0 commit comments