mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
mtd: nand: mtk-ecc: stop on ECC idle timeouts
mtk_ecc_wait_idle() logs when the encoder or decoder does not become
idle, but returns void. Callers can therefore configure a non-idle ECC
engine or read parity bytes after an unconfirmed encoder idle state.
Return the idle poll result and propagate it from the enable and encode
paths that require the engine to be idle before continuing.
Fixes: 1d6b1e4649 ("mtd: mediatek: driver for MTK Smart Device")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
parent
66fb313581
commit
16f7ec8d5d
|
|
@ -123,8 +123,8 @@ static int mt7622_ecc_regs[] = {
|
|||
[ECC_DECIRQ_STA] = 0x144,
|
||||
};
|
||||
|
||||
static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc,
|
||||
enum mtk_ecc_operation op)
|
||||
static inline int mtk_ecc_wait_idle(struct mtk_ecc *ecc,
|
||||
enum mtk_ecc_operation op)
|
||||
{
|
||||
struct device *dev = ecc->dev;
|
||||
u32 val;
|
||||
|
|
@ -136,6 +136,8 @@ static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc,
|
|||
if (ret)
|
||||
dev_warn(dev, "%s NOT idle\n",
|
||||
op == ECC_ENCODE ? "encoder" : "decoder");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static irqreturn_t mtk_ecc_irq(int irq, void *id)
|
||||
|
|
@ -318,7 +320,11 @@ int mtk_ecc_enable(struct mtk_ecc *ecc, struct mtk_ecc_config *config)
|
|||
return ret;
|
||||
}
|
||||
|
||||
mtk_ecc_wait_idle(ecc, op);
|
||||
ret = mtk_ecc_wait_idle(ecc, op);
|
||||
if (ret) {
|
||||
mutex_unlock(&ecc->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mtk_ecc_config(ecc, config);
|
||||
if (ret) {
|
||||
|
|
@ -418,7 +424,9 @@ int mtk_ecc_encode(struct mtk_ecc *ecc, struct mtk_ecc_config *config,
|
|||
if (ret)
|
||||
goto timeout;
|
||||
|
||||
mtk_ecc_wait_idle(ecc, ECC_ENCODE);
|
||||
ret = mtk_ecc_wait_idle(ecc, ECC_ENCODE);
|
||||
if (ret)
|
||||
goto timeout;
|
||||
|
||||
/* Program ECC bytes to OOB: per sector oob = FDM + ECC + SPARE */
|
||||
len = (config->strength * ecc->caps->parity_bits + 7) >> 3;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user