]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mtd: rawnand: brcmnand: skip DMA during panic write
authorKamal Dasu <kamal.dasu@broadcom.com>
Thu, 5 Mar 2026 20:21:57 +0000 (15:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:13:30 +0000 (11:13 +0100)
[ Upstream commit da9ba4dcc01e7cf52b7676f0ee9607b8358c2171 ]

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")
Signed-off-by: Kamal Dasu <kamal.dasu@broadcom.com>
Reviewed-by: William Zhang <william.zhang@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/nand/raw/brcmnand/brcmnand.c

index 835653bdd5abccc3f594234620238f21801a146b..8f4d001377a1c369da09d314aae87b2b64de09be 100644 (file)
@@ -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;