ソースを参照

msm: camera: smmu: IOMMU fault id's API update

Need to update API's provided by memory team for retreiving fault id's when an
SMMU translation fault occurs for the new kernel version.

CRs-Fixed: 2835738
Change-Id: I061914ce01196fd1271c8a466f6a4ef8e6dce28f
Signed-off-by: Karthik Jayakumar <[email protected]>
Karthik Jayakumar 4 年 前
コミット
bc04b3a8ef

+ 4 - 12
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])) {

+ 35 - 0
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 <linux/qcom-iommu-util.h>
+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

+ 4 - 0
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 <linux/msm_ion.h>
+#include <linux/iommu.h>
 #include <linux/ion.h>
 #include <linux/qcom_scm.h>
 
@@ -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_ */