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

Commit 38ae91ef authored by Neeti Desai's avatar Neeti Desai Committed by Olav Haugan
Browse files

iommu: msm: Program non secure registers only in non secure environment



The non secure registers in IOMMU are programmed when
CONFIG_IOMMU_NON_SECURE is enabled. The programming of these registers
is no longer dependent on this config, but depends on a check to see
if the secure environment is available.

CONFIG_IOMMU_NON_SECURE is now only used to force all SMMUs to be
programmed by the Linux kernel SMMU driver for debugging purposes.

Change-Id: I367f92fd6e5198395b83e6ca8acde66b1b012620
Signed-off-by: default avatarNeeti Desai <neetid@codeaurora.org>
parent a18f488c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -364,6 +364,10 @@ static inline int msm_soc_version_supports_iommu_v0(void)
	return 0;
}
#endif

int msm_iommu_get_scm_call_avail(void);
void msm_iommu_check_scm_call_avail(void);

u32 msm_iommu_get_mair0(void);
u32 msm_iommu_get_mair1(void);
u32 msm_iommu_get_prrr(void);
+6 −15
Original line number Diff line number Diff line
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -297,7 +297,6 @@ static void __reset_iommu(void __iomem *base)
	mb();
}

#ifdef CONFIG_IOMMU_NON_SECURE
static void __reset_iommu_secure(void __iomem *base)
{
	SET_NSACR(base, 0);
@@ -319,23 +318,14 @@ static void __program_iommu_secure(void __iomem *base)
	SET_NSCR0_CLIENTPD(base, 0);
}

#else
static inline void __reset_iommu_secure(void __iomem *base)
{
}

static inline void __program_iommu_secure(void __iomem *base)
{
}

#endif

/*
 * May only be called for non-secure iommus
 */
static void __program_iommu(void __iomem *base)
{
	__reset_iommu(base);

	if (!msm_iommu_get_scm_call_avail())
		__reset_iommu_secure(base);

	SET_CR0_SMCFCFG(base, 1);
@@ -347,6 +337,7 @@ static void __program_iommu(void __iomem *base)
	SET_CR0_GFRE(base, 1);
	SET_CR0_CLIENTPD(base, 0);

	if (!msm_iommu_get_scm_call_avail())
		__program_iommu_secure(base);

	mb(); /* Make sure writes complete before returning */
+13 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -126,6 +126,11 @@ static void __put_bus_vote_client(struct msm_iommu_drvdata *drvdata)
	drvdata->bus_client = 0;
}

/*
 * CONFIG_IOMMU_NON_SECURE allows us to override the secure
 * designation of SMMUs in device tree. With this config enabled
 * all SMMUs will be programmed by this driver.
 */
#ifdef CONFIG_IOMMU_NON_SECURE
static inline void get_secure_id(struct device_node *node,
			  struct msm_iommu_drvdata *drvdata)
@@ -141,12 +146,15 @@ static inline void get_secure_ctx(struct device_node *node,
static void get_secure_id(struct device_node *node,
			  struct msm_iommu_drvdata *drvdata)
{
	of_property_read_u32(node, "qcom,iommu-secure-id", &drvdata->sec_id);
	if (msm_iommu_get_scm_call_avail())
		of_property_read_u32(node, "qcom,iommu-secure-id",
				     &drvdata->sec_id);
}

static void get_secure_ctx(struct device_node *node,
			   struct msm_iommu_ctx_drvdata *ctx_drvdata)
{
	if (msm_iommu_get_scm_call_avail())
		ctx_drvdata->secure_context =
			of_property_read_bool(node, "qcom,secure-context");
}
@@ -597,6 +605,8 @@ static int __init msm_iommu_driver_init(void)
{
	int ret;

	msm_iommu_check_scm_call_avail();

	msm_set_iommu_access_ops(&iommu_access_ops_v1);
	msm_iommu_sec_set_access_ops(&iommu_access_ops_v1);

+11 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@


static struct iommu_access_ops *iommu_access_ops;
static int is_secure;

static const struct of_device_id msm_smmu_list[] = {
	{ .compatible = "qcom,msm-smmu-v1", },
@@ -787,6 +788,16 @@ static phys_addr_t msm_iommu_get_pt_base_addr(struct iommu_domain *domain)
	return 0;
}

void msm_iommu_check_scm_call_avail(void)
{
	is_secure = scm_is_call_available(SCM_SVC_MP, IOMMU_SECURE_CFG);
}

int msm_iommu_get_scm_call_avail(void)
{
	return is_secure;
}

static struct iommu_ops msm_iommu_ops = {
	.domain_init = msm_iommu_domain_init,
	.domain_destroy = msm_iommu_domain_destroy,