Skip to contentSkip to conversation

memory: renesas-rpc-if: Remove redundant division of dummy

GIT PULL Applied Krzysztof Kozlowski 2 participants 2 messages Feb 7, 2023 – Feb 9, 2023 Memory controller drivers

lore
Share & tools
lore
#0 lore raw

From: Cong Dang <[email protected]>

The dummy cycles value was wrongly calculated if dummy.buswidth > 1, which affects QSPI, OSPI, HyperFlash on various SoCs. We're lucky in Single SPI case since its dummy.buswidth equals to 1, so the result of the division is unchanged

This issue can be reproduced using something like the following commands A. QSPI mode: Mount device with jffs2 format

    jffs2: CLEANMARKER node found at 0x00000004, not first node in block (0x00000000)

B. QSPI mode: Write data to mtd10, where mtd10 is a parition on SPI Flash storage, defined properly in a device tree

[Correct fragment, read from SPI Flash]

  root@v3x:~# echo "hello" > /dev/mtd10
  root@v3x:~# hexdump -C -n100 /dev/mtd10
  00000000  68 65 6c 6c 6f 0a ff ff  ff ff ff ff ff ff ff ff  |hello...........|
  00000010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

[Incorrect read of the same fragment: see the difference at offsets 0-3]

  root@v3x:~# echo "hello" > /dev/mtd10
  root@v3x:~# hexdump -C -n100 /dev/mtd10
  00000000  00 00 00 00 68 65 6c 6c  6f 0a ff ff ff ff ff ff  |....hello.......|
  00000010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

As seen from the result, 4 NULL bytes were inserted before the test data. Wrong calculation in rpcif_prepare() led to miss of some dummy cycle. A division by bus width is redundant because it had been performed already in spi-rpc-if.c::rpcif_spi_mem_prepare()

Fix this by removing the redundant division.

---

One patch for memory-controllers drivers on top of previous pull.

 drivers/memory/renesas-rpc-if.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/memory/renesas-rpc-if.c +1 -2
index 62b06041d758..025bb628aaf3 100644
@@ -435,8 +435,7 @@ void rpcif_prepare(struct device *dev, const struct rpcif_op *op, u64 *offs,
 
 	if (op->dummy.buswidth) {
 		rpc->enable |= RPCIF_SMENR_DME;
-		rpc->dummy = RPCIF_SMDMCR_DMCYC(op->dummy.ncycles /
-						op->dummy.buswidth);
+		rpc->dummy = RPCIF_SMDMCR_DMCYC(op->dummy.ncycles);
 	}
 
 	if (op->option.buswidth) {
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to soc/soc.git (for-next) by Arnd Bergmann <[email protected]>:

Hello:

This patch was applied to soc/soc.git (for-next)
by Arnd Bergmann <[email protected]>:

Quoted 8 lines · On Tue, 7 Feb 2023 18:30:51 +0100 you wrote:

From: Cong Dang <[email protected]>

The dummy cycles value was wrongly calculated if dummy.buswidth > 1, which affects QSPI, OSPI, HyperFlash on various SoCs. We're lucky in Single SPI case since its dummy.buswidth equals to 1, so the result of the division is unchanged

[...]

Here is the summary with links:
- [PULL] memory: renesas-rpc-if: Remove redundant division of dummy

    https://git.kernel.org/soc/soc/c/637581ce6040

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html