tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0f4498cef9f5cd18d7c6639a2a902ec1edc5be4e
commit: 111d746bb4767ad476f80fe49067e3df3d9a9375 misc: bcm-vk: add VK messaging 
support
date:   9 weeks ago
config: mips-randconfig-r035-20210327 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
d50fe9f0d6b9ee61df8830a67ea0a33c27a637e7)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=111d746bb4767ad476f80fe49067e3df3d9a9375
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 111d746bb4767ad476f80fe49067e3df3d9a9375
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:13:52: note: expanded from macro 
'__get_unaligned_le'
   #define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({                  
   \
                                                      ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:14:33: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr),                   
   \
                                          ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:14:47: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr),                   
   \
                                                        ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:15:33: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 2, 
get_unaligned_le16((ptr)),   \
                                          ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:15:65: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 2, 
get_unaligned_le16((ptr)),   \
                                                                          ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:16:33: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 4, 
get_unaligned_le32((ptr)),   \
                                          ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:16:65: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 4, 
get_unaligned_le32((ptr)),   \
                                                                          ^~~
>> drivers/misc/bcm-vk/bcm_vk_sg.c:52:24: warning: taking address of packed 
>> member 'address' of class or structure '_vk_data' may result in an unaligned 
>> pointer value [-Waddress-of-packed-member]
           data = get_unaligned(&vkdata->address);
                                 ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:22:24: note: expanded from macro 
'get_unaligned'
   # define get_unaligned  __get_unaligned_le
                           ^
   include/linux/unaligned/generic.h:17:33: note: expanded from macro 
'__get_unaligned_le'
           __builtin_choose_expr(sizeof(*(ptr)) == 8, 
get_unaligned_le64((ptr)),   \
                                          ^~~
   drivers/misc/bcm-vk/bcm_vk_sg.c:141:35: warning: taking address of packed 
member 'address' of class or structure '_vk_data' may result in an unaligned 
pointer value [-Waddress-of-packed-member]
                           put_unaligned(sg_addr, (u64 *)&sgdata->address);
                                                          ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:23:24: note: expanded from macro 
'put_unaligned'
   # define put_unaligned  __put_unaligned_le
                           ^
   include/linux/unaligned/generic.h:30:18: note: expanded from macro 
'__put_unaligned_le'
           void *__gu_p = (ptr);                                           \
                           ^~~
   drivers/misc/bcm-vk/bcm_vk_sg.c:141:35: warning: taking address of packed 
member 'address' of class or structure '_vk_data' may result in an unaligned 
pointer value [-Waddress-of-packed-member]
                           put_unaligned(sg_addr, (u64 *)&sgdata->address);
                                                          ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:23:24: note: expanded from macro 
'put_unaligned'
   # define put_unaligned  __put_unaligned_le
                           ^
   include/linux/unaligned/generic.h:31:19: note: expanded from macro 
'__put_unaligned_le'
           switch (sizeof(*(ptr))) {                                       \
                            ^~~
   drivers/misc/bcm-vk/bcm_vk_sg.c:152:33: warning: taking address of packed 
member 'address' of class or structure '_vk_data' may result in an unaligned 
pointer value [-Waddress-of-packed-member]
           put_unaligned(sg_addr, (u64 *)&sgdata->address);
                                          ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:23:24: note: expanded from macro 
'put_unaligned'
   # define put_unaligned  __put_unaligned_le
                           ^
   include/linux/unaligned/generic.h:30:18: note: expanded from macro 
'__put_unaligned_le'
           void *__gu_p = (ptr);                                           \
                           ^~~
   drivers/misc/bcm-vk/bcm_vk_sg.c:152:33: warning: taking address of packed 
member 'address' of class or structure '_vk_data' may result in an unaligned 
pointer value [-Waddress-of-packed-member]
           put_unaligned(sg_addr, (u64 *)&sgdata->address);
                                          ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:23:24: note: expanded from macro 
'put_unaligned'
   # define put_unaligned  __put_unaligned_le
                           ^
   include/linux/unaligned/generic.h:31:19: note: expanded from macro 
'__put_unaligned_le'
           switch (sizeof(*(ptr))) {                                       \
                            ^~~
   drivers/misc/bcm-vk/bcm_vk_sg.c:156:35: warning: taking address of packed 
member 'address' of class or structure '_vk_data' may result in an unaligned 
pointer value [-Waddress-of-packed-member]
           put_unaligned((u64)dma->handle, &vkdata->address);
                                            ^~~~~~~~~~~~~~~
   include/asm-generic/unaligned.h:23:24: note: expanded from macro 
'put_unaligned'
   # define put_unaligned  __put_unaligned_le
                           ^
   include/linux/unaligned/generic.h:31:19: note: expanded from macro 
'__put_unaligned_le'
           switch (sizeof(*(ptr))) {                                       \
                            ^~~
   13 warnings generated.


vim +52 drivers/misc/bcm-vk/bcm_vk_sg.c

    34  
    35  static int bcm_vk_dma_alloc(struct device *dev,
    36                              struct bcm_vk_dma *dma,
    37                              int direction,
    38                              struct _vk_data *vkdata)
    39  {
    40          dma_addr_t addr, sg_addr;
    41          int err;
    42          int i;
    43          int offset;
    44          u32 size;
    45          u32 remaining_size;
    46          u32 transfer_size;
    47          u64 data;
    48          unsigned long first, last;
    49          struct _vk_data *sgdata;
    50  
    51          /* Get 64-bit user address */
  > 52          data = get_unaligned(&vkdata->address);
    53  
    54          /* offset into first page */
    55          offset = offset_in_page(data);
    56  
    57          /* Calculate number of pages */
    58          first = (data & PAGE_MASK) >> PAGE_SHIFT;
    59          last  = ((data + vkdata->size - 1) & PAGE_MASK) >> PAGE_SHIFT;
    60          dma->nr_pages = last - first + 1;
    61  
    62          /* Allocate DMA pages */
    63          dma->pages = kmalloc_array(dma->nr_pages,
    64                                     sizeof(struct page *),
    65                                     GFP_KERNEL);
    66          if (!dma->pages)
    67                  return -ENOMEM;
    68  
    69          dev_dbg(dev, "Alloc DMA Pages [0x%llx+0x%x => %d pages]\n",
    70                  data, vkdata->size, dma->nr_pages);
    71  
    72          dma->direction = direction;
    73  
    74          /* Get user pages into memory */
    75          err = get_user_pages_fast(data & PAGE_MASK,
    76                                    dma->nr_pages,
    77                                    direction == DMA_FROM_DEVICE,
    78                                    dma->pages);
    79          if (err != dma->nr_pages) {
    80                  dma->nr_pages = (err >= 0) ? err : 0;
    81                  dev_err(dev, "get_user_pages_fast, err=%d [%d]\n",
    82                          err, dma->nr_pages);
    83                  return err < 0 ? err : -EINVAL;
    84          }
    85  
    86          /* Max size of sg list is 1 per mapped page + fields at start */
    87          dma->sglen = (dma->nr_pages * sizeof(*sgdata)) +
    88                       (sizeof(u32) * SGLIST_VKDATA_START);
    89  
    90          /* Allocate sglist */
    91          dma->sglist = dma_alloc_coherent(dev,
    92                                           dma->sglen,
    93                                           &dma->handle,
    94                                           GFP_KERNEL);
    95          if (!dma->sglist)
    96                  return -ENOMEM;
    97  
    98          dma->sglist[SGLIST_NUM_SG] = 0;
    99          dma->sglist[SGLIST_TOTALSIZE] = vkdata->size;
   100          remaining_size = vkdata->size;
   101          sgdata = (struct _vk_data *)&dma->sglist[SGLIST_VKDATA_START];
   102  
   103          /* Map all pages into DMA */
   104          size = min_t(size_t, PAGE_SIZE - offset, remaining_size);
   105          remaining_size -= size;
   106          sg_addr = dma_map_page(dev,
   107                                 dma->pages[0],
   108                                 offset,
   109                                 size,
   110                                 dma->direction);
   111          transfer_size = size;
   112          if (unlikely(dma_mapping_error(dev, sg_addr))) {
   113                  __free_page(dma->pages[0]);
   114                  return -EIO;
   115          }
   116  
   117          for (i = 1; i < dma->nr_pages; i++) {
   118                  size = min_t(size_t, PAGE_SIZE, remaining_size);
   119                  remaining_size -= size;
   120                  addr = dma_map_page(dev,
   121                                      dma->pages[i],
   122                                      0,
   123                                      size,
   124                                      dma->direction);
   125                  if (unlikely(dma_mapping_error(dev, addr))) {
   126                          __free_page(dma->pages[i]);
   127                          return -EIO;
   128                  }
   129  
   130                  /*
   131                   * Compress SG list entry when pages are contiguous
   132                   * and transfer size less or equal to 
BCM_VK_MAX_SGL_CHUNK
   133                   */
   134                  if ((addr == (sg_addr + transfer_size)) &&
   135                      ((transfer_size + size) <= BCM_VK_MAX_SGL_CHUNK)) {
   136                          /* pages are contiguous, add to same sg entry */
   137                          transfer_size += size;
   138                  } else {
   139                          /* pages are not contiguous, write sg entry */
   140                          sgdata->size = transfer_size;
   141                          put_unaligned(sg_addr, (u64 *)&sgdata->address);
   142                          dma->sglist[SGLIST_NUM_SG]++;
   143  
   144                          /* start new sg entry */
   145                          sgdata++;
   146                          sg_addr = addr;
   147                          transfer_size = size;
   148                  }
   149          }
   150          /* Write last sg list entry */
   151          sgdata->size = transfer_size;
   152          put_unaligned(sg_addr, (u64 *)&sgdata->address);
   153          dma->sglist[SGLIST_NUM_SG]++;
   154  
   155          /* Update pointers and size field to point to sglist */
   156          put_unaligned((u64)dma->handle, &vkdata->address);
   157          vkdata->size = (dma->sglist[SGLIST_NUM_SG] * sizeof(*sgdata)) +
   158                         (sizeof(u32) * SGLIST_VKDATA_START);
   159  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

Reply via email to