public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [asahilinux:bits/020-dart 13/13] drivers/iommu/apple-dart.c:779:16: warning: implicit conversion from 'unsigned long long' to 'dma_addr_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295
@ 2023-08-08 14:14 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-08-08 14:14 UTC (permalink / raw)
  To: Hector Martin; +Cc: llvm, oe-kbuild-all, Janne Grunau

tree:   https://github.com/AsahiLinux/linux bits/020-dart
head:   cb0b356d0c09b50ed669ae17f2b238289ff6c03d
commit: cb0b356d0c09b50ed669ae17f2b238289ff6c03d [13/13] iommu: apple-dart: Support specifying the DMA aperture in the DT
config: i386-buildonly-randconfig-r006-20230808 (https://download.01.org/0day-ci/archive/20230808/202308082218.yGjSIIUU-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230808/202308082218.yGjSIIUU-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308082218.yGjSIIUU-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/iommu/apple-dart.c:779:16: warning: implicit conversion from 'unsigned long long' to 'dma_addr_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion]
                                           dma_max = DMA_BIT_MASK(pgtbl_cfg.ias);
                                                   ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dma-mapping.h:76:40: note: expanded from macro 'DMA_BIT_MASK'
   #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
                                          ^~~~~
   drivers/iommu/apple-dart.c:1347:18: warning: implicit conversion from 'unsigned long long' to 'dma_addr_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion]
           dart->dma_max = DMA_BIT_MASK(dart->ias);
                         ~ ^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dma-mapping.h:76:40: note: expanded from macro 'DMA_BIT_MASK'
   #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
                                          ^~~~~
   2 warnings generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for OF_IOMMU
   Depends on [n]: IOMMU_SUPPORT [=y] && OF [=n] && IOMMU_API [=y]
   Selected by [y]:
   - APPLE_DART [=y] && IOMMU_SUPPORT [=y] && (ARCH_APPLE || COMPILE_TEST [=y]) && !GENERIC_ATOMIC64 [=n]


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

   721	
   722	static int apple_dart_finalize_domain(struct iommu_domain *domain,
   723					      struct device *dev,
   724					      struct apple_dart_master_cfg *cfg)
   725	{
   726		struct apple_dart_domain *dart_domain = to_dart_domain(domain);
   727		struct apple_dart *dart = cfg->stream_maps[0].dart;
   728		struct io_pgtable_cfg pgtbl_cfg;
   729		dma_addr_t dma_max = dart->dma_max;
   730		u32 ias = min_t(u32, dart->ias, fls64(dma_max));
   731		int ret = 0;
   732		int i, j;
   733	
   734		mutex_lock(&dart_domain->init_lock);
   735	
   736		if (dart_domain->finalized)
   737			goto done;
   738	
   739		for (i = 0; i < MAX_DARTS_PER_DEVICE; ++i) {
   740			dart_domain->stream_maps[i].dart = cfg->stream_maps[i].dart;
   741			for (j = 0; j < BITS_TO_LONGS(dart->num_streams); j++)
   742				atomic_long_set(&dart_domain->stream_maps[i].sidmap[j],
   743						cfg->stream_maps[i].sidmap[j]);
   744		}
   745	
   746		pgtbl_cfg = (struct io_pgtable_cfg){
   747			.pgsize_bitmap = dart->pgsize,
   748			.ias = ias,
   749			.oas = dart->oas,
   750			.coherent_walk = 1,
   751			.iommu_dev = dart->dev,
   752		};
   753	
   754		if (dart->locked) {
   755			unsigned long *sidmap;
   756			int sid;
   757			u32 ttbr;
   758	
   759			/* Locked DARTs can only have a single stream bound */
   760			sidmap = cfg->stream_maps[0].sidmap;
   761			sid = find_first_bit(sidmap, dart->num_streams);
   762	
   763			WARN_ON((sid < 0) || bitmap_weight(sidmap, dart->num_streams) > 1);
   764			ttbr = readl(dart->regs + DART_TTBR(dart, sid, 0));
   765	
   766			WARN_ON(!(ttbr & dart->hw->ttbr_valid));
   767	
   768			/* If the DART is locked, we need to keep the translation level count. */
   769			if (dart->hw->tcr_4level && dart->ias > 36) {
   770				if (readl(dart->regs + DART_TCR(dart, sid)) & dart->hw->tcr_4level) {
   771					if (ias < 37) {
   772						dev_info(dart->dev, "Expanded to ias=37 due to lock\n");
   773						pgtbl_cfg.ias = 37;
   774					}
   775				} else if (ias > 36) {
   776					dev_info(dart->dev, "Limited to ias=36 due to lock\n");
   777					pgtbl_cfg.ias = 36;
   778					if (dart->dma_min == 0 && dma_max == DMA_BIT_MASK(dart->ias)) {
 > 779						dma_max = DMA_BIT_MASK(pgtbl_cfg.ias);
   780					} else if ((dart->dma_min ^ dma_max) & ~DMA_BIT_MASK(36)) {
   781						dev_err(dart->dev,
   782							"Invalid DMA range for locked 3-level PT\n");
   783						ret = -ENOMEM;
   784						goto done;
   785					}
   786				}
   787			}
   788		}
   789	
   790		dart_domain->pgtbl_ops =
   791			alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain);
   792		if (!dart_domain->pgtbl_ops) {
   793			ret = -ENOMEM;
   794			goto done;
   795		}
   796	
   797		if (pgtbl_cfg.pgsize_bitmap == SZ_4K)
   798			dart_domain->mask = DMA_BIT_MASK(min_t(u32, dart->ias, 32));
   799		else if (pgtbl_cfg.apple_dart_cfg.n_levels == 3)
   800			dart_domain->mask = DMA_BIT_MASK(min_t(u32, dart->ias, 36));
   801		else if (pgtbl_cfg.apple_dart_cfg.n_levels == 4)
   802			dart_domain->mask = DMA_BIT_MASK(min_t(u32, dart->ias, 47));
   803	
   804		domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
   805		domain->geometry.aperture_start = dart->dma_min;
   806		domain->geometry.aperture_end = dma_max;
   807		domain->geometry.force_aperture = true;
   808	
   809		dart_domain->finalized = true;
   810	
   811		ret = apple_dart_setup_resv_locked(domain, dev, dart->pgsize);
   812	done:
   813		mutex_unlock(&dart_domain->init_lock);
   814		return ret;
   815	}
   816	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-08 14:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08 14:14 [asahilinux:bits/020-dart 13/13] drivers/iommu/apple-dart.c:779:16: warning: implicit conversion from 'unsigned long long' to 'dma_addr_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox