msm: ipa3: Retry to attach smmu nodes if fails

Updated change to retry attaching smmu nodes if it fails, in a
deffered work queue with 500msec delay.

Change-Id: Ia54d801543224caf81085fedfd16305eca99995e
Signed-off-by: Raghavendar rao l <rlomte@codequrora.org>
This commit is contained in:
Raghavendar rao l 2021-10-21 22:20:55 +05:30
commit 7f159650b1
2 changed files with 54 additions and 14 deletions

View file

@ -6815,14 +6815,15 @@ static void ipa3_load_ipa_fw(struct work_struct *work)
IPADBG("Entry\n");
IPA_ACTIVE_CLIENTS_INC_SIMPLE();
if(!ipa3_ctx->ipa_pil_load)
{
result = ipa3_attach_to_smmu();
if (result) {
IPAERR("IPA attach to smmu failed %d\n", result);
IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
return;
}
result = ipa3_attach_to_smmu();
if (result) {
IPAERR("IPA attach to smmu failed %d\n", result);
IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
queue_delayed_work(ipa3_ctx->transport_power_mgmt_wq,
&ipa3_fw_load_failure_handle,
msecs_to_jiffies(DELAY_BEFORE_FW_LOAD));
return;
}
if (ipa3_ctx->ipa3_hw_mode != IPA_HW_MODE_EMULATION &&
@ -8817,6 +8818,7 @@ static int ipa_smmu_wlan_cb_probe(struct device *dev)
}
}
cb->done = true;
return 0;
}
@ -8896,10 +8898,35 @@ static int ipa_smmu_uc_cb_probe(struct device *dev)
ipa3_ctx->s1_bypass_arr[IPA_SMMU_CB_UC] = (bypass != 0);
ipa3_ctx->uc_pdev = dev;
cb->done = true;
return 0;
}
static void ipa3_ap_iommu_unmap(struct ipa_smmu_cb_ctx *cb, const u32 *add_map, u32 add_map_size) {
int i, res;
/* iterate of each entry of the additional mapping array */
for (i = 0; i < add_map_size / sizeof(u32); i += 3) {
u32 iova = be32_to_cpu(add_map[i]);
u32 pa = be32_to_cpu(add_map[i + 1]);
u32 size = be32_to_cpu(add_map[i + 2]);
unsigned long iova_p;
phys_addr_t pa_p;
u32 size_p;
IPA_SMMU_ROUND_TO_PAGE(iova, pa, size,
iova_p, pa_p, size_p);
IPADBG_LOW("unmapping 0x%lx to 0x%pa size %d\n",
iova_p, &pa_p, size_p);
res = iommu_unmap(cb->iommu_domain,iova_p, size_p);
if(res != size_p) {
pr_err("iommu unmap failed for AP cb\n");
ipa_assert();
}
}
}
static int ipa_smmu_ap_cb_probe(struct device *dev)
{
struct ipa_smmu_cb_ctx *cb = ipa3_get_smmu_ctx(IPA_SMMU_CB_AP);
@ -9034,6 +9061,8 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
if (ret < 0 && ret != -EEXIST) {
IPAERR("unable to allocate smem MODEM entry\n");
cb->valid = false;
if(add_map)
ipa3_ap_iommu_unmap(cb, add_map, add_map_size);
return -EFAULT;
}
smem_addr = qcom_smem_get(SMEM_MODEM,
@ -9042,6 +9071,8 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
if (IS_ERR(smem_addr)) {
IPAERR("unable to acquire smem MODEM entry\n");
cb->valid = false;
if(add_map)
ipa3_ap_iommu_unmap(cb, add_map, add_map_size);
return -EFAULT;
}
if (smem_size != ipa_smem_size)
@ -9062,6 +9093,7 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
smmu_info.present[IPA_SMMU_CB_AP] = true;
cb->done = true;
ipa3_ctx->pdev = dev;
cb->next_addr = cb->va_end;
@ -9114,18 +9146,26 @@ static int ipa_smmu_11ad_cb_probe(struct device *dev)
IPADBG("11AD using shared CB\n");
cb->shared = true;
}
cb->done = true;
return 0;
}
static int ipa_smmu_cb_probe(struct device *dev, enum ipa_smmu_cb_type cb_type)
{
struct ipa_smmu_cb_ctx *cb = ipa3_get_smmu_ctx(cb_type);
if((cb != NULL) && (cb->done == true)) {
IPADBG("SMMU CB type %d already initialized\n", cb_type);
return 0;
}
switch (cb_type) {
case IPA_SMMU_CB_AP:
ipa3_ctx->pdev = &ipa3_ctx->master_pdev->dev;
return ipa_smmu_ap_cb_probe(dev);
case IPA_SMMU_CB_WLAN:
return ipa_smmu_wlan_cb_probe(dev);
case IPA_SMMU_CB_UC:
ipa3_ctx->uc_pdev = &ipa3_ctx->master_pdev->dev;
return ipa_smmu_uc_cb_probe(dev);
case IPA_SMMU_CB_11AD:
return ipa_smmu_11ad_cb_probe(dev);
@ -9140,16 +9180,15 @@ static int ipa3_attach_to_smmu(void)
struct ipa_smmu_cb_ctx *cb;
int i, result;
ipa3_ctx->pdev = &ipa3_ctx->master_pdev->dev;
ipa3_ctx->uc_pdev = &ipa3_ctx->master_pdev->dev;
if (smmu_info.arm_smmu) {
IPADBG("smmu is enabled\n");
for (i = 0; i < IPA_SMMU_CB_MAX; i++) {
cb = ipa3_get_smmu_ctx(i);
result = ipa_smmu_cb_probe(cb->dev, i);
if (result)
if (result) {
IPAERR("probe failed for cb %d\n", i);
return result;
}
}
} else {
IPADBG("smmu is disabled\n");

View file

@ -544,6 +544,7 @@ struct ipa_smmu_cb_ctx {
u32 va_end;
bool shared;
bool is_cache_coherent;
bool done;
};
/**