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

Commit bfda8b98 authored by Alan Kwong's avatar Alan Kwong
Browse files

msm: sde: allow offline session to wait for inline closing



Add delay during session open to wait for any inline
session to close. This enables smooth inline-offline
transition, avoiding race condition such that inline
session is still in process of closing while a new
offline session is opening.

Change-Id: I0fa2a973e4ec7f7c670b0a7fb94c088e41f145ec
Signed-off-by: default avatarAlan Kwong <akwong@codeaurora.org>
parent aa53e68c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2345,6 +2345,7 @@ static int sde_rotator_config_session(struct sde_rot_mgr *mgr,

	if (config->output.sbuf && mgr->sbuf_ctx != private && mgr->sbuf_ctx) {
		SDEROT_ERR("too many sbuf sessions\n");
		ret = -EBUSY;
		goto done;
	}

+7 −0
Original line number Diff line number Diff line
@@ -1438,6 +1438,13 @@ struct dentry *sde_rotator_create_debugfs(
		return NULL;
	}

	if (!debugfs_create_u32("open_timeout", 0644,
			debugfs_root, &rot_dev->open_timeout)) {
		SDEROT_ERR("fail create open_timeout\n");
		debugfs_remove_recursive(debugfs_root);
		return NULL;
	}

	if (!debugfs_create_u32("disable_syscache", 0644,
			debugfs_root, &rot_dev->disable_syscache)) {
		SDEROT_ERR("fail create disable_syscache\n");
+43 −1
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@
/* acquire fence time out, following other driver fence time out practice */
#define SDE_ROTATOR_FENCE_TIMEOUT	MSEC_PER_SEC

/* Timeout (msec) waiting for ctx open */
#define SDE_ROTATOR_CTX_OPEN_TIMEOUT	500

/* Rotator default fps */
#define SDE_ROTATOR_DEFAULT_FPS	60

@@ -896,6 +899,29 @@ struct sde_rotator_ctx *sde_rotator_ctx_open(
		goto error_lock;
	}

	/* wait until exclusive ctx, if exists, finishes or timeout */
	while (rot_dev->excl_ctx) {
		SDEROT_DBG("waiting to open %s session %d ...\n",
				file ? "v4l2" : "excl",	rot_dev->session_id);
		mutex_unlock(&rot_dev->lock);
		ret = wait_event_interruptible_timeout(rot_dev->open_wq,
				!rot_dev->excl_ctx,
				msecs_to_jiffies(rot_dev->open_timeout));
		if (ret < 0) {
			goto error_lock;
		} else if (!ret) {
			SDEROT_WARN("timeout to open session %d\n",
					rot_dev->session_id);
			SDEROT_EVTLOG(rot_dev->session_id,
					SDE_ROT_EVTLOG_ERROR);
			ret = -EBUSY;
			goto error_lock;
		} else if (mutex_lock_interruptible(&rot_dev->lock)) {
			ret = -ERESTARTSYS;
			goto error_lock;
		}
	}

	ctx->rot_dev = rot_dev;
	ctx->file = file;

@@ -994,8 +1020,8 @@ struct sde_rotator_ctx *sde_rotator_ctx_open(
	}
	sde_rot_mgr_unlock(rot_dev->mgr);

	/* Create control */
	if (ctx->file) {
		/* Create control */
		ctrl_handler = &ctx->ctrl_handler;
		v4l2_ctrl_handler_init(ctrl_handler, 4);
		v4l2_ctrl_new_std(ctrl_handler,
@@ -1015,7 +1041,14 @@ struct sde_rotator_ctx *sde_rotator_ctx_open(
		}
		ctx->fh.ctrl_handler = ctrl_handler;
		v4l2_ctrl_handler_setup(ctrl_handler);
	} else {
		/* acquire exclusive context */
		SDEDEV_DBG(rot_dev->dev, "acquire exclusive session id:%u\n",
				ctx->session_id);
		SDEROT_EVTLOG(ctx->session_id);
		rot_dev->excl_ctx = ctx;
	}

	mutex_unlock(&rot_dev->lock);

	SDEDEV_DBG(ctx->rot_dev->dev, "SDE v4l2 rotator open success\n");
@@ -1062,6 +1095,12 @@ static int sde_rotator_ctx_release(struct sde_rotator_ctx *ctx,

	SDEDEV_DBG(rot_dev->dev, "release s:%d\n", session_id);
	mutex_lock(&rot_dev->lock);
	if (rot_dev->excl_ctx == ctx) {
		SDEDEV_DBG(rot_dev->dev, "release exclusive session id:%u\n",
				session_id);
		SDEROT_EVTLOG(session_id);
		rot_dev->excl_ctx = NULL;
	}
	if (ctx->file) {
		v4l2_ctrl_handler_free(&ctx->ctrl_handler);
		SDEDEV_DBG(rot_dev->dev, "release streams s:%d\n", session_id);
@@ -1108,6 +1147,7 @@ static int sde_rotator_ctx_release(struct sde_rotator_ctx *ctx,
	kfree(ctx->vbinfo_out);
	kfree(ctx->vbinfo_cap);
	kfree(ctx);
	wake_up_interruptible(&rot_dev->open_wq);
	mutex_unlock(&rot_dev->lock);
	SDEDEV_DBG(rot_dev->dev, "release complete s:%d\n", session_id);
	return 0;
@@ -3314,6 +3354,8 @@ static int sde_rotator_probe(struct platform_device *pdev)
	rot_dev->min_bw = 0;
	rot_dev->min_overhead_us = 0;
	rot_dev->drvdata = sde_rotator_get_drv_data(&pdev->dev);
	rot_dev->open_timeout = SDE_ROTATOR_CTX_OPEN_TIMEOUT;
	init_waitqueue_head(&rot_dev->open_wq);

	rot_dev->pdev = pdev;
	rot_dev->dev = &pdev->dev;
+6 −0
Original line number Diff line number Diff line
@@ -205,6 +205,9 @@ struct sde_rotator_statistics {
 * @min_overhead_us: Override the minimum overhead in us from perf calculation
 * @debugfs_root: Pointer to debugfs directory entry.
 * @stats: placeholder for rotator statistics
 * @open_timeout: maximum wait time for ctx open in msec
 * @open_wq: wait queue for ctx open
 * @excl_ctx: Pointer to exclusive ctx
 */
struct sde_rotator_device {
	struct mutex lock;
@@ -227,6 +230,9 @@ struct sde_rotator_device {
	struct sde_rotator_statistics stats;
	struct dentry *debugfs_root;
	struct dentry *perf_root;
	u32 open_timeout;
	wait_queue_head_t open_wq;
	struct sde_rotator_ctx *excl_ctx;
};

static inline