Skip to content

spi: spi-mem: odd byte condition changes in dtr_supports_op

Nikhil M Jain u-boot 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2spi: spi-mem: s/dummy/data buswidth check in dtr_supports_op()drivers/spi/spi-mem.c+5 -10 replies
2/2spi: spi-mem: perform odd len check only while writing datadrivers/spi/spi-mem.c+1 -10 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchNikhil M JainPratyush Yadav
1/2T-b R-b
2/2T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] spi: spi-mem: odd byte condition changes in dtr_supports_op

From: Dhruva Gole <[email protected]>

Currently if one tries to read an odd filesize from a flash in OSPI DTR Mode then the transaction just straightaway returns failure without even attempting a read.

Base on comments from a series a while back:
https://lore.kernel.org/u-boot/[email protected]/

where Pratyush highlights the risk of on writes an extra byte goes to the flash. Hence this series makes sure that we perform this ODD Byte check only if the transactions are "non-read" related ie. only write related.

An alternative solution was suggested here:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

However the code is in linux kernel where it's a full fledge OS running with presumambly enough DDR RAM and we dont really have memory contraints as tight as in a bootloader. The part where the above solution does

...
tmp_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
...

This is something we do not have the luxury of doing at bootloader stage where the RAM is very limited. In TI K3 AM625 SOC's case we have the same code running on R5 SPL Stage where memory is extremely limited and we can't really afford to allocate some at runtime as and when we want.

These patches have been tested on AM625 SK EVM platform and check for odd and even byte reads, updates and also full bootup from OSPI Flash till U-Boot prompt:

...
U-Boot SPL 2023.04-rc2-00040-gbe9fd01af6 (Mar 01 2023 - 11:30:52 +0530) SYSFW ABI: 3.1 (firmware rev 0x0008 '8.5.3--v08.05.03 (Chill Capybar') Trying to boot from SPI
Starting ATF on ARM64 core...

NOTICE:  BL31: v2.7(release):v2.7.0-359-g1309c6c805-dirty
NOTICE:  BL31: Built : 11:48:12, Dec 14 2022

I/TC:
I/TC: OP-TEE version: 3.19.0-15-gd6c5d0037 (gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))) #1 Wed Dec 14 11:52:03 UTC 2022 aarch64 I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: SYSFW ABI: 3.1 (firmware rev 0x0008 '8.5.3--v08.05.03 (Chill Capybar')
I/TC: HUK Initialized
I/TC: Activated SA2UL device
I/TC: Fixing SA2UL firewall owner for GP device
I/TC: Enabled firewalls for SA2UL TRNG device
I/TC: SA2UL TRNG initialized
I/TC: SA2UL Drivers initialized
I/TC: Primary CPU switching to normal world boot

U-Boot SPL 2023.04-rc2-00040-gbe9fd01af6 (Mar 01 2023 - 11:31:30 +0530) SYSFW ABI: 3.1 (firmware rev 0x0008 '8.5.3--v08.05.03 (Chill Capybar') Trying to boot from SPI

U-Boot 2023.04-rc2-00040-gbe9fd01af6 (Mar 01 2023 - 11:31:30 +0530)

SoC:   AM62X SR1.0 GP
Model: Texas Instruments AM625 SK
DRAM:  2 GiB
Core:  50 devices, 20 uclasses, devicetree: separate
MMC:   mmc@fa10000: 0, mmc@fa00000: 1, mmc@fa20000: 2
Loading Environment from nowhere... OK
In:    serial@2800000
Out:   serial@2800000
Err:   serial@2800000
Net:   eth0: ethernet@8000000port@1
Hit any key to stop autoboot:  0

=>
...

Odd length reads:
...
=> sf probe
SF: Detected s28hs512t with page size 256 Bytes, erase size 256 KiB, total 64 MiB => fatload mmc 1 $loadaddr ti.gz
12285 bytes read in 8 ms (1.5 MiB/s)
=> sf update $loadaddr 0x700000 $filesize
device 0 offset 0x700000, size 0x2ffd
12285 bytes written, 0 bytes skipped in 1.478s, speed 8494 B/s
sf read 0x90000000 0x700000 $filesize
device 0 offset 0x700000, size 0x2ffd
SF: 12285 bytes @ 0x700000 Read: OK
=> cmp.b $loadaddr 0x90000000 $filesize

# all bytes were same #
...
Cc Vignesh Raghavendra <[email protected]>
Cc Pratyush Yadav <[email protected]>
Cc Vaishnav Achath <[email protected]>
Cc Nikhil M Jain <[email protected]>

Dhruva Gole (2):
spi: spi-mem: s/dummy/data buswidth check in dtr_supports_op()
spi: spi-mem: perform odd len check only while writing data

 drivers/spi/spi-mem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2