* [PATCH AUTOSEL 6.17-6.1] spi: rpc-if: Add resume support for RZ/G3E
[not found] <20251009155752.773732-1-sashal@kernel.org>
@ 2025-10-09 15:54 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] spi: loopback-test: Don't use %pK through printk Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.16] spi: spi-qpic-snand: handle 'use_ecc' parameter of qcom_spi_config_cw_read() Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-10-09 15:54 UTC (permalink / raw)
To: patches, stable; +Cc: Biju Das, Mark Brown, Sasha Levin, linux-spi
From: Biju Das <biju.das.jz@bp.renesas.com>
[ Upstream commit ad4728740bd68d74365a43acc25a65339a9b2173 ]
On RZ/G3E using PSCI, s2ram powers down the SoC. After resume,
reinitialize the hardware for SPI operations.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://patch.msgid.link/20250921112649.104516-3-biju.das.jz@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What changed: The resume callback now reinitializes the underlying
RPC-IF hardware by calling `rpcif_hw_init(dev, false)` before resuming
the SPI controller queue. See drivers/spi/spi-rpc-if.c:210. The rest
of the resume path remains unchanged and returns
`spi_controller_resume(ctlr)` (drivers/spi/spi-rpc-if.c:212). The
patch is a small, contained 2-line addition in a single driver file.
- Why it’s needed: On RZ/G3E systems using PSCI, s2ram powers the SoC
off, so the RPC-IF/xSPI controller loses register state. The SPI
core’s `spi_controller_resume()` does not reconfigure hardware
(drivers/spi/spi.c:3519), it only restarts the message queue. Without
reinitialization, resumed SPI operations can fail or misbehave. The
added `rpcif_hw_init()` reprograms controller registers and ensures
the hardware is ready post-resume.
- Correctness of the reinit: `rpcif_hw_init()` is the standard hardware
bring-up routine used in probe; it resumes runtime PM, reconfigures
the controller for the appropriate mode, and then drops the PM
reference. See drivers/memory/renesas-rpc-if.c:315. It’s already
invoked during probe for the SPI path (drivers/spi/spi-rpc-if.c:173),
so reusing it on resume is appropriate and consistent.
- Scope and risk: The change is isolated to RPC-IF SPI driver resume. It
does not alter normal operation, only system-suspend resume behavior.
The call is idempotent and guarded by runtime PM
(pm_runtime_resume_and_get/put inside rpcif_hw_init), minimizing risk.
It doesn’t introduce features or architectural changes.
- Impacted platforms: Although the commit message highlights RZ/G3E
(xSPI), the reinit is generally safe for other RPC-IF variants too and
can only improve robustness after system suspend.
- Stable-tree suitability:
- Fixes a real user-visible bug (SPI transactions can fail after S2RAM
on RZ/G3E).
- Minimal change (two added lines), fully contained in the driver.
- Low regression risk and no API or architectural churn.
- Touches a specific subsystem driver (SPI/Renesas RPC-IF), not core
kernel paths.
- Backport notes (API/context):
- `rpcif_hw_init()` currently takes a `struct device *`
(drivers/memory/renesas-rpc-if.c:315; include/memory/renesas-rpc-
if.h:75). On older stable trees that predate commit a198fcd1d53cb
(which changed RPC-IF APIs to pass a device instead of an internal
handle), the signature may differ. In such trees, adapt the call
accordingly (e.g., pass `rpc->dev` or the older handle type).
- Ensure the device passed to `rpcif_hw_init()` is the one holding
`rpcif_priv` (in probe we pass `rpc->dev`, which is the parent RPC-
IF device). If the stable branch still uses the older arrangement,
the backport should call `rpcif_hw_init(rpc->dev, false)` after
obtaining `struct rpcif *rpc = spi_controller_get_devdata(ctlr)` in
resume.
- Macro context (SIMPLE_DEV_PM_OPS vs DEFINE_SIMPLE_DEV_PM_OPS) may
differ between branches; this is mechanical and does not affect the
substance of the fix.
In summary, this is a classic, low-risk, correctness fix for resume on
RZ/G3E that should be backported to stable kernels that include the RPC-
IF xSPI support, with trivial API/context adjustments as needed.
drivers/spi/spi-rpc-if.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c
index 627cffea5d5c7..300a7c10b3d40 100644
--- a/drivers/spi/spi-rpc-if.c
+++ b/drivers/spi/spi-rpc-if.c
@@ -207,6 +207,8 @@ static int __maybe_unused rpcif_spi_resume(struct device *dev)
{
struct spi_controller *ctlr = dev_get_drvdata(dev);
+ rpcif_hw_init(dev, false);
+
return spi_controller_resume(ctlr);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.17-5.4] spi: loopback-test: Don't use %pK through printk
[not found] <20251009155752.773732-1-sashal@kernel.org>
2025-10-09 15:54 ` [PATCH AUTOSEL 6.17-6.1] spi: rpc-if: Add resume support for RZ/G3E Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.16] spi: spi-qpic-snand: handle 'use_ecc' parameter of qcom_spi_config_cw_read() Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Thomas Weißschuh, Mark Brown, Sasha Levin, bigeasy,
clrkwllms, rostedt, linux-spi, linux-rt-devel
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
[ Upstream commit b832b19318534bb4f1673b24d78037fee339c679 ]
In the past %pK was preferable to %p as it would not leak raw pointer
values into the kernel log.
Since commit ad67b74d2469 ("printk: hash addresses printed with %p")
the regular %p has been improved to avoid this issue.
Furthermore, restricted pointers ("%pK") were never meant to be used
through printk(). They can still unintentionally leak raw pointers or
acquire sleeping locks in atomic contexts.
Switch to the regular pointer formatting which is safer and
easier to reason about.
There are still a few users of %pK left, but these use it through seq_file,
for which its usage is safe.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://patch.msgid.link/20250811-restricted-pointers-spi-v1-1-32c47f954e4d@linutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Based on my comprehensive analysis of this commit and the broader
context, here is my determination:
**Backport Status: YES**
## Analysis
### Nature of the Change
This commit replaces the `%pK` (restricted pointer) format specifier
with `%p` (regular pointer) in debugging output functions within the SPI
loopback test driver. The changes affect:
- `spi_test_dump_message()` - debugging output for SPI messages (lines
449, 459, 461, 467)
- `spi_check_rx_ranges()` - error reporting (line 561)
- `spi_test_translate()` - error reporting (line 699)
### Technical Justification for Backporting
**1. Real Bug Fix - Sleeping Locks in Atomic Context**
The commit message's claim about "acquiring sleeping locks in atomic
contexts" is accurate and documented. My investigation reveals:
- `%pK` implementation (lib/vsprintf.c:863-904) calls
`has_capability_noaudit()` which invokes `security_capable()` through
the LSM framework
- Under CONFIG_PREEMPT_RT with SELinux and kptr_restrict=1, this
triggers "sleeping function called from invalid context" warnings
- The code explicitly checks for atomic context (lib/vsprintf.c:874) and
returns "pK-error" if in hardirq, softirq, or NMI context
- This is a real correctness issue, not just theoretical
**2. Security Improvement**
Since commit ad67b74d2469 (v4.15-rc2, November 2017), `%p` already
hashes addresses and doesn't leak raw pointers. The commit message
correctly notes that `%pK` through printk() can "still unintentionally
leak raw pointers" depending on kptr_restrict settings, whereas `%p`
consistently hashes addresses.
**3. Part of Tree-Wide Cleanup**
This is part of a coordinated effort to remove `%pK` from printk() paths
across the entire kernel:
- Similar commits already backported: BPF (c2f48cb89b76f), SCSI, WiFi,
remoteproc, DRM, crypto, etc.
- All authored by Thomas Weißschuh with identical commit messages
- Shows this is recognized as a kernel-wide issue requiring systematic
fixing
**4. Low Regression Risk**
- Only changes format specifiers, no logic changes
- Confined to test/debugging driver (spi-loopback-test.c) used for
regression testing, not production code
- Changes 6 format strings across 3 functions
- Output remains functionally equivalent (both show pointer addresses,
just hashed differently)
**5. Stable Tree Criteria Compliance**
✓ Fixes important bug (sleeping locks in atomic context under RT
kernels)
✓ No new features introduced
✓ No architectural changes
✓ Minimal regression risk
✓ Small and contained change (12 lines, 1 file)
✓ Part of security hardening effort
### Evidence of Backport Intent
The commit has already been queued for backport to this stable tree
(commit c51f79c2aadcd with "Signed-off-by: Sasha Levin"), indicating it
has passed stable tree review criteria. It's currently 66 commits ahead
of the v6.17 release tag.
### Conclusion
This commit should definitively be backported to stable trees. It fixes
a real correctness bug affecting RT kernel configurations, improves
security posture, carries minimal risk, and is part of a systematic
kernel-wide cleanup that's already being backported across subsystems.
drivers/spi/spi-loopback-test.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
index 7dd92deffe3fb..e0b131aa29b62 100644
--- a/drivers/spi/spi-loopback-test.c
+++ b/drivers/spi/spi-loopback-test.c
@@ -446,7 +446,7 @@ static void spi_test_dump_message(struct spi_device *spi,
int i;
u8 b;
- dev_info(&spi->dev, " spi_msg@%pK\n", msg);
+ dev_info(&spi->dev, " spi_msg@%p\n", msg);
if (msg->status)
dev_info(&spi->dev, " status: %i\n",
msg->status);
@@ -456,15 +456,15 @@ static void spi_test_dump_message(struct spi_device *spi,
msg->actual_length);
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
- dev_info(&spi->dev, " spi_transfer@%pK\n", xfer);
+ dev_info(&spi->dev, " spi_transfer@%p\n", xfer);
dev_info(&spi->dev, " len: %i\n", xfer->len);
- dev_info(&spi->dev, " tx_buf: %pK\n", xfer->tx_buf);
+ dev_info(&spi->dev, " tx_buf: %p\n", xfer->tx_buf);
if (dump_data && xfer->tx_buf)
spi_test_print_hex_dump(" TX: ",
xfer->tx_buf,
xfer->len);
- dev_info(&spi->dev, " rx_buf: %pK\n", xfer->rx_buf);
+ dev_info(&spi->dev, " rx_buf: %p\n", xfer->rx_buf);
if (dump_data && xfer->rx_buf)
spi_test_print_hex_dump(" RX: ",
xfer->rx_buf,
@@ -558,7 +558,7 @@ static int spi_check_rx_ranges(struct spi_device *spi,
/* if still not found then something has modified too much */
/* we could list the "closest" transfer here... */
dev_err(&spi->dev,
- "loopback strangeness - rx changed outside of allowed range at: %pK\n",
+ "loopback strangeness - rx changed outside of allowed range at: %p\n",
addr);
/* do not return, only set ret,
* so that we list all addresses
@@ -696,7 +696,7 @@ static int spi_test_translate(struct spi_device *spi,
}
dev_err(&spi->dev,
- "PointerRange [%pK:%pK[ not in range [%pK:%pK[ or [%pK:%pK[\n",
+ "PointerRange [%p:%p[ not in range [%p:%p[ or [%p:%p[\n",
*ptr, *ptr + len,
RX(0), RX(SPI_TEST_MAX_SIZE),
TX(0), TX(SPI_TEST_MAX_SIZE));
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.17-6.16] spi: spi-qpic-snand: handle 'use_ecc' parameter of qcom_spi_config_cw_read()
[not found] <20251009155752.773732-1-sashal@kernel.org>
2025-10-09 15:54 ` [PATCH AUTOSEL 6.17-6.1] spi: rpc-if: Add resume support for RZ/G3E Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] spi: loopback-test: Don't use %pK through printk Sasha Levin
@ 2025-10-09 15:55 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-10-09 15:55 UTC (permalink / raw)
To: patches, stable
Cc: Gabor Juhos, Konrad Dybcio, Mark Brown, Sasha Levin, linux-spi
From: Gabor Juhos <j4g8y7@gmail.com>
[ Upstream commit 9c45f95222beecd6a284fd1284d54dd7a772cf59 ]
During raw read, neither the status of the ECC correction nor the erased
state of the codeword gets checked by the qcom_spi_read_cw_raw() function,
so in case of raw access reading the corresponding registers via DMA is
superfluous.
Extend the qcom_spi_config_cw_read() function to evaluate the existing
(but actually unused) 'use_ecc' parameter, and configure reading only
the flash status register when ECC is not used.
With the change, the code gets in line with the corresponding part of
the config_nand_cw_read() function in the qcom_nandc driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20250808-qpic-snand-handle-use_ecc-v1-1-67289fbb5e2f@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Based on my comprehensive analysis of this commit, here is my
assessment:
## Backport Recommendation: **YES**
### Analysis Summary:
**Context & History:**
This commit fixes a code correctness issue in the spi-qpic-snand driver
(added in v6.17, Feb 2025). The `qcom_spi_config_cw_read()` function had
a `use_ecc` parameter since the driver's inception, but it was
completely ignored - the function always read both ECC-related registers
regardless of whether ECC was being used.
**Technical Details:**
The change modifies lines 491-500 in `drivers/spi/spi-qpic-snand.c`:
**Before:** Always reads 3 registers via DMA:
- `NAND_FLASH_STATUS` + `NAND_BUFFER_STATUS` (2 registers)
- `NAND_ERASED_CW_DETECT_STATUS` (1 register)
**After:** Conditionally reads based on `use_ecc`:
- When `use_ecc=true`: Reads all 3 registers (normal ECC-enabled reads)
- When `use_ecc=false`: Reads only `NAND_FLASH_STATUS` (raw reads)
**Why This Matters:**
1. **Code Correctness:** During raw reads (`use_ecc=false`), the
`qcom_spi_check_raw_flash_errors()` function (line 557-571) only
checks the flash status register, never the ECC registers. Reading
those ECC registers via DMA is "superfluous" as the commit message
states.
2. **Established Pattern:** This aligns with the qcom_nandc driver's
`config_nand_cw_read()` function, which has had this exact same
conditional logic since 2018 (commit 5bc36b2bf6e2c8). That commit's
message explained: "For raw reads, there won't be any ECC failure but
the operational failures are possible, so schedule the
NAND_FLASH_STATUS read."
3. **Already Backported:** The commit shows `[ Upstream commit
9c45f95222bee ]` and `Signed-off-by: Sasha Levin
<sashal@kernel.org>`, indicating it was already selected by AUTOSEL.
**Backport Justification:**
✅ **Pros:**
- Small, contained change (11 lines, 1 file)
- Fixes code correctness (parameter was being ignored)
- Removes unnecessary DMA operations (optimization)
- Aligns with well-established pattern from related driver
- Very low regression risk
- Already reviewed and approved by Konrad Dybcio and Mark Brown
- No follow-up fixes or reverts since Aug 8, 2025
❌ **Cons:**
- No explicit `Fixes:` tag
- No `Cc: stable@vger.kernel.org` tag
- Not fixing a critical user-visible bug
- More optimization/cleanup than bug fix
- Limited impact (Qualcomm-specific hardware only)
**Conclusion:**
While this doesn't fix a critical bug, it fixes a code correctness issue
where a function parameter was being completely ignored. The unnecessary
DMA operations during raw reads waste resources and could potentially
cause subtle timing or performance issues. The change is safe, well-
reviewed, and follows the established pattern from the mature qcom_nandc
driver. The fact that AUTOSEL has already selected it confirms its
suitability for stable backporting.
drivers/spi/spi-qpic-snand.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-qpic-snand.c b/drivers/spi/spi-qpic-snand.c
index 780abb967822a..5a247eebde4d9 100644
--- a/drivers/spi/spi-qpic-snand.c
+++ b/drivers/spi/spi-qpic-snand.c
@@ -494,9 +494,14 @@ qcom_spi_config_cw_read(struct qcom_nand_controller *snandc, bool use_ecc, int c
qcom_write_reg_dma(snandc, &snandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
qcom_write_reg_dma(snandc, &snandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
- qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 2, 0);
- qcom_read_reg_dma(snandc, NAND_ERASED_CW_DETECT_STATUS, 1,
- NAND_BAM_NEXT_SGL);
+ if (use_ecc) {
+ qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 2, 0);
+ qcom_read_reg_dma(snandc, NAND_ERASED_CW_DETECT_STATUS, 1,
+ NAND_BAM_NEXT_SGL);
+ } else {
+ qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 1,
+ NAND_BAM_NEXT_SGL);
+ }
}
static int qcom_spi_block_erase(struct qcom_nand_controller *snandc)
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-09 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251009155752.773732-1-sashal@kernel.org>
2025-10-09 15:54 ` [PATCH AUTOSEL 6.17-6.1] spi: rpc-if: Add resume support for RZ/G3E Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-5.4] spi: loopback-test: Don't use %pK through printk Sasha Levin
2025-10-09 15:55 ` [PATCH AUTOSEL 6.17-6.16] spi: spi-qpic-snand: handle 'use_ecc' parameter of qcom_spi_config_cw_read() Sasha Levin
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).