Re: [PATCH v2] media: iris: vpu3x: Add MNoC low power handshake during hardware power-off

From: Bryan O'Donoghue
Date: Wed Aug 13 2025 - 16:22:24 EST


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