[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9fd1c355-d206-4a2a-bfa5-1e1f15729a1e@iopsys.eu>
Date: Fri, 22 Aug 2025 17:36:45 +0300
From: Mikhail Kshevetskiy <mikhail.kshevetskiy@...sys.eu>
To: Lorenzo Bianconi <lorenzo@...nel.org>
Cc: Ray Liu <ray.liu@...oha.com>, Mark Brown <broonie@...nel.org>,
linux-arm-kernel@...ts.infradead.org, linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org, Frieder Schrempf <frieder.schrempf@...tron.de>
Subject: Re: [PATCH v3 00/14] spi: airoha: driver fixes & improvements
patch 7 (spi: airoha: fix reading/writing of flashes with more than one
plane per lun) is absolutely necessary for my flash. Without a patch
[ 2.980989] spi-nand spi0.0: Micron SPI NAND was found.
[ 2.986309] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size:
2048, OOB size: 128
[ 2.994978] 2 fixed-partitions partitions found on MTD device spi0.0
[ 3.001350] Creating 2 MTD partitions on "spi0.0":
[ 3.006159] 0x000000000000-0x000000020000 : "bl2"
[ 3.011663] 0x000000020000-0x000010000000 : "ubi"
...
[ 6.391748] ubi0: attaching mtd1
[ 6.412545] ubi0 error: ubi_attach: PEB 0 contains corrupted VID
header, and the data does not contain all 0xFF
[ 6.422677] ubi0 error: ubi_attach: this may be a non-UBI PEB or a
severe VID header corruption which requires manual inspection
[ 6.434249] Volume identifier header dump:
[ 6.438349] magic 55424923
[ 6.441482] version 1
[ 6.444007] vol_type 0
[ 6.446539] copy_flag 0
[ 6.449068] compat 0
[ 6.451594] vol_id 0
[ 6.454120] lnum 1
[ 6.456651] data_size 4096
[ 6.459442] used_ebs 1061644134
[ 6.462748] data_pad 0
[ 6.465274] sqnum 0
[ 6.467805] hdr_crc 61169820
[ 6.470943] Volume identifier header hexdump:
[ 6.475308] hexdump of PEB 0 offset 4096, length 126976
[ 6.507391] ubi0 warning: ubi_attach: valid VID header but corrupted
EC header at PEB 4
[ 6.515415] ubi0 error: ubi_compare_lebs: unsupported on-flash UBI format
[ 6.522222] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1,
error -22
[ 6.529294] UBI error: cannot attach mtd1
[ 6.533450] clk: Disabling unused clocks
[ 6.537583] Waiting for root device /dev/ubiblock0_5...
With a patch
[ 2.980791] spi-nand spi0.0: Micron SPI NAND was found.
[ 2.986049] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size:
2048, OOB size: 128
[ 2.994452] 2 fixed-partitions partitions found on MTD device spi0.0
[ 3.000820] Creating 2 MTD partitions on "spi0.0":
[ 3.005614] 0x000000000000-0x000000020000 : "bl2"
[ 3.011209] 0x000000020000-0x000010000000 : "ubi"
...
[ 6.403811] ubi0: attaching mtd1
[ 7.474901] ubi0: scanning is finished
[ 7.487134] ubi0: attached mtd1 (name "ubi", size 255 MiB)
[ 7.492649] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976
bytes
[ 7.499538] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 7.506326] ubi0: VID header offset: 2048 (aligned 2048), data
offset: 4096
[ 7.513281] ubi0: good PEBs: 2047, bad PEBs: 0, corrupted PEBs: 0
[ 7.519379] ubi0: user volume: 9, internal volumes: 1, max. volumes
count: 128
[ 7.526603] ubi0: max/mean erase counter: 2/1, WL threshold: 4096,
image sequence number: 1061644134
[ 7.535729] ubi0: available PEBs: 0, total reserved PEBs: 2047, PEBs
reserved for bad PEB handling: 40
[ 7.545041] ubi0: background thread "ubi_bgt0d" started, PID 619
[ 7.545882] block ubiblock0_5: created from ubi0:5(rootfs)
[ 7.556540] ubiblock: device ubiblock0_5 (rootfs) set to be root
filesystem
[ 7.563598] clk: Disabling unused clocks
[ 7.573181] VFS: Mounted root (squashfs filesystem) readonly on
device 254:0.
On 22.08.2025 16:14, Lorenzo Bianconi wrote:
>> On 22.08.2025 09:46, Lorenzo Bianconi wrote:
>>>> On 21.08.2025 14:34, Lorenzo Bianconi wrote:
>>>>>> On 21.08.2025 09:58, Lorenzo Bianconi wrote:
>>>>>>>> This patch series greatly improve airoha snfi driver and fix a
>>>>>>>> number of serious bug.
>>>>>>>>
>>>>>>>> Fixed bugs:
>>>>>>>> * Fix reading/writing of flashes with more than one plane per lun
>>>>>>>> * Fix inability to read/write oob area
>>>>>>>> * Fill the buffer with 0xff before writing
>>>>>>>> * Fix reading of flashes supporting continuous reading mode
>>>>>>>> * Fix error paths
>>>>>>>>
>>>>>>>> Improvements:
>>>>>>>> * Add support of dual/quad wires spi modes in exec_op().
>>>>>>>> * Support of dualio/quadio flash reading commands
>>>>>>>> * Remove dirty hack that reads flash page settings from SNFI registers
>>>>>>>> during driver startup
>>>>>>>>
>>>>>>>> Unfortunately I am unable to test the driver with linux at the moment,
>>>>>>>> so only the following testing was done:
>>>>>>> It seems to me this is quite an important rework of the driver. I would prefer
>>>>>>> to have some test results for this series. Are you able to run mtd_test kernel
>>>>>>> module for testing?
>>>>>> I'll try to build latest openwrt with this patches and mtd_test kernel
>>>>>> module and try it on one of our boards.
>>>>> what board are you using for testing? If it is based on Airoha-7581 you could
>>>>> use the following repo for testing.
>>>>>
>>>>> https://github.com/Ansuel/openwrt/tree/openwrt-24.10-airoha-an7581-stable
>>>>>
>>>>> Regards,
>>>>> Lorenzo
>>>> What tests do you suggest to run?
>>> IIRC I run all of them. Can you please report even if there are some
>>> improvements (or penalties) in read/write speed
>> Do you mean to run it twice? with patches and without?
> I mean I would suggest to check if there are any difference in read/write
> speed (so yes, you need a baseline).
>
> Regards,
> Lorenzo
>
>>>> I have a single flash I boot from. It have only 2 mtd partitions:
>>>>
>>>> [ 2.980849] spi-nand spi0.0: Micron SPI NAND was found.
>>>> [ 2.986102] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size:
>>>> 2048, OOB size: 128
>>>> [ 2.994493] 2 fixed-partitions partitions found on MTD device spi0.0
>>>> [ 3.000856] Creating 2 MTD partitions on "spi0.0":
>>>> [ 3.005651] 0x000000000000-0x000000020000 : "bl2"
>>>> [ 3.011247] 0x000000020000-0x000010000000 : "ubi"
>>>>
>>>> Most of tests are destructive. So If I use "bl2" or "ubi" partition for
>>>> test, next time I will be unable to boot :-(
>>> yes, I flashed the device after carrying out the test.
>>>
>>> Regards,
>>> Lorenzo
>>>
>>>> Do you suggest to patch u-boot & linux to have more mtd partitions?
>>>>
>>>> This is the results of the only read-only test I found.
>>>>
>>>> root@...nWrt:/lib/modules/6.6.79# insmod mtd_test.ko
>>>> root@...nWrt:/lib/modules/6.6.79# insmod mtd_readtest.ko dev=1
>>>> [ 159.121706]
>>>> [ 159.123220] =================================================
>>>> [ 159.129053] mtd_readtest: MTD device: 1
>>>> [ 159.132898] mtd_readtest: MTD device size 268304384, eraseblock size
>>>> 131072, page size 2048, count of eraseblocks 2047, pages per eraseblock
>>>> 64, OOB size 128
>>>> [ 159.147008] mtd_test: scanning for bad eraseblocks
>>>> [ 159.152141] mtd_test: scanned 2047 eraseblocks, 0 are bad
>>>> [ 159.157549] mtd_readtest: testing page read
>>>>
>>>> Mikhail
>>>>
>>>>>> Actually patches can be divided on to parts:
>>>>>> * fixes of current driver (patches 1-10)
>>>>>> * change of behavior to avoid reading flash page settings from SNFI
>>>>>> registers during driver startup (patches 11-14)
>>>>>>
>>>>>> The changes are based on the code we are using for more than 3 years. I
>>>>>> adapt it to latest linux/u-boot code.
>>>>>>
>>>>>> Up to now the only known issue appears on en7523 chips only. Here a
>>>>>> corresponding patch description (not added to this series)
>>>>>> ====================================================== spi: airoha:
>>>>>> en7523: workaround flash damaging if UART_TXD was short to GND We found
>>>>>> that some serial console may pull TX line to GROUND during board boot
>>>>>> time. Airoha uses TX line as one of it's BOOT pins. This will lead to
>>>>>> booting in RESERVED boot mode. It was found that some flashes operates
>>>>>> incorrectly in RESERVED mode. Micron and Skyhigh flashes are definitely
>>>>>> affected by the issue, Winbond flashes are NOT affected. Details:
>>>>>> -------- DMA reading of odd pages on affected flashes operates
>>>>>> incorrectly. Page reading offset (start of the page) on hardware level
>>>>>> is replaced by 0x10. Thus results in incorrect data reading. Usage of
>>>>>> UBI make things even worse. Any attempt to access UBI leads to ubi
>>>>>> damaging. As result OS loading becomes impossible. Non-DMA reading is
>>>>>> OK. =======================================================
>>>>>>
>>>>>> Regards,
>>>>>> Mikhail
>>>>>>
>>>>>>
>>>>>>> Regards,
>>>>>>> Lorenzo
>>>>>>>
>>>>>>>> * Driver compiles without error.
>>>>>>>> * All changes were tested with corresponding u-boot driver. U-Boot
>>>>>>>> SpiNAND driver was modified as well to match linux-6.17-rc2 with
>>>>>>>> additional fixes for continuous mode.
>>>>>>>>
>>>>>>>> Changes v2:
>>>>>>>> * minor fix
>>>>>>>> * add comments to code
>>>>>>>>
>>>>>>>> Changes v3:
>>>>>>>> * add patch to prevent continuous reading
>>>>>>>>
>>>>>>>> Mikhail Kshevetskiy (14):
>>>>>>>> spi: airoha: return an error for continuous mode dirmap creation cases
>>>>>>>> spi: airoha: remove unnecessary restriction length
>>>>>>>> spi: airoha: add support of dual/quad wires spi modes
>>>>>>>> spi: airoha: remove unnecessary switch to non-dma mode
>>>>>>>> spi: airoha: unify dirmap read/write code
>>>>>>>> spi: airoha: switch back to non-dma mode in the case of error
>>>>>>>> spi: airoha: fix reading/writing of flashes with more than one plane
>>>>>>>> per lun
>>>>>>>> spi: airoha: support of dualio/quadio flash reading commands
>>>>>>>> spi: airoha: allow reading/writing of oob area
>>>>>>>> spi: airoha: buffer must be 0xff-ed before writing
>>>>>>>> spi: airoha: avoid setting of page/oob sizes in REG_SPI_NFI_PAGEFMT
>>>>>>>> spi: airoha: reduce the number of modification of REG_SPI_NFI_CNFG and
>>>>>>>> REG_SPI_NFI_SECCUS_SIZE registers
>>>>>>>> spi: airoha: set custom sector size equal to flash page size
>>>>>>>> spi: airoha: avoid reading flash page settings from SNFI registers
>>>>>>>> during driver startup
>>>>>>>>
>>>>>>>> drivers/spi/spi-airoha-snfi.c | 508 +++++++++++++++++-----------------
>>>>>>>> 1 file changed, 260 insertions(+), 248 deletions(-)
>>>>>>>>
>>>>>>>> --
>>>>>>>> 2.50.1
>>>>>>>>
Powered by blists - more mailing lists