参照元

説明

引数

返り値

参考

実装

/**
 * iommu_group_get_for_dev - Find or create the IOMMU group for a device
 * @dev: target device
 *
 * This function is intended to be called by IOMMU drivers and extended to
 * support common, bus-defined algorithms when determining or creating the
 * IOMMU group for a device.  On success, the caller will hold a reference
 * to the returned IOMMU group, which will already include the provided
 * device.  The reference should be released with iommu_group_put().
 */
struct iommu_group *iommu_group_get_for_dev(struct device *dev)
{
	const struct iommu_ops *ops = dev->bus->iommu_ops;
	struct iommu_group *group;
	int ret;
	group = iommu_group_get(dev);
	if (group)
		return group;
	group = ERR_PTR(-EINVAL);
	if (ops && ops->device_group)
		group = ops->device_group(dev);

	if (IS_ERR(group))
		return group;
	/*
	 * Try to allocate a default domain - needs support from the
	 * IOMMU driver.
	 */
	if (!group->default_domain) {
		group->default_domain = __iommu_domain_alloc(dev->bus,
							     IOMMU_DOMAIN_DMA);
		group->domain = group->default_domain;
	}
	ret = iommu_group_add_device(group, dev);
	if (ret) {
		iommu_group_put(group);
		return ERR_PTR(ret);
	}
	return group;
}

コメント


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS