Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B
Date: Mon, 16 Nov 2026 15:28:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-217274@kernel.org> (raw)
In-Reply-To: <20261116151017.274764-2-clamor95@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm: unbalanced of_node_put() in mipi_dbi_device_release()
- [Low] drm: mismatched Return kernel-doc in drm_mipi_dbi_bus.c
--

commit 3fe40d87109b802b6b8c4ac15ef288e1fecb74a0
Author: Svyatoslav Ryhel <clamor95@gmail.com>

drm: Add MIPI DBI bus support for MIPI DBI Type A and B

This commit introduces a MIPI DBI bus and driver model infrastructure to
support MIPI DBI Type A and Type B hosts and peripheral devices.

> diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c
> new file mode 100644
> index 0000000000000..fa8cd748d7b3c
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c

[ ... ]

> +static void mipi_dbi_device_release(struct device *dev)
> +{
> +	of_node_put(dev->of_node);
> +	kfree(to_mipi_dbi_device(dev));
> +}
> +
> +static void mipi_dbi_device_unregister(void *data)
> +{
> +	struct device *dev = data;
> +
> +	of_node_clear_flag(dev->of_node, OF_POPULATED);
> +	device_unregister(dev);
> +}
> +
> +/**
> + * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI
> + *				     Type A or B device.
> + * @dev: device to tie the MIPI-DBI device lifetime to
> + * @host: DBI host to which this device is connected
> + * @np: device tree node associated with the panel MIPI DBI device
> + *
> + * This function is called by DBI host driver to create panel device.
> + * It automatically calls mipi_dbi_device_unregister() when @dev is
> + * unbound. It does not automatically free passed device node pointer,
> + * it must be put manually.
> + *
> + * Returns:
> + * A pointer to the newly created MIPI DBI device, or, a pointer encoded
> + * with an error.
> + */
> +struct mipi_dbi_device *
> +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host,
> +			      struct device_node *np)
> +{
> +	struct mipi_dbi_device *dbidev;
> +	int ret;
> +
> +	if (!host || !host->dev || !host->dbi || !host->dbi->command ||
> +	    !host->ops || !host->ops->attach || !host->ops->detach || !np)
> +		return ERR_PTR(-EINVAL);
> +
> +	if (!of_device_is_available(np))
> +		return ERR_PTR(-ENODEV);
> +
> +	dbidev = kzalloc_obj(*dbidev);
> +	if (!dbidev)
> +		return ERR_PTR(-ENOMEM);
> +
> +	if (of_node_test_and_set_flag(np, OF_POPULATED)) {
> +		kfree(dbidev);
> +		return ERR_PTR(-EBUSY);
> +	}
> +
> +	dbidev->host = host;
> +	dbidev->dbi = host->dbi;
> +	device_initialize(&dbidev->dev);
> +	dbidev->dev.parent = host->dev;
> +	dbidev->dev.bus = &mipi_dbi_bus_type;
> +	dbidev->dev.release = mipi_dbi_device_release;
> +	device_set_node(&dbidev->dev, of_fwnode_handle(np));
> +
> +	ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name);
> +	if (ret)
> +		goto put_device;
> +
> +	ret = device_add(&dbidev->dev);
> +	if (ret)
> +		goto put_device;
> +
> +	ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister,
> +				       &dbidev->dev);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	return dbidev;
> +
> +put_device:
> +	of_node_clear_flag(np, OF_POPULATED);
> +	put_device(&dbidev->dev);
> +	return ERR_PTR(ret);
> +}

[Severity: High]
Does mipi_dbi_device_release() drop a reference on dev->of_node that
devm_mipi_dbi_device_register() never acquired?

device_set_node(&dbidev->dev, of_fwnode_handle(np)) does not call
of_node_get(np), and callers are documented as still owning their reference
to np.  When put_device() runs on error unwind or when
mipi_dbi_device_unregister() later unregisters the device,
mipi_dbi_device_release() calls of_node_put(dev->of_node) and underflows the
device_node refcount.  Should devm_mipi_dbi_device_register() call
of_node_get(np) when associating np with dbidev->dev?

[ ... ]

> +/**
> + * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI
> + *			    DBI Type A or B devices.
> + * @dev: device to tie the MIPI-DBI device lifetime to
> + * @dbidev: DBI peripheral
> + */
> +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev)

[ ... ]

> +/**
> + * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices.
> + * @drv: DBI driver structure
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv)

[ ... ]

> diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h
> new file mode 100644
> index 0000000000000..886f175a80cb9
> --- /dev/null
> +++ b/include/drm/drm_mipi_dbi_bus.h

[ ... ]

> +/**
> + * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B.
> + *			    This structure describes a peripheral DBI device,
> + *			    an endpoint for DSC commands and video data, and must
> + *			    be paired with a DBI host device for MIPI DBI Type A
> + *			    and B. This layout is built to closely resemble
> + *			    the DSI framework.
> + *
> + *			    If your device is MIPI DBI Type C (with an SPI
> + *			    control bus) and incorporates DBI within, you
> + *			    should use the mipi_dbi_dev structure and Type C
> + *			    framework from drm_mipi_dbi.c.
> + * @dev: driver model device node for this peripheral
> + * @dbi: MIPI DBI interface
> + * @host: DBI host for this peripheral
> + * @attached: the DBI device has been successfully attached
> + */
> +struct mipi_dbi_device {

[Severity: Low]
This isn't a bug, but the Return: kernel-doc line on
mipi_dbi_driver_unregister() (which returns void) looks like it belongs on
devm_mipi_dbi_attach(), which returns int and has no Return: section.  Also,
in struct mipi_dbi_device, the extended description paragraphs appear before
the @member entries without a blank comment line after the one-line summary.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116151017.274764-1-clamor95@gmail.com?part=1

  reply	other threads:[~2026-11-16 15:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 15:10 [PATCH v7 00/12] drm/tegra: Add support for Tegra20/Tegra30 8-bit CPU interface Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 01/12] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Svyatoslav Ryhel
2026-11-16 15:28   ` sashiko-bot [this message]
2026-11-16 15:10 ` [PATCH v7 02/12] drm/panel: panel-hitachi-tx10d07vm0baa: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 03/12] drm/panel: panel-hitachi-tx10d07vm0baa: Drop redundant disable() operation Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 04/12] drm/panel: panel-lg-lh400wv3: Convert to use MIPI DBI bus Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 05/12] drm/panel: panel-lg-lh400wv3: Drop redundant disable() operation Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 06/12] drm/tegra: dc: Add elements required by Tegra MIPI DBI Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 07/12] dt-bindings: display: tegra: Document Tegra20 DSI port Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 08/12] drm/tegra: output: Make panel parsing configurable Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 09/12] drm/tegra: Convert to use atomic versions of drm_encoder_helper_funcs Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 10/12] drm/tegra: rgb: Parameterize configuration based on bus flags Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 11/12] dt-bindings: display: tegra: Document 8-bit CPU parallel interface Svyatoslav Ryhel
2026-11-16 15:10 ` [PATCH v7 12/12] drm/tegra: Add support for 8-bit CPU interface Svyatoslav Ryhel

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=sashiko-outbox-217274@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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