Skip to contentSkip to conversation

mtd: rawnand: brcmnand: skip DMA during panic write

PATCH Applied Kamal Dasu 4 participants 4 messages Mar 5 – Mar 11

Subsystems (3)
lore
Share & tools
lore

Kamal Dasu

author maintainer
#0 lore raw

PATCH 1/1 mtd: rawnand: brcmnand: skip DMA during panic write

When oops_panic_write is set, the driver disables interrupts and switches to PIO polling mode but still falls through into the DMA path. DMA cannot be used reliably in panic context, so make the DMA path an else branch to ensure only PIO is used during panic writes.

Fixes c1ac2dc34b51 ("mtd: rawnand: brcmnand: When oops in progress use pio and interrupt polling")
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -4
index 0427d76f45d0..5b9dadd5405e 100644
@@ -2350,14 +2350,12 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,
 	for (i = 0; i < ctrl->max_oob; i += 4)
 		oob_reg_write(ctrl, i, 0xffffffff);
 
-	if (mtd->oops_panic_write)
+	if (mtd->oops_panic_write) {
 		/* switch to interrupt polling and PIO mode */
 		disable_ctrl_irqs(ctrl);
-
-	if (use_dma(ctrl) && (has_edu(ctrl) || !oob) && flash_dma_buf_ok(buf)) {
+	} else if (use_dma(ctrl) && (has_edu(ctrl) || !oob) && flash_dma_buf_ok(buf)) {
 		if (ctrl->dma_trans(host, addr, (u32 *)buf, oob, mtd->writesize,
 				    CMD_PROGRAM_PAGE))
-
 			ret = -EIO;
 
 		goto out;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Kamal Dasu

When oops_panic_write is set, the driver disables interrupts and switches to PIO polling mode but still falls through into the DMA path. DMA cannot be used reliably in panic context, so make the DMA path an else branch to ensure only PIO is used during panic writes.

Fixes c1ac2dc34b51 ("mtd: rawnand: brcmnand: When oops in progress use pio and interrupt polling")
Signature · 1 line
Florian
Reviewed-by on v1 1/1
#2 lore raw
In reply to Kamal Dasu
Quoted 35 lines · Kamal Dasu

When oops_panic_write is set, the driver disables interrupts and switches to PIO polling mode but still falls through into the DMA path. DMA cannot be used reliably in panic context, so make the DMA path an else branch to ensure only PIO is used during panic writes.

Fixes c1ac2dc34b51 ("mtd: rawnand: brcmnand: When oops in progress use pio and interrupt polling")
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -5
index 0427d76f45d0..5b9dadd5405e 100644
@@ -2350,14 +2350,12 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,
        for (i = 0; i < ctrl->max_oob; i += 4)
                oob_reg_write(ctrl, i, 0xffffffff);
 
-       if (mtd->oops_panic_write)
+       if (mtd->oops_panic_write) {
                /* switch to interrupt polling and PIO mode */
                disable_ctrl_irqs(ctrl);
-
-       if (use_dma(ctrl) && (has_edu(ctrl) || !oob) && flash_dma_buf_ok(buf)) {
+       } else if (use_dma(ctrl) && (has_edu(ctrl) || !oob) && flash_dma_buf_ok(buf)) {
                if (ctrl->dma_trans(host, addr, (u32 *)buf, oob, mtd->writesize,
                                    CMD_PROGRAM_PAGE))
-
                        ret = -EIO;
 
                goto out;
--
Quoted 2 lines

2.34.1

maintainer Applied
#3 lore raw
In reply to Kamal Dasu
Quoted 8 lines · Kamal Dasu

When oops_panic_write is set, the driver disables interrupts and switches to PIO polling mode but still falls through into the DMA path. DMA cannot be used reliably in panic context, so make the DMA path an else branch to ensure only PIO is used during panic writes.

[...]

Applied to mtd/fixes, thanks!

[1/1] mtd: rawnand: brcmnand: skip DMA during panic write

      commit: da9ba4dcc01e7cf52b7676f0ee9607b8358c2171

Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl