From: Manik Bajpai <manik.bajpai@intel.com>
To: sakari.ailus@linux.intel.com
Cc: linux-media@vger.kernel.org, antti.laakso@linux.intel.com,
sarang.sapre@intel.com
Subject: [PATCH v2 2/4] media: ipu6: Always run cleanup in ipu7 power on/off on timeout
Date: Tue, 29 Sep 2026 14:01:28 +0530 [thread overview]
Message-ID: <20260929083130.88381-3-manik.bajpai@intel.com> (raw)
In-Reply-To: <20260929083130.88381-1-manik.bajpai@intel.com>
__ipu7_power_on() and __ipu7_power_off() both return early when the
pwr_status readl_poll_timeout() call times out, skipping cleanup that
was previously done only on the success path:
- __ipu7_power_on() left the clock-ownership override bit set in
SLEEP_LEVEL_CFG instead of clearing it, which could break
subsequent power transitions.
- __ipu7_power_off() skipped D2D power-down and NDE-disable, leaving
those subsystems powered despite reporting a failure.
- Additionally, the return value of ipu7_isys_d2d_power() in
__ipu7_power_off() was discarded, silently masking D2D power-down
failures.
Always run the clock-override clear / D2D-NDE teardown regardless of
whether the status poll timed out, and propagate a D2D power-down
failure through the return value when the poll itself succeeded.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Manik Bajpai <manik.bajpai@intel.com>
---
drivers/media/pci/intel/ipu6/ipu6-buttress.c | 24 ++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-buttress.c b/drivers/media/pci/intel/ipu6/ipu6-buttress.c
index 105de1744dff..06a773b5b66b 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-buttress.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-buttress.c
@@ -530,16 +530,15 @@ static int __ipu7_power_on(struct device *dev,
ret = readl_poll_timeout(isp->base + isp->buttress.regs->pwr_status,
val, (val & ctrl->pwr_sts_mask) == pwr_sts,
100, BUTTRESS_POWER_TIMEOUT_US);
- if (ret) {
+ if (ret)
dev_err(&isp->pdev->dev,
"Change power status timeout with 0x%x\n", val);
- return ret;
- }
+ /* Always drop the clock override, even if the poll above timed out. */
slp = readl(isp->base + IPU7_BUTTRESS_REG_SLEEP_LEVEL_CFG);
writel(slp & ~ovrd_clk, isp->base + IPU7_BUTTRESS_REG_SLEEP_LEVEL_CFG);
- return 0;
+ return ret;
}
static int __ipu7_power_off(struct device *dev,
@@ -555,18 +554,25 @@ static int __ipu7_power_off(struct device *dev,
ret = readl_poll_timeout(isp->base + isp->buttress.regs->pwr_status,
val, (val & ctrl->pwr_sts_mask) == pwr_sts,
100, BUTTRESS_POWER_TIMEOUT_US);
- if (ret) {
+ if (ret)
dev_err(&isp->pdev->dev,
"Change power status timeout with 0x%x\n", val);
- return ret;
- }
+ /* Always release D2D/NDE, even if the power status poll timed out. */
if (ctrl->subsys_id == IPU_ISYS) {
- ipu7_isys_d2d_power(isp, false);
+ int d2d_ret;
+
+ d2d_ret = ipu7_isys_d2d_power(isp, false);
+ if (d2d_ret) {
+ dev_err(&isp->pdev->dev,
+ "D2D power down failed (%d)\n", d2d_ret);
+ if (!ret)
+ ret = d2d_ret;
+ }
ipu7_nde_control(isp, false);
}
- return 0;
+ return ret;
}
static int __ipu6_power(struct device *dev,
--
2.53.0
next prev parent reply other threads:[~2026-09-29 8:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 11:56 [PATCH v1 0/4] media: ipu6: A few defensive fixes for ipu7 buttress, fw-com and mmu paths Manik Bajpai
2026-09-28 11:56 ` [PATCH v1 1/4] media: ipu6: Free boot config on queue memory alloc failure Manik Bajpai
2026-09-28 11:56 ` [PATCH v1 2/4] media: ipu6: Always run cleanup in ipu7 power on/off on timeout Manik Bajpai
2026-09-28 11:56 ` [PATCH v1 3/4] media: ipu6: Validate fw-com queue indices before use Manik Bajpai
2026-09-28 11:56 ` [PATCH v1 4/4] media: ipu6: Fix NULL deref in ipu6_mmu_iova_to_phys() Manik Bajpai
2026-09-28 12:08 ` Sakari Ailus
2026-09-29 8:31 ` [PATCH v2 0/4] media: ipu6: A few defensive fixes for ipu7 buttress, fw-com and mmu paths Manik Bajpai
2026-09-29 8:31 ` [PATCH v2 1/4] media: ipu6: Free boot config on queue memory alloc failure Manik Bajpai
2026-09-30 8:53 ` Sakari Ailus
2026-09-29 8:31 ` Manik Bajpai [this message]
2026-09-30 13:17 ` [PATCH v2 2/4] media: ipu6: Always run cleanup in ipu7 power on/off on timeout Antti Laakso
2026-09-29 8:31 ` [PATCH v2 3/4] media: ipu6: Validate fw-com queue indices before use Manik Bajpai
2026-09-29 8:31 ` [PATCH v2 4/4] media: ipu6: Fix NULL deref in ipu6_mmu_iova_to_phys() Manik Bajpai
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=20260929083130.88381-3-manik.bajpai@intel.com \
--to=manik.bajpai@intel.com \
--cc=antti.laakso@linux.intel.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sarang.sapre@intel.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