Merge "msm: ipa3: Adding changes to reset next addr to domain end addr"
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index 771950b..f331c43 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -11190,6 +11190,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);
@@ -11238,6 +11239,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 f0951cb..6eaea66 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;
}