Skip to content

Commit 320475f

Browse files
committed
Merge tag 'mtd/fixes-for-6.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
Pull mtd fixes from Miquel Raynal: "SPI NAND fix: - Wrong OOB layout for Winbond W25N01JW SPI NAND devices Raw NAND fixes: - Atmel raw NAND controller timings - Buffer handling in stm32_fmc2 driver - Error handling in Nuvoton's driver MTD devices fixes: - Wrong depends-on dependencies on the Intel DRM driver * tag 'mtd/fixes-for-6.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: mtd: spinand: winbond: Fix oob_layout for W25N01JW mtd: nand: raw: atmel: Respect tAR, tCLR in read setup timing mtd: rawnand: stm32_fmc2: fix ECC overwrite mtd: rawnand: stm32_fmc2: avoid overlapping mappings on ECC buffer mtd: rawnand: nuvoton: Fix an error handling path in ma35_nand_chips_init() mtd: MTD_INTEL_DG should depend on DRM_I915 or DRM_XE
2 parents db87bd2 + 4550d33 commit 320475f

5 files changed

Lines changed: 77 additions & 30 deletions

File tree

drivers/mtd/devices/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ config MTD_POWERNV_FLASH
185185

186186
config MTD_INTEL_DG
187187
tristate "Intel Discrete Graphics non-volatile memory driver"
188-
depends on AUXILIARY_BUS
189-
depends on MTD
188+
depends on AUXILIARY_BUS && MTD
189+
depends on DRM_I915!=n || DRM_XE!=n || COMPILE_TEST
190190
help
191191
This provides an MTD device to access Intel Discrete Graphics
192192
non-volatile memory.

drivers/mtd/nand/raw/atmel/nand-controller.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,14 +1377,24 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
13771377
if (ret)
13781378
return ret;
13791379

1380+
/*
1381+
* Read setup timing depends on the operation done on the NAND:
1382+
*
1383+
* NRD_SETUP = max(tAR, tCLR)
1384+
*/
1385+
timeps = max(conf->timings.sdr.tAR_min, conf->timings.sdr.tCLR_min);
1386+
ncycles = DIV_ROUND_UP(timeps, mckperiodps);
1387+
totalcycles += ncycles;
1388+
ret = atmel_smc_cs_conf_set_setup(smcconf, ATMEL_SMC_NRD_SHIFT, ncycles);
1389+
if (ret)
1390+
return ret;
1391+
13801392
/*
13811393
* The read cycle timing is directly matching tRC, but is also
13821394
* dependent on the setup and hold timings we calculated earlier,
13831395
* which gives:
13841396
*
1385-
* NRD_CYCLE = max(tRC, NRD_PULSE + NRD_HOLD)
1386-
*
1387-
* NRD_SETUP is always 0.
1397+
* NRD_CYCLE = max(tRC, NRD_SETUP + NRD_PULSE + NRD_HOLD)
13881398
*/
13891399
ncycles = DIV_ROUND_UP(conf->timings.sdr.tRC_min, mckperiodps);
13901400
ncycles = max(totalcycles, ncycles);

drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,10 @@ static void ma35_chips_cleanup(struct ma35_nand_info *nand)
935935

936936
static int ma35_nand_chips_init(struct device *dev, struct ma35_nand_info *nand)
937937
{
938-
struct device_node *np = dev->of_node, *nand_np;
938+
struct device_node *np = dev->of_node;
939939
int ret;
940940

941-
for_each_child_of_node(np, nand_np) {
941+
for_each_child_of_node_scoped(np, nand_np) {
942942
ret = ma35_nand_chip_init(dev, nand, nand_np);
943943
if (ret) {
944944
ma35_chips_cleanup(nand);

drivers/mtd/nand/raw/stm32_fmc2_nand.c

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ struct stm32_fmc2_nfc {
272272
struct sg_table dma_data_sg;
273273
struct sg_table dma_ecc_sg;
274274
u8 *ecc_buf;
275+
dma_addr_t dma_ecc_addr;
275276
int dma_ecc_len;
276277
u32 tx_dma_max_burst;
277278
u32 rx_dma_max_burst;
@@ -902,17 +903,10 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
902903

903904
if (!write_data && !raw) {
904905
/* Configure DMA ECC status */
905-
p = nfc->ecc_buf;
906906
for_each_sg(nfc->dma_ecc_sg.sgl, sg, eccsteps, s) {
907-
sg_set_buf(sg, p, nfc->dma_ecc_len);
908-
p += nfc->dma_ecc_len;
909-
}
910-
911-
ret = dma_map_sg(nfc->dev, nfc->dma_ecc_sg.sgl,
912-
eccsteps, dma_data_dir);
913-
if (!ret) {
914-
ret = -EIO;
915-
goto err_unmap_data;
907+
sg_dma_address(sg) = nfc->dma_ecc_addr +
908+
s * nfc->dma_ecc_len;
909+
sg_dma_len(sg) = nfc->dma_ecc_len;
916910
}
917911

918912
desc_ecc = dmaengine_prep_slave_sg(nfc->dma_ecc_ch,
@@ -921,15 +915,15 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
921915
DMA_PREP_INTERRUPT);
922916
if (!desc_ecc) {
923917
ret = -ENOMEM;
924-
goto err_unmap_ecc;
918+
goto err_unmap_data;
925919
}
926920

927921
reinit_completion(&nfc->dma_ecc_complete);
928922
desc_ecc->callback = stm32_fmc2_nfc_dma_callback;
929923
desc_ecc->callback_param = &nfc->dma_ecc_complete;
930924
ret = dma_submit_error(dmaengine_submit(desc_ecc));
931925
if (ret)
932-
goto err_unmap_ecc;
926+
goto err_unmap_data;
933927

934928
dma_async_issue_pending(nfc->dma_ecc_ch);
935929
}
@@ -949,7 +943,7 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
949943
if (!write_data && !raw)
950944
dmaengine_terminate_all(nfc->dma_ecc_ch);
951945
ret = -ETIMEDOUT;
952-
goto err_unmap_ecc;
946+
goto err_unmap_data;
953947
}
954948

955949
/* Wait DMA data transfer completion */
@@ -969,11 +963,6 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
969963
}
970964
}
971965

972-
err_unmap_ecc:
973-
if (!write_data && !raw)
974-
dma_unmap_sg(nfc->dev, nfc->dma_ecc_sg.sgl,
975-
eccsteps, dma_data_dir);
976-
977966
err_unmap_data:
978967
dma_unmap_sg(nfc->dev, nfc->dma_data_sg.sgl, eccsteps, dma_data_dir);
979968

@@ -996,9 +985,21 @@ static int stm32_fmc2_nfc_seq_write(struct nand_chip *chip, const u8 *buf,
996985

997986
/* Write oob */
998987
if (oob_required) {
999-
ret = nand_change_write_column_op(chip, mtd->writesize,
1000-
chip->oob_poi, mtd->oobsize,
1001-
false);
988+
unsigned int offset_in_page = mtd->writesize;
989+
const void *buf = chip->oob_poi;
990+
unsigned int len = mtd->oobsize;
991+
992+
if (!raw) {
993+
struct mtd_oob_region oob_free;
994+
995+
mtd_ooblayout_free(mtd, 0, &oob_free);
996+
offset_in_page += oob_free.offset;
997+
buf += oob_free.offset;
998+
len = oob_free.length;
999+
}
1000+
1001+
ret = nand_change_write_column_op(chip, offset_in_page,
1002+
buf, len, false);
10021003
if (ret)
10031004
return ret;
10041005
}
@@ -1610,7 +1611,8 @@ static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc)
16101611
return ret;
16111612

16121613
/* Allocate a buffer to store ECC status registers */
1613-
nfc->ecc_buf = devm_kzalloc(nfc->dev, FMC2_MAX_ECC_BUF_LEN, GFP_KERNEL);
1614+
nfc->ecc_buf = dmam_alloc_coherent(nfc->dev, FMC2_MAX_ECC_BUF_LEN,
1615+
&nfc->dma_ecc_addr, GFP_KERNEL);
16141616
if (!nfc->ecc_buf)
16151617
return -ENOMEM;
16161618

drivers/mtd/nand/spi/winbond.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,36 @@ static const struct mtd_ooblayout_ops w25n02kv_ooblayout = {
176176
.free = w25n02kv_ooblayout_free,
177177
};
178178

179+
static int w25n01jw_ooblayout_ecc(struct mtd_info *mtd, int section,
180+
struct mtd_oob_region *region)
181+
{
182+
if (section > 3)
183+
return -ERANGE;
184+
185+
region->offset = (16 * section) + 12;
186+
region->length = 4;
187+
188+
return 0;
189+
}
190+
191+
static int w25n01jw_ooblayout_free(struct mtd_info *mtd, int section,
192+
struct mtd_oob_region *region)
193+
{
194+
if (section > 3)
195+
return -ERANGE;
196+
197+
region->offset = (16 * section);
198+
region->length = 12;
199+
200+
/* Extract BBM */
201+
if (!section) {
202+
region->offset += 2;
203+
region->length -= 2;
204+
}
205+
206+
return 0;
207+
}
208+
179209
static int w35n01jw_ooblayout_ecc(struct mtd_info *mtd, int section,
180210
struct mtd_oob_region *region)
181211
{
@@ -206,6 +236,11 @@ static int w35n01jw_ooblayout_free(struct mtd_info *mtd, int section,
206236
return 0;
207237
}
208238

239+
static const struct mtd_ooblayout_ops w25n01jw_ooblayout = {
240+
.ecc = w25n01jw_ooblayout_ecc,
241+
.free = w25n01jw_ooblayout_free,
242+
};
243+
209244
static const struct mtd_ooblayout_ops w35n01jw_ooblayout = {
210245
.ecc = w35n01jw_ooblayout_ecc,
211246
.free = w35n01jw_ooblayout_free,
@@ -394,7 +429,7 @@ static const struct spinand_info winbond_spinand_table[] = {
394429
&write_cache_variants,
395430
&update_cache_variants),
396431
0,
397-
SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL),
432+
SPINAND_ECCINFO(&w25n01jw_ooblayout, NULL),
398433
SPINAND_CONFIGURE_CHIP(w25n0xjw_hs_cfg)),
399434
SPINAND_INFO("W25N01KV", /* 3.3V */
400435
SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xae, 0x21),

0 commit comments

Comments
 (0)