[RFT PATCH 2/2] mtd: cfi-flash: call ctrlc() during CFI reads
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon May 22 01:38:12 PDT 2023
On 22.05.23 07:25, Ahmad Fatoum wrote:
> Memory mapped flash access can be quite slow on older processors. For
> writing and erasing, we already call resched() indirectly to feed the
> watchdog, so let's do this when reading as well. This fixes an issue
> of short running watchdogs triggering on PowerPC, because kernel boot
> takes too long.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> drivers/mtd/nor/cfi_flash.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
> index f1555a72a42e..10542c710118 100644
> --- a/drivers/mtd/nor/cfi_flash.c
> +++ b/drivers/mtd/nor/cfi_flash.c
> @@ -25,7 +25,9 @@
> #include <io.h>
> #include <errno.h>
> #include <progress.h>
> +#include <string.h>
> #include <linux/err.h>
> +#include <linux/sizes.h>
> #include <asm/unaligned.h>
> #include <linux/mtd/concat.h>
> #include "cfi_flash.h"
> @@ -891,10 +893,16 @@ static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
> size_t *retlen, u8 *buf)
> {
> struct flash_info *info = container_of(mtd, struct flash_info, mtd);
> + const void *src = info->base + from;
> + size_t i;
> +
> + for (i = 0; i < len; i = size_add(i, SZ_1M)) {
> + buf = mempcpy(buf, src + i, min_t(size_t, len, SZ_1M));
> + if (ctrlc())
> + return -EINTR;
Christian mentioned in IRC that it may be surprising to users that a boot could be
aborted with ctrlc(). Thoughts? Also, the POSIXy thing to do is to return a short
read count, but I didn't do that, because I have not vetted that everything handles
that gracefully.. (read_file e.g. does, but I don't know about others).
Cheers,
Ahmad
> + }
>
> - memcpy(buf, info->base + from, len);
> *retlen = len;
> -
> return 0;
> }
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list