diff --git a/drivers/cam_smmu/cam_smmu_api.c b/drivers/cam_smmu/cam_smmu_api.c index ec4cbc2f44..5980a9070e 100644 --- a/drivers/cam_smmu/cam_smmu_api.c +++ b/drivers/cam_smmu/cam_smmu_api.c @@ -27,6 +27,7 @@ #include "camera_main.h" #include "cam_trace.h" #include "cam_common_util.h" +#include "cam_compat.h" #define SHARED_MEM_POOL_GRANULARITY 16 @@ -486,8 +487,8 @@ static void cam_smmu_page_fault_work(struct work_struct *work) int idx; struct cam_smmu_work_payload *payload; uint32_t buf_info; - struct iommu_fault_ids fault_ids = {0, 0, 0}; - struct cam_smmu_pf_info pf_info; + /* struct iommu_fault_ids fault_ids = {0, 0, 0}; */ + struct cam_smmu_pf_info pf_info; mutex_lock(&iommu_cb_set.payload_list_lock); if (list_empty(&iommu_cb_set.payload_list)) { @@ -502,13 +503,7 @@ static void cam_smmu_page_fault_work(struct work_struct *work) list_del(&payload->list); mutex_unlock(&iommu_cb_set.payload_list_lock); - - if ((iommu_get_fault_ids(payload->domain, &fault_ids))) - CAM_ERR(CAM_SMMU, - "Error: Can not get smmu fault ids"); - - CAM_ERR(CAM_SMMU, "smmu fault ids bid:%d pid:%d mid:%d", - fault_ids.bid, fault_ids.pid, fault_ids.mid); + cam_check_iommu_faults(payload->domain, &pf_info); /* Dereference the payload to call the handler */ idx = payload->idx; @@ -521,9 +516,6 @@ static void cam_smmu_page_fault_work(struct work_struct *work) pf_info.iova = payload->iova; pf_info.flags = payload->flags; pf_info.buf_info = buf_info; - pf_info.bid = fault_ids.bid; - pf_info.pid = fault_ids.pid; - pf_info.mid = fault_ids.mid; for (j = 0; j < CAM_SMMU_CB_MAX; j++) { if ((iommu_cb_set.cb_info[idx].handler[j])) { diff --git a/drivers/cam_utils/cam_compat.c b/drivers/cam_utils/cam_compat.c index b0efb091f3..ee528d0415 100644 --- a/drivers/cam_utils/cam_compat.c +++ b/drivers/cam_utils/cam_compat.c @@ -248,3 +248,38 @@ int camera_component_match_add_drivers(struct device *master_dev, end: return rc; } + +#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE +#include +void cam_check_iommu_faults(struct iommu_domain *domain, + struct cam_smmu_pf_info *pf_info) +{ + struct qcom_iommu_fault_ids fault_ids = {0, 0, 0}; + + if (qcom_iommu_get_fault_ids(domain, &fault_ids)) + CAM_ERR(CAM_SMMU, "Cannot get smmu fault ids"); + else + CAM_ERR(CAM_SMMU, "smmu fault ids bid:%d pid:%d mid:%d", + fault_ids.bid, fault_ids.pid, fault_ids.mid); + + pf_info->bid = fault_ids.bid; + pf_info->pid = fault_ids.pid; + pf_info->mid = fault_ids.mid; +} +#else +void cam_check_iommu_faults(struct iommu_domain *domain, + struct cam_smmu_pf_info *pf_info) +{ + struct iommu_fault_ids fault_ids = {0, 0, 0}; + + if (iommu_get_fault_ids(domain, &fault_ids)) + CAM_ERR(CAM_SMMU, "Error: Can not get smmu fault ids"); + + CAM_ERR(CAM_SMMU, "smmu fault ids bid:%d pid:%d mid:%d", + fault_ids.bid, fault_ids.pid, fault_ids.mid); + + pf_info->bid = fault_ids.bid; + pf_info->pid = fault_ids.pid; + pf_info->mid = fault_ids.mid; +} +#endif \ No newline at end of file diff --git a/drivers/cam_utils/cam_compat.h b/drivers/cam_utils/cam_compat.h index 1d13928850..c92ef82ae4 100644 --- a/drivers/cam_utils/cam_compat.h +++ b/drivers/cam_utils/cam_compat.h @@ -12,6 +12,7 @@ #include "cam_csiphy_dev.h" #include "cam_cpastop_hw.h" +#include "cam_smmu_api.h" #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0) @@ -22,6 +23,7 @@ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) #include +#include #include #include @@ -48,5 +50,7 @@ int camera_component_match_add_drivers(struct device *master_dev, int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, bool protect, int32_t offset); void cam_free_clear(const void *); +void cam_check_iommu_faults(struct iommu_domain *domain, + struct cam_smmu_pf_info *pf_info); #endif /* _CAM_COMPAT_H_ */