From: Itai Handler <itai.handler@gmail.com>
To: stable@vger.kernel.org
Cc: Itai Handler <itai.handler@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>, Mark Brown <broonie@kernel.org>,
Marek Vasut <marex@nabladev.com>, Marek Vasut <marex@denx.de>,
Michal Simek <michal.simek@amd.com>,
linux-spi@vger.kernel.org
Subject: [PATCH 5.10.y v2 0/4] spi: spi-zynqmp-gqspi: fix runtime PM, then stop on shutdown
Date: Sun, 1 Nov 2026 18:31:50 +0200 [thread overview]
Message-ID: <20261101163154.2274099-1-itai.handler@gmail.com> (raw)
This is v2 of the 5.10.y backport of e922bad8b2d5 ("spi:
spi-zynqmp-gqspi: stop the controller on shutdown"). v1 was dropped
[1]: on 5.10.y its pm_runtime_get_if_in_use() check always returns 0,
so ->shutdown never stops the controller. Rather than give 5.10.y
runtime PM and MMIO logic of its own, v2 first brings the driver's
runtime PM in line with upstream (1-3/4), then applies e922bad8b2d5
as-is (4/4, unchanged from v1).
Why it always returns 0 on 5.10.y
---------------------------------
5.10.y has none of 1-3/4. Its probe() calls
pm_runtime_put_autosuspend() without a matching get, so the usage
count rests at -1. The controller runtime suspends 3s after probe, and
a flash access never resumes it: without auto_runtime_pm, spi-mem
takes no runtime PM reference around an op.
Until 5.10.37 the clocks stayed on regardless, as
zynqmp_qspi_setup_op() enabled them a second time. 24159580abcc, the
5.10.37 backport of c6bdae08012b ("spi: spi-zynqmp-gqspi: fix
clk_enable/disable imbalance issue"), removed that because "pm_runtime
works now"; upstream it was applied directly on top of 1/4, but 5.10.y
took it without 1/4. Since then only probe() and the runtime resume
callback enable the clocks, so flash accesses made more than 3s after
probe run on a controller whose clocks Linux has disabled.
At shutdown, device_shutdown()'s pm_runtime_get_noresume() lifts the
count from -1 to 0, and pm_runtime_get_if_in_use() returns 0 whether
the controller is active or not.
Why 5.10.y lacks the fixes
--------------------------
5.10.198 carried 1/4 and 2/4, line for line as they are here: 2/4 as
19f3d5d13b75, and 1/4 as its Stable-dep-of, 2cdec9c13f81. But
2cdec9c13f81 bears the upstream ID and message of a21fbc42807b, an
earlier commit with the same subject: a one-line change to the probe
error path, dropped in favour of 1/4 when the two branches were merged
for v5.13. Marek reported that 2cdec9c13f81 looked very different from
a21fbc42807b and that it broke a platform for him [2], and 5.10.199
reverted both (1ceaf0d3a883, 649237ccf440). The difference he saw
comes from the label: 2cdec9c13f81's code is that of 58eaa7b2d07d.
What broke was not reported.
Marek, do you remember which platform it was and how it failed? If it
is still around, could you give this series a try?
I could not make this series, or 5.10.198, fail in emulation. Besides
the testing below, I ran both on a full ZynqMP system in QEMU: the PMU
firmware, TF-A and U-Boot of PetaLinux 2021.1 and 2024.2, the QSPI node
with and without its power domain, and a local QEMU change that stalls
the GQSPI while the firmware gates QSPI_REF. Flash reads and writes
across runtime suspend, and unbind and bind, worked with both, and
neither touched the controller while its clock was gated, 4/4's
->shutdown included. v5.10.272 without this series, by contrast, hangs
on its first flash access made more than 3s after probe.
The series
----------
1/4 58eaa7b2d07d makes probe take the reference it drops, and sets
auto_runtime_pm so that spi-mem resumes the controller around
every op
2/4 1527b076ae2c makes sure the controller is not runtime suspended
when the probe error path and remove() disable its clocks by hand
3/4 2219576883e7 undoes autosuspend at driver exit
4/4 e922bad8b2d5 the v1 backport, unchanged
1-3/4 are in 5.15.y and 6.1.y, with no reverts there: 58eaa7b2d07d
since v5.13, 1527b076ae2c since 5.15.135 and 6.1.57, and 2219576883e7
since 5.15.174 and 6.1.120. With them, the runtime PM, clock and
controller (un)registration calls in probe(), remove() and the runtime
PM callbacks are the same as in v7.3, in the same order, bar a
pm_runtime_mark_last_busy() that v7.3's pm_runtime_put_autosuspend()
now makes itself.
Testing
-------
Tested in QEMU only, not on hardware: Xilinx QEMU (xilinx_v2024.2) and
its ZynqMP GQSPI model with an n25q512a11, running v5.10.272 with v1
alone against v5.10.272 with this series.
v1 alone v2
usage count after probe -1 0
usage count after unbind and bind -1 0
runtime status after a flash read suspended active
GQSPI_EN after "halt -f" 0x1 0x0
The last row is what e922bad8b2d5 is for: with v1 alone ->shutdown
returns early and leaves the controller enabled. The halt follows a
flash read, with the autosuspend delay raised so that the controller is
still active when ->shutdown runs; GQSPI_EN is then read through the
QEMU monitor. The usage count is read from sysfs, which needs
CONFIG_PM_ADVANCED_DEBUG. v7.3 passes the two checks that do not need
the usage count.
Caveats
-------
- The QEMU GQSPI has fixed clocks and no power domain here, so runtime
suspend gates nothing: this shows that runtime PM is balanced and
that ->shutdown now acts. The full-system runs above add the PMU
firmware and a modelled clock gate, but a model is not silicon: if
what broke in 5.10.198 depends on the hardware or on that platform's
firmware, none of this would catch it, hence the question to Marek.
- spi_controller_suspend() in ->shutdown is a no-op on 5.10.y, as the
controller is not queued. Upstream it also takes the bus lock, and so
waits for an in-flight spi-mem op; that came with bef4a48f4ef7 ("spi:
Fix null dereference on suspend", v6.7), which is in 6.1.y but not in
5.15.y or 5.10.y. 5.10.y's own zynqmp_qspi_suspend() has the same
gap, so I have left that core change out of this series.
Changes in v2:
- add 1-3/4, so that 4/4 works on 5.10.y as-is
- 4/4 is unchanged
v1: https://lore.kernel.org/stable/20260922140318.668429-1-itai.handler@gmail.com/
[1] https://lore.kernel.org/stable/2026-09-24-daily-reply-0010-re-spi-zynqmp-gqspi-shutdown-5-10-drop@kernel.org/
[2] https://lore.kernel.org/stable/9afe9285-6f46-46d9-bd21-2ea5c4dc43c0@denx.de/
Dinghao Liu (1):
spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe
Itai Handler (1):
spi: spi-zynqmp-gqspi: stop the controller on shutdown
Jinjie Ruan (1):
spi: zynqmp-gqspi: Undo runtime PM changes at driver exit time
Johan Hovold (1):
spi: zynqmp-gqspi: fix clock imbalance on probe failure
drivers/spi/spi-zynqmp-gqspi.c | 60 +++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 5 deletions(-)
base-commit: aca95a35f1bcc0626c4fa4d1252bf2d4c990a1a2
--
2.34.1
next reply other threads:[~2026-11-01 16:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 16:31 Itai Handler [this message]
2026-11-01 16:31 ` [PATCH 5.10.y v2 1/4] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe Itai Handler
2026-11-01 16:31 ` [PATCH 5.10.y v2 2/4] spi: zynqmp-gqspi: fix clock imbalance on probe failure Itai Handler
2026-11-01 16:31 ` [PATCH 5.10.y v2 3/4] spi: zynqmp-gqspi: Undo runtime PM changes at driver exit time Itai Handler
2026-11-01 16:31 ` [PATCH 5.10.y v2 4/4] spi: spi-zynqmp-gqspi: stop the controller on shutdown Itai Handler
2026-11-02 15:33 ` [PATCH 5.10.y v2 0/4] spi: spi-zynqmp-gqspi: fix runtime PM, then stop " Sasha Levin
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=20261101163154.2274099-1-itai.handler@gmail.com \
--to=itai.handler@gmail.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-spi@vger.kernel.org \
--cc=marex@denx.de \
--cc=marex@nabladev.com \
--cc=michal.simek@amd.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/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