*参照元 [#mbee36c9] #backlinks *説明 [#sa71bb69] -パス: [[linux-4.4.1/arch/arm64/mm/dma-mapping.c]] -FIXME: これは何? --説明 **引数 [#t4948f31] -struct device *dev -- --[[linux-4.4.1/device]] -const struct iommu_ops *ops -- --[[linux-4.4.1/iommu_ops]] -u64 dma_base -- -u64 size -- **返り値 [#w641b359] -bool -- **参考 [#t1005523] *実装 [#ec8491c4] static bool do_iommu_attach(struct device *dev, const struct iommu_ops *ops, u64 dma_base, u64 size) { struct iommu_domain *domain = iommu_get_domain_for_dev(dev); - --[[linux-4.4.1/iommu_domain]] --[[linux-4.4.1/iommu_get_domain_for_dev()]] /* * Best case: The device is either part of a group which was * already attached to a domain in a previous call, or it's * been put in a default DMA domain by the IOMMU core. */ if (!domain) { /* * Urgh. The IOMMU core isn't going to do default domains * for non-PCI devices anyway, until it has some means of * abstracting the entirely implementation-specific * sideband data/SoC topology/unicorn dust that may or * may not differentiate upstream masters. * So until then, HORRIBLE HACKS! */ domain = ops->domain_alloc(IOMMU_DOMAIN_DMA); if (!domain) goto out_no_domain; domain->ops = ops; domain->type = IOMMU_DOMAIN_DMA | __IOMMU_DOMAIN_FAKE_DEFAULT; if (iommu_attach_device(domain, dev)) goto out_put_domain; - --[[linux-4.4.1/iommu_attach_device()]] } if (iommu_dma_init_domain(domain, dma_base, size)) goto out_detach; - --[[linux-4.4.1/iommu_dma_init_domain()]] dev->archdata.dma_ops = &iommu_dma_ops; return true; - --[[linux-4.4.1/]] -dev->archdata は struct dev_archdata 型 --[[linux-4.4.1/dev_archdata]] --[[linux-4.4.1/iommu_dma_ops(global)]] out_detach: iommu_detach_device(domain, dev); - --[[linux-4.4.1/iommu_detach_device()]] out_put_domain: if (domain->type & __IOMMU_DOMAIN_FAKE_DEFAULT) iommu_domain_free(domain); - --[[linux-4.4.1/iommu_domain_free()]] out_no_domain: pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", dev_name(dev)); return false; - --[[linux-4.4.1/pr_warn()]] --[[linux-4.4.1/dev_name()]] } *コメント [#uaad4962]