Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a44a4c42 authored by Surajit Podder's avatar Surajit Podder Committed by Shivendra Kakrania
Browse files

msm: vidc: Synchronize flush and release reference event



Synchronize flush command and release reference event with
instance flush lock to ensure output buffers are not queued
in release reference while waiting for flush response from
firmware.

Change-Id: Id4aa251fd52ae913f8b321918123295baf7b5b7b
Signed-off-by: default avatarSurajit Podder <spodder@codeaurora.org>
parent e81208da
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1612,6 +1612,7 @@ void *msm_vidc_open(int core_id, int session_type)
	mutex_init(&inst->bufq[CAPTURE_PORT].lock);
	mutex_init(&inst->bufq[OUTPUT_PORT].lock);
	mutex_init(&inst->lock);
	mutex_init(&inst->flush_lock);

	INIT_MSM_VIDC_LIST(&inst->scratchbufs);
	INIT_MSM_VIDC_LIST(&inst->freqs);
@@ -1714,6 +1715,7 @@ void *msm_vidc_open(int core_id, int session_type)
	mutex_destroy(&inst->bufq[CAPTURE_PORT].lock);
	mutex_destroy(&inst->bufq[OUTPUT_PORT].lock);
	mutex_destroy(&inst->lock);
	mutex_destroy(&inst->flush_lock);

	DEINIT_MSM_VIDC_LIST(&inst->scratchbufs);
	DEINIT_MSM_VIDC_LIST(&inst->persistbufs);
@@ -1843,6 +1845,7 @@ int msm_vidc_destroy(struct msm_vidc_inst *inst)
	mutex_destroy(&inst->bufq[CAPTURE_PORT].lock);
	mutex_destroy(&inst->bufq[OUTPUT_PORT].lock);
	mutex_destroy(&inst->lock);
	mutex_destroy(&inst->flush_lock);

	msm_vidc_debugfs_deinit_inst(inst);

+9 −0
Original line number Diff line number Diff line
@@ -2019,6 +2019,7 @@ static void handle_session_flush(enum hal_command_response cmd, void *data)
		return;
	}

	mutex_lock(&inst->flush_lock);
	if (msm_comm_get_stream_output_mode(inst) ==
			HAL_VIDEO_DECODER_SECONDARY) {

@@ -2061,6 +2062,7 @@ static void handle_session_flush(enum hal_command_response cmd, void *data)
	v4l2_event_queue_fh(&inst->event_handler, &flush_event);

exit:
	mutex_unlock(&inst->flush_lock);
	put_inst(inst);
}

@@ -4844,6 +4846,10 @@ int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags)
		return 0;
	}

	mutex_lock(&inst->flush_lock);
	/* enable in flush */
	inst->in_flush = true;

	mutex_lock(&inst->registeredbufs.lock);
	list_for_each_entry_safe(mbuf, next, &inst->registeredbufs.list, list) {
		/* don't flush input buffers if input flush is not requested */
@@ -4897,6 +4903,7 @@ int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags)
		rc = call_hfi_op(hdev, session_flush, inst->session,
			HAL_FLUSH_OUTPUT);
	}
	mutex_unlock(&inst->flush_lock);
	if (rc) {
		dprintk(VIDC_ERR,
			"Sending flush to firmware failed, flush out all buffers\n");
@@ -6237,6 +6244,7 @@ void handle_release_buffer_reference(struct msm_vidc_inst *inst,
	bool found = false;
	int i = 0;

	mutex_lock(&inst->flush_lock);
	mutex_lock(&inst->registeredbufs.lock);
	found = false;
	/* check if mbuf was not removed by any chance */
@@ -6317,6 +6325,7 @@ void handle_release_buffer_reference(struct msm_vidc_inst *inst,
			print_vidc_buffer(VIDC_ERR,
				"rbr qbuf failed", inst, mbuf);
	}
	mutex_unlock(&inst->flush_lock);
}

int msm_comm_unmap_vidc_buffer(struct msm_vidc_inst *inst,
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -362,7 +362,7 @@ struct msm_vidc_core {

struct msm_vidc_inst {
	struct list_head list;
	struct mutex sync_lock, lock;
	struct mutex sync_lock, lock, flush_lock;
	struct msm_vidc_core *core;
	enum session_type session_type;
	void *session;