Explorar o código

msm: ipa3: Adding changes to reset next addr to domain end addr

In 2x Pine unload/load scenarios wdi map count never resetting to
zero, so next addr keep on increasing and crossing the geometry range.
So Adding changes to reset next addr to domain end addr.

Change-Id: I1d4762c1a907564001f4451eb9978ddbeea1d269
Signed-off-by: Ashok Vuyyuru <[email protected]>
Ashok Vuyyuru %!s(int64=2) %!d(string=hai) anos
pai
achega
413e7398bf

+ 14 - 0
drivers/platform/msm/ipa/ipa_v3/ipa.c

@@ -11179,6 +11179,7 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0))
 	int mapping_config;
 #endif
+	u32 geometry_ap_mapping[2];
 
 	IPADBG("AP CB PROBE dev=%pK\n", dev);
 
@@ -11227,6 +11228,19 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
 
 	IPADBG("AP CB PROBE dev=%pK va_start=0x%x va_size=0x%x\n",
 		   dev, cb->va_start, cb->va_size);
+	if (of_property_read_u32_array(
+			dev->of_node, "qcom,iommu-geometry",
+			geometry_ap_mapping, 2) == 0) {
+		cb->geometry_start = geometry_ap_mapping[0];
+		cb->geometry_end  = geometry_ap_mapping[1];
+	} else {
+		IPADBG("AP CB PROBE Geometry not defined using max!\n");
+		cb->geometry_start = 0;
+		cb->geometry_end = 0xF0000000;
+	}
+
+	IPADBG("AP CB PROBE dev=%pK geometry_start=0x%x geometry_end=0x%x\n",
+		   dev, cb->geometry_start, cb->geometry_end);
 
 	/*
 	 * Prior to these calls to iommu_domain_get_attr(), these

+ 2 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_i.h

@@ -651,6 +651,8 @@ struct ipa_smmu_cb_ctx {
 	u32 va_start;
 	u32 va_size;
 	u32 va_end;
+	u32 geometry_start;
+	u32 geometry_end;
 	bool shared;
 	bool is_cache_coherent;
 	bool done;

+ 8 - 1
drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include "ipa_i.h"
@@ -590,6 +591,8 @@ static int ipa_create_ap_smmu_mapping_pa(phys_addr_t pa, size_t len,
 
 	ipa3_ctx->wdi_map_cnt++;
 	cb->next_addr = va + true_len;
+	if (cb->next_addr >= cb->geometry_end)
+		cb->next_addr = cb->va_end;
 	*iova = va + pa - rounddown(pa, PAGE_SIZE);
 	return 0;
 }
@@ -672,6 +675,10 @@ static int ipa_create_ap_smmu_mapping_sgt(struct sg_table *sgt,
 		count++;
 	}
 	cb->next_addr = va;
+
+	if (cb->next_addr >= cb->geometry_end)
+		cb->next_addr = cb->va_end;
+
 	*iova = start_iova;
 
 	return 0;
@@ -966,7 +973,7 @@ void ipa3_release_wdi3_gsi_smmu_mappings(u8 dir)
 		}
 	}
 
-	if (ipa3_ctx->wdi_map_cnt == 0)
+	if (ipa3_ctx->wdi_map_cnt == 0 || cb->next_addr >= cb->geometry_end)
 		cb->next_addr = cb->va_end;
 }