Skip to content

Commit 4b92e7f

Browse files
committed
Merge tag 'mtd/fixes-for-4.19-rc5' of git://git.infradead.org/linux-mtd
Boris writes: "- Fixes a bug in the ->read/write_reg() implementation of the m25p80 driver - Make sure of_node_get/put() calls are balanced in the partition parsing code - Fix a race in the denali NAND controller driver - Fix false positive WARN_ON() in the marvell NAND controller driver" * tag 'mtd/fixes-for-4.19-rc5' of git://git.infradead.org/linux-mtd: mtd: devices: m25p80: Make sure the buffer passed in op is DMA-able mtd: partitions: fix unbalanced of_node_get/put() mtd: rawnand: denali: fix a race condition when DMA is kicked mtd: rawnand: marvell: prevent harmless warnings
2 parents d829208 + 4a3e85f commit 4b92e7f

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

drivers/mtd/devices/m25p80.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,23 @@ static int m25p80_read_reg(struct spi_nor *nor, u8 code, u8 *val, int len)
3939
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(code, 1),
4040
SPI_MEM_OP_NO_ADDR,
4141
SPI_MEM_OP_NO_DUMMY,
42-
SPI_MEM_OP_DATA_IN(len, val, 1));
42+
SPI_MEM_OP_DATA_IN(len, NULL, 1));
43+
void *scratchbuf;
4344
int ret;
4445

46+
scratchbuf = kmalloc(len, GFP_KERNEL);
47+
if (!scratchbuf)
48+
return -ENOMEM;
49+
50+
op.data.buf.in = scratchbuf;
4551
ret = spi_mem_exec_op(flash->spimem, &op);
4652
if (ret < 0)
4753
dev_err(&flash->spimem->spi->dev, "error %d reading %x\n", ret,
4854
code);
55+
else
56+
memcpy(val, scratchbuf, len);
57+
58+
kfree(scratchbuf);
4959

5060
return ret;
5161
}
@@ -56,9 +66,19 @@ static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
5666
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 1),
5767
SPI_MEM_OP_NO_ADDR,
5868
SPI_MEM_OP_NO_DUMMY,
59-
SPI_MEM_OP_DATA_OUT(len, buf, 1));
69+
SPI_MEM_OP_DATA_OUT(len, NULL, 1));
70+
void *scratchbuf;
71+
int ret;
6072

61-
return spi_mem_exec_op(flash->spimem, &op);
73+
scratchbuf = kmemdup(buf, len, GFP_KERNEL);
74+
if (!scratchbuf)
75+
return -ENOMEM;
76+
77+
op.data.buf.out = scratchbuf;
78+
ret = spi_mem_exec_op(flash->spimem, &op);
79+
kfree(scratchbuf);
80+
81+
return ret;
6282
}
6383

6484
static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,

drivers/mtd/mtdpart.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,11 @@ static int mtd_part_of_parse(struct mtd_info *master,
873873
int ret, err = 0;
874874

875875
np = mtd_get_of_node(master);
876-
if (!mtd_is_partition(master))
876+
if (mtd_is_partition(master))
877+
of_node_get(np);
878+
else
877879
np = of_get_child_by_name(np, "partitions");
880+
878881
of_property_for_each_string(np, "compatible", prop, compat) {
879882
parser = mtd_part_get_compatible_parser(compat);
880883
if (!parser)

drivers/mtd/nand/raw/denali.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf,
596596
}
597597

598598
iowrite32(DMA_ENABLE__FLAG, denali->reg + DMA_ENABLE);
599+
/*
600+
* The ->setup_dma() hook kicks DMA by using the data/command
601+
* interface, which belongs to a different AXI port from the
602+
* register interface. Read back the register to avoid a race.
603+
*/
604+
ioread32(denali->reg + DMA_ENABLE);
599605

600606
denali_reset_irq(denali);
601607
denali->setup_dma(denali, dma_addr, page, write);

drivers/mtd/nand/raw/marvell_nand.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ static void marvell_nfc_parse_instructions(struct nand_chip *chip,
15471547
for (op_id = 0; op_id < subop->ninstrs; op_id++) {
15481548
unsigned int offset, naddrs;
15491549
const u8 *addrs;
1550-
int len = nand_subop_get_data_len(subop, op_id);
1550+
int len;
15511551

15521552
instr = &subop->instrs[op_id];
15531553

@@ -1593,6 +1593,7 @@ static void marvell_nfc_parse_instructions(struct nand_chip *chip,
15931593
nfc_op->ndcb[0] |=
15941594
NDCB0_CMD_XTYPE(XTYPE_MONOLITHIC_RW) |
15951595
NDCB0_LEN_OVRD;
1596+
len = nand_subop_get_data_len(subop, op_id);
15961597
nfc_op->ndcb[3] |= round_up(len, FIFO_DEPTH);
15971598
}
15981599
nfc_op->data_delay_ns = instr->delay_ns;
@@ -1606,6 +1607,7 @@ static void marvell_nfc_parse_instructions(struct nand_chip *chip,
16061607
nfc_op->ndcb[0] |=
16071608
NDCB0_CMD_XTYPE(XTYPE_MONOLITHIC_RW) |
16081609
NDCB0_LEN_OVRD;
1610+
len = nand_subop_get_data_len(subop, op_id);
16091611
nfc_op->ndcb[3] |= round_up(len, FIFO_DEPTH);
16101612
}
16111613
nfc_op->data_delay_ns = instr->delay_ns;

0 commit comments

Comments
 (0)