Skip to content

Commit 13d0fe8

Browse files
juhosgbroonie
authored andcommitted
spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties
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: 7304d19 ("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> Link: https://patch.msgid.link/20250805-qpic-snand-oob-ecc-fix-v2-1-e6f811c70d6f@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent af357a6 commit 13d0fe8

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

drivers/spi/spi-qpic-snand.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,21 @@ static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section,
210210
struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand);
211211
struct qpic_ecc *qecc = snandc->qspi->ecc;
212212

213-
if (section > 1)
214-
return -ERANGE;
215-
216-
oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes;
217-
oobregion->offset = mtd->oobsize - oobregion->length;
213+
switch (section) {
214+
case 0:
215+
oobregion->offset = 0;
216+
oobregion->length = qecc->bytes * (qecc->steps - 1) +
217+
qecc->bbm_size;
218+
return 0;
219+
case 1:
220+
oobregion->offset = qecc->bytes * (qecc->steps - 1) +
221+
qecc->bbm_size +
222+
qecc->steps * 4;
223+
oobregion->length = mtd->oobsize - oobregion->offset;
224+
return 0;
225+
}
218226

219-
return 0;
227+
return -ERANGE;
220228
}
221229

222230
static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section,

0 commit comments

Comments
 (0)