[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <bb919b4f-b51f-41c5-aed8-a3809316f7fb@linaro.org>
Date: Wed, 13 Aug 2025 21:20:35 +0100
From: Bryan O'Donoghue <bryan.odonoghue@...aro.org>
To: Dikshita Agarwal <quic_dikshita@...cinc.com>,
Vikash Garodia <quic_vgarodia@...cinc.com>,
Abhinav Kumar <abhinav.kumar@...ux.dev>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: linux-media@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org, Neil Armstrong <neil.armstrong@...aro.org>
Subject: Re: [PATCH v2] media: iris: vpu3x: Add MNoC low power handshake
during hardware power-off
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
Powered by blists - more mailing lists