All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gianfranco Mariotti" <gianfranco.mariotti94@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] drm/bridge: Add Lontium LT9721 HDMI to eDP bridge driver
Date: Tue, 24 Nov 2026 19:39:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-231900@kernel.org> (raw)
In-Reply-To: <20261124191803.283266-3-gianfranco.mariotti94@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/bridge: lt9721: refcount underflow on next_bridge in
  lt9721_link_panel()
- [Medium] drm/bridge: lt9721: off-by-one partial write count in
  lt9721_aux_transfer_i2c()
- [Low] drm/bridge: lt9721: missing DRM_BRIDGE_OP_DETECT for panels in
  lt9721_link_panel()
- [Low] drm/bridge: lt9721: positional initializer in lt9721_i2c_ids[]
--

commit aa23cf54f8347a08ccdc8bd2c65d1c07c8f8ba0d
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

drm/bridge: Add Lontium LT9721 HDMI to eDP bridge driver

This commit adds a DRM bridge driver for the Lontium LT9721 HDMI 1.4 to
1/2/4-lane eDP 1.4 bridge chip.

> diff --git a/drivers/gpu/drm/bridge/lontium-lt9721.c b/drivers/gpu/drm/bridge/lontium-lt9721.c
> new file mode 100644
> index 0000000000000..582e9e59dfb4d
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/lontium-lt9721.c
[ ... ]
> +static ssize_t lt9721_aux_transfer_i2c(struct lt9721 *lt9721,
> +				       struct drm_dp_aux_msg *msg)
> +{
[ ... ]
> +	if (is_read) {
> +		data_len = min_t(size_t, msg->size, rx_cnt - 1);
> +		for (i = 0; i < data_len; i++) {
> +			ret = regmap_read(lt9721->regmap,
> +					  LT9721_REG_AUX_SOFT_FIFO, &val);
> +			if (ret)
> +				goto out_drain;
> +			buf[i] = val;
> +		}
> +		ret = data_len;
> +	} else if (rx_cnt > 1) {
> +		/* Partial write: sink returned count M (M + 1 bytes written) */
> +		ret = regmap_read(lt9721->regmap, LT9721_REG_AUX_SOFT_FIFO,
> +				  &val);
> +		if (ret == 0)
> +			ret = min_t(size_t, msg->size, val + 1);
> +	} else {
> +		ret = msg->size;
> +	}

[Severity: Medium]
Does this over-report partial I2C-over-AUX writes by one byte?

Unlike the 4-bit length field in the AUX request header, the reply data
byte M returned by a DisplayPort sink on a short I2C write is already the
exact number of bytes written (0 < M < msg->size).  Returning val + 1
causes drm_dp_i2c_drain_msg() to advance msg.buffer by one unwritten byte
on each partial write.

[ ... ]

> +static enum drm_connector_status
> +lt9721_bridge_detect(struct drm_bridge *bridge,
> +		     struct drm_connector *connector)
> +{
> +	struct lt9721 *lt9721 = bridge_to_lt9721(bridge);
> +	unsigned int val = 0;
> +
> +	if (lt9721->is_panel)
> +		return connector_status_connected;
> +
> +	if (regmap_read(lt9721->regmap, LT9721_REG_HPD_STATUS, &val))
> +		return connector_status_unknown;
> +
> +	return (val & LT9721_EDP_HPD_STATUS) ?
> +		connector_status_connected : connector_status_disconnected;
> +}
[ ... ]
> +static int lt9721_link_panel(struct drm_dp_aux *aux)
> +{
> +	struct lt9721 *lt9721 = aux_to_lt9721(aux);
> +	struct device *dev = lt9721->dev;
> +	struct drm_bridge *next_bridge;
> +
> +	next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);
> +	if (IS_ERR(next_bridge))
> +		return PTR_ERR(next_bridge);
> +
> +	if (drm_bridge_is_panel(next_bridge))
> +		lt9721->is_panel = true;
> +	else
> +		lt9721->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;

[Severity: Low]
Should DRM_BRIDGE_OP_DETECT also be set when drm_bridge_is_panel() is
true?  Without it, drm_bridge_connector_init() and drm_bridge_detect()
never invoke lt9721_bridge_detect() for panels, leaving the
lt9721->is_panel check unreachable and failing to override an upstream
HDMI bridge's DRM_BRIDGE_OP_DETECT.

> +
> +	lt9721->bridge.next_bridge = next_bridge;
> +
> +	return devm_drm_bridge_add(dev, &lt9721->bridge);
> +}

[Severity: High]
Does assigning devm_drm_of_get_bridge() to lt9721->bridge.next_bridge
underflow next_bridge->refcount when lt9721->bridge is freed?

__drm_bridge_free() unconditionally calls
drm_bridge_put(bridge->next_bridge), so bridge.next_bridge requires an
owned reference.  devm_drm_of_get_bridge() does not return a reference for
bridge.next_bridge to consume: for a panel, devm_drm_panel_bridge_add()
already registers devm_drm_panel_bridge_release() to drop its reference on
unbind, and for a non-panel bridge, drm_of_find_panel_or_bridge() returns
an unreferenced pointer from of_drm_find_bridge().  On driver unbind or
probe unwind, __drm_bridge_free() drops an extra reference and frees the
downstream bridge prematurely.

Using of_drm_get_bridge_by_endpoint() (or taking a reference with
drm_bridge_get()) would provide the reference that bridge.next_bridge
expects.

[ ... ]

> +static const struct i2c_device_id lt9721_i2c_ids[] = {
> +	{ "lt9721" },
> +	{ }
> +};

[Severity: Low]
This isn't a bug, but new struct i2c_device_id entries should use named
initializers ({ .name = "lt9721" }).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124191803.283266-1-gianfranco.mariotti94@gmail.com?part=2

      reply	other threads:[~2026-11-24 19:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 19:18 [PATCH 0/2] drm/bridge: Add Lontium LT9721 HDMI to eDP bridge support Gianfranco Mariotti
2026-11-24 19:18 ` [PATCH 1/2] dt-bindings: display: bridge: Add Lontium LT9721 HDMI to eDP bridge Gianfranco Mariotti
2026-11-24 19:18 ` [PATCH 2/2] drm/bridge: Add Lontium LT9721 HDMI to eDP bridge driver Gianfranco Mariotti
2026-11-24 19:39   ` sashiko-bot [this message]

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-231900@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gianfranco.mariotti94@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.