Преглед на файлове

Merge "video: driver: Cancel batch work in case of pm_suspend"

qctecmdr преди 3 години
родител
ревизия
554cadb057
променени са 3 файла, в които са добавени 32 реда и са изтрити 2 реда
  1. 1 0
      driver/vidc/inc/msm_vidc_core.h
  2. 9 1
      driver/vidc/src/msm_vidc_driver.c
  3. 22 1
      driver/vidc/src/msm_vidc_probe.c

+ 1 - 0
driver/vidc/inc/msm_vidc_core.h

@@ -112,6 +112,7 @@ struct msm_vidc_core {
 	struct completion                      init_done;
 	bool                                   handoff_done;
 	bool                                   hw_power_control;
+	bool                                   pm_suspended;
 };
 
 #endif // _MSM_VIDC_CORE_H_

+ 9 - 1
driver/vidc/src/msm_vidc_driver.c

@@ -4303,6 +4303,7 @@ int msm_vidc_core_init(struct msm_vidc_core *core)
 	init_completion(&core->init_done);
 	core->smmu_fault_handled = false;
 	core->ssr.trigger = false;
+	core->pm_suspended = false;
 
 	rc = venus_hfi_core_init(core);
 	if (rc) {
@@ -4632,21 +4633,28 @@ void msm_vidc_batch_handler(struct work_struct *work)
 {
 	struct msm_vidc_inst *inst;
 	enum msm_vidc_allow allow;
+	struct msm_vidc_core *core;
 	int rc = 0;
 
 	inst = container_of(work, struct msm_vidc_inst, decode_batch.work.work);
 	inst = get_inst_ref(g_core, inst);
-	if (!inst) {
+	if (!inst || !inst->core) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		return;
 	}
 
+	core = inst->core;
 	inst_lock(inst, __func__);
 	if (is_session_error(inst)) {
 		i_vpr_e(inst, "%s: failled. Session error\n", __func__);
 		goto exit;
 	}
 
+	if (core->pm_suspended) {
+		i_vpr_h(inst, "%s: device in pm suspend state\n", __func__);
+		goto exit;
+	}
+
 	allow = msm_vidc_allow_qbuf(inst, OUTPUT_MPLANE);
 	if (allow != MSM_VIDC_ALLOW) {
 		i_vpr_e(inst, "%s: not allowed in state: %s\n", __func__,

+ 22 - 1
driver/vidc/src/msm_vidc_probe.c

@@ -475,7 +475,6 @@ static int msm_vidc_pm_suspend(struct device *dev)
 	int rc = 0;
 	struct msm_vidc_core *core;
 
-	d_vpr_h("%s\n", __func__);
 	/*
 	 * Bail out if
 	 * - driver possibly not probed yet
@@ -492,18 +491,40 @@ static int msm_vidc_pm_suspend(struct device *dev)
 		return -EINVAL;
 	}
 
+	d_vpr_h("%s\n", __func__);
 	rc = msm_vidc_suspend(core);
 	if (rc == -ENOTSUPP)
 		rc = 0;
 	else if (rc)
 		d_vpr_e("Failed to suspend: %d\n", rc);
+	else
+		core->pm_suspended  = true;
 
 	return rc;
 }
 
 static int msm_vidc_pm_resume(struct device *dev)
 {
+	struct msm_vidc_core *core;
+
+	/*
+	 * Bail out if
+	 * - driver possibly not probed yet
+	 * - not the main device. We don't support power management on
+	 *   subdevices (e.g. context banks)
+	 */
+	if (!dev || !dev->driver ||
+		!of_device_is_compatible(dev->of_node, "qcom,msm-vidc"))
+		return 0;
+
+	core = dev_get_drvdata(dev);
+	if (!core) {
+		d_vpr_e("%s: invalid core\n", __func__);
+		return -EINVAL;
+	}
+
 	d_vpr_h("%s\n", __func__);
+	core->pm_suspended  = false;
 	return 0;
 }