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

Commit 1d8ba62c authored by Karthik Anantha Ram's avatar Karthik Anantha Ram
Browse files

msm: camera: Modify shutdown sequence in KMD



This change ensures subdevices close before the video device
cleans up. Memory manager is currently associated with request
manager, with this change we ensure all subdevices cleanup prior
to cleaning up the request/memory manager.

Signed-off-by: default avatarKarthik Anantha Ram <kartanan@codeaurora.org>
Change-Id: Ia6b715025ee940ad14e4b4bbe8ed747d895fb342
parent 552fac7b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ int cam_context_shutdown(struct cam_context *ctx)
	int rc = 0;
	int32_t ctx_hdl = ctx->dev_hdl;

	mutex_lock(&ctx->ctx_mutex);
	if (ctx->state_machine[ctx->state].ioctl_ops.stop_dev) {
		rc = ctx->state_machine[ctx->state].ioctl_ops.stop_dev(
			ctx, NULL);
@@ -54,6 +55,7 @@ int cam_context_shutdown(struct cam_context *ctx)
		if (rc < 0)
			CAM_ERR(CAM_CORE, "Error while dev release %d", rc);
	}
	mutex_unlock(&ctx->ctx_mutex);

	if (!rc)
		rc = cam_destroy_device_hdl(ctx_hdl);
+3 −0
Original line number Diff line number Diff line
@@ -430,6 +430,9 @@ int cam_node_shutdown(struct cam_node *node)

	for (i = 0; i < node->ctx_size; i++) {
		if (node->ctx_list[i].dev_hdl > 0) {
			CAM_DBG(CAM_CORE,
				"Node [%s] invoking shutdown on context [%d]",
				node->name, i);
			rc = cam_context_shutdown(&(node->ctx_list[i]));
			if (rc)
				continue;
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ static int cam_icp_subdev_close(struct v4l2_subdev *sd,

	mutex_lock(&g_icp_dev.icp_lock);
	if (g_icp_dev.open_cnt <= 0) {
		CAM_ERR(CAM_ICP, "ICP subdev is already closed");
		CAM_DBG(CAM_ICP, "ICP subdev is already closed");
		rc = -EINVAL;
		goto end;
	}
+27 −3
Original line number Diff line number Diff line
@@ -56,23 +56,47 @@ static const struct of_device_id cam_isp_dt_match[] = {
	{}
};

static int cam_isp_subdev_open(struct v4l2_subdev *sd,
	struct v4l2_subdev_fh *fh)
{
	mutex_lock(&g_isp_dev.isp_mutex);
	g_isp_dev.open_cnt++;
	mutex_unlock(&g_isp_dev.isp_mutex);

	return 0;
}

static int cam_isp_subdev_close(struct v4l2_subdev *sd,
	struct v4l2_subdev_fh *fh)
{
	int rc = 0;
	struct cam_node *node = v4l2_get_subdevdata(sd);

	mutex_lock(&g_isp_dev.isp_mutex);
	if (g_isp_dev.open_cnt <= 0) {
		CAM_DBG(CAM_ISP, "ISP subdev is already closed");
		rc = -EINVAL;
		goto end;
	}

	g_isp_dev.open_cnt--;
	if (!node) {
		CAM_ERR(CAM_ISP, "Node ptr is NULL");
		return -EINVAL;
		rc = -EINVAL;
		goto end;
	}

	if (g_isp_dev.open_cnt == 0)
		cam_node_shutdown(node);

	return 0;
end:
	mutex_unlock(&g_isp_dev.isp_mutex);
	return rc;
}

static const struct v4l2_subdev_internal_ops cam_isp_subdev_internal_ops = {
	.close = cam_isp_subdev_close,
	.open = cam_isp_subdev_open,
};

static int cam_isp_dev_remove(struct platform_device *pdev)
+5 −2
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-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
@@ -24,12 +24,15 @@
 * @sd:                    Commone camera subdevice node
 * @ctx:                   Isp base context storage
 * @ctx_isp:               Isp private context storage
 *
 * @isp_mutex:             ISP dev mutex
 * @open_cnt:              Open device count
 */
struct cam_isp_dev {
	struct cam_subdev          sd;
	struct cam_context         ctx[CAM_CTX_MAX];
	struct cam_isp_context     ctx_isp[CAM_CTX_MAX];
	struct mutex               isp_mutex;
	int32_t                    open_cnt;
};

#endif /* __CAM_ISP_DEV_H__ */
Loading