linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Ray Liu <ray.liu@airoha.com>, Mark Brown <broonie@kernel.org>,
	Andy Shevchenko <andy@kernel.org>,
	linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Andreas Gnau <andreas.gnau@iopsys.eu>
Subject: Re: [PATCH RESEND v5 06/13] spi: airoha: fix reading/writing of flashes with more than one plane per lun
Date: Wed, 1 Oct 2025 13:34:11 +0200	[thread overview]
Message-ID: <f5e10c75-9263-416d-a3de-32af4bb7c2dc@collabora.com> (raw)
In-Reply-To: <20250930022658.1485767-7-mikhail.kshevetskiy@iopsys.eu>

Il 30/09/25 04:26, Mikhail Kshevetskiy ha scritto:
> Attaching UBI on the flash with more than one plane per lun will lead to
> the following error:
> 
> [    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
> 
> Non dirmap reading works good. Looking to spi_mem_no_dirmap_read() code we'll see:
> 
> 	static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc,
> 					      u64 offs, size_t len, void *buf)
> 	{
> 		struct spi_mem_op op = desc->info.op_tmpl;
> 		int ret;
> 
> // --- see here ---
> 		op.addr.val = desc->info.offset + offs;
> //-----------------
> 		op.data.buf.in = buf;
> 		op.data.nbytes = len;
> 		ret = spi_mem_adjust_op_size(desc->mem, &op);
> 		if (ret)
> 		return ret;
> 
> 		ret = spi_mem_exec_op(desc->mem, &op);
> 		if (ret)
> 			return ret;
> 
> 		return op.data.nbytes;
> 	}
> 
> The similar happens for spi_mem_no_dirmap_write(). Thus the address
> passed to the flash should take in the account the value of
> desc->info.offset.
> 
> This patch fix dirmap reading/writing of flashes with more than one
> plane per lun.
> 
> Fixes: a403997c12019 ("spi: airoha: add SPI-NAND Flash controller driver")
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



  reply	other threads:[~2025-10-01 11:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30  2:26 [PATCH RESEND v5 00/13] spi: airoha: driver fixes & improvements Mikhail Kshevetskiy
2025-09-30  2:26 ` [PATCH RESEND v5 01/13] spi: airoha: return an error for continuous mode dirmap creation cases Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 02/13] spi: airoha: remove unnecessary restriction length Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 03/13] spi: airoha: add support of dual/quad wires spi modes to exec_op() handler Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 04/13] spi: airoha: remove unnecessary switch to non-dma mode Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 05/13] spi: airoha: switch back to non-dma mode in the case of error Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 06/13] spi: airoha: fix reading/writing of flashes with more than one plane per lun Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno [this message]
2025-09-30  2:26 ` [PATCH RESEND v5 07/13] spi: airoha: unify dirmap read/write code Mikhail Kshevetskiy
2025-09-30  2:26 ` [PATCH RESEND v5 08/13] spi: airoha: support of dualio/quadio flash reading commands Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 09/13] spi: airoha: avoid setting of page/oob sizes in REG_SPI_NFI_PAGEFMT Mikhail Kshevetskiy
2025-09-30  2:26 ` [PATCH RESEND v5 10/13] spi: airoha: reduce the number of modification of REG_SPI_NFI_CNFG and REG_SPI_NFI_SECCUS_SIZE registers Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 11/13] spi: airoha: set custom sector size equal to flash page size Mikhail Kshevetskiy
2025-10-01 11:34   ` AngeloGioacchino Del Regno
2025-09-30  2:26 ` [PATCH RESEND v5 12/13] spi: airoha: avoid reading flash page settings from SNFI registers during driver startup Mikhail Kshevetskiy
2025-09-30  2:26 ` [PATCH RESEND v5 13/13] spi: airoha: buffer must be 0xff-ed before writing Mikhail Kshevetskiy
2025-10-01 11:30   ` AngeloGioacchino Del Regno
2025-10-01 22:13     ` Mikhail Kshevetskiy
  -- strict thread matches above, loose matches on Subject: below --
2025-09-17 21:58 [PATCH RESEND v5 00/13] spi: airoha: driver fixes & improvements Mikhail Kshevetskiy
2025-09-17 21:58 ` [PATCH RESEND v5 06/13] spi: airoha: fix reading/writing of flashes with more than one plane per lun Mikhail Kshevetskiy
2025-09-04 14:23 [PATCH RESEND v5 00/13] spi: airoha: driver fixes & improvements Mikhail Kshevetskiy
2025-09-04 14:23 ` [PATCH RESEND v5 06/13] spi: airoha: fix reading/writing of flashes with more than one plane per lun Mikhail Kshevetskiy

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=f5e10c75-9263-416d-a3de-32af4bb7c2dc@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=andreas.gnau@iopsys.eu \
    --cc=andy@kernel.org \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=ray.liu@airoha.com \
    /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;
as well as URLs for NNTP newsgroup(s).