linux-brain/drivers/mtd
Xiaolei Li d8dacf4545 mtd: nand: mtk: fix infinite ECC decode IRQ issue
commit 1d2fcdcf33 upstream.

For MT2701 NAND Controller, there may generate infinite ECC decode IRQ
during long time burn test on some platforms. Once this issue occurred,
the ECC decode IRQ status cannot be cleared in the IRQ handler function,
and threads cannot be scheduled.

ECC HW generates decode IRQ each sector, so there will have more than one
decode IRQ if read one page of large page NAND.

Currently, ECC IRQ handle flow is that we will check whether it is decode
IRQ at first by reading the register ECC_DECIRQ_STA. This is a read-clear
type register. If this IRQ is decode IRQ, then the ECC IRQ signal will be
cleared at the same time.
Secondly, we will check whether all sectors are decoded by reading the
register ECC_DECDONE. This is because the current IRQ may be not dealed
in time, and the next sectors have been decoded before reading the
register ECC_DECIRQ_STA. Then, the next sectors's decode IRQs will not
be generated.
Thirdly, if all sectors are decoded by comparing with ecc->sectors, then we
will complete ecc->done, set ecc->sectors as 0, and disable ECC IRQ by
programming the register ECC_IRQ_REG(op) as 0. Otherwise, wait for the
next ECC IRQ.

But, there is a timing issue between step one and two. When we read the
reigster ECC_DECIRQ_STA, all sectors are decoded except the last sector,
and the ECC IRQ signal is cleared. But the last sector is decoded before
reading ECC_DECDONE, so the ECC IRQ signal is enabled again by ECC HW, and
it means we will receive one extra ECC IRQ later. In step three, we will
find that all sectors were decoded, then disable ECC IRQ and return.
When deal with the extra ECC IRQ, the ECC IRQ status cannot be cleared
anymore. That is because the register ECC_DECIRQ_STA can only be cleared
when the register ECC_IRQ_REG(op) is enabled. But actually we have
disabled ECC IRQ in the previous ECC IRQ handle. So, there will
keep receiving ECC decode IRQ.

Now, we read the register ECC_DECIRQ_STA once again before completing the
ecc done event. This ensures that there will be no extra ECC decode IRQ.

Also, remove writel(0, ecc->regs + ECC_IRQ_REG(op)) from irq handler,
because ECC IRQ is disabled in mtk_ecc_disable(). And clear ECC_DECIRQ_STA
in mtk_ecc_disable() in case there is a timeout to wait decode IRQ.

Fixes: 1d6b1e4649 ("mtd: mediatek: driver for MTK Smart Device")
Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-30 08:39:06 +00:00
..
chips mtd: cfi_cmdset_0020: Deinline do_write_buffer, save 5316 bytes 2016-07-09 18:53:33 -07:00
devices MTD updates for v4.8: 2016-08-02 17:05:11 -04:00
lpddr mtd: lpddr: show parent device in sysfs 2015-10-13 09:21:17 -07:00
maps mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy 2017-03-18 19:14:28 +08:00
nand mtd: nand: mtk: fix infinite ECC decode IRQ issue 2017-11-30 08:39:06 +00:00
onenand mtd: silence some uninitialized variable warnings 2016-07-09 18:14:39 -07:00
spi-nor mtd: spi-nor: fix spansion quad enable 2017-06-29 13:00:31 +02:00
tests mtd: nandbiterrs: Support for NAND biterrors test on platforms without raw write 2016-07-11 08:40:13 +02:00
ubi ubi/upd: Always flush after prepared for an update 2017-04-27 09:10:38 +02:00
afs.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
ar7part.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
bcm47xxpart.c mtd: bcm47xxpart: fix parsing first block after aligned TRX 2017-04-18 07:11:47 +02:00
bcm63xxpart.c mtd: bcm63xxpart: give width specifier an 'int', not 'size_t' 2016-03-07 13:13:58 -08:00
cmdlinepart.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
ftl.c mtd: ftl: use swap() in copy_erase_unit() 2015-12-18 16:56:07 -08:00
inftlcore.c
inftlmount.c mtd: intflmount: fix off by one error in INFTL_dumpVUchains() 2014-11-05 13:19:21 -08:00
Kconfig mtd: bcm63xxpart: Remove dependency on mach-bcm63xx 2016-02-12 10:27:48 -08:00
Makefile mtd: spi-nor: shorten Kconfig naming 2014-04-14 11:23:01 -07:00
mtd_blkdevs.c block: convert to device_add_disk() 2016-06-27 12:26:08 -07:00
mtdblock_ro.c
mtdblock.c mtd: mtdblock: remove the needless mtdblks_lock 2015-01-07 12:51:56 -08:00
mtdchar.c mtd: kill the nand_ecclayout struct 2016-05-05 23:51:51 +02:00
mtdconcat.c mtd: create an mtd_ooblayout_ops struct to ease ECC layout definition 2016-04-19 22:05:55 +02:00
mtdcore.c treewide: remove redundant #include <linux/kconfig.h> 2016-10-11 15:06:33 -07:00
mtdcore.h mtd: partitions: support a cleanup callback for parsers 2015-12-09 14:57:44 -08:00
mtdoops.c
mtdpart.c treewide: remove redundant #include <linux/kconfig.h> 2016-10-11 15:06:33 -07:00
mtdsuper.c
mtdswap.c mtd: mtdswap: remove useless if (!mtd->ecclayout) test 2016-03-07 16:23:09 -08:00
nftlcore.c
nftlmount.c mtd: nftl: reorganize operations in condition check 2015-01-09 15:26:29 -08:00
ofpart.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
redboot.c mtd: partitions: make parsers return 'const' partition arrays 2015-12-09 10:21:57 -08:00
rfd_ftl.c mtd: remove some duplicative checks 2014-03-10 22:42:25 -07:00
sm_ftl.c treewide: Fix typos in printk 2016-04-18 11:23:24 +02:00
sm_ftl.h
ssfdc.c mtd: Replace if and BUG with BUG_ON 2016-07-09 18:48:54 -07:00