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

Commit f4288449 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iommu: arm-smmu: Enable io-coherency in bypass mode"

parents 4093a080 93985477
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -192,9 +192,16 @@ enum arm_smmu_s2cr_privcfg {
#define ARM_SMMU_CB_ATS1PR		0x800
#define ARM_SMMU_CB_ATSR		0x8f0

#define SCTLR_MEM_ATTR_SHIFT		16
#define SCTLR_SHCFG_SHIFT		22
#define SCTLR_RACFG_SHIFT		24
#define SCTLR_WACFG_SHIFT		26
#define SCTLR_SHCFG_MASK		0x3
#define SCTLR_SHCFG_NSH			0x3
#define SCTLR_RACFG_RA			0x2
#define SCTLR_WACFG_WA			0x2
#define SCTLR_MEM_ATTR_OISH_WB_CACHE	0xf
#define SCTLR_MTCFG			(1 << 20)
#define SCTLR_S1_ASIDPNE		(1 << 12)
#define SCTLR_CFCFG			(1 << 7)
#define SCTLR_HUPCF			(1 << 8)
+26 −3
Original line number Diff line number Diff line
@@ -431,6 +431,12 @@ static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom)
	return container_of(dom, struct arm_smmu_domain, domain);
}

static struct arm_smmu_domain*
cb_cfg_to_smmu_domain(struct arm_smmu_cfg *cfg)
{
	return container_of(cfg, struct arm_smmu_domain, cfg);
}

static void parse_driver_options(struct arm_smmu_device *smmu)
{
	int i = 0;
@@ -1554,6 +1560,7 @@ static void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx,
	bool stage1;
	struct arm_smmu_cb *cb = &smmu->cbs[idx];
	struct arm_smmu_cfg *cfg = cb->cfg;
	struct arm_smmu_domain *smmu_domain = NULL;
	void __iomem *cb_base, *gr1_base;

	cb_base = ARM_SMMU_CB(smmu, idx);
@@ -1627,7 +1634,23 @@ static void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx,
	/* SCTLR */
	reg = SCTLR_CFCFG | SCTLR_CFIE | SCTLR_CFRE | SCTLR_AFE | SCTLR_TRE;

	/* Ensure bypass transactions are Non-shareable */
	/*
	 * Ensure bypass transactions are Non-shareable only for clients
	 * who are not io-coherent.
	 */
	smmu_domain = cb_cfg_to_smmu_domain(cfg);

	/*
	 * Override cacheability, shareability, r/w allocation for
	 * clients who are io-coherent
	 */
	if (of_dma_is_coherent(smmu_domain->dev->of_node)) {

		reg |= SCTLR_RACFG_RA << SCTLR_RACFG_SHIFT;
		reg |= SCTLR_WACFG_WA << SCTLR_WACFG_SHIFT;
		reg |= SCTLR_MTCFG;
		reg |= SCTLR_MEM_ATTR_OISH_WB_CACHE << SCTLR_MEM_ATTR_SHIFT;
	} else
		reg |= SCTLR_SHCFG_NSH << SCTLR_SHCFG_SHIFT;

	if (attributes & (1 << DOMAIN_ATTR_CB_STALL_DISABLE)) {