From e1ddf1f284d0da67b782db5b83c61296d26cf4d5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 5 Jul 2018 20:22:53 +0200 Subject: [PATCH] 4.4-stable patches added patches: arm-dts-imx6q-use-correct-sdma-script-for-spi5-core.patch ubi-fastmap-correctly-handle-interrupted-erasures-in-eba.patch --- ...se-correct-sdma-script-for-spi5-core.patch | 41 +++++ queue-4.4/series | 2 + ...y-handle-interrupted-erasures-in-eba.patch | 143 ++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 queue-4.4/arm-dts-imx6q-use-correct-sdma-script-for-spi5-core.patch create mode 100644 queue-4.4/ubi-fastmap-correctly-handle-interrupted-erasures-in-eba.patch diff --git a/queue-4.4/arm-dts-imx6q-use-correct-sdma-script-for-spi5-core.patch b/queue-4.4/arm-dts-imx6q-use-correct-sdma-script-for-spi5-core.patch new file mode 100644 index 00000000000..75f8948e217 --- /dev/null +++ b/queue-4.4/arm-dts-imx6q-use-correct-sdma-script-for-spi5-core.patch @@ -0,0 +1,41 @@ +From df07101e1c4a29e820df02f9989a066988b160e6 Mon Sep 17 00:00:00 2001 +From: Sean Nyekjaer +Date: Tue, 22 May 2018 19:45:09 +0200 +Subject: ARM: dts: imx6q: Use correct SDMA script for SPI5 core + +From: Sean Nyekjaer + +commit df07101e1c4a29e820df02f9989a066988b160e6 upstream. + +According to the reference manual the shp_2_mcu / mcu_2_shp +scripts must be used for devices connected through the SPBA. + +This fixes an issue we saw with DMA transfers. +Sometimes the SPI controller RX FIFO was not empty after a DMA +transfer and the driver got stuck in the next PIO transfer when +it read one word more than expected. + +commit dd4b487b32a35 ("ARM: dts: imx6: Use correct SDMA script +for SPI cores") is fixing the same issue but only for SPI1 - 4. + +Fixes: 677940258dd8e ("ARM: dts: imx6q: enable dma for ecspi5") +Signed-off-by: Sean Nyekjaer +Reviewed-by: Fabio Estevam +Signed-off-by: Shawn Guo +Signed-off-by: Greg Kroah-Hartman + +--- + arch/arm/boot/dts/imx6q.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/arm/boot/dts/imx6q.dtsi ++++ b/arch/arm/boot/dts/imx6q.dtsi +@@ -95,7 +95,7 @@ + clocks = <&clks IMX6Q_CLK_ECSPI5>, + <&clks IMX6Q_CLK_ECSPI5>; + clock-names = "ipg", "per"; +- dmas = <&sdma 11 7 1>, <&sdma 12 7 2>; ++ dmas = <&sdma 11 8 1>, <&sdma 12 8 2>; + dma-names = "rx", "tx"; + status = "disabled"; + }; diff --git a/queue-4.4/series b/queue-4.4/series index b9a70be7428..9f0b5757d60 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -11,3 +11,5 @@ ipv4-fix-error-return-value-in-fib_convert_metrics.patch kprobes-x86-do-not-modify-singlestep-buffer-while-resuming.patch nvme-pci-initialize-queue-memory-before-interrupts.patch netfilter-nf_tables-use-warn_on_once-instead-of-bug_on-in-nft_do_chain.patch +arm-dts-imx6q-use-correct-sdma-script-for-spi5-core.patch +ubi-fastmap-correctly-handle-interrupted-erasures-in-eba.patch diff --git a/queue-4.4/ubi-fastmap-correctly-handle-interrupted-erasures-in-eba.patch b/queue-4.4/ubi-fastmap-correctly-handle-interrupted-erasures-in-eba.patch new file mode 100644 index 00000000000..b69e41c9ace --- /dev/null +++ b/queue-4.4/ubi-fastmap-correctly-handle-interrupted-erasures-in-eba.patch @@ -0,0 +1,143 @@ +From 781932375ffc6411713ee0926ccae8596ed0261c Mon Sep 17 00:00:00 2001 +From: Richard Weinberger +Date: Mon, 28 May 2018 22:04:32 +0200 +Subject: ubi: fastmap: Correctly handle interrupted erasures in EBA + +From: Richard Weinberger + +commit 781932375ffc6411713ee0926ccae8596ed0261c upstream. + +Fastmap cannot track the LEB unmap operation, therefore it can +happen that after an interrupted erasure the mapping still looks +good from Fastmap's point of view, while reading from the PEB will +cause an ECC error and confuses the upper layer. + +Instead of teaching users of UBI how to deal with that, we read back +the VID header and check for errors. If the PEB is empty or shows ECC +errors we fixup the mapping and schedule the PEB for erasure. + +Fixes: dbb7d2a88d2a ("UBI: Add fastmap core") +Cc: +Reported-by: martin bayern +Signed-off-by: Richard Weinberger +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mtd/ubi/eba.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 91 insertions(+), 1 deletion(-) + +--- a/drivers/mtd/ubi/eba.c ++++ b/drivers/mtd/ubi/eba.c +@@ -350,6 +350,82 @@ out_unlock: + return err; + } + ++#ifdef CONFIG_MTD_UBI_FASTMAP ++/** ++ * check_mapping - check and fixup a mapping ++ * @ubi: UBI device description object ++ * @vol: volume description object ++ * @lnum: logical eraseblock number ++ * @pnum: physical eraseblock number ++ * ++ * Checks whether a given mapping is valid. Fastmap cannot track LEB unmap ++ * operations, if such an operation is interrupted the mapping still looks ++ * good, but upon first read an ECC is reported to the upper layer. ++ * Normaly during the full-scan at attach time this is fixed, for Fastmap ++ * we have to deal with it while reading. ++ * If the PEB behind a LEB shows this symthom we change the mapping to ++ * %UBI_LEB_UNMAPPED and schedule the PEB for erasure. ++ * ++ * Returns 0 on success, negative error code in case of failure. ++ */ ++static int check_mapping(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ++ int *pnum) ++{ ++ int err; ++ struct ubi_vid_hdr *vid_hdr; ++ ++ if (!ubi->fast_attach) ++ return 0; ++ ++ vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); ++ if (!vid_hdr) ++ return -ENOMEM; ++ ++ err = ubi_io_read_vid_hdr(ubi, *pnum, vid_hdr, 0); ++ if (err > 0 && err != UBI_IO_BITFLIPS) { ++ int torture = 0; ++ ++ switch (err) { ++ case UBI_IO_FF: ++ case UBI_IO_FF_BITFLIPS: ++ case UBI_IO_BAD_HDR: ++ case UBI_IO_BAD_HDR_EBADMSG: ++ break; ++ default: ++ ubi_assert(0); ++ } ++ ++ if (err == UBI_IO_BAD_HDR_EBADMSG || err == UBI_IO_FF_BITFLIPS) ++ torture = 1; ++ ++ down_read(&ubi->fm_eba_sem); ++ vol->eba_tbl[lnum] = UBI_LEB_UNMAPPED; ++ up_read(&ubi->fm_eba_sem); ++ ubi_wl_put_peb(ubi, vol->vol_id, lnum, *pnum, torture); ++ ++ *pnum = UBI_LEB_UNMAPPED; ++ } else if (err < 0) { ++ ubi_err(ubi, "unable to read VID header back from PEB %i: %i", ++ *pnum, err); ++ ++ goto out_free; ++ } ++ ++ err = 0; ++ ++out_free: ++ ubi_free_vid_hdr(ubi, vid_hdr); ++ ++ return err; ++} ++#else ++static int check_mapping(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ++ int *pnum) ++{ ++ return 0; ++} ++#endif ++ + /** + * ubi_eba_read_leb - read data. + * @ubi: UBI device description object +@@ -381,7 +457,13 @@ int ubi_eba_read_leb(struct ubi_device * + return err; + + pnum = vol->eba_tbl[lnum]; +- if (pnum < 0) { ++ if (pnum >= 0) { ++ err = check_mapping(ubi, vol, lnum, &pnum); ++ if (err < 0) ++ goto out_unlock; ++ } ++ ++ if (pnum == UBI_LEB_UNMAPPED) { + /* + * The logical eraseblock is not mapped, fill the whole buffer + * with 0xFF bytes. The exception is static volumes for which +@@ -697,6 +779,14 @@ int ubi_eba_write_leb(struct ubi_device + + pnum = vol->eba_tbl[lnum]; + if (pnum >= 0) { ++ err = check_mapping(ubi, vol, lnum, &pnum); ++ if (err < 0) { ++ leb_write_unlock(ubi, vol_id, lnum); ++ return err; ++ } ++ } ++ ++ if (pnum >= 0) { + dbg_eba("write %d bytes at offset %d of LEB %d:%d, PEB %d", + len, offset, vol_id, lnum, pnum); + -- 2.47.3