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

Commit 420482e3 authored by Hardik Kantilal Patel's avatar Hardik Kantilal Patel
Browse files

icnss: Use fixed memory region for WLAN MSA0 memory



During first time boot up WLAN Platform driver allocate
1 MB MSA0 Memory region. This region may be adjacent to
other regions that also requires access control, due to
that TZ will merge the two sections into one single resource
group. During this Q6 will lose access to memory region causing
a NOC Error. To avoid use fixed memory region for WLAN MSA0
memory.

CRs-Fixed: 2066025
Change-Id: Ie878e010954524bbe48a29d6ad6f2f53848ab25e
Signed-off-by: default avatarHardik Kantilal Patel <hkpatel@codeaurora.org>
parent c619a7c2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ Optional properties:
  - qcom,icnss-vadc: VADC handle for vph_pwr read APIs.
  - qcom,icnss-adc_tm: VADC handle for vph_pwr notification APIs.
  - qcom,smmu-s1-bypass: Boolean context flag to set SMMU to S1 bypass
  - qcom,wlan-msa-fixed-region: phandle, specifier pairs to children of /reserved-memory

Example:

@@ -54,6 +55,7 @@ Example:
		   <0 140 0 /* CE10 */ >,
		   <0 141 0 /* CE11 */ >;
        qcom,wlan-msa-memory = <0x200000>;
	qcom,wlan-msa-fixed-region = <&wlan_msa_mem>;
	qcom,smmu-s1-bypass;
	vdd-0.8-cx-mx-supply = <&pm8998_l5>;
	qcom,vdd-0.8-cx-mx-config = <800000 800000 2400 1000>;
+48 −15
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#define pr_fmt(fmt) "icnss: " fmt

#include <asm/dma-iommu.h>
#include <linux/of_address.h>
#include <linux/clk.h>
#include <linux/iommu.h>
#include <linux/export.h>
@@ -4160,6 +4161,9 @@ static int icnss_probe(struct platform_device *pdev)
	int i;
	struct device *dev = &pdev->dev;
	struct icnss_priv *priv;
	const __be32 *addrp;
	u64 prop_size = 0;
	struct device_node *np;

	if (penv) {
		icnss_pr_err("Driver is already initialized\n");
@@ -4231,24 +4235,53 @@ static int icnss_probe(struct platform_device *pdev)
		}
	}

	np = of_parse_phandle(dev->of_node,
			      "qcom,wlan-msa-fixed-region", 0);
	if (np) {
		addrp = of_get_address(np, 0, &prop_size, NULL);
		if (!addrp) {
			icnss_pr_err("Failed to get assigned-addresses or property\n");
			ret = -EINVAL;
			goto out;
		}

		priv->msa_pa = of_translate_address(np, addrp);
		if (priv->msa_pa == OF_BAD_ADDR) {
			icnss_pr_err("Failed to translate MSA PA from device-tree\n");
			ret = -EINVAL;
			goto out;
		}

		priv->msa_va = memremap(priv->msa_pa,
					(unsigned long)prop_size, MEMREMAP_WT);
		if (!priv->msa_va) {
			icnss_pr_err("MSA PA ioremap failed: phy addr: %pa\n",
				     &priv->msa_pa);
			ret = -EINVAL;
			goto out;
		}
		priv->msa_mem_size = prop_size;
	} else {
		ret = of_property_read_u32(dev->of_node, "qcom,wlan-msa-memory",
					   &priv->msa_mem_size);

		if (ret || priv->msa_mem_size == 0) {
		icnss_pr_err("Fail to get MSA Memory Size: %u, ret: %d\n",
			icnss_pr_err("Fail to get MSA Memory Size: %u ret: %d\n",
				     priv->msa_mem_size, ret);
			goto out;
		}

	priv->msa_va = dmam_alloc_coherent(&pdev->dev, priv->msa_mem_size,
					   &priv->msa_pa, GFP_KERNEL);
		priv->msa_va = dmam_alloc_coherent(&pdev->dev,
				priv->msa_mem_size, &priv->msa_pa, GFP_KERNEL);

		if (!priv->msa_va) {
			icnss_pr_err("DMA alloc failed for MSA\n");
			ret = -ENOMEM;
			goto out;
		}
	icnss_pr_dbg("MSA pa: %pa, MSA va: 0x%p\n", &priv->msa_pa,
		     priv->msa_va);
	}

	icnss_pr_dbg("MSA pa: %pa, MSA va: 0x%p MSA Memory Size: 0x%x\n",
		     &priv->msa_pa, (void *)priv->msa_va, priv->msa_mem_size);

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
					   "smmu_iova_base");