From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Dingxian Wen <shawn.wen@rock-chips.com>,
Shreeya Patel <shreeya.patel@collabora.com>
Cc: Gerald Loacker <gerald.loacker@wolfvision.net>,
Lucas Sinn <lucas.sinn@wolfvision.net>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
kernel@collabora.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 06/10] media: synopsys: hdmirx: give the signal lock wait a real timeout
Date: Wed, 4 Nov 2026 17:12:31 +0300 [thread overview]
Message-ID: <fe1c9fc6-53b8-461c-a183-411e4bc85eea@collabora.com> (raw)
In-Reply-To: <20261005-hdmirx-media-v3-6-71a11a2e3e76@pengutronix.de>
On 10/5/26 16:28, Sascha Hauer wrote:
> From: Gerald Loacker <gerald.loacker@wolfvision.net>
>
> hdmirx_wait_signal_lock() bounded itself by a count of 300 iterations.
> How long that came to depended on the debounce inside
> tx_5v_power_present(), which the loop calls once per iteration and which
> sleeps about 7ms of it, so the effective timeout was around two seconds
> by accident rather than by design.
>
> That accident is about to go away. A later patch in this series takes the
> 5V state from an upstream subdev where the board has no hpd-gpios, which
> leaves tx_5v_power_present() a plain read of a flag costing microseconds.
> The same 300 iterations would then be over in a few milliseconds and the
> wait would give up almost immediately.
>
> Poll on a fixed 10ms interval against an explicit three second deadline.
> Check the deadline after the 5V test so a disconnect is still reported as
> -ENOLINK rather than a timeout, and report the timeout as -ETIMEDOUT; the
> sole caller only tests for non-zero, so neither is a change in behaviour.
>
> Assisted-by: LLM
> Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> .../media/platform/synopsys/hdmirx/snps_hdmirx.c | 40 +++++++++++++++-------
> 1 file changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> index 6231bb28616c1..a28eb86e0b83c 100644
> --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> @@ -2129,13 +2129,25 @@ static irqreturn_t hdmirx_dma_irq_handler(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +/*
> + * Wait for the HDMI signal to lock: TMDS clock detection and ratio
> + * configuration, then PHY and CMU lock, then DMA lock.
> + *
> + * The wait used to be bounded by a count of 300 iterations. What that came
> + * to in wall clock time was decided by the debounce inside
> + * tx_5v_power_present(), which is called once per iteration and sleeps
> + * about 7ms of it, so the real timeout was an accident of how 5V happens to
> + * be sensed. Poll on a fixed interval against an explicit deadline instead.
> + */
> static int hdmirx_wait_signal_lock(struct snps_hdmirx_dev *hdmirx_dev)
> {
> struct v4l2_device *v4l2_dev = &hdmirx_dev->v4l2_dev;
> u32 mu_status, scdc_status, dma_st10, cmu_st;
> - u32 i;
> + unsigned long timeout;
> +
> + timeout = jiffies + msecs_to_jiffies(3000);
>
> - for (i = 0; i < 300; i++) {
> + for (;;) {
> mu_status = hdmirx_readl(hdmirx_dev, MAINUNIT_STATUS);
> scdc_status = hdmirx_readl(hdmirx_dev, SCDC_REGBANK_STATUS3);
> dma_st10 = hdmirx_readl(hdmirx_dev, DMA_STATUS10);
> @@ -2149,21 +2161,25 @@ static int hdmirx_wait_signal_lock(struct snps_hdmirx_dev *hdmirx_dev)
> if (!tx_5v_power_present(hdmirx_dev)) {
> v4l2_dbg(1, debug, v4l2_dev,
> "%s: HDMI pull out, return\n", __func__);
> - return -1;
> + return -ENOLINK;
> }
>
> - hdmirx_tmds_clk_ratio_config(hdmirx_dev);
> - }
> + if (time_after(jiffies, timeout)) {
> + v4l2_err(v4l2_dev,
> + "%s: signal not lock, tmds_clk_ratio:%d\n",
> + __func__, hdmirx_dev->tmds_clk_ratio);
> + v4l2_err(v4l2_dev,
> + "%s: mu_st:%#x, scdc_st:%#x, dma_st10:%#x, cmu_st:%#x\n",
> + __func__, mu_status, scdc_status, dma_st10,
> + cmu_st);
> + return -ETIMEDOUT;
> + }
>
> - if (i == 300) {
> - v4l2_err(v4l2_dev, "%s: signal not lock, tmds_clk_ratio:%d\n",
> - __func__, hdmirx_dev->tmds_clk_ratio);
> - v4l2_err(v4l2_dev, "%s: mu_st:%#x, scdc_st:%#x, dma_st10:%#x\n",
> - __func__, mu_status, scdc_status, dma_st10);
> - return -1;
> + hdmirx_tmds_clk_ratio_config(hdmirx_dev);
> + usleep_range(10000, 11000);
> }
>
> - v4l2_dbg(1, debug, v4l2_dev, "%s: signal lock ok, i:%d\n", __func__, i);
> + v4l2_dbg(1, debug, v4l2_dev, "%s: signal lock ok\n", __func__);
> hdmirx_writel(hdmirx_dev, GLOBAL_SWRESET_REQUEST, DATAPATH_SWRESETREQ);
>
> reinit_completion(&hdmirx_dev->avi_pkt_rcv);
>
Acked-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
--
Best regards,
Dmitry
next prev parent reply other threads:[~2026-11-04 14:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 13:28 [PATCH v3 00/10] media: synopsys: hdmirx: support an HDMI bridge in front of the receiver Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 01/10] media: synopsys: hdmirx: free the driver data when the last user is gone Sascha Hauer
2026-10-07 11:20 ` Dmitry Osipenko
2026-10-16 11:06 ` Sascha Hauer
2026-11-04 14:18 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 02/10] media: synopsys: hdmirx: add media device infrastructure Sascha Hauer
2026-11-04 14:11 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 03/10] media: synopsys: hdmirx: add media entity for video capture device Sascha Hauer
2026-11-04 14:11 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 04/10] dt-bindings: media: snps,dw-hdmi-rx: add a port for a bridge in front Sascha Hauer
2026-11-04 14:11 ` Dmitry Osipenko
2026-11-04 14:12 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 05/10] media: synopsys: hdmirx: add async subdevice support Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 06/10] media: synopsys: hdmirx: give the signal lock wait a real timeout Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko [this message]
2026-10-05 13:28 ` [PATCH v3 07/10] media: synopsys: hdmirx: skip the 5V detect interrupt without a GPIO Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 08/10] media: v4l2-device: wait for notifications when unregistering a subdev Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 09/10] media: v4l2-subdev: notify the bridge when the source power changes Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 10/10] media: synopsys: hdmirx: get the 5V state from the upstream subdev Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
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=fe1c9fc6-53b8-461c-a183-411e4bc85eea@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gerald.loacker@wolfvision.net \
--cc=hverkuil@kernel.org \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lucas.sinn@wolfvision.net \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawn.wen@rock-chips.com \
--cc=shreeya.patel@collabora.com \
/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®