From aef0eadb39ccf40be0c28d075767b8d228499ebe Mon Sep 17 00:00:00 2001 From: Manikanta Pubbisetty Date: Fri, 23 Apr 2021 13:00:18 +0530 Subject: [PATCH] qcacmn: assert on IPA SMMU map/unmap failures The status of the IPA SMMU MAP/UNMAP operation is stored in the result field of the mem info structure that is passed to the IPA driver. Currently, this field is not checked for MAP/UNMAP failures; when IPA HW accesses such a buffer for which mapping is not correctly setup, it will lead to SMMU faults. Check the result and assert(on failures) to avoid such issues. Also, check if the physical address passed to the IPA driver is non zero value. Change-Id: Iec0702bdf4a07ea37e1213a33dc970028da654df CRs-Fixed: 2928744 --- dp/wifi3.0/dp_ipa.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dp/wifi3.0/dp_ipa.c b/dp/wifi3.0/dp_ipa.c index d9da572607ee..8de4e8f2da0a 100644 --- a/dp/wifi3.0/dp_ipa.c +++ b/dp/wifi3.0/dp_ipa.c @@ -100,6 +100,7 @@ static QDF_STATUS __dp_ipa_handle_buf_smmu_mapping(struct dp_soc *soc, bool create) { qdf_mem_info_t mem_map_table = {0}; + QDF_STATUS ret = QDF_STATUS_SUCCESS; if (!qdf_ipa_is_ready()) return QDF_STATUS_SUCCESS; @@ -108,10 +109,27 @@ static QDF_STATUS __dp_ipa_handle_buf_smmu_mapping(struct dp_soc *soc, qdf_nbuf_get_frag_paddr(nbuf, 0), size); + if (create) { + /* Assert if PA is zero */ + qdf_assert_always(mem_map_table.pa); + + ret = qdf_ipa_wdi_create_smmu_mapping(1, &mem_map_table); + } else { + ret = qdf_ipa_wdi_release_smmu_mapping(1, &mem_map_table); + } + + qdf_assert_always(!ret); + + /* Return status of mapping/unmapping is stored in + * mem_map_table.result field, assert if the result + * is failure + */ if (create) - return qdf_ipa_wdi_create_smmu_mapping(1, &mem_map_table); + qdf_assert_always(!mem_map_table.result); else - return qdf_ipa_wdi_release_smmu_mapping(1, &mem_map_table); + qdf_assert_always(mem_map_table.result >= mem_map_table.size); + + return ret; } QDF_STATUS dp_ipa_handle_rx_buf_smmu_mapping(struct dp_soc *soc,