accel/amdxdna: Allow forcing IOVA-based DMA via module parameter
Hello Lizhi Hou,
Commit ece3e8980907 ("accel/amdxdna: Allow forcing IOVA-based DMA via module parameter") from Jan 26, 2026 (linux-next), leads to the following Smatch static checker warning:
drivers/accel/amdxdna/amdxdna_iommu.c:68 amdxdna_iommu_map_bo()
warn: error code type promoted to positive: 'size'
drivers/accel/amdxdna/amdxdna_iommu.c
38 int amdxdna_iommu_map_bo(struct amdxdna_dev *xdna, struct amdxdna_gem_obj *abo)
39 {
40 struct sg_table *sgt;
41 dma_addr_t dma_addr;
42 struct iova *iova;
43 size_t size;
44
45 if (abo->type != AMDXDNA_BO_DEV_HEAP && abo->type != AMDXDNA_BO_SHMEM)
46 return 0;
47
48 sgt = drm_gem_shmem_get_pages_sgt(&abo->base);
49 if (IS_ERR(sgt)) {
50 XDNA_ERR(xdna, "Get sgt failed, ret %ld", PTR_ERR(sgt));
51 return PTR_ERR(sgt);
52 }
53
54 if (!sgt->orig_nents || !sg_page(sgt->sgl)) {
55 XDNA_ERR(xdna, "sgl is zero length or not page backed");
56 return -EOPNOTSUPP;
57 }
58
59 iova = amdxdna_iommu_alloc_iova(xdna, abo->mem.size, &dma_addr,
60 (abo->type == AMDXDNA_BO_DEV_HEAP));
61 if (IS_ERR(iova)) {
62 XDNA_ERR(xdna, "Alloc iova failed, ret %ld", PTR_ERR(iova));
63 return PTR_ERR(iova);
64 }
65
66 size = iommu_map_sgtable(xdna->domain, dma_addr, sgt,
67 IOMMU_READ | IOMMU_WRITE);--> 68 if (size < abo->mem.size) {
iommu_map_sgtable() returns negative error codes but size is unsigned.
69 __free_iova(&xdna->iovad, iova);
70 return -ENXIO;
71 }
72
73 abo->mem.dma_addr = dma_addr;
74
75 return 0;
76 }This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter