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

Commit 0ce944d8 authored by Lakshmi Narayana Kalavala's avatar Lakshmi Narayana Kalavala Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: Cleanup all the command queues upon close node



When the backend camera daemon is crashed for some reason,
camera application waits for the completion of the command
processing till the timeout is reached which is unnecessary.

Hence clean all the command queues when the config node is
closed and immediately wake up all the command queues so
that camera application is notified immediately.

Change-Id: Iff5c331e8c5bb39305087fd4defe332690653b10
Signed-off-by: default avatarLakshmi Narayana Kalavala <lkalaval@codeaurora.org>
parent 5f838c4f
Loading
Loading
Loading
Loading
+35 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016, 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
@@ -614,6 +614,37 @@ static int __msm_close_destry_session_notify_apps(void *d1, void *d2)
	return 0;
}

static int __msm_wakeup_all_cmdack_session_stream(void *d1, void *d2)
{
	struct msm_stream *stream = d1;
	struct msm_session *session = d2;
	struct msm_command_ack *cmd_ack = NULL;
	unsigned long spin_flags = 0;

	cmd_ack = msm_queue_find(&session->command_ack_q,
		struct msm_command_ack, list,
		__msm_queue_find_command_ack_q,
		&stream->stream_id);
	if (cmd_ack) {
		spin_lock_irqsave(&(session->command_ack_q.lock),
			spin_flags);
		complete(&cmd_ack->wait_complete);
		spin_unlock_irqrestore(&(session->command_ack_q.lock),
			spin_flags);
	}
	return 0;
}

static int __msm_close_wakeup_all_cmdack_session(void *d1, void *d2)
{
	struct msm_stream  *stream = NULL;
	struct msm_session *session = d1;

	stream = msm_queue_find(&session->stream_q, struct msm_stream,
		list, __msm_wakeup_all_cmdack_session_stream, d1);
	return 0;
}

static long msm_private_ioctl(struct file *file, void *fh,
	bool valid_prio, unsigned int cmd, void *arg)
{
@@ -882,6 +913,9 @@ static int msm_close(struct file *filep)
	msm_queue_traverse_action(msm_session_q, struct msm_session, list,
		__msm_close_destry_session_notify_apps, NULL);

	msm_queue_traverse_action(msm_session_q, struct msm_session, list,
		__msm_close_wakeup_all_cmdack_session, NULL);

	spin_lock_irqsave(&msm_eventq_lock, flags);
	msm_eventq = NULL;
	spin_unlock_irqrestore(&msm_eventq_lock, flags);