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 <quic_avuyyuru@quicinc.com>
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index e6cce06..b8b9fb9 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -11178,6 +11178,7 @@
#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);
@@ -11226,6 +11227,19 @@
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
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
index 9f1ea0b..6aba0a9 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
@@ -651,6 +651,8 @@
u32 va_start;
u32 va_size;
u32 va_end;
+ u32 geometry_start;
+ u32 geometry_end;
bool shared;
bool is_cache_coherent;
bool done;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
index 1762de6..97810b1 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
+++ b/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"
@@ -589,6 +590,8 @@
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;
}
@@ -671,6 +674,10 @@
count++;
}
cb->next_addr = va;
+
+ if (cb->next_addr >= cb->geometry_end)
+ cb->next_addr = cb->va_end;
+
*iova = start_iova;
return 0;
@@ -965,7 +972,7 @@
}
}
- 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;
}