Re: [PATCH v2 3/3] iommu: dart: Add DART iommu driver

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

 



Hi Sven,

I love your patch! Yet something to improve:

[auto build test ERROR on arm-perf/for-next/perf]
[also build test ERROR on linus/master v5.12-rc4]
[cannot apply to iommu/next next-20210326]
[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/Apple-M1-DART-IOMMU-driver/20210328-154437
base:   https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git for-next/perf
config: sparc-allmodconfig (attached as .config)
compiler: sparc64-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
        # https://github.com/0day-ci/linux/commit/ecad602f1731c2ad5ba1579d56da519e38f57b2b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sven-Peter/Apple-M1-DART-IOMMU-driver/20210328-154437
        git checkout ecad602f1731c2ad5ba1579d56da519e38f57b2b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc 

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

All error/warnings (new ones prefixed by >>):

   drivers/iommu/apple-dart-iommu.c: In function 'apple_dart_finalize_domain':
>> drivers/iommu/apple-dart-iommu.c:427:34: error: implicit declaration of function 'DMA_BIT_MASK'; did you mean 'BIT_MASK'? [-Werror=implicit-function-declaration]
     427 |  domain->geometry.aperture_end = DMA_BIT_MASK(32);
         |                                  ^~~~~~~~~~~~
         |                                  BIT_MASK
   drivers/iommu/apple-dart-iommu.c: In function 'apple_dart_attach_stream':
>> drivers/iommu/apple-dart-iommu.c:456:11: error: implicit declaration of function 'kzalloc'; did you mean 'kvzalloc'? [-Werror=implicit-function-declaration]
     456 |  stream = kzalloc(sizeof(*stream), GFP_KERNEL);
         |           ^~~~~~~
         |           kvzalloc
>> drivers/iommu/apple-dart-iommu.c:456:9: warning: assignment to 'struct apple_dart_stream *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     456 |  stream = kzalloc(sizeof(*stream), GFP_KERNEL);
         |         ^
   drivers/iommu/apple-dart-iommu.c: In function 'apple_dart_detach_stream':
>> drivers/iommu/apple-dart-iommu.c:523:5: error: implicit declaration of function 'kfree'; did you mean 'kvfree'? [-Werror=implicit-function-declaration]
     523 |     kfree(stream);
         |     ^~~~~
         |     kvfree
   drivers/iommu/apple-dart-iommu.c: In function 'apple_dart_domain_alloc':
>> drivers/iommu/apple-dart-iommu.c:627:14: warning: assignment to 'struct apple_dart_domain *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     627 |  dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL);
         |              ^
   drivers/iommu/apple-dart-iommu.c: In function 'apple_dart_of_xlate':
>> drivers/iommu/apple-dart-iommu.c:659:7: warning: assignment to 'struct apple_dart_master_cfg *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     659 |   cfg = kzalloc(struct_size(cfg, streams, 1), GFP_KERNEL);
         |       ^
>> drivers/iommu/apple-dart-iommu.c:663:13: error: implicit declaration of function 'krealloc'; did you mean 'kvcalloc'? [-Werror=implicit-function-declaration]
     663 |   cfg_new = krealloc(
         |             ^~~~~~~~
         |             kvcalloc
   drivers/iommu/apple-dart-iommu.c:663:11: warning: assignment to 'struct apple_dart_master_cfg *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     663 |   cfg_new = krealloc(
         |           ^
   cc1: some warnings being treated as errors


vim +427 drivers/iommu/apple-dart-iommu.c

   397	
   398	/* must be called with held dart_domain->lock */
   399	static int apple_dart_finalize_domain(struct iommu_domain *domain)
   400	{
   401		struct apple_dart_domain *dart_domain = to_dart_domain(domain);
   402		struct apple_dart *dart = dart_domain->dart;
   403		struct io_pgtable_cfg pgtbl_cfg;
   404	
   405		if (dart_domain->pgtbl_ops)
   406			return 0;
   407		if (dart_domain->type != IOMMU_DOMAIN_DMA &&
   408		    dart_domain->type != IOMMU_DOMAIN_UNMANAGED)
   409			return 0;
   410	
   411		pgtbl_cfg = (struct io_pgtable_cfg){
   412			.pgsize_bitmap = SZ_16K,
   413			.ias = 32,
   414			.oas = 36,
   415			.coherent_walk = 1,
   416			.tlb = &apple_dart_tlb_ops,
   417			.iommu_dev = dart->dev,
   418		};
   419	
   420		dart_domain->pgtbl_ops =
   421			alloc_io_pgtable_ops(ARM_APPLE_DART, &pgtbl_cfg, domain);
   422		if (!dart_domain->pgtbl_ops)
   423			return -ENOMEM;
   424	
   425		domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
   426		domain->geometry.aperture_start = 0;
 > 427		domain->geometry.aperture_end = DMA_BIT_MASK(32);
   428		domain->geometry.force_aperture = true;
   429	
   430		return 0;
   431	}
   432	
   433	/* must be called with held domain->lock */
   434	static int apple_dart_attach_stream(struct apple_dart_domain *domain,
   435					    struct apple_dart *dart, u32 sid)
   436	{
   437		unsigned long flags;
   438		struct apple_dart_stream *stream;
   439		struct io_pgtable_cfg *pgtbl_cfg;
   440		int ret;
   441	
   442		list_for_each_entry(stream, &domain->streams, stream_head) {
   443			if (stream->dart == dart && stream->sid == sid) {
   444				stream->num_devices++;
   445				return 0;
   446			}
   447		}
   448	
   449		spin_lock_irqsave(&dart->lock, flags);
   450	
   451		if (WARN_ON(dart->used_sids & BIT(sid))) {
   452			ret = -EINVAL;
   453			goto error;
   454		}
   455	
 > 456		stream = kzalloc(sizeof(*stream), GFP_KERNEL);
   457		if (!stream) {
   458			ret = -ENOMEM;
   459			goto error;
   460		}
   461	
   462		stream->dart = dart;
   463		stream->sid = sid;
   464		stream->num_devices = 1;
   465		list_add(&stream->stream_head, &domain->streams);
   466	
   467		dart->used_sids |= BIT(sid);
   468		spin_unlock_irqrestore(&dart->lock, flags);
   469	
   470		apple_dart_hw_clear_all_ttbrs(stream->dart, stream->sid);
   471	
   472		switch (domain->type) {
   473		case IOMMU_DOMAIN_IDENTITY:
   474			apple_dart_hw_enable_bypass(stream->dart, stream->sid);
   475			break;
   476		case IOMMU_DOMAIN_BLOCKED:
   477			apple_dart_hw_enable_isolation(stream->dart, stream->sid);
   478			break;
   479		case IOMMU_DOMAIN_UNMANAGED:
   480		case IOMMU_DOMAIN_DMA:
   481			pgtbl_cfg = &io_pgtable_ops_to_pgtable(domain->pgtbl_ops)->cfg;
   482			apple_dart_hw_set_ttbr(stream->dart, stream->sid, 0,
   483					       pgtbl_cfg->apple_dart_cfg.ttbr);
   484	
   485			apple_dart_hw_enable_translation(stream->dart, stream->sid);
   486			apple_dart_hw_invalidate_tlb_stream(stream->dart, stream->sid);
   487			break;
   488		}
   489	
   490		return 0;
   491	
   492	error:
   493		spin_unlock_irqrestore(&dart->lock, flags);
   494		return ret;
   495	}
   496	
   497	static void apple_dart_disable_stream(struct apple_dart *dart, u32 sid)
   498	{
   499		unsigned long flags;
   500	
   501		apple_dart_hw_enable_isolation(dart, sid);
   502		apple_dart_hw_clear_all_ttbrs(dart, sid);
   503		apple_dart_hw_invalidate_tlb_stream(dart, sid);
   504	
   505		spin_lock_irqsave(&dart->lock, flags);
   506		dart->used_sids &= ~BIT(sid);
   507		spin_unlock_irqrestore(&dart->lock, flags);
   508	}
   509	
   510	/* must be called with held domain->lock */
   511	static void apple_dart_detach_stream(struct apple_dart_domain *domain,
   512					     struct apple_dart *dart, u32 sid)
   513	{
   514		struct apple_dart_stream *stream;
   515	
   516		list_for_each_entry(stream, &domain->streams, stream_head) {
   517			if (stream->dart == dart && stream->sid == sid) {
   518				stream->num_devices--;
   519	
   520				if (stream->num_devices == 0) {
   521					apple_dart_disable_stream(dart, sid);
   522					list_del(&stream->stream_head);
 > 523					kfree(stream);
   524				}
   525				return;
   526			}
   527		}
   528	}
   529	

---
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]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux