* [PATCH v2] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties
@ 2025-08-05 16:05 Gabor Juhos
2025-08-07 11:30 ` Konrad Dybcio
2025-08-07 19:09 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Gabor Juhos @ 2025-08-05 16:05 UTC (permalink / raw)
To: Mark Brown, Konrad Dybcio, Varadarajan Narayanan,
Sricharan Ramabadhran, Md Sadre Alam
Cc: linux-spi, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The OOB layout used by the driver has two distinct regions which contains
hardware specific ECC data, yet the qcom_spi_ooblayout_ecc() function sets
the same offset and length values for both regions which is clearly wrong.
Change the code to calculate the correct values for both regions.
For reference, the following table shows the computed offset and length
values for various OOB size/ECC strength configurations:
+-----------------+-----------------+
|before the change| after the change|
+-------+----------+--------+--------+--------+--------+--------+
| OOB | ECC | region | region | region | region | region |
| size | strength | index | offset | length | offset | length |
+-------+----------+--------+--------+--------+--------+--------+
| 128 | 8 | 0 | 113 | 15 | 0 | 49 |
| | | 1 | 113 | 15 | 65 | 63 |
+-------+----------+--------+--------+--------+--------+--------+
| 128 | 4 | 0 | 117 | 11 | 0 | 37 |
| | | 1 | 117 | 11 | 53 | 75 |
+-------+----------+--------+--------+--------+--------+--------+
| 64 | 4 | 0 | 53 | 11 | 0 | 37 |
| | | 1 | 53 | 11 | 53 | 11 |
+-------+----------+--------+--------+--------+--------+--------+
Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface")
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- use switch statement to handle section numbers
- reject negative section numbers as out-of-range
- Link to v1: https://lore.kernel.org/r/20250731-qpic-snand-oob-ecc-fix-v1-1-29ba1c6f94e5@gmail.com
---
drivers/spi/spi-qpic-snand.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-qpic-snand.c b/drivers/spi/spi-qpic-snand.c
index 0cfa0d960fd3c245c2bbf4f5e02d0fc0b13e7696..53205d5037dc4fd58a69063532b20ab10c652694 100644
--- a/drivers/spi/spi-qpic-snand.c
+++ b/drivers/spi/spi-qpic-snand.c
@@ -210,13 +210,21 @@ static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section,
struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand);
struct qpic_ecc *qecc = snandc->qspi->ecc;
- if (section > 1)
- return -ERANGE;
-
- oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes;
- oobregion->offset = mtd->oobsize - oobregion->length;
+ switch (section) {
+ case 0:
+ oobregion->offset = 0;
+ oobregion->length = qecc->bytes * (qecc->steps - 1) +
+ qecc->bbm_size;
+ return 0;
+ case 1:
+ oobregion->offset = qecc->bytes * (qecc->steps - 1) +
+ qecc->bbm_size +
+ qecc->steps * 4;
+ oobregion->length = mtd->oobsize - oobregion->offset;
+ return 0;
+ }
- return 0;
+ return -ERANGE;
}
static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section,
---
base-commit: 926406a85ad895fbe6ee4577cdbc4f55245a0742
change-id: 20250731-qpic-snand-oob-ecc-fix-8d3d80cc8680
Best regards,
--
Gabor Juhos <j4g8y7@gmail.com>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties
2025-08-05 16:05 [PATCH v2] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties Gabor Juhos
@ 2025-08-07 11:30 ` Konrad Dybcio
2025-08-07 19:09 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2025-08-07 11:30 UTC (permalink / raw)
To: Gabor Juhos, Mark Brown, Varadarajan Narayanan,
Sricharan Ramabadhran, Md Sadre Alam
Cc: linux-spi, linux-mtd, linux-arm-msm, linux-kernel
On 8/5/25 6:05 PM, Gabor Juhos wrote:
> The OOB layout used by the driver has two distinct regions which contains
> hardware specific ECC data, yet the qcom_spi_ooblayout_ecc() function sets
> the same offset and length values for both regions which is clearly wrong.
>
> Change the code to calculate the correct values for both regions.
>
> For reference, the following table shows the computed offset and length
> values for various OOB size/ECC strength configurations:
>
> +-----------------+-----------------+
> |before the change| after the change|
> +-------+----------+--------+--------+--------+--------+--------+
> | OOB | ECC | region | region | region | region | region |
> | size | strength | index | offset | length | offset | length |
> +-------+----------+--------+--------+--------+--------+--------+
> | 128 | 8 | 0 | 113 | 15 | 0 | 49 |
> | | | 1 | 113 | 15 | 65 | 63 |
> +-------+----------+--------+--------+--------+--------+--------+
> | 128 | 4 | 0 | 117 | 11 | 0 | 37 |
> | | | 1 | 117 | 11 | 53 | 75 |
> +-------+----------+--------+--------+--------+--------+--------+
> | 64 | 4 | 0 | 53 | 11 | 0 | 37 |
> | | | 1 | 53 | 11 | 53 | 11 |
> +-------+----------+--------+--------+--------+--------+--------+
>
> Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface")
> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties
2025-08-05 16:05 [PATCH v2] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties Gabor Juhos
2025-08-07 11:30 ` Konrad Dybcio
@ 2025-08-07 19:09 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-08-07 19:09 UTC (permalink / raw)
To: Konrad Dybcio, Varadarajan Narayanan, Sricharan Ramabadhran,
Md Sadre Alam, Gabor Juhos
Cc: linux-spi, linux-mtd, linux-arm-msm, linux-kernel
On Tue, 05 Aug 2025 18:05:42 +0200, Gabor Juhos wrote:
> The OOB layout used by the driver has two distinct regions which contains
> hardware specific ECC data, yet the qcom_spi_ooblayout_ecc() function sets
> the same offset and length values for both regions which is clearly wrong.
>
> Change the code to calculate the correct values for both regions.
>
> For reference, the following table shows the computed offset and length
> values for various OOB size/ECC strength configurations:
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties
commit: 13d0fe84a214658254a7412b2b46ec1507dc51f0
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-07 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05 16:05 [PATCH v2] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties Gabor Juhos
2025-08-07 11:30 ` Konrad Dybcio
2025-08-07 19:09 ` Mark Brown
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).