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

Commit 8dae723c authored by Chintan Pandya's avatar Chintan Pandya
Browse files

iommu: msm: secure: support attributes which clients use



Some IOMMU client drivers expect certain attributes to
be available. Present MSM IOMMU driver really don't deal
with them. But clients don't really care what IOMMU driver
does behind the doors. For ex.
DOMAIN_ATTR_COHERENT_HTW_DISABLE is really not enabled
for secure MSM driver. So, just let clients calm down
by providing dummy support for those attributes.

Change-Id: I5cc1874d194f3d001f29aee1a9ff72e510ae16bd
Signed-off-by: default avatarChintan Pandya <cpandya@codeaurora.org>
parent 387f2853
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <linux/kmemleak.h>
#include <linux/dma-mapping.h>
#include <soc/qcom/scm.h>
#include <soc/qcom/secure_buffer.h>

#include <asm/cacheflush.h>
#include <linux/sizes.h>
@@ -1009,6 +1010,28 @@ static int msm_iommu_dma_supported(struct iommu_domain *domain,
	return ((1ULL << 32) - 1) < mask ? 0 : 1;
}

static int msm_iommu_domain_set_attr(struct iommu_domain *domain,
				enum iommu_attr attr, void *data)
{
	switch (attr) {
	case DOMAIN_ATTR_COHERENT_HTW_DISABLE:
		/*
		 * Just quietly bail out as L2-redirect feature
		 * cannot be enabled for Secure context banks.
		 */
		break;
	case DOMAIN_ATTR_SECURE_VMID:
		/*
		 * MSM iommu driver doesn't set the VMID for
		 * any domain.
		 */
		break;
	default:
		return -EINVAL;
	}
	return 0;
}

static int msm_iommu_domain_get_attr(struct iommu_domain *domain,
				enum iommu_attr attr, void *data)
{
@@ -1016,6 +1039,16 @@ static int msm_iommu_domain_get_attr(struct iommu_domain *domain,
	struct msm_iommu_ctx_drvdata *ctx_drvdata;

	switch (attr) {
	case DOMAIN_ATTR_COHERENT_HTW_DISABLE:
		/*
		 * This is the case always for secure
		 * context banks
		 */
		*((unsigned int *) data) = 1;
		break;
	case DOMAIN_ATTR_SECURE_VMID:
		*((int *) data) = -VMID_INVAL;
		break;
	case DOMAIN_ATTR_CONTEXT_BANK:
		if (list_empty(&priv->list_attached))
			return -ENODEV;
@@ -1043,6 +1076,7 @@ static struct iommu_ops msm_iommu_ops = {
	.iova_to_phys = msm_iommu_iova_to_phys,
	.capable = msm_iommu_capable,
	.pgsize_bitmap = MSM_IOMMU_PGSIZES,
	.domain_set_attr = msm_iommu_domain_set_attr,
	.domain_get_attr = msm_iommu_domain_get_attr,
	.dma_supported = msm_iommu_dma_supported,
};