Re: [PATCH v7 08/12] device core: Introduce DMA range map, supplanting dma_pfn_offset

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

 



Hi Jim,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pci/next]
[also build test ERROR on robh/for-next sunxi/sunxi/for-next linuxtv-media/master usb/usb-testing linus/master v5.8-rc4 next-20200710]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jim-Quinlan/PCI-brcmstb-enable-PCIe-for-STB-chips/20200709-033557
base:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: m68k-randconfig-r035-20200710 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
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
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

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

All errors (new ones prefixed by >>):

   drivers/of/device.c: In function 'of_dma_configure':
>> drivers/of/device.c:116:37: error: dereferencing pointer to incomplete type 'const struct bus_dma_region'
     116 |   for (dma_start = ~(dma_addr_t)0; r->size; r++) {
         |                                     ^~
>> drivers/of/device.c:116:46: error: increment of pointer to an incomplete type 'const struct bus_dma_region'
     116 |   for (dma_start = ~(dma_addr_t)0; r->size; r++) {
         |                                              ^~
   In file included from drivers/of/device.c:8:
   At top level:
   include/linux/dma-mapping.h:498:12: warning: 'dma_attach_offset_range' defined but not used [-Wunused-function]
     498 | static int dma_attach_offset_range(struct device *dev, phys_addr_t cpu_start,
         |            ^~~~~~~~~~~~~~~~~~~~~~~
--
   drivers/of/address.c: In function 'dma_create_offset_map':
>> drivers/of/address.c:929:37: error: dereferencing pointer to incomplete type 'struct bus_dma_region'
     929 |  r = kcalloc(num_ranges + 1, sizeof(*r), GFP_KERNEL);
         |                                     ^~
>> drivers/of/address.c:950:4: error: increment of pointer to an incomplete type 'struct bus_dma_region'
     950 |   r++;
         |    ^~
   In file included from include/linux/pci-dma-compat.h:8,
                    from include/linux/pci.h:2415,
                    from drivers/of/address.c:11:
   At top level:
   include/linux/dma-mapping.h:498:12: warning: 'dma_attach_offset_range' defined but not used [-Wunused-function]
     498 | static int dma_attach_offset_range(struct device *dev, phys_addr_t cpu_start,
         |            ^~~~~~~~~~~~~~~~~~~~~~~

vim +116 drivers/of/device.c

    74	
    75	/**
    76	 * of_dma_configure - Setup DMA configuration
    77	 * @dev:	Device to apply DMA configuration
    78	 * @np:		Pointer to OF node having DMA configuration
    79	 * @force_dma:  Whether device is to be set up by of_dma_configure() even if
    80	 *		DMA capability is not explicitly described by firmware.
    81	 *
    82	 * Try to get devices's DMA configuration from DT and update it
    83	 * accordingly.
    84	 *
    85	 * If platform code needs to use its own special DMA configuration, it
    86	 * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events
    87	 * to fix up DMA configuration.
    88	 */
    89	int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
    90	{
    91		const struct iommu_ops *iommu;
    92		const struct bus_dma_region *map;
    93		dma_addr_t dma_start = 0;
    94		u64 mask, end, size = 0;
    95		bool coherent;
    96		int ret;
    97	
    98		map = of_dma_get_range(np);
    99		ret = PTR_ERR_OR_ZERO(map);
   100		if (ret < 0) {
   101			/*
   102			 * For legacy reasons, we have to assume some devices need
   103			 * DMA configuration regardless of whether "dma-ranges" is
   104			 * correctly specified or not.
   105			 */
   106			if (!force_dma)
   107				return ret == -ENODEV ? 0 : ret;
   108	
   109			dma_start = 0;
   110			map = NULL;
   111		} else if (map) {
   112			const struct bus_dma_region *r = map;
   113			dma_addr_t dma_end = 0;
   114	
   115			/* Determine the overall bounds of all DMA regions */
 > 116			for (dma_start = ~(dma_addr_t)0; r->size; r++) {
   117				/* Take lower and upper limits */
   118				if (r->dma_start < dma_start)
   119					dma_start = r->dma_start;
   120				if (r->dma_start + r->size > dma_end)
   121					dma_end = r->dma_start + r->size;
   122			}
   123			size = dma_end - dma_start;
   124	
   125			/*
   126			 * Add a work around to treat the size as mask + 1 in case
   127			 * it is defined in DT as a mask.
   128			 */
   129			if (size & 1) {
   130				dev_warn(dev, "Invalid size 0x%llx for dma-range(s)\n", size);
   131				size = size + 1;
   132			}
   133	
   134			if (!size) {
   135				dev_err(dev, "Adjusted size 0x%llx invalid\n", size);
   136				kfree(map);
   137				return -EINVAL;
   138			}
   139		}
   140	
   141		/*
   142		 * If @dev is expected to be DMA-capable then the bus code that created
   143		 * it should have initialised its dma_mask pointer by this point. For
   144		 * now, we'll continue the legacy behaviour of coercing it to the
   145		 * coherent mask if not, but we'll no longer do so quietly.
   146		 */
   147		if (!dev->dma_mask) {
   148			dev_warn(dev, "DMA mask not set\n");
   149			dev->dma_mask = &dev->coherent_dma_mask;
   150		}
   151	
   152		if (!size && dev->coherent_dma_mask)
   153			size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);
   154		else if (!size)
   155			size = 1ULL << 32;
   156	
   157		/*
   158		 * Limit coherent and dma mask based on size and default mask
   159		 * set by the driver.
   160		 */
   161		end = dma_start + size - 1;
   162		mask = DMA_BIT_MASK(ilog2(end) + 1);
   163		dev->coherent_dma_mask &= mask;
   164		*dev->dma_mask &= mask;
   165		/* ...but only set bus limit if we found valid dma-ranges earlier */
   166		if (!ret)
   167			dev->bus_dma_limit = end;
   168	
   169		coherent = of_dma_is_coherent(np);
   170		dev_dbg(dev, "device is%sdma coherent\n",
   171			coherent ? " " : " not ");
   172	
   173		iommu = of_iommu_configure(dev, np);
   174		if (PTR_ERR(iommu) == -EPROBE_DEFER) {
   175			kfree(map);
   176			return -EPROBE_DEFER;
   177		}
   178	
   179		dev_dbg(dev, "device is%sbehind an iommu\n",
   180			iommu ? " " : " not ");
   181	
   182		arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
   183	
   184		dev->dma_range_map = map;
   185		return 0;
   186	}
   187	EXPORT_SYMBOL_GPL(of_dma_configure);
   188	

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux