Thread (1 message) 1 message, 1 author, 2021-08-28

Re: [PATCH v2 4/8] iommu/dma: Support granule > PAGE_SIZE in dma_map_sg

From: kernel test robot <hidden>
Date: 2021-08-28 22:33:09
Also in: linux-iommu, oe-kbuild-all

Possibly related (same subject, not in this thread)

Hi Sven,

I love your patch! Perhaps something to improve:

[auto build test WARNING on iommu/next]
[also build test WARNING on v5.14-rc7 next-20210827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sven-Peter/Support-IOMMU-page-sizes-larger-than-the-CPU-page-size/20210828-233909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next
config: x86_64-randconfig-r004-20210827 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4e1a164d7bd53653f79decc121afe784d2fde0a7)
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
        # https://github.com/0day-ci/linux/commit/fa978f84667cfd7d8cb467899da60c08321798a5
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sven-Peter/Support-IOMMU-page-sizes-larger-than-the-CPU-page-size/20210828-233909
        git checkout fa978f84667cfd7d8cb467899da60c08321798a5
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

   drivers/iommu/dma-iommu.c:935:18: error: implicit declaration of function 'phys_to_page' [-Werror,-Wimplicit-function-declaration]
                   sg_set_page(s, phys_to_page(sg_phys(s) + s_iova_off), s_length,
                                  ^
quoted
drivers/iommu/dma-iommu.c:935:18: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'struct page *' [-Wint-conversion]
                   sg_set_page(s, phys_to_page(sg_phys(s) + s_iova_off), s_length,
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/scatterlist.h:110:69: note: passing argument to parameter 'page' here
   static inline void sg_set_page(struct scatterlist *sg, struct page *page,
                                                                       ^
   drivers/iommu/dma-iommu.c:982:9: error: implicit declaration of function 'phys_to_page' [-Werror,-Wimplicit-function-declaration]
                                       phys_to_page(sg_phys(s) + sg_dma_address(s)),
                                       ^
   drivers/iommu/dma-iommu.c:982:9: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'struct page *' [-Wint-conversion]
                                       phys_to_page(sg_phys(s) + sg_dma_address(s)),
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/scatterlist.h:110:69: note: passing argument to parameter 'page' here
   static inline void sg_set_page(struct scatterlist *sg, struct page *page,
                                                                       ^
   drivers/iommu/dma-iommu.c:1068:18: error: implicit declaration of function 'phys_to_page' [-Werror,-Wimplicit-function-declaration]
                   sg_set_page(s, phys_to_page(s_phys - s_iova_off),
                                  ^
   drivers/iommu/dma-iommu.c:1068:18: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'struct page *' [-Wint-conversion]
                   sg_set_page(s, phys_to_page(s_phys - s_iova_off),
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/scatterlist.h:110:69: note: passing argument to parameter 'page' here
   static inline void sg_set_page(struct scatterlist *sg, struct page *page,
                                                                       ^
   3 warnings and 3 errors generated.


vim +935 drivers/iommu/dma-iommu.c

   913	
   914	/*
   915	 * Prepare a successfully-mapped scatterlist to give back to the caller.
   916	 *
   917	 * At this point the segments are already laid out by iommu_dma_map_sg() to
   918	 * avoid individually crossing any boundaries, so we merely need to check a
   919	 * segment's start address to avoid concatenating across one.
   920	 */
   921	static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
   922			dma_addr_t dma_addr)
   923	{
   924		struct scatterlist *s, *cur = sg;
   925		unsigned long seg_mask = dma_get_seg_boundary(dev);
   926		unsigned int cur_len = 0, max_len = dma_get_max_seg_size(dev);
   927		int i, count = 0;
   928	
   929		for_each_sg(sg, s, nents, i) {
   930			/* Restore this segment's original unaligned fields first */
   931			unsigned int s_iova_off = sg_dma_address(s);
   932			unsigned int s_length = sg_dma_len(s);
   933			unsigned int s_iova_len = s->length;
   934	
 > 935			sg_set_page(s, phys_to_page(sg_phys(s) + s_iova_off), s_length,
   936				    s_iova_off & ~PAGE_MASK);
   937			sg_dma_address(s) = DMA_MAPPING_ERROR;
   938			sg_dma_len(s) = 0;
   939	
   940			/*
   941			 * Now fill in the real DMA data. If...
   942			 * - there is a valid output segment to append to
   943			 * - and this segment starts on an IOVA page boundary
   944			 * - but doesn't fall at a segment boundary
   945			 * - and wouldn't make the resulting output segment too long
   946			 */
   947			if (cur_len && !s_iova_off && (dma_addr & seg_mask) &&
   948			    (max_len - cur_len >= s_length)) {
   949				/* ...then concatenate it with the previous one */
   950				cur_len += s_length;
   951			} else {
   952				/* Otherwise start the next output segment */
   953				if (i > 0)
   954					cur = sg_next(cur);
   955				cur_len = s_length;
   956				count++;
   957	
   958				sg_dma_address(cur) = dma_addr + s_iova_off;
   959			}
   960	
   961			sg_dma_len(cur) = cur_len;
   962			dma_addr += s_iova_len;
   963	
   964			if (s_length + s_iova_off < s_iova_len)
   965				cur_len = 0;
   966		}
   967		return count;
   968	}
   969	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help