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

Commit 4b390331 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: BA: Fix a race condition in BA event handling"

parents 863822f1 613b0e48
Loading
Loading
Loading
Loading
+12 −3
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
@@ -524,14 +524,18 @@ int msm_ba_save_restore_input(void *instance, enum msm_ba_save_restore_ip sr)
		msm_ba_reset_ip_in_use_from_sd(inst->sd);
		ba_input = msm_ba_find_input_from_sd(inst->sd,
					inst->saved_input);
		if (ba_input)
			ba_input->in_use = 1;
		else
			dprintk(BA_WARN, "Could not find input %d from sd: %s",
				inst->saved_input, inst->sd->name);
		inst->restore = 0;
		inst->saved_input = BA_IP_MAX;
		dprintk(BA_DBG, "Stream on from save restore");
		rc = msm_ba_streamon(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
	} else if (BA_SR_SAVE_IP == sr) {
		ba_input = msm_ba_find_input(inst->sd_input.index);
		if (ba_input->ba_out_in_use) {
		if (ba_input && ba_input->ba_out_in_use) {
			inst->restore = 1;
			inst->saved_input =
				msm_ba_find_ip_in_use_from_sd(inst->sd);
@@ -543,6 +547,9 @@ int msm_ba_save_restore_input(void *instance, enum msm_ba_save_restore_ip sr)
				inst->saved_input);
			rc = -EBUSY;
		}
		if (!ba_input)
			dprintk(BA_WARN, "Couldn't find input idx %d to save",
				inst->sd_input.index);
	} else {
		dprintk(BA_DBG, "Nothing to do in save and restore");
	}
@@ -729,7 +736,9 @@ void msm_ba_subdev_event_hndlr(struct v4l2_subdev *sd,

	ba_sd_event->sd_event = *(struct v4l2_event *)arg;
	((int *)ba_sd_event->sd_event.u.data)[0] = ba_input->ba_ip_idx;
	mutex_lock(&dev_ctxt->dev_cs);
	list_add_tail(&ba_sd_event->list, &dev_ctxt->sd_events);
	mutex_unlock(&dev_ctxt->dev_cs);

	schedule_delayed_work(&dev_ctxt->sd_events_work, 0);
}
+4 −4
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
@@ -139,7 +139,6 @@ static void msm_ba_signal_sessions_event(struct v4l2_event *sd_event)
	dev_ctxt = get_ba_dev();
	ptr = (unsigned int *)sd_event->u.data;

	mutex_lock(&dev_ctxt->dev_cs);
	list_for_each_entry(inst, &(dev_ctxt->instances), list) {
		if (inst->ext_ops && inst->ext_ops->msm_ba_cb) {
			arg = ptr[1];
@@ -149,7 +148,6 @@ static void msm_ba_signal_sessions_event(struct v4l2_event *sd_event)
			msm_ba_queue_v4l2_event(inst, &event);
		}
	}
	mutex_unlock(&dev_ctxt->dev_cs);
}

void msm_ba_subdev_event_hndlr_delayed(struct work_struct *work)
@@ -160,17 +158,19 @@ void msm_ba_subdev_event_hndlr_delayed(struct work_struct *work)

	dev_ctxt = get_ba_dev();

	mutex_lock(&dev_ctxt->dev_cs);
	if (!list_empty(&dev_ctxt->sd_events)) {
		list_for_each_entry_safe(ba_sd_event, ba_sd_event_tmp,
				&(dev_ctxt->sd_events), list) {
			list_del(&ba_sd_event->list);
			msm_ba_signal_sessions_event(&ba_sd_event->sd_event);
			list_del(&ba_sd_event->list);
			kfree(ba_sd_event);
			break;
		}
	} else {
		dprintk(BA_ERR, "%s - queue empty!!!", __func__);
	}
	mutex_unlock(&dev_ctxt->dev_cs);
}

struct v4l2_subdev *msm_ba_sd_find(const char *name)