Re: [PATCH] scsi: Fix scsi_get/set_resid() interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Damien,

I love your patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v5.4-rc5 next-20191029]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/scsi-Fix-scsi_get-set_resid-interface/20191030-074824
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   In file included from include/linux/jiffies.h:7:0,
                    from drivers/usb/storage/ene_ub6250.c:2:
   drivers/usb/storage/ene_ub6250.c: In function 'ene_send_scsi_cmd':
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:882:19: note: in expansion of macro '__careful_cmp'
    #define max(x, y) __careful_cmp(x, y, >)
                      ^~~~~~~~~~~~~
>> drivers/usb/storage/ene_ub6250.c:563:28: note: in expansion of macro 'max'
       scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
                               ^~~

vim +/max +563 drivers/usb/storage/ene_ub6250.c

41e568d14ec0ac huajun li    2011-03-04  492  
41e568d14ec0ac huajun li    2011-03-04  493  static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
41e568d14ec0ac huajun li    2011-03-04  494  {
41e568d14ec0ac huajun li    2011-03-04  495  	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
41e568d14ec0ac huajun li    2011-03-04  496  	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
41e568d14ec0ac huajun li    2011-03-04  497  
41e568d14ec0ac huajun li    2011-03-04  498  	int result;
41e568d14ec0ac huajun li    2011-03-04  499  	unsigned int residue;
41e568d14ec0ac huajun li    2011-03-04  500  	unsigned int cswlen = 0, partial = 0;
41e568d14ec0ac huajun li    2011-03-04  501  	unsigned int transfer_length = bcb->DataTransferLength;
41e568d14ec0ac huajun li    2011-03-04  502  
191648d03d2022 Joe Perches  2013-04-19  503  	/* usb_stor_dbg(us, "transport --- ene_send_scsi_cmd\n"); */
41e568d14ec0ac huajun li    2011-03-04  504  	/* send cmd to out endpoint */
41e568d14ec0ac huajun li    2011-03-04  505  	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
41e568d14ec0ac huajun li    2011-03-04  506  					    bcb, US_BULK_CB_WRAP_LEN, NULL);
41e568d14ec0ac huajun li    2011-03-04  507  	if (result != USB_STOR_XFER_GOOD) {
191648d03d2022 Joe Perches  2013-04-19  508  		usb_stor_dbg(us, "send cmd to out endpoint fail ---\n");
41e568d14ec0ac huajun li    2011-03-04  509  		return USB_STOR_TRANSPORT_ERROR;
41e568d14ec0ac huajun li    2011-03-04  510  	}
41e568d14ec0ac huajun li    2011-03-04  511  
41e568d14ec0ac huajun li    2011-03-04  512  	if (buf) {
41e568d14ec0ac huajun li    2011-03-04  513  		unsigned int pipe = fDir;
41e568d14ec0ac huajun li    2011-03-04  514  
41e568d14ec0ac huajun li    2011-03-04  515  		if (fDir  == FDIR_READ)
41e568d14ec0ac huajun li    2011-03-04  516  			pipe = us->recv_bulk_pipe;
41e568d14ec0ac huajun li    2011-03-04  517  		else
41e568d14ec0ac huajun li    2011-03-04  518  			pipe = us->send_bulk_pipe;
41e568d14ec0ac huajun li    2011-03-04  519  
41e568d14ec0ac huajun li    2011-03-04  520  		/* Bulk */
41e568d14ec0ac huajun li    2011-03-04  521  		if (use_sg) {
41e568d14ec0ac huajun li    2011-03-04  522  			result = usb_stor_bulk_srb(us, pipe, us->srb);
41e568d14ec0ac huajun li    2011-03-04  523  		} else {
41e568d14ec0ac huajun li    2011-03-04  524  			result = usb_stor_bulk_transfer_sg(us, pipe, buf,
41e568d14ec0ac huajun li    2011-03-04  525  						transfer_length, 0, &partial);
41e568d14ec0ac huajun li    2011-03-04  526  		}
41e568d14ec0ac huajun li    2011-03-04  527  		if (result != USB_STOR_XFER_GOOD) {
191648d03d2022 Joe Perches  2013-04-19  528  			usb_stor_dbg(us, "data transfer fail ---\n");
41e568d14ec0ac huajun li    2011-03-04  529  			return USB_STOR_TRANSPORT_ERROR;
41e568d14ec0ac huajun li    2011-03-04  530  		}
41e568d14ec0ac huajun li    2011-03-04  531  	}
41e568d14ec0ac huajun li    2011-03-04  532  
41e568d14ec0ac huajun li    2011-03-04  533  	/* Get CSW for device status */
41e568d14ec0ac huajun li    2011-03-04  534  	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
41e568d14ec0ac huajun li    2011-03-04  535  					    US_BULK_CS_WRAP_LEN, &cswlen);
41e568d14ec0ac huajun li    2011-03-04  536  
41e568d14ec0ac huajun li    2011-03-04  537  	if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
191648d03d2022 Joe Perches  2013-04-19  538  		usb_stor_dbg(us, "Received 0-length CSW; retrying...\n");
41e568d14ec0ac huajun li    2011-03-04  539  		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
41e568d14ec0ac huajun li    2011-03-04  540  					    bcs, US_BULK_CS_WRAP_LEN, &cswlen);
41e568d14ec0ac huajun li    2011-03-04  541  	}
41e568d14ec0ac huajun li    2011-03-04  542  
41e568d14ec0ac huajun li    2011-03-04  543  	if (result == USB_STOR_XFER_STALLED) {
41e568d14ec0ac huajun li    2011-03-04  544  		/* get the status again */
191648d03d2022 Joe Perches  2013-04-19  545  		usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n");
41e568d14ec0ac huajun li    2011-03-04  546  		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
41e568d14ec0ac huajun li    2011-03-04  547  						bcs, US_BULK_CS_WRAP_LEN, NULL);
41e568d14ec0ac huajun li    2011-03-04  548  	}
41e568d14ec0ac huajun li    2011-03-04  549  
41e568d14ec0ac huajun li    2011-03-04  550  	if (result != USB_STOR_XFER_GOOD)
41e568d14ec0ac huajun li    2011-03-04  551  		return USB_STOR_TRANSPORT_ERROR;
41e568d14ec0ac huajun li    2011-03-04  552  
41e568d14ec0ac huajun li    2011-03-04  553  	/* check bulk status */
41e568d14ec0ac huajun li    2011-03-04  554  	residue = le32_to_cpu(bcs->Residue);
41e568d14ec0ac huajun li    2011-03-04  555  
f0183a338e4f90 Felipe Balbi 2016-04-18  556  	/*
f0183a338e4f90 Felipe Balbi 2016-04-18  557  	 * try to compute the actual residue, based on how much data
f0183a338e4f90 Felipe Balbi 2016-04-18  558  	 * was really transferred and what the device tells us
f0183a338e4f90 Felipe Balbi 2016-04-18  559  	 */
41e568d14ec0ac huajun li    2011-03-04  560  	if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
41e568d14ec0ac huajun li    2011-03-04  561  		residue = min(residue, transfer_length);
41e568d14ec0ac huajun li    2011-03-04  562  		if (us->srb != NULL)
41e568d14ec0ac huajun li    2011-03-04 @563  			scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
41e568d14ec0ac huajun li    2011-03-04  564  								(int)residue));
41e568d14ec0ac huajun li    2011-03-04  565  	}
41e568d14ec0ac huajun li    2011-03-04  566  
41e568d14ec0ac huajun li    2011-03-04  567  	if (bcs->Status != US_BULK_STAT_OK)
41e568d14ec0ac huajun li    2011-03-04  568  		return USB_STOR_TRANSPORT_ERROR;
41e568d14ec0ac huajun li    2011-03-04  569  
41e568d14ec0ac huajun li    2011-03-04  570  	return USB_STOR_TRANSPORT_GOOD;
41e568d14ec0ac huajun li    2011-03-04  571  }
41e568d14ec0ac huajun li    2011-03-04  572  

:::::: The code at line 563 was first introduced by commit
:::::: 41e568d14ec0aca1b2bb19563517aad3b06d6805 Staging: Merge ENE UB6250 SD card codes from keucr to drivers/usb/storage

:::::: TO: huajun li <huajun.li.lee@xxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux