[PATCH v4 3/4] mtd: core: protect access to MTD devices while in suspend

Boris Brezillon boris.brezillon at collabora.com
Mon Nov 1 00:40:59 PDT 2021


On Tue, 26 Oct 2021 07:55:50 +0200
Sean Nyekjaer <sean at geanix.com> wrote:

> @@ -1406,6 +1423,7 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
>  		    const u_char *buf)
>  {
>  	struct mtd_info *master = mtd_get_master(mtd);
> +	int ret;
>  
>  	*retlen = 0;
>  	if (!master->_panic_write)
> @@ -1419,8 +1437,12 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
>  	if (!master->oops_panic_write)
>  		master->oops_panic_write = true;
>  
> -	return master->_panic_write(master, mtd_get_master_ofs(mtd, to), len,
> -				    retlen, buf);
> +	mtd_start_access(master);
> +	ret = master->_panic_write(master, mtd_get_master_ofs(mtd, to), len,
> +				   retlen, buf);
> +	mtd_end_access(master);
> +
> +	return ret;
>  }

I suspect panic_write should be an exception, otherwise a panic in the
suspend path would never be able to write its data to the flash.



More information about the linux-mtd mailing list