mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nas Chung <nas.chung@chipsnmedia.com>
To: Frank Li <Frank.li@oss.nxp.com>
Cc: "mchehab@kernel.org" <mchehab@kernel.org>,
	"hverkuil@xs4all.nl" <hverkuil@xs4all.nl>,
	"robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-imx@nxp.com" <linux-imx@nxp.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"jackson.lee" <jackson.lee@chipsnmedia.com>,
	"lafley.kim" <lafley.kim@chipsnmedia.com>,
	"marek.vasut@mailbox.org" <marek.vasut@mailbox.org>,
	Ming Qian <ming.qian@oss.nxp.com>
Subject: RE: [PATCH v7 5/9] media: chips-media: wave6: Add Wave6 core driver
Date: Fri, 11 Sep 2026 08:35:46 +0000	[thread overview]
Message-ID: <SL2P216MB2441946218CB8AEB1D07DEB2FBBE2@SL2P216MB2441.KORP216.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <aqMXumGHR9JjvVrf@lizhi-Precision-Tower-5810>

Hi, Frank.

>-----Original Message-----
>From: Frank Li <Frank.li@oss.nxp.com>
>Sent: Friday, September 11, 2026 5:49 AM
>To: Nas Chung <nas.chung@chipsnmedia.com>
>Cc: mchehab@kernel.org; hverkuil@xs4all.nl; robh@kernel.org;
>krzk+dt@kernel.org; conor+dt@kernel.org; shawnguo@kernel.org;
>s.hauer@pengutronix.de; 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
><jackson.lee@chipsnmedia.com>; lafley.kim <lafley.kim@chipsnmedia.com>;
>marek.vasut@mailbox.org; Ming Qian <ming.qian@oss.nxp.com>
>Subject: Re: [PATCH v7 5/9] media: chips-media: wave6: Add Wave6 core
>driver
>
>On Fri, Sep 04, 2026 at 03:46:31PM +0900, Nas Chung wrote:
>> Add the core driver for the Chips&Media Wave6 video codec IP.
>>
>> The hardware contains one control register region and four interface
>> register regions for a shared video processing engine. This driver
>> handles the interface register regions, each with its own MMIO range and
>> interrupt, while relying on the control driver for firmware loading 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 = dev_get_platdata(&pdev->dev);
>> +	if (!res)
>> +		return -ENODEV;
>> +
>> +	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>> +	if (ret < 0) {
>> +		dev_err(&pdev->dev, "failed to set DMA mask: %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;
>> +
>> +	spin_lock_init(&core->inst_lock);
>> +	INIT_LIST_HEAD(&core->instances);
>> +	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))
>
>why need check this?

I'll remove the condition in v8.

>
>> +		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)
>> +		return dev_err_probe(&pdev->dev, ret, "failed to get
>clocks\n");
>> +
>> +	core->num_clks = ret;
>> +
>> +	ret = kfifo_init(&core->irq_fifo, core->irq_buffer,
>> +			 sizeof(core->irq_buffer));
>> +	if (ret)
>> +		return ret;
>> +
>> +	irq = platform_get_irq(pdev, 0);
>> +	if (irq < 0)
>> +		return irq;
>> +
>> +	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, "failed to request IRQ: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	ret = v4l2_device_register(&pdev->dev, &core->v4l2_dev);
>> +	if (ret) {
>> +		dev_err(&pdev->dev, "failed to register v4l2_dev: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	ret = wave6_vpu_init_m2m_dev(core);
>> +	if (ret)
>> +		goto err_v4l2_unregister;
>> +
>> +	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, "failed to allocate temp_vbuf: %d\n",
>ret);
>> +		goto err_m2m_dev_release;
>> +	}
>> +
>> +	core->debugfs = debugfs_lookup(WAVE6_VPU_DEBUGFS_DIR, NULL);
>> +	if (!IS_ERR_OR_NULL(core->debugfs))
>> +		dput(core->debugfs);
>> +	else
>> +		core->debugfs = debugfs_create_dir(WAVE6_VPU_DEBUGFS_DIR,
>NULL);
>> +
>> +	pm_runtime_enable(&pdev->dev);
>
>devm_pm_runtime_enable()

OK.

>
>> +
>> +	if (core->res->codec_types & WAVE6_IS_DEC) {
>> +		ret = wave6_vpu_dec_register_device(core);
>> +		if (ret) {
>> +			dev_err(&pdev->dev,
>> +				"failed to register video_dev_dec: %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,
>> +				"failed to register video_dev_enc: %d\n", ret);
>> +			goto err_dec_unreg;
>> +		}
>> +	}
>> +
>> +	dev_dbg(&pdev->dev, "Added wave6 driver with caps %s %s\n",
>> +		core->res->codec_types & WAVE6_IS_ENC ? "'ENCODE'" : "",
>> +		core->res->codec_types & WAVE6_IS_DEC ? "'DECODE'" : "");
>> +
>> +	return 0;
>> +
>> +err_dec_unreg:
>> +	if (core->res->codec_types & WAVE6_IS_DEC)
>> +		wave6_vpu_dec_unregister_device(core);
>> +err_temp_vbuf_free:
>> +	pm_runtime_disable(&pdev->dev);
>> +	wave6_vdi_free_dma(&core->temp_vbuf);
>> +err_m2m_dev_release:
>> +	wave6_vpu_release_m2m_dev(core);
>> +err_v4l2_unregister:
>> +	v4l2_device_unregister(&core->v4l2_dev);
>
>can you try use devm_add_action_or_reset() to elimiate these error label?

OK, I'll address this in v8.

>
>> +
>> +	return ret;
>> +}
>> +
>> +static void wave6_vpu_core_remove(struct platform_device *pdev)
>> +{
>> +	struct vpu_core_device *core = dev_get_drvdata(&pdev->dev);
>> +
>> +	wave6_vpu_enc_unregister_device(core);
>> +	wave6_vpu_dec_unregister_device(core);
>> +	pm_runtime_disable(&pdev->dev);
>> +	wave6_vdi_free_dma(&core->temp_vbuf);
>> +	wave6_vpu_release_m2m_dev(core);
>> +	v4l2_device_unregister(&core->v4l2_dev);
>> +}
>> +
>> +static int wave6_vpu_core_runtime_suspend(struct device *dev)
>> +{
>> +	struct vpu_core_device *core = dev_get_drvdata(dev);
>> +
>> +	if (WARN_ON(!core))
>> +		return -ENODEV;
>> +
>> +	/*
>> +	 * Only call parent VPU put_vpu if the core has a parent and is
>active.
>> +	 * - core->vpu: prevent access in core without parent VPU.
>> +	 * - core->active: execute sleep only after m2m streaming is started.
>> +	 */
>> +	if (core->vpu && core->active)
>> +		core->vpu->put_vpu(core->vpu, core);
>> +
>> +	if (core->num_clks)
>
>Need check it. clk_bulk_disable_unprepare() is empty ops when num_clks is 0

I'll drop the guard in v8.

>
>> +		clk_bulk_disable_unprepare(core->num_clks, core->clks);
>> +
>> +	return 0;
>> +}
>> +
>> +static int wave6_vpu_core_runtime_resume(struct device *dev)
>> +{
>> +	struct vpu_core_device *core = dev_get_drvdata(dev);
>> +	bool boot_vpu;
>> +	int ret;
>> +
>> +	if (WARN_ON(!core))
>> +		return -ENODEV;
>> +
>> +	if (core->num_clks) {
>
>need checkit. clk_bulk_prepare_enable() is empty ops when num_clks is 0

Same here.

Thanks.
Nas.

>
>Frank

  reply	other threads:[~2026-09-11  8:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  6:46 [PATCH v7 0/9] Add support for Wave6 video codec driver Nas Chung
2026-09-04  6:46 ` [PATCH v7 1/9] media: v4l2-common: Fix P010 format info Nas Chung
2026-09-04  6:46 ` [PATCH v7 2/9] dt-bindings: media: nxp: Add Wave6 video codec device Nas Chung
2026-09-08  9:50   ` Krzysztof Kozlowski
2026-09-09 16:33   ` Frank Li
2026-09-04  6:46 ` [PATCH v7 3/9] media: chips-media: wave6: Add Wave6 VPU interface Nas Chung
2026-09-09 19:49   ` Frank Li
2026-09-10  8:14     ` Nas Chung
2026-09-10 19:50   ` Frank Li
2026-09-14  4:37     ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 4/9] media: chips-media: wave6: Add v4l2 m2m driver support Nas Chung
2026-09-10 20:37   ` Frank Li
2026-09-11  7:12     ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 5/9] media: chips-media: wave6: Add Wave6 core driver Nas Chung
2026-09-10 20:48   ` Frank Li
2026-09-11  8:35     ` Nas Chung [this message]
2026-09-04  6:46 ` [PATCH v7 6/9] media: chips-media: wave6: Improve debugging capabilities Nas Chung
2026-09-09 20:40   ` Frank Li
2026-09-10  4:38     ` Nas Chung
2026-09-10 16:16       ` Frank Li
2026-09-11  3:53         ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 7/9] media: chips-media: wave6: Add Wave6 thermal cooling device Nas Chung
2026-09-04  6:46 ` [PATCH v7 8/9] media: chips-media: wave6: Add Wave6 control driver Nas Chung
2026-09-10 21:04   ` Frank Li
2026-09-11  7:07     ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 9/9] arm64: dts: freescale: imx95: Add video codec node Nas Chung
2026-09-10 20:00 ` [PATCH v7 0/9] Add support for Wave6 video codec driver Frank Li
2026-09-11  6:58   ` 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=SL2P216MB2441946218CB8AEB1D07DEB2FBBE2@SL2P216MB2441.KORP216.PROD.OUTLOOK.COM \
    --to=nas.chung@chipsnmedia.com \
    --cc=Frank.li@oss.nxp.com \
    --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=marek.vasut@mailbox.org \
    --cc=mchehab@kernel.org \
    --cc=ming.qian@oss.nxp.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

all inboxes | Powered by JetHome®