linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "robh@kernel.org" <robh@kernel.org>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"Shangyao Lin (林上堯)" <Shangyao.Lin@mediatek.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2 08/13] media: platform: mediatek: add isp_7x camsys unit
Date: Thu, 10 Jul 2025 07:46:06 +0000	[thread overview]
Message-ID: <600de87b908be63c2a5064837e4e9684d703527c.camel@mediatek.com> (raw)
In-Reply-To: <20250707013154.4055874-9-shangyao.lin@mediatek.com>

On Mon, 2025-07-07 at 09:31 +0800, shangyao lin wrote:
> From: "shangyao.lin" <shangyao.lin@mediatek.com>
> 
> Introduces the top media device driver for the MediaTek ISP7X CAMSYS. The driver maintains the camera system, including sub-device management, DMA operations, and integration with the V4L2 framework. It handles request stream data, buffer management, MediaTek-specific features, pipeline management, streaming control, and error handling mechanisms. Additionally, it aggregates sub-drivers for the camera interface, raw, and yuv pipelines.
> 
> ---

[snip]

> +struct mtk_cam_ctx *mtk_cam_start_ctx(struct mtk_cam_device *cam,
> +				      struct mtk_cam_video_device *node)
> +{
> +	struct mtk_cam_ctx *ctx = node->ctx;
> +	struct device *dev;
> +	struct v4l2_subdev **target_sd;
> +	int ret, i, is_first_ctx;
> +	struct media_entity *entity = &node->vdev.entity;
> +	struct media_graph graph;
> +
> +	dev_info(cam->dev, "%s:ctx(%d): triggered by %s\n",
> +		 __func__, ctx->stream_id, entity->name);
> +
> +	atomic_set(&ctx->enqueued_frame_seq_no, 0);
> +	ctx->composed_frame_seq_no = 0;
> +	ctx->dequeued_frame_seq_no = 0;
> +	atomic_set(&ctx->running_s_data_cnt, 0);
> +	init_completion(&ctx->session_complete);
> +
> +	is_first_ctx = !cam->composer_cnt;
> +	if (is_first_ctx) {
> +		spin_lock(&cam->dma_processing_lock);
> +		cam->dma_processing_count = 0;
> +		spin_unlock(&cam->dma_processing_lock);
> +		spin_lock(&cam->running_job_lock);
> +		cam->running_job_count = 0;
> +		spin_unlock(&cam->running_job_lock);
> +
> +		dev_info(cam->dev, "%s: power on camsys\n", __func__);
> +		ret = pm_runtime_resume_and_get(cam->dev);
> +		if (ret < 0) {
> +			dev_info(cam->dev, "%s: power on camsys failed\n",
> +				 __func__);
> +			return NULL;
> +		}
> +
> +		ret = isp_composer_init(cam);
> +		if (ret)
> +			goto fail_shutdown;
> +	}
> +	cam->composer_cnt++;
> +	if (is_yuv_node(node->desc.id))
> +		dev = cam->raw.yuvs[0];
> +	else
> +		dev = cam->raw.devs[0];
> +
> +	ret = mtk_cam_working_buf_pool_init(ctx, dev);
> +	if (ret) {
> +		dev_info(cam->dev, "failed to reserve DMA memory:%d\n", ret);
> +		goto fail_uninit_composer;
> +	}
> +
> +	kthread_init_worker(&ctx->sensor_worker);

You does not do anything to sensor_worker, so it's usedless.
Drop it.

> +	ctx->sensor_worker_task = kthread_run(kthread_worker_fn,
> +					      &ctx->sensor_worker,
> +					      "sensor_worker-%d",
> +					      ctx->stream_id);
> +	if (IS_ERR(ctx->sensor_worker_task)) {
> +		dev_info(cam->dev,
> +			 "%s:ctx(%d): could not create sensor_worker_task\n",
> +			 __func__, ctx->stream_id);
> +		goto fail_release_buffer_pool;
> +	}
> +
> +	sched_set_fifo(ctx->sensor_worker_task);
> +
> +	ctx->composer_wq = alloc_ordered_workqueue(dev_name(cam->dev),
> +						   WQ_HIGHPRI | WQ_FREEZABLE);
> +	if (!ctx->composer_wq) {
> +		dev_info(cam->dev, "failed to alloc composer workqueue\n");
> +		goto fail_uninit_sensor_worker_task;
> +	}
> +
> +	ctx->frame_done_wq = alloc_ordered_workqueue(dev_name(cam->dev),
> +						     WQ_HIGHPRI | WQ_FREEZABLE);
> +	if (!ctx->frame_done_wq) {
> +		dev_info(cam->dev, "failed to alloc frame_done workqueue\n");
> +		goto fail_uninit_composer_wq;
> +	}
> +
> +	ret = media_pipeline_start(&entity->pads[0], &ctx->pipeline);
> +	if (ret) {
> +		dev_warn(cam->dev,
> +			 "%s:pipe(%d):failed in media_pipeline_start:%d\n",
> +			 __func__, node->uid.pipe_id, ret);
> +		goto fail_uninit_frame_done_wq;
> +	}
> +
> +	/* traverse to update used subdevs & number of nodes */
> +	i = 0;
> +	ret = media_graph_walk_init(&graph, entity->graph_obj.mdev);
> +	if (ret)
> +		goto fail_stop_pipeline;
> +
> +	media_graph_walk_start(&graph, entity);
> +	while ((entity = media_graph_walk_next(&graph))) {
> +		dev_dbg(cam->dev, "linked entity %s\n", entity->name);
> +
> +		target_sd = NULL;
> +
> +		switch (entity->function) {
> +		case MEDIA_ENT_F_IO_V4L:
> +			ctx->enabled_node_cnt++;
> +			break;
> +		case MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER: /* pipeline */
> +			if (i >= MAX_PIPES_PER_STREAM)
> +				goto fail_stop_pipeline;
> +			target_sd = ctx->pipe_subdevs + i;
> +			i++;
> +			break;
> +		case MEDIA_ENT_F_VID_IF_BRIDGE: /* seninf */
> +			target_sd = &ctx->seninf;
> +			break;
> +		case MEDIA_ENT_F_CAM_SENSOR:
> +			target_sd = &ctx->sensor;

In this series, no entity's function is MEDIA_ENT_F_CAM_SENSOR,
so ctx->sensor is always NULL.
Drop it.

Regards,
CK

> +			break;
> +		default:
> +			break;
> +		}
> +
> +		if (!target_sd)
> +			continue;
> +
> +		if (*target_sd) {
> +			dev_info(cam->dev, "duplicated subdevs!!!\n");
> +			goto fail_traverse_subdev;
> +		}
> +
> +		if (is_media_entity_v4l2_subdev(entity))
> +			*target_sd = media_entity_to_v4l2_subdev(entity);
> +	}
> +	media_graph_walk_cleanup(&graph);
> +
> +	return ctx;
> +
> +fail_traverse_subdev:
> +	media_graph_walk_cleanup(&graph);
> +fail_stop_pipeline:
> +	media_pipeline_stop(&entity->pads[0]);
> +fail_uninit_frame_done_wq:
> +	destroy_workqueue(ctx->frame_done_wq);
> +fail_uninit_composer_wq:
> +	destroy_workqueue(ctx->composer_wq);
> +fail_uninit_sensor_worker_task:
> +	kthread_stop(ctx->sensor_worker_task);
> +	ctx->sensor_worker_task = NULL;
> +fail_release_buffer_pool:
> +	mtk_cam_working_buf_pool_release(ctx, dev);
> +fail_uninit_composer:
> +	isp_composer_uninit(cam);
> +	cam->composer_cnt--;
> +fail_shutdown:
> +	if (is_first_ctx)
> +		rproc_shutdown(cam->rproc_handle);
> +
> +	return NULL;
> +}
> +


  parent reply	other threads:[~2025-07-10  7:46 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07  1:31 [PATCH v2 00/13] Add MediaTek ISP7.x camera system support shangyao lin
2025-07-07  1:31 ` [PATCH v2 01/13] dt-bindings: media: mediatek: add camisp binding shangyao lin
2025-07-07  2:46   ` Rob Herring (Arm)
2025-07-07  5:42   ` Krzysztof Kozlowski
2025-07-15  8:25   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 02/13] dt-bindings: media: mediatek: add seninf-core binding shangyao lin
2025-07-07  2:46   ` Rob Herring (Arm)
2025-07-07  5:44   ` Krzysztof Kozlowski
2025-07-15  7:28   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 03/13] dt-bindings: media: mediatek: add cam-raw binding shangyao lin
2025-07-07  2:46   ` Rob Herring (Arm)
2025-07-07  5:48   ` Krzysztof Kozlowski
2025-07-15  8:13   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 04/13] dt-bindings: media: mediatek: add cam-yuv binding shangyao lin
2025-07-07  2:46   ` Rob Herring (Arm)
2025-07-07  5:47   ` Krzysztof Kozlowski
2025-07-15  7:41   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 05/13] media: platform: mediatek: add isp_7x seninf unit shangyao lin
2025-07-07  5:50   ` Krzysztof Kozlowski
2025-07-10  6:39   ` CK Hu (胡俊光)
2025-07-16  4:06   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 06/13] media: platform: mediatek: add isp_7x state ctrl shangyao lin
2025-07-11  8:56   ` CK Hu (胡俊光)
2025-07-21  1:40   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 07/13] MEDIA: PLATFORM: MEDIATEK: ADD ISP_7X CAM-RAW UNIT shangyao lin
2025-07-15  4:07   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 08/13] media: platform: mediatek: add isp_7x camsys unit shangyao lin
2025-07-07  5:58   ` Krzysztof Kozlowski
2025-07-10  5:20   ` CK Hu (胡俊光)
2025-07-10  7:46   ` CK Hu (胡俊光) [this message]
2025-07-24  8:36   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 09/13] media: platform: mediatek: add isp_7x utility shangyao lin
2025-07-22  2:19   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 10/13] media: platform: mediatek: add isp_7x video ops shangyao lin
2025-08-01  5:45   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 11/13] media: platform: mediatek: add isp_7x build config shangyao lin
2025-07-07  1:31 ` [PATCH v2 12/13] uapi: linux: add mediatek isp_7x camsys user api shangyao lin
2025-07-08  1:34   ` CK Hu (胡俊光)
2025-07-07  1:31 ` [PATCH v2 13/13] media: uapi: mediatek: document ISP7x camera system and user controls shangyao lin
2025-07-11  3:12   ` CK Hu (胡俊光)
2025-07-07  5:55 ` [PATCH v2 00/13] Add MediaTek ISP7.x camera system support Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=600de87b908be63c2a5064837e4e9684d703527c.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Shangyao.Lin@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=krzk+dt@kernel.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).