*参照元 [#y6a52341]
#backlinks

*説明 [#i3c4a9fe]
-パス: [[linux-4.4.1/]]
-パス: [[linux-4.4.1/drivers/iommu/dma-iommu.c]]

-FIXME: これは何?
--説明


**引数 [#p5014b5f]
-struct iommu_domain *domain
--
--[[linux-4.4.1/iommu_domain]]
-dma_addr_t base
--
--[[linux-4.4.1/dma_addr_t]]
-u64 size
--


**返り値 [#s5657385]
-int
--


**参考 [#q86b8eed]


*実装 [#e196c8a4]
 /**
  * iommu_dma_init_domain - Initialise a DMA mapping domain
  * @domain: IOMMU domain previously prepared by iommu_get_dma_cookie()
  * @base: IOVA at which the mappable address space starts
  * @size: Size of IOVA space
  *
  * @base and @size should be exact multiples of IOMMU page granularity to
  * avoid rounding surprises. If necessary, we reserve the page at address 0
  * to ensure it is an invalid IOVA. It is safe to reinitialise a domain, but
  * any change which could make prior IOVAs invalid will fail.
  */
 int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, u64 size)
 {
 	struct iova_domain *iovad = domain->iova_cookie;
 	unsigned long order, base_pfn, end_pfn;
 
-
--[[linux-4.4.1/iova_domain]]

 	if (!iovad)
 		return -ENODEV;
 
 	/* Use the smallest supported page size for IOVA granularity */
 	order = __ffs(domain->ops->pgsize_bitmap);
 	base_pfn = max_t(unsigned long, 1, base >> order);
 	end_pfn = (base + size - 1) >> order;
 
-
--[[linux-4.4.1/__ffs()]]
--[[linux-4.4.1/max_t()]]

 	/* Check the domain allows at least some access to the device... */
 	if (domain->geometry.force_aperture) {
 		if (base > domain->geometry.aperture_end ||
 		    base + size <= domain->geometry.aperture_start) {
 			pr_warn("specified DMA range outside IOMMU capability\n");
 			return -EFAULT;
 		}
 		/* ...then finally give it a kicking to make sure it fits */
 		base_pfn = max_t(unsigned long, base_pfn,
 				domain->geometry.aperture_start >> order);
 		end_pfn = min_t(unsigned long, end_pfn,
 				domain->geometry.aperture_end >> order);
 	}
 
-
--[[linux-4.4.1/pr_warn()]]
--[[linux-4.4.1/min_t()]]

 	/* All we can safely do with an existing domain is enlarge it */
 	if (iovad->start_pfn) {
 		if (1UL << order != iovad->granule ||
 		    base_pfn != iovad->start_pfn ||
 		    end_pfn < iovad->dma_32bit_pfn) {
 			pr_warn("Incompatible range for DMA domain\n");
 			return -EFAULT;
 		}
 		iovad->dma_32bit_pfn = end_pfn;
 	} else {
 		init_iova_domain(iovad, 1UL << order, base_pfn, end_pfn);
 	}
-
--[[linux-4.4.1/init_iova_domain()]]

 	return 0;
 }
 EXPORT_SYMBOL(iommu_dma_init_domain);
-
--[[linux-4.4.1/EXPORT_SYMBOL()]]


*コメント [#e2b6d751]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS