dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cristian Ciocaltea" <cristian.ciocaltea@collabora.com>
Cc: linux-sunxi@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v11 10/74] drm/display: hdmi: Add HDMI 2.0 scrambling management helpers
Date: Tue, 01 Sep 2026 19:18:24 +0000	[thread overview]
Message-ID: <20260901191824.80F491F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260901-dw-hdmi-qp-scramb-v11-10-bc12954a0688@collabora.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] HDMI scrambling lifecycle helpers introduce sleeping functions into atomic display paths.
- [Medium] Logic error in SCDC scrambling status monitor: the delayed work item stops scheduling itself, violating the intended periodic monitoring.
--

commit eedf8ebd00133222505fd96065a3aa6dbeefff8d
Author: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>

drm/display: hdmi: Add HDMI 2.0 scrambling management helpers

This commit introduces helpers to manage the full lifecycle of HDMI 2.0
SCDC scrambling on both source and sink sides. It includes configuration
of scrambling, high TMDS clock ratios, and a delayed work item to
monitor and restore the sink's scrambling status.

> diff --git a/drivers/gpu/drm/display/drm_hdmi_helper.c b/drivers/gpu/drm/display/drm_hdmi_helper.c
> index 5cb0b033b1713..bf1c7963b984b 100644
> --- a/drivers/gpu/drm/display/drm_hdmi_helper.c
> +++ b/drivers/gpu/drm/display/drm_hdmi_helper.c
[ ... ]
> +static int drm_connector_hdmi_try_scrambling_setup(struct drm_connector *connector)
> +{
> +	bool done;
> +
> +	done = drm_scdc_set_high_tmds_clock_ratio(connector, true);
> +	if (!done)
> +		return -EIO;

[Severity: High]
Since drm_connector_hdmi_enable_scrambling() might be called from atomic
commit paths (like CRTC atomic enable), is it safe to call
drm_scdc_set_high_tmds_clock_ratio() here?

Looking at drm_scdc_set_high_tmds_clock_ratio() in drm_scdc_helper.c, it
uses a sleeping wait:

    usleep_range(1000, 2000);

Could this lead to sleeping in atomic context warnings or deadlocks if
reached during an atomic display update?

[Severity: Medium]
If drm_scdc_set_high_tmds_clock_ratio() or drm_scdc_set_scrambling() fail due
to a transient DDC error, we return -EIO early here and bypass the
schedule_delayed_work() call below.

Does this inadvertently stop the periodic monitoring from retrying the setup
later?

> +
> +	done = drm_scdc_set_scrambling(connector, true);
> +	if (!done)
> +		return -EIO;
> +
> +	if (READ_ONCE(connector->hdmi.scrambler_enabled))
> +		schedule_delayed_work(&connector->hdmi.scdc_work,
> +				      msecs_to_jiffies(DRM_HDMI_SCDC_POLL_DELAY_MS));
> +
> +	return 0;
> +}
> +
> +static void drm_connector_hdmi_scdc_work(struct work_struct *work)
> +{
[ ... ]
> +	if (READ_ONCE(connector->hdmi.scrambler_enabled) &&
> +	    !drm_scdc_get_scrambling_status(connector))
> +		drm_connector_hdmi_try_scrambling_setup(connector);
> +}

[Severity: Medium]
If the sink scrambling status is healthy (drm_scdc_get_scrambling_status()
returns true), this function exits without rescheduling itself.

Does this mean the periodic work item stops monitoring the SCDC status
entirely after the first successful check? The commit message mentions a
periodic work item that monitors the status and retries when lost, but it
appears the loop breaks as soon as the sink is in a good state.

[ ... ]
> +int drm_connector_hdmi_disable_scrambling(struct drm_connector *connector)
> +{
[ ... ]
> +	/*
> +	 * A driver may force scrambler_enabled at init to trigger a disable
> +	 * at boot (e.g. vc4), bypassing the enable path that sets up the work
> +	 * item. Only cancel it once it has actually been initialized.
> +	 */
> +	if (hdmi->scdc_work_initialized)
> +		cancel_delayed_work_sync(&hdmi->scdc_work);

[Severity: High]
If drm_connector_hdmi_disable_scrambling() is invoked from an atomic
context (e.g., during CRTC or encoder atomic disable callbacks), could
calling cancel_delayed_work_sync() cause a sleep in atomic context?

Since cancel_delayed_work_sync() can block waiting for the work to finish,
this might cause system instability if called while holding spinlocks or
from a non-preemptible path.

> +
> +	if (connector->ddc &&
> +	    connector->status == connector_status_connected &&
> +	    drm_scdc_sink_supports_scrambling(connector)) {
> +		drm_scdc_set_scrambling(connector, false);
> +		drm_scdc_set_high_tmds_clock_ratio(connector, false);
> +	}
> +
> +	return hdmi->funcs->scrambler_disable(connector);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-dw-hdmi-qp-scramb-v11-0-bc12954a0688@collabora.com?part=10

  reply	other threads:[~2026-09-01 19:18 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 18:50 [PATCH v11 00/74] Add HDMI 2.0 support to DW HDMI QP TX Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 01/74] video/hdmi: Introduce HDMI version enum Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 02/74] drm/connector: hdmi: Handle reset() state allocation failure Cristian Ciocaltea
2026-09-01 19:07   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 03/74] drm/display: hdmi: Rename drmm_connector_hdmi_init() to *_ini2() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 04/74] drm/connector: Add drmm_connector_hdmi_init() with new signature Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 05/74] drm/display: bridge_connector: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 06/74] drm/probe-helper: Introduce .force_ctx() connector callback Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 07/74] drm/connector: Add HDMI 2.0 scrambler infrastructure Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 08/74] drm/display: scdc-helper: Add macro for connector-prefixed debug messages Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 09/74] drm/display: scdc-helper: Add helper to set SCDC version information Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 10/74] drm/display: hdmi: Add HDMI 2.0 scrambling management helpers Cristian Ciocaltea
2026-09-01 19:18   ` sashiko-bot [this message]
2026-09-01 18:50 ` [PATCH v11 11/74] drm/display: hdmi: Advertise SCDC source version when scrambling Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 12/74] drm/bridge: Fix unlocked list_del in drm_bridge_add() Cristian Ciocaltea
2026-09-01 19:17   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 13/74] drm/bridge: Fix NULL deref in drm_bridge_add() for legacy bridges Cristian Ciocaltea
2026-09-01 19:19   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 14/74] drm/bridge: Fix unlocked list access in drm_bridge_attach() Cristian Ciocaltea
2026-09-01 19:16   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 15/74] drm/bridge: Remove redundant error check in drm_bridge_helper_reset_crtc() Cristian Ciocaltea
2026-09-01 19:21   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 16/74] drm/bridge: Add bridge ops for source-side HDMI 2.0 scrambling Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 17/74] drm/display: bridge_connector: Use cached connector status in .get_modes() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 18/74] drm/display: bridge_connector: Switch to .detect_ctx() connector helper Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 19/74] drm/display: bridge_connector: Wire up HDMI 2.0 scrambler callbacks Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 20/74] drm/display: hdmi-state-helper: Add source TMDS rate validation Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 21/74] drm/display: hdmi-state-helper: Pass acquire ctx to hotplug helpers Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 22/74] drm/display: hdmi-state-helper: Add drm_atomic_helper_connector_hdmi_force_ctx() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 23/74] drm/display: hdmi-state-helper: Sync SCDC state on hotplug Cristian Ciocaltea
2026-09-01 19:40   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 24/74] drm/display: hdmi-state-helper: Set HDMI scrambling requirement Cristian Ciocaltea
2026-09-01 19:39   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 25/74] drm/display: bridge_connector: Switch to .force_ctx() connector helper Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 26/74] drm/bridge: dw-hdmi-qp: Rate limit i2c read error messages Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 27/74] drm/bridge: dw-hdmi-qp: Provide .{enable,disable}_hpd() PHY ops Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 28/74] drm/bridge: dw-hdmi-qp: Remove unused workqueue include and define Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 29/74] drm/bridge: dw-hdmi-qp: Add HDMI 2.0 scrambling support Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 30/74] drm/bridge: dw-hdmi-qp: Provide dw_hdmi_qp_hpd_notify() helper Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 31/74] drm/rockchip: dw_hdmi_qp: Fix invalid drvdata access in PM ops Cristian Ciocaltea
2026-09-01 19:46   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 32/74] drm/rockchip: dw_hdmi_qp: Cancel pending HPD work on suspend Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 33/74] drm/rockchip: dw_hdmi_qp: Add missing newlines in dev_err_probe() messages Cristian Ciocaltea
2026-09-01 19:52   ` sashiko-bot
2026-09-01 18:50 ` [PATCH v11 34/74] drm/rockchip: dw_hdmi_qp: Use local dev variable consistently in bind() Cristian Ciocaltea
2026-09-01 18:50 ` [PATCH v11 35/74] drm/rockchip: dw_hdmi_qp: Avoid spurious HPD IRQ thread wakeups Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 36/74] drm/rockchip: dw_hdmi_qp: Mask RK3576 HPD IRQ in io_init Cristian Ciocaltea
2026-09-01 19:50   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 37/74] drm/rockchip: dw_hdmi_qp: Implement .{enable,disable}_hpd() PHY ops Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 38/74] drm/rockchip: dw_hdmi_qp: Factor out HPD interrupt (un)mask helpers Cristian Ciocaltea
2026-09-01 19:55   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 39/74] drm/rockchip: dw_hdmi_qp: Control the HPD IRQ line via the bridge HPD ops Cristian Ciocaltea
2026-09-01 20:03   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 40/74] drm/rockchip: dw_hdmi_qp: Use dw_hdmi_qp_hpd_notify() for HPD reports Cristian Ciocaltea
2026-09-01 20:05   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 41/74] drm/bridge: dw-hdmi-qp: Drop unused .setup_hpd() phy op Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 42/74] drm/vc4: hdmi: Use common TMDS char rate constants Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 43/74] drm/vc4: hdmi: Switch to drm_hdmi_mode_needs_scrambling() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 44/74] drm/vc4: hdmi: Switch to .force_ctx() connector helper Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 45/74] drm/vc4: hdmi: Propagate -EDEADLK to the top level Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 46/74] drm/vc4: hdmi: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 47/74] drm/vc4: hdmi: Convert to common HDMI 2.0 scrambling infrastructure Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 48/74] drm/vc4: hdmi: Defer pixel clock validation to HDMI helpers Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 49/74] drm/display: hdmi-state-helper: Drop drm_atomic_helper_connector_hdmi_force() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 50/74] drm/bridge: adv7511: Advertise HDMI 1.2 capabilities Cristian Ciocaltea
2026-09-01 20:17   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 51/74] drm/bridge: inno-hdmi: " Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 52/74] drm/bridge: ite-it6263: Drop redundant .mode_valid hook Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 53/74] drm/bridge: ite-it6263: Advertise HDMI 1.3 capabilities Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 54/74] drm/bridge: ite-it66121: Advertise HDMI 1.2 capabilities Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 55/74] drm/bridge: lontium-lt9611: Advertise HDMI 1.4 capabilities Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 56/74] drm/rockchip: rk3066_hdmi: " Cristian Ciocaltea
2026-09-01 20:24   ` sashiko-bot
2026-09-01 18:51 ` [PATCH v11 57/74] drm/sun4i: hdmi: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 58/74] drm/tests: edid: Add 4K@60Hz EDID with 600MHz TMDS Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 59/74] drm/tests: edid: Fix conformity for 1080p+4K YUV420 200MHz EDID Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 60/74] drm/tests: edid: Fix conformity for 4K RGB/YUV 340MHz EDID Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 61/74] drm/tests: bridge: Set supported HDMI version Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 62/74] drm/tests: connector: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 63/74] drm/tests: connector: Add HDMI max_tmds_char_rate init coverage Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 64/74] drm/tests: connector: Add HDMI source-side scrambler coverage Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 65/74] drm/tests: hdmi_state_helper: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 66/74] drm/tests: hdmi_state_helper: Add connector-provided max_tmds_char_rate coverage Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 67/74] drm/tests: hdmi_state_helper: Cover source-side scrambling decision Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 68/74] drm/connector: Remove drmm_connector_hdmi_ini2() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 69/74] drm/connector: Drop redundant hdmi vendor/product fields Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 70/74] drm/connector: Drop redundant hdmi supported_formats field Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 71/74] drm/connector: Drop redundant max_bpc field Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 72/74] video/hdmi: Define SPD InfoFrame field lengths and use strtomem_pad() Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 73/74] drm/connector: Use the SPD InfoFrame field length defines Cristian Ciocaltea
2026-09-01 18:51 ` [PATCH v11 74/74] drm/tests: hdmi: Add SPD InfoFrame vendor/product coverage Cristian Ciocaltea
2026-09-02 15:28 ` [PATCH v11 00/74] Add HDMI 2.0 support to DW HDMI QP TX Igor Paunovic
2026-09-02 18:00   ` Cristian Ciocaltea

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=20260901191824.80F491F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-sunxi@lists.linux.dev \
    --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