Quellcode durchsuchen

msm: camera: cdm: Correct the CDM iommu handle

Correct the CDM iommu handler by changing the
false pid and mid values written in the cdm
header file. Also, adding a support to read the
pid and mid from the dtsi file, since there is
already support for the PID values available in the
dtsi.

CRs-fixed: 2982542
Change-Id: I319a32fdcba44a6a96b79e4e67b0a2cc0e01bc4c
Signed-off-by: Jigar Agrawal <[email protected]>
Jigar Agrawal vor 4 Jahren
Ursprung
Commit
42d92dea61

+ 3 - 10
drivers/cam_cdm/cam_cdm.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _CAM_CDM_H_
@@ -132,14 +132,6 @@
 	 CAM_CDM_IRQ_STATUS_ERROR_OVER_FLOW_MASK | \
 	 CAM_CDM_IRQ_STATUS_ERROR_AHB_BUS_MASK)
 
-
-struct cam_cdm_pid_mid_data {
-	int cdm_pid;
-	int cdm_mid;
-	int ope_cdm_pid;
-	int ope_cdm_mid;
-};
-
 /* Structure to store hw version info */
 struct cam_version_reg {
 	uint32_t hw_version;
@@ -383,7 +375,6 @@ struct cam_cdm_common_regs {
 	const struct cam_cdm_icl_regs *icl_reg;
 	uint32_t spare;
 	uint32_t priority_group_bit_offset;
-	struct cam_cdm_pid_mid_data *cdm_pid_mid_info;
 };
 
 /**
@@ -570,6 +561,8 @@ struct cam_cdm_private_dt_data {
 	uint8_t priority_group;
 	uint32_t fifo_depth[CAM_CDM_BL_FIFO_MAX];
 	uint32_t dt_num_supported_clients;
+	uint32_t pid;
+	uint32_t mid;
 	const char *dt_cdm_client_name[CAM_PER_CDM_MAX_REGISTERED_CLIENTS];
 };
 

+ 14 - 11
drivers/cam_cdm/cam_cdm_hw_core.c

@@ -737,6 +737,10 @@ bool cam_hw_cdm_bl_write(
 {
 	struct cam_cdm *cdm_core = (struct cam_cdm *)cdm_hw->core_info;
 
+	CAM_DBG(CAM_CDM, "%s%d Base: 0x%x, Len: %u, Tag: %u, set_arb: %u, fifo_idx: %u",
+		cdm_hw->soc_info.label_name, cdm_hw->soc_info.index,
+		src, len, tag, set_arb, fifo_idx);
+
 	if (cam_cdm_write_hw_reg(cdm_hw,
 		cdm_core->offsets->bl_fifo_reg[fifo_idx]->bl_fifo_base,
 		src)) {
@@ -1487,25 +1491,24 @@ static void cam_hw_cdm_iommu_fault_handler(struct cam_smmu_pf_info *pf_info)
 {
 	struct cam_hw_info *cdm_hw = NULL;
 	struct cam_cdm *core = NULL;
-	struct cam_cdm_pid_mid_data *pid_mid_info = NULL;
+	struct cam_cdm_private_dt_data *pvt_data;
 	int i;
 
+	if (!pf_info) {
+		CAM_ERR(CAM_CDM, "pf_info is null");
+		return;
+	}
+
 	if (pf_info->token) {
 		cdm_hw = (struct cam_hw_info *)pf_info->token;
 		core = (struct cam_cdm *)cdm_hw->core_info;
-		pid_mid_info = core->offsets->cmn_reg->cdm_pid_mid_info;
+		pvt_data = (struct cam_cdm_private_dt_data *) cdm_hw->soc_info.soc_private;
 		CAM_ERR_RATE_LIMIT(CAM_CDM, "Page fault iova addr %pK\n",
 			(void *)pf_info->iova);
 
-		if (pid_mid_info) {
-			/*
-			 * If its CDM or OPE CDM then only handle the pf for CDM
-			 * else return.
-			 */
-			if (((pf_info->pid == pid_mid_info->cdm_pid) &&
-				(pf_info->mid == pid_mid_info->cdm_mid)) ||
-				((pf_info->pid == pid_mid_info->ope_cdm_pid) &&
-				(pf_info->mid == pid_mid_info->ope_cdm_mid)))
+		/* Check if the PID and MID are valid, if not handle the pf */
+		if ((pvt_data->pid >= 0) && (pvt_data->mid >= 0)) {
+			if (((pf_info->pid == pvt_data->pid) && (pf_info->mid == pvt_data->mid)))
 				goto handle_cdm_pf;
 			else
 				return;

+ 1 - 9
drivers/cam_cdm/cam_cdm_hw_reg_2_1.h

@@ -1,17 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  */
 
 #include "cam_cdm.h"
 
-struct cam_cdm_pid_mid_data cdm_hw_2_1_pid_mid_data = {
-	.cdm_pid = 2,
-	.cdm_mid = 0,
-	.ope_cdm_pid = 0,
-	.ope_cdm_mid = 2,
-};
-
 struct cam_cdm_bl_pending_req_reg_params cdm_hw_2_1_bl_pending_req0 = {
 	.rb_offset = 0x6c,
 	.rb_mask = 0x1ff,
@@ -233,7 +226,6 @@ static struct cam_cdm_common_regs cdm_hw_2_1_cmn_reg_offset = {
 	.icl_reg = &cdm_2_1_icl,
 	.spare = 0x3fc,
 	.priority_group_bit_offset = 20,
-	.cdm_pid_mid_info = &cdm_hw_2_1_pid_mid_data,
 };
 
 static struct cam_cdm_common_reg_data cdm_hw_2_1_cmn_reg_data = {

+ 10 - 3
drivers/cam_cdm/cam_cdm_soc.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/delay.h>
@@ -115,8 +115,15 @@ int cam_cdm_soc_load_dt_private(struct platform_device *pdev,
 	}
 
 	cdm_pvt_data->is_single_ctx_cdm =
-		of_property_read_bool(pdev->dev.of_node,
-			"single-context-cdm");
+		of_property_read_bool(pdev->dev.of_node, "single-context-cdm");
+
+	rc = of_property_read_u32(pdev->dev.of_node, "cam_hw_pid", &cdm_pvt_data->pid);
+	if (rc)
+		cdm_pvt_data->pid = -1;
+
+	rc = of_property_read_u32(pdev->dev.of_node, "cam-hw-mid", &cdm_pvt_data->mid);
+	if (rc)
+		cdm_pvt_data->mid = -1;
 
 	rc = of_property_read_u8(pdev->dev.of_node, "cdm-priority-group",
 			&cdm_pvt_data->priority_group);