From: sashiko-bot@kernel.org
To: "Hermes Wu" <Hermes.wu@ite.com.tw>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 2/2] drm/bridge: Add ITE IT6162 MIPI DSI to HDMI bridge driver
Date: Wed, 02 Dec 2026 02:43:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-244709@kernel.org> (raw)
In-Reply-To: <20261202-upstream-6162-v6-2-508a142766a2@ite.com.tw>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [High] drm/bridge: it6162: missing downstream bridge attach on DT
port@3
- [High] drm/bridge: it6162: missing modeset on HDCP property changes in
atomic_check()
- [High] drm/bridge: it6162: incomplete mipi_cfg and disabled IRQ during
attach
- [Medium] drm/bridge: it6162: unpropagated HDCP topology errors in
it6162_update_hdcp()
- [Medium] drm/bridge: it6162: infinite HDCP 1.4 fallback loop in
it6162_hdcp_handler()
- [Medium] drm/bridge: it6162: race on hdcp_work queueing and unlocked
HDCP state
- [Low] drm/bridge: it6162: error codes overwritten with -ENODEV in
probe path
--
commit b7302ef734d960c18ef7e381678faab767cea1d0
Author: Hermes Wu <Hermes.wu@ite.com.tw>
drm/bridge: Add ITE IT6162 MIPI DSI to HDMI bridge driver
This commit adds a DRM bridge driver for the ITE IT6162 MIPI DSI to HDMI
2.0 bridge chip, supporting single and dual MIPI DSI inputs, EDID
retrieval, HPD, HDMI audio, and HDCP.
> diff --git a/drivers/gpu/drm/bridge/ite-it6162.c b/drivers/gpu/drm/bridge/ite-it6162.c
> new file mode 100644
> index 0000000000000..05e8d0f34173c
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/ite-it6162.c
> @@ -0,0 +1,1876 @@
[ ... ]
> +static void it6162_update_hdcp14(struct it6162 *it6162)
> +{
> + struct drm_device *drm = it6162->drm;
> + int dev_count;
> + u8 bksv[5];
> + u8 bstatus[2];
> + u8 ksvlist[5 * 30];
> + int ret;
> +
> + ret = it6162_hdcp_read_information(it6162, bstatus, bksv);
> + if (ret < 0) {
> + drm_err(drm, "fail to read Bstatus");
> + return;
> + }
> +
> + dev_count = DRM_HDCP_NUM_DOWNSTREAM(bstatus[0]);
> + if (dev_count == 0)
> + return;
> +
> + if (DRM_HDCP_MAX_DEVICE_EXCEEDED(bstatus[0]) ||
> + DRM_HDCP_MAX_CASCADE_EXCEEDED(bstatus[1])) {
> + drm_err(drm, "HDCP1.4 Max Topology Limit Exceeded");
> + return;
> + }
> +
> + dev_count = dev_count > 30 ? 30 : dev_count;
> + ret = it6162_hdcp_read_list(it6162, ksvlist, dev_count);
> + if (ret < 0) {
> + drm_err(drm, "fail to read KSV list");
> + return;
> + }
> +}
> +
> +static void it6162_update_hdcp23(struct it6162 *it6162)
> +{
> + struct drm_device *drm = it6162->drm;
> + int dev_count;
> + u8 rxid[5];
> + u8 rxinfo[2];
> + u8 rxid_list[5 * 30];
> + int ret;
> +
> + ret = it6162_hdcp_read_information(it6162, rxinfo, rxid);
> + if (ret < 0) {
> + drm_err(drm, "fail to read Rxinfo");
> + return;
> + }
> +
> + dev_count = (HDCP_2_2_DEV_COUNT_HI(rxinfo[0]) << 4 |
> + HDCP_2_2_DEV_COUNT_LO(rxinfo[1]));
> + if (dev_count == 0)
> + return;
> +
> + if (HDCP_2_2_MAX_CASCADE_EXCEEDED(rxinfo[1]) ||
> + HDCP_2_2_MAX_DEVS_EXCEEDED(rxinfo[1])) {
> + drm_err(drm, "HDCP2.3 Topology Max Size Exceeded");
> + return;
> + }
> +
> + dev_count = dev_count > 30 ? 30 : dev_count;
> + ret = it6162_hdcp_read_list(it6162, rxid_list, dev_count);
> + if (ret < 0) {
> + drm_err(drm, "fail to read RxID list");
> + return;
> + }
> +}
> +
> +static void it6162_update_hdcp(struct it6162 *it6162, u8 version)
> +{
> + if (version == HDCP_23)
> + it6162_update_hdcp23(it6162);
> + else
> + it6162_update_hdcp14(it6162);
> +}
[ ... ]
> +static void it6162_hdcp_handler(struct it6162 *it6162)
> +{
> + struct regmap *regmap = it6162->regmap;
> + unsigned int tx_status, sink_cap;
> + enum hdcp_state hdcp_sts;
> + struct it6162_hdcp_cfg *hdcp_cfg = &it6162->hdcp_cfg;
> + u8 hdcp_ver;
> + u64 cp_status = DRM_MODE_CONTENT_PROTECTION_DESIRED;
> +
> + if (hdcp_cfg->hdcp_version == HDCP_DISABLE || !READ_ONCE(it6162->en_hdcp))
> + return;
> +
> + if (it6162->hdcp_version != HDCP_DISABLE) {
> + if (regmap_read(regmap, OFFSET_TX_STATUS, &tx_status) < 0 ||
> + regmap_read(regmap, OFFSET_SINK_CAP, &sink_cap) < 0)
> + return;
> +
> + if (!GET_TX_VIDEO_STATUS(tx_status)) {
> + drm_dbg(it6162->drm, "video not stable, skip hdcp check");
> + return;
> + }
> +
> + hdcp_sts = GET_TX_HDCP_STATUS(tx_status);
> + hdcp_ver = GET_SINK_CAP_HDCP_VER(sink_cap);
> + if (it6162->hdcp_sts != hdcp_sts ||
> + it6162->hdcp_sts == HDCP_STATE_IDLE) {
> + it6162->hdcp_sts = hdcp_sts;
> + switch (hdcp_sts) {
> + case HDCP_STATE_AUTH_DONE:
> + it6162_update_hdcp(it6162, hdcp_ver);
> + cp_status = DRM_MODE_CONTENT_PROTECTION_ENABLED;
> + break;
[Severity: Medium]
Should it6162_update_hdcp() return an error code so HDCP_STATE_AUTH_DONE
does not report DRM_MODE_CONTENT_PROTECTION_ENABLED when Bstatus/RxInfo
reads fail or topology limits are exceeded?
In addition, it6162_update_hdcp14() and it6162_update_hdcp23() return
early when dev_count == 0 before checking the MAX_DEVICE_EXCEEDED and
MAX_CASCADE_EXCEEDED overflow bits, and the bksv, ksvlist, rxid, and
rxid_list buffers are read over I2C into stack arrays that are never
checked or passed to drm_hdcp_check_ksvs_revoked().
> + case HDCP_STATE_AUTH_FAIL:
> + /* Content Type 1 needs HDCP 2.3: no fallback */
> + if (hdcp_ver == HDCP_23 &&
> + !READ_ONCE(it6162->hdcp_stream_type))
> + it6162_tx_hdcp_setup(it6162, HDCP_14,
> + true);
> + else
> + it6162_tx_hdcp_disable(it6162);
> +
> + break;
> + default:
> + it6162_tx_hdcp_setup(it6162,
> + it6162->hdcp_version,
> + true);
> + break;
> + }
> + it6162_hdcp_queue_prop_update(it6162, cp_status);
> + }
> + }
> +}
[Severity: Medium]
If the HDCP 1.4 fallback also fails with HDCP_STATE_AUTH_FAIL, will this
retry HDCP 1.4 forever instead of calling it6162_tx_hdcp_disable()?
hdcp_ver is read from OFFSET_SINK_CAP (the sink's capability, which stays
HDCP_23) and it6162_tx_hdcp_enable() resets it6162->hdcp_sts to
HDCP_STATE_IDLE without recording that the driver has already fallen back
to HDCP_14. On the next failure, hdcp_ver == HDCP_23 is still true, so
it6162_hdcp_handler() calls it6162_tx_hdcp_setup(it6162, HDCP_14, true)
again and never reaches the else branch.
> +static void it6162_interrupt_handler(struct it6162 *it6162)
> +{
[ ... ]
> + if (READ_ONCE(it6162->en_hdcp) && GET_TX_VIDEO_STATUS(tx_status) &&
> + connector_status == connector_status_connected)
> + queue_delayed_work(system_percpu_wq, &it6162->hdcp_work,
> + msecs_to_jiffies(2000));
> +}
[Severity: Medium]
Can it6162_interrupt_handler() race with it6162_bridge_atomic_disable() to
leave hdcp_work pending after the bridge is disabled?
CPU0 (modeset) CPU1 (threaded IRQ)
it6162_bridge_atomic_disable()
it6162_interrupt_handler()
if (READ_ONCE(it6162->en_hdcp) && ...)
scoped_guard(mutex, &it6162->lock)
WRITE_ONCE(it6162->en_hdcp, false)
it6162_tx_disable()
cancel_delayed_work_sync(&it6162->hdcp_work)
queue_delayed_work(..., &it6162->hdcp_work, ...)
<-- hdcp_work queued after cancel
Furthermore, in it6162_bridge_atomic_enable(), it6162->en_hdcp is set to
true before it6162_tx_enable() sets it6162->hdcp_version and before
it6162_mipi_enable() starts video, so a pending hdcp_work (or an interrupt
arriving during enable) can run before hdcp_version is initialized or keep
the 2000 ms stabilization timer from being reset when video becomes
stable. it6162->hdcp_version and it6162->hdcp_sts are also read and
modified without it6162->lock in it6162_tx_hdcp_disable(),
it6162_tx_enable(), and it6162_hdcp_handler().
[ ... ]
> +static int it6162_detect_devices(struct it6162 *it6162)
> +{
> + struct device *dev = it6162->dev;
> + const struct it6162_chip_info *chip_info;
> + u32 chip_id, version;
> + u8 buf[6];
> + int ret = -ENODEV;
> +
> + chip_info = i2c_get_match_data(it6162->it6162_i2c);
> + if (!chip_info)
> + return -ENODEV;
> +
> + if (it6162_platform_set_power(it6162) < 0)
> + return -ENODEV;
[Severity: Low]
Should this propagate the error returned by it6162_platform_set_power()
(and should it6162_probe() propagate the return value of
it6162_detect_devices()) instead of overwriting it with -ENODEV? The
driver core treats -ENODEV as an absent device and silently suppresses
probe failure logging for regulator, I2C, or devres errors.
[ ... ]
> +static int it6162_attach_dsi(struct it6162 *it6162)
> +{
> + struct device *dev = it6162->dev;
> + const struct mipi_dsi_device_info info = {
> + .type = "it6162-mipi",
> + .channel = 0,
> + .node = NULL,
> + };
> + struct mipi_dsi_device *dsi;
> + struct mipi_dsi_host *host;
> + struct it6162_mipi_cfg *mipi_cfg = &it6162->mipi_cfg;
> + int ret = 0;
> +
> + it6162->dsi = NULL;
> + for (int port = 0; port < 2; port++) {
> + host = it6162_of_get_dsi_host_by_port(it6162, port);
> + if (IS_ERR(host))
> + continue;
> +
> + mipi_cfg->en_port[port] = true;
> +
> + dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
> + if (IS_ERR(dsi)) {
> + dev_err(dev, "failed to create dsi device");
> + return PTR_ERR(dsi);
> + }
> + /* uses a single DSI configuration for both ports in dual-link mode */
> + if (!it6162->dsi) {
> + ret = it6162_load_mipi_pars_from_port(it6162, port);
> + if (ret <= 0)
> + return ret;
> + it6162->dsi = dsi;
> + }
> +
> + dsi->lanes = mipi_cfg->lane_num;
> + dsi->format = mipi_cfg->format;
> + dsi->mode_flags = mipi_cfg->mode_flags;
> + ret = devm_mipi_dsi_attach(dev, dsi);
> + if (ret) {
> + dev_err(dev, "failed to attach dsi device %d", port);
> + return ret;
> + }
> + }
> +
> + return it6162_hw_start(it6162);
> +}
[Severity: High]
Can the DRM pipeline bind and access the bridge during
devm_mipi_dsi_attach() (or after devm_drm_bridge_add()) before mipi_cfg is
populated for both ports and before it6162_hw_start() initializes the chip
and enables the IRQ?
Many DSI host drivers bind the DRM component master inside their
mipi_dsi_host_ops.attach callback. When that happens during port 0's
devm_mipi_dsi_attach() in dual-DSI mode, mipi_cfg->en_port[1] is still
false, so it6162_bridge_mode_valid() computes ports = 1 and rejects dual-
DSI 4K@60Hz modes with MODE_CLOCK_HIGH. In addition, because
it6162_hw_start() has not run yet, an EDID read on a forced connector will
time out waiting for an IRQ still disabled with IRQF_NO_AUTOEN, and when
it6162_hw_start() -> it6162_reset_init() finally runs, it overwrites
OFFSET_MIPI_CONFIG_L and OFFSET_TX_SETTING with 0, clobbering any initial
modeset that already ran it6162_bridge_atomic_enable().
[ ... ]
> +static int it6162_bridge_attach(struct drm_bridge *bridge,
> + struct drm_encoder *encoder,
> + enum drm_bridge_attach_flags flags)
> +{
> + struct it6162 *it6162 = bridge_to_it6162(bridge);
> + struct drm_device *drm = bridge->dev;
> +
> + it6162->drm = drm;
> + if (!drm_core_check_feature(drm, DRIVER_ATOMIC)) {
> + drm_dbg(drm, "it6162 driver only copes with atomic updates");
> + return -EOPNOTSUPP;
> + }
> +
> + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
> + drm_err(drm, "DRM_BRIDGE_ATTACH_NO_CONNECTOR must be supplied");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
[Severity: High]
Does the driver need to look up and attach the downstream bridge on DT
port@3?
The ite,it6162.yaml binding defines port@3 as the HDMI output port
connected to an hdmi-connector node, but it6162_probe() only checks ports
0..2 and it6162_bridge_attach() never calls drm_bridge_attach() on a next
bridge, leaving any downstream display-connector or HDMI bridge unattached
from the encoder bridge chain.
[ ... ]
> +static int it6162_bridge_atomic_check(struct drm_bridge *bridge,
> + struct drm_bridge_state *bridge_state,
> + struct drm_crtc_state *crtc_state,
> + struct drm_connector_state *conn_state)
> +{
> + struct drm_display_mode *adj = &crtc_state->adjusted_mode;
> + struct drm_display_mode *mode = &crtc_state->mode;
> + struct it6162 *it6162 = bridge_to_it6162(bridge);
> + struct drm_connector_state *old_conn_state;
> + u32 hfp, hsw, hbp;
> + u32 clock;
> + u32 hfp_check;
> +
> + /*
> + * A new HDCP content type needs a new authentication, which happens
> + * at the next modeset; report DESIRED until then.
> + */
> + old_conn_state = drm_atomic_get_old_connector_state(conn_state->state,
> + conn_state->connector);
> + if (old_conn_state &&
> + old_conn_state->hdcp_content_type != conn_state->hdcp_content_type &&
> + conn_state->content_protection !=
> + DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
> + conn_state->content_protection =
> + DRM_MODE_CONTENT_PROTECTION_DESIRED;
> + }
[Severity: High]
How are changes to conn_state->content_protection or
conn_state->hdcp_content_type applied when userspace updates those
properties on an already active display without changing the mode?
Because the driver only reads content_protection and hdcp_content_type in
it6162_bridge_atomic_enable() and stops HDCP in
it6162_bridge_atomic_disable(), and it6162_bridge_atomic_check() never
sets crtc_state->mode_changed = true when those properties change,
enabling or disabling HDCP without a modeset will never start or stop HDCP
in hardware.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-upstream-6162-v6-0-508a142766a2@ite.com.tw?part=2
prev parent reply other threads:[~2026-12-02 2:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:18 [PATCH v6 0/2] Add ITE IT6162 MIPI DSI to HDMI bridge driver Hermes Wu via B4 Relay
2026-12-02 2:18 ` [PATCH v6 1/2] dt-bindings: display: bridge: Add ITE IT6162 MIPI DSI to HDMI bridge Hermes Wu via B4 Relay
2026-12-02 2:18 ` [PATCH v6 2/2] drm/bridge: Add ITE IT6162 MIPI DSI to HDMI bridge driver Hermes Wu via B4 Relay
2026-12-02 2:43 ` 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-244709@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Hermes.wu@ite.com.tw \
--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