linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Dikshita Agarwal <quic_dikshita@quicinc.com>,
	Vikash Garodia <quic_vgarodia@quicinc.com>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Neil Armstrong <neil.armstrong@linaro.org>
Subject: Re: [PATCH v2] media: iris: vpu3x: Add MNoC low power handshake during hardware power-off
Date: Wed, 13 Aug 2025 21:20:35 +0100	[thread overview]
Message-ID: <bb919b4f-b51f-41c5-aed8-a3809316f7fb@linaro.org> (raw)
In-Reply-To: <20250813-sm8650-power-sequence-fix-v2-1-9ed0fc2c45cb@quicinc.com>

On 13/08/2025 08:53, Dikshita Agarwal wrote:
> +	/* set MNoC to low power */
> +	writel(REQ_POWER_DOWN_PREP, core->reg_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);
> +
> +	do {
> +		value = readl(core->reg_base + AON_WRAPPER_MVP_NOC_LPI_STATUS);
> +
> +		handshake_done = value & NOC_LPI_STATUS_DONE;
> +		handshake_busy = value & (NOC_LPI_STATUS_DENY | NOC_LPI_STATUS_ACTIVE);
> +
> +		if (handshake_done || !handshake_busy)
> +			break;
> +
> +		writel(0, core->reg_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);
> +
> +		udelay(15);
> +
> +		writel(REQ_POWER_DOWN_PREP, core->reg_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);
> +	} while (++count < 1000);

So if this loop executes 999 times but succeeds on the 1000th try, your 
test would fail because your final write never gets evaluated in a 
subsequent loop.

Wouldn't this be more logical like this

do {
	/* issue command */
	writel(REQ_POWER_DOWN_PREP, core->reg_base +
	       AON_WRAPPER_MVP_NOC_LPI_CONTROL);

	/* wait for command to take effect */
	udelay(15);

	/* read back status */
	value = readl(core->reg_base + AON_WRAPPER_MVP_NOC_LPI_STATUS);

	handshake_done = value & NOC_LPI_STATUS_DONE;
	handshake_busy = value & (NOC_LPI_STATUS_DENY |
				  NOC_LPI_STATUS_ACTIVE);

	if (handshake_done || !handshake_busy)
		break;

	/* power down? the mnoc */
	writel(0, core->reg_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);

	/* Let that command take effect ? */
	udelay(15);

} while (++count < 1000);

That way you exit the loop with the mnoc state in a known state, instead 
of as your loop currently is perhaps having succeeded but incorrectly 
signalling failure.

Also why 1000 ? Thats 1000 x 1.5 microseconds - 1.5 milliseconds 
potentially in your submitted patch now nearly 3 milliseconds assuming 
the power-down command similarly requires a grace period.

Please at least fix the loop so that the last power-on command should it 
succeed at the termination of your loop can be captured.

> +	if (!handshake_done && handshake_busy)
> +		dev_err(core->dev, "LPI handshake timeout\n");

---
bod

      parent reply	other threads:[~2025-08-13 20:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  7:53 [PATCH v2] media: iris: vpu3x: Add MNoC low power handshake during hardware power-off Dikshita Agarwal
2025-08-13  8:26 ` Neil Armstrong
2025-08-13  9:42 ` Konrad Dybcio
2025-08-13 20:20 ` Bryan O'Donoghue [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=bb919b4f-b51f-41c5-aed8-a3809316f7fb@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=abhinav.kumar@linux.dev \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_dikshita@quicinc.com \
    --cc=quic_vgarodia@quicinc.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;
as well as URLs for NNTP newsgroup(s).