tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
usb-testing
head:   f1ac9f310d6d883b3551f4cb948eb441c780b59d
commit: f1ac9f310d6d883b3551f4cb948eb441c780b59d [46/46] usb: clean up some of 
the computations in adu_read
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
        git checkout f1ac9f310d6d883b3551f4cb948eb441c780b59d
        # 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 <l...@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/printk.h:332:0,
                    from include/linux/kernel.h:15,
                    from drivers/usb//misc/adutux.c:19:
   drivers/usb//misc/adutux.c: In function 'adu_read':
>> drivers/usb//misc/adutux.c:375:4: warning: format '%lu' expects argument of 
>> type 'long unsigned int', but argument 5 has type 'size_t {aka unsigned 
>> int}' [-Wformat=]
       "%s : while, data_in_secondary=%lu, status=%d\n",
       ^
   include/linux/dynamic_debug.h:125:15: note: in definition of macro 
'__dynamic_func_call'
      func(&id, ##__VA_ARGS__);  \
                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:157:2: note: in expansion of macro 
'_dynamic_func_call'
     _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
     ^~~~~~~~~~~~~~~~~~
   include/linux/device.h:1494:2: note: in expansion of macro 'dynamic_dev_dbg'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~
   include/linux/device.h:1494:23: note: in expansion of macro 'dev_fmt'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
                          ^~~~~~~
   drivers/usb//misc/adutux.c:374:3: note: in expansion of macro 'dev_dbg'
      dev_dbg(&dev->udev->dev,
      ^~~~~~~

vim +375 drivers/usb//misc/adutux.c

   339  
   340  static ssize_t adu_read(struct file *file, __user char *buffer, size_t 
count,
   341                          loff_t *ppos)
   342  {
   343          struct adu_device *dev;
   344          size_t bytes_read = 0;
   345          size_t bytes_to_read = count;
   346          int retval = 0;
   347          int timeout = 0;
   348          int should_submit = 0;
   349          unsigned long flags;
   350          DECLARE_WAITQUEUE(wait, current);
   351  
   352          dev = file->private_data;
   353          if (mutex_lock_interruptible(&dev->mtx))
   354                  return -ERESTARTSYS;
   355  
   356          /* verify that the device wasn't unplugged */
   357          if (dev->udev == NULL) {
   358                  retval = -ENODEV;
   359                  pr_err("No device or device unplugged %d\n", retval);
   360                  goto exit;
   361          }
   362  
   363          /* verify that some data was requested */
   364          if (count == 0) {
   365                  dev_dbg(&dev->udev->dev, "%s : read request of 0 
bytes\n",
   366                          __func__);
   367                  goto exit;
   368          }
   369  
   370          timeout = COMMAND_TIMEOUT;
   371          dev_dbg(&dev->udev->dev, "%s : about to start looping\n", 
__func__);
   372          while (bytes_to_read) {
   373                  size_t data_in_secondary = dev->secondary_tail - 
dev->secondary_head;
   374                  dev_dbg(&dev->udev->dev,
 > 375                          "%s : while, data_in_secondary=%lu, 
 > status=%d\n",
   376                          __func__, data_in_secondary,
   377                          dev->interrupt_in_urb->status);
   378  
   379                  if (data_in_secondary) {
   380                          /* drain secondary buffer */
   381                          size_t amount = min(bytes_to_read, 
data_in_secondary);
   382                          if (copy_to_user(buffer, 
dev->read_buffer_secondary+dev->secondary_head, amount)) {
   383                                  retval = -EFAULT;
   384                                  goto exit;
   385                          }
   386                          dev->secondary_head += amount;
   387                          bytes_read += amount;
   388                          bytes_to_read -= amount;
   389                  } else {
   390                          /* we check the primary buffer */
   391                          spin_lock_irqsave (&dev->buflock, flags);
   392                          if (dev->read_buffer_length) {
   393                                  /* we secure access to the primary */
   394                                  char *tmp;
   395                                  dev_dbg(&dev->udev->dev,
   396                                          "%s : swap, read_buffer_length 
= %d\n",
   397                                          __func__, 
dev->read_buffer_length);
   398                                  tmp = dev->read_buffer_secondary;
   399                                  dev->read_buffer_secondary = 
dev->read_buffer_primary;
   400                                  dev->read_buffer_primary = tmp;
   401                                  dev->secondary_head = 0;
   402                                  dev->secondary_tail = 
dev->read_buffer_length;
   403                                  dev->read_buffer_length = 0;
   404                                  spin_unlock_irqrestore(&dev->buflock, 
flags);
   405                                  /* we have a free buffer so use it */
   406                                  should_submit = 1;
   407                          } else {
   408                                  /* even the primary was empty - we may 
need to do IO */
   409                                  if (!dev->read_urb_finished) {
   410                                          /* somebody is doing IO */
   411                                          
spin_unlock_irqrestore(&dev->buflock, flags);
   412                                          dev_dbg(&dev->udev->dev,
   413                                                  "%s : submitted 
already\n",
   414                                                  __func__);
   415                                  } else {
   416                                          /* we must initiate input */
   417                                          dev_dbg(&dev->udev->dev,
   418                                                  "%s : initiate input\n",
   419                                                  __func__);
   420                                          dev->read_urb_finished = 0;
   421                                          
spin_unlock_irqrestore(&dev->buflock, flags);
   422  
   423                                          
usb_fill_int_urb(dev->interrupt_in_urb, dev->udev,
   424                                                          
usb_rcvintpipe(dev->udev,
   425                                                                  
dev->interrupt_in_endpoint->bEndpointAddress),
   426                                                           
dev->interrupt_in_buffer,
   427                                                           
usb_endpoint_maxp(dev->interrupt_in_endpoint),
   428                                                           
adu_interrupt_in_callback,
   429                                                           dev,
   430                                                           
dev->interrupt_in_endpoint->bInterval);
   431                                          retval = 
usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
   432                                          if (retval) {
   433                                                  dev->read_urb_finished 
= 1;
   434                                                  if (retval == -ENOMEM) {
   435                                                          retval = 
bytes_read ? bytes_read : -ENOMEM;
   436                                                  }
   437                                                  dev_dbg(&dev->udev->dev,
   438                                                          "%s : submit 
failed\n",
   439                                                          __func__);
   440                                                  goto exit;
   441                                          }
   442                                  }
   443  
   444                                  /* we wait for I/O to complete */
   445                                  set_current_state(TASK_INTERRUPTIBLE);
   446                                  add_wait_queue(&dev->read_wait, &wait);
   447                                  spin_lock_irqsave(&dev->buflock, flags);
   448                                  if (!dev->read_urb_finished) {
   449                                          
spin_unlock_irqrestore(&dev->buflock, flags);
   450                                          timeout = 
schedule_timeout(COMMAND_TIMEOUT);
   451                                  } else {
   452                                          
spin_unlock_irqrestore(&dev->buflock, flags);
   453                                          set_current_state(TASK_RUNNING);
   454                                  }
   455                                  remove_wait_queue(&dev->read_wait, 
&wait);
   456  
   457                                  if (timeout <= 0) {
   458                                          dev_dbg(&dev->udev->dev,
   459                                                  "%s : timeout\n", 
__func__);
   460                                          retval = bytes_read ? 
bytes_read : -ETIMEDOUT;
   461                                          goto exit;
   462                                  }
   463  
   464                                  if (signal_pending(current)) {
   465                                          dev_dbg(&dev->udev->dev,
   466                                                  "%s : signal pending\n",
   467                                                  __func__);
   468                                          retval = bytes_read ? 
bytes_read : -EINTR;
   469                                          goto exit;
   470                                  }
   471                          }
   472                  }
   473          }
   474  
   475          retval = bytes_read;
   476          /* if the primary buffer is empty then use it */
   477          spin_lock_irqsave(&dev->buflock, flags);
   478          if (should_submit && dev->read_urb_finished) {
   479                  dev->read_urb_finished = 0;
   480                  spin_unlock_irqrestore(&dev->buflock, flags);
   481                  usb_fill_int_urb(dev->interrupt_in_urb, dev->udev,
   482                                   usb_rcvintpipe(dev->udev,
   483                                          
dev->interrupt_in_endpoint->bEndpointAddress),
   484                                  dev->interrupt_in_buffer,
   485                                  
usb_endpoint_maxp(dev->interrupt_in_endpoint),
   486                                  adu_interrupt_in_callback,
   487                                  dev,
   488                                  dev->interrupt_in_endpoint->bInterval);
   489                  if (usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL) 
!= 0)
   490                          dev->read_urb_finished = 1;
   491                  /* we ignore failure */
   492          } else {
   493                  spin_unlock_irqrestore(&dev->buflock, flags);
   494          }
   495  
   496  exit:
   497          /* unlock the device */
   498          mutex_unlock(&dev->mtx);
   499  
   500          return retval;
   501  }
   502  

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

Attachment: .config.gz
Description: application/gzip

Reply via email to