[asahilinux:bits/020-dart 4/20] drivers/iommu/apple-dart.c:851:54: warning: left shift count >= width of type

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild-all
Message-ID <[email protected]>
tree:   https://github.com/AsahiLinux/linux bits/020-dart
head:   45b2aa771c5241177bad6c3f1777bb34871aa5ef
commit: 679ee8da9f5f0497de57348d1c60a8a856f411b2 [4/20] iommu: apple-dart: Support specifying the DMA aperture in the DT
config: i386-buildonly-randconfig-006-20260825 (https://download.01.org/0day-ci/archive/20260825/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260825/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

   drivers/iommu/apple-dart.c: In function 'apple_dart_of_xlate':
>> drivers/iommu/apple-dart.c:851:54: warning: left shift count >= width of type [-Wshift-count-overflow]
     851 |                 dma_min = ((dma_addr_t)args->args[1] << 32) | args->args[2];
         |                                                      ^~
   drivers/iommu/apple-dart.c:852:62: warning: left shift count >= width of type [-Wshift-count-overflow]
     852 |                 dma_addr_t size = ((dma_addr_t)args->args[3] << 32) | args->args[4];
         |                                                              ^~


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

   831	
   832	static int apple_dart_of_xlate(struct device *dev,
   833				       const struct of_phandle_args *args)
   834	{
   835		struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
   836		struct platform_device *iommu_pdev = of_find_device_by_node(args->np);
   837		struct apple_dart *dart = platform_get_drvdata(iommu_pdev);
   838		struct apple_dart *cfg_dart;
   839		dma_addr_t dma_max = DMA_BIT_MASK(dart->ias);
   840		dma_addr_t dma_min = 0;
   841		int i, sid;
   842	
   843		put_device(&iommu_pdev->dev);
   844	
   845		if (args->args_count != 1 && args->args_count != 5)
   846			return -EINVAL;
   847	
   848		sid = args->args[0];
   849	
   850		if (args->args_count == 5) {
 > 851			dma_min = ((dma_addr_t)args->args[1] << 32) | args->args[2];
   852			dma_addr_t size = ((dma_addr_t)args->args[3] << 32) | args->args[4];
   853			if (!(IS_ALIGNED(dma_min, dart->pgsize) || !IS_ALIGNED(size, dart->pgsize))) {
   854				dev_err(dev, "Unaligned DMA window %pad..%pad for page size 0x%x\n",
   855					&dma_min, &size, dart->pgsize);
   856				return -EINVAL;
   857			}
   858			dma_max = dma_min + size - 1;
   859			/*
   860			 * Ensure that the DMA window does not exceed the dart's ias.
   861			 */
   862			if ((dma_min ^ dma_max) & ~DMA_BIT_MASK(dart->ias)) {
   863				dev_err(dev, "Invalid DMA window for ias=%d\n",
   864					dart->ias);
   865				return -EINVAL;
   866			}
   867		}
   868	
   869		if (!cfg) {
   870			cfg = kzalloc_obj(*cfg);
   871			if (!cfg)
   872				return -ENOMEM;
   873			/* Will be ANDed with DART capabilities */
   874			cfg->supports_bypass = true;
   875			/* Will be merged with other DARTs to the to fully overlapping range. */
   876			cfg->dma_min = dma_min;
   877			cfg->dma_max = dma_max;
   878		} else {
   879			if (dma_min >= cfg->dma_max || cfg->dma_min >= dma_max) {
   880				dev_err(dev, "non-overlapping DMA windows: %pad..%pad, "
   881					"%pad..%pad\n", &dma_min, &dma_max,
   882					&cfg->dma_min, &cfg->dma_max);
   883				return -EINVAL;
   884			}
   885			cfg->dma_min = max(dma_min, cfg->dma_min);
   886			cfg->dma_max = min(dma_max, cfg->dma_max);
   887		}
   888		dev_iommu_priv_set(dev, cfg);
   889	
   890		cfg_dart = cfg->stream_maps[0].dart;
   891		if (cfg_dart) {
   892			if (cfg_dart->pgsize != dart->pgsize)
   893				return -EINVAL;
   894			if (cfg_dart->ias != dart->ias)
   895				return -EINVAL;
   896		}
   897	
   898		cfg->supports_bypass &= dart->supports_bypass;
   899	
   900		for (i = 0; i < MAX_DARTS_PER_DEVICE; ++i) {
   901			if (cfg->stream_maps[i].dart == dart) {
   902				set_bit(sid, cfg->stream_maps[i].sidmap);
   903				return 0;
   904			}
   905		}
   906		for (i = 0; i < MAX_DARTS_PER_DEVICE; ++i) {
   907			if (!cfg->stream_maps[i].dart) {
   908				cfg->stream_maps[i].dart = dart;
   909				set_bit(sid, cfg->stream_maps[i].sidmap);
   910				return 0;
   911			}
   912		}
   913	
   914		return -EINVAL;
   915	}
   916	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.