Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67206876 authored by Neeti Desai's avatar Neeti Desai Committed by Matt Wagantall
Browse files

iommu/arm-smmu: Implement .dma_supported()



The .dma_supported() checks to see if the device can support DMA to the
memory described by the mask.  Implement this for the arm-smmu driver.

Change-Id: Ie494d574b613c1c76e6f878048c74444dc25902c
Signed-off-by: default avatarNeeti Desai <neetid@codeaurora.org>
Signed-off-by: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
parent f91f6136
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -1934,6 +1934,27 @@ out_unlock:
	return ret;
}

static int arm_smmu_dma_supported(struct iommu_domain *domain,
				  struct device *dev, u64 mask)
{
	struct arm_smmu_device *smmu;
	struct arm_smmu_domain *smmu_domain = domain->priv;
	int ret;

	mutex_lock(&smmu_domain->lock);
	smmu = smmu_domain->smmu;
	if (!smmu) {
		dev_err(dev,
			"Can't call dma_supported on an unattached domain\n");
		mutex_unlock(&smmu_domain->lock);
		return 0;
	}

	ret = ((1ULL << smmu->va_size) - 1) <= mask ? 0 : 1;
	mutex_unlock(&smmu_domain->lock);
	return ret;
}

static struct iommu_ops arm_smmu_ops = {
	.capable		= arm_smmu_capable,
	.domain_init		= arm_smmu_domain_init,
@@ -1949,6 +1970,7 @@ static struct iommu_ops arm_smmu_ops = {
	.domain_get_attr	= arm_smmu_domain_get_attr,
	.domain_set_attr	= arm_smmu_domain_set_attr,
	.pgsize_bitmap		= -1UL, /* Restricted during device attach */
	.dma_supported		= arm_smmu_dma_supported,
};

static void arm_smmu_device_reset(struct arm_smmu_device *smmu)