linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Nas Chung <nas.chung@chipsnmedia.com>,
	mchehab@kernel.org, hverkuil@xs4all.nl, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org,
	jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com,
	Ming Qian <ming.qian@oss.nxp.com>
Subject: Re: [PATCH v3 5/9] media: chips-media: wave6: Add Wave6 core driver
Date: Fri, 29 Aug 2025 16:02:36 +0200	[thread overview]
Message-ID: <19196605-50fb-440f-9666-7502de9ddfd5@kernel.org> (raw)
In-Reply-To: <20250829084649.359-6-nas.chung@chipsnmedia.com>

On 29/08/2025 10:46, Nas Chung wrote:
> This adds the core driver for the Chips&Media Wave6 video codec IP.

Please do not use "This commit/patch/change", but imperative mood. See
longer explanation here:
https://elixir.bootlin.com/linux/v6.16/source/Documentation/process/submitting-patches.rst#L94

> 
> The core region provides the encoding and decoding capabilities of
> the VPU and depends on the control region for firmware and shared
> resource management.
> 


...

> +
> +static int wave6_vpu_core_probe(struct platform_device *pdev)
> +{
> +	struct vpu_core_device *core;
> +	const struct wave6_vpu_core_resource *res;
> +	int ret;
> +	int irq;
> +
> +	res = device_get_match_data(&pdev->dev);
> +	if (!res) {
> +		dev_err(&pdev->dev, "missing resource\n");

This is almost impossible condition. Not worth printing errors.

> +		return -EINVAL;
> +	}
> +
> +	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "dma_set_mask_and_coherent failed: %d\n", ret);
> +		return ret;
> +	}
> +
> +	core = devm_kzalloc(&pdev->dev, sizeof(*core), GFP_KERNEL);
> +	if (!core)
> +		return -ENOMEM;
> +
> +	ret = devm_mutex_init(&pdev->dev, &core->dev_lock);
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_mutex_init(&pdev->dev, &core->hw_lock);
> +	if (ret)
> +		return ret;
> +
> +	init_completion(&core->irq_done);
> +	dev_set_drvdata(&pdev->dev, core);
> +	core->dev = &pdev->dev;
> +	core->res = res;
> +
> +	if (pdev->dev.parent->driver && pdev->dev.parent->driver->name &&
> +	    !strcmp(pdev->dev.parent->driver->name, WAVE6_VPU_PLATFORM_DRIVER_NAME))
> +		core->vpu = dev_get_drvdata(pdev->dev.parent);
> +
> +	core->reg_base = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(core->reg_base))
> +		return PTR_ERR(core->reg_base);
> +
> +	ret = devm_clk_bulk_get_all(&pdev->dev, &core->clks);
> +	if (ret < 0) {
> +		dev_warn(&pdev->dev, "unable to get clocks: %d\n", ret);

You should handle deferred probe instead.

> +		ret = 0;
> +	}
> +	core->num_clks = ret;
> +
> +	ret = v4l2_device_register(&pdev->dev, &core->v4l2_dev);
> +	if (ret) {
> +		dev_err(&pdev->dev, "v4l2_device_register fail: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = wave6_vpu_init_m2m_dev(core);
> +	if (ret)
> +		goto err_v4l2_unregister;
> +
> +	irq = platform_get_irq(pdev, 0);
> +	if (irq < 0) {
> +		dev_err(&pdev->dev, "failed to get irq resource\n");

Syntax is: dev_err_probe

> +		ret = -ENXIO;

Don't override error codes.

> +		goto err_m2m_dev_release;
> +	}
> +
> +	ret = kfifo_alloc(&core->irq_status, 16 * sizeof(int), GFP_KERNEL);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to allocate fifo\n");
> +		goto err_m2m_dev_release;
> +	}
> +
> +	ret = devm_request_threaded_irq(&pdev->dev, irq,
> +					wave6_vpu_core_irq,
> +					wave6_vpu_core_irq_thread,
> +					0, "vpu_irq", core);
> +	if (ret) {
> +		dev_err(&pdev->dev, "fail to register interrupt handler: %d\n", ret);
> +		goto err_kfifo_free;
> +	}
> +
> +	core->temp_vbuf.size = ALIGN(W6_TEMPBUF_SIZE, 4096);
> +	ret = wave6_vdi_alloc_dma(core->dev, &core->temp_vbuf);
> +	if (ret) {
> +		dev_err(&pdev->dev, "alloc temp of size %zu failed\n",
> +			core->temp_vbuf.size);
> +		goto err_kfifo_free;
> +	}
> +
> +	core->debugfs = debugfs_lookup(WAVE6_VPU_DEBUGFS_DIR, NULL);
> +	if (IS_ERR_OR_NULL(core->debugfs))
> +		core->debugfs = debugfs_create_dir(WAVE6_VPU_DEBUGFS_DIR, NULL);
> +
> +	pm_runtime_enable(&pdev->dev);
> +
> +	if (core->res->codec_types & WAVE6_IS_DEC) {
> +		ret = wave6_vpu_dec_register_device(core);
> +		if (ret) {
> +			dev_err(&pdev->dev, "wave6_vpu_dec_register_device fail: %d\n", ret);
> +			goto err_temp_vbuf_free;
> +		}
> +	}
> +	if (core->res->codec_types & WAVE6_IS_ENC) {
> +		ret = wave6_vpu_enc_register_device(core);
> +		if (ret) {
> +			dev_err(&pdev->dev, "wave6_vpu_enc_register_device fail: %d\n", ret);
> +			goto err_dec_unreg;
> +		}
> +	}
Best regards,
Krzysztof

  reply	other threads:[~2025-08-29 14:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29  8:46 [PATCH v3 0/9] Add support for Wave6 video codec driver Nas Chung
2025-08-29  8:46 ` [PATCH v3 1/9] media: v4l2-common: Add YUV24 format info Nas Chung
2025-08-29  8:46 ` [PATCH v3 2/9] dt-bindings: media: nxp: Add Wave6 video codec device Nas Chung
2025-08-29 13:57   ` Krzysztof Kozlowski
2025-09-02  5:45     ` Nas Chung
2025-09-02  7:42       ` Nas Chung
2025-08-29  8:46 ` [PATCH v3 3/9] media: chips-media: wave6: Add Wave6 VPU interface Nas Chung
2025-08-29  8:46 ` [PATCH v3 4/9] media: chips-media: wave6: Add v4l2 m2m driver support Nas Chung
2025-08-29  8:46 ` [PATCH v3 5/9] media: chips-media: wave6: Add Wave6 core driver Nas Chung
2025-08-29 14:02   ` Krzysztof Kozlowski [this message]
2025-09-01  8:34     ` Nas Chung
2025-08-29  8:46 ` [PATCH v3 6/9] media: chips-media: wave6: Improve debugging capabilities Nas Chung
2025-08-29  8:46 ` [PATCH v3 7/9] media: chips-media: wave6: Add Wave6 thermal cooling device Nas Chung
2025-08-29  8:46 ` [PATCH v3 8/9] media: chips-media: wave6: Add Wave6 control driver Nas Chung
2025-08-29 14:06   ` Krzysztof Kozlowski
2025-09-01  8:13     ` Nas Chung
2025-09-01 10:44       ` Krzysztof Kozlowski
2025-09-02  2:03         ` Nas Chung
2025-08-29  8:46 ` [PATCH v3 9/9] arm64: dts: freescale: imx95: Add video codec node Nas Chung
2025-08-29 14:07   ` Krzysztof Kozlowski
2025-09-01  7:38     ` Nas Chung

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=19196605-50fb-440f-9666-7502de9ddfd5@kernel.org \
    --to=krzk@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=jackson.lee@chipsnmedia.com \
    --cc=krzk+dt@kernel.org \
    --cc=lafley.kim@chipsnmedia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ming.qian@oss.nxp.com \
    --cc=nas.chung@chipsnmedia.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@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).