diff mbox series

[v3,1/2] mtd: Add flag to indicate panic_write

Message ID 1558024913-26502-1-git-send-email-kdasu.kdev@gmail.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series [v3,1/2] mtd: Add flag to indicate panic_write | expand

Commit Message

Kamal Dasu May 16, 2019, 4:41 p.m. UTC
Added a flag to indicate a panic_write so that low level drivers can
use it to take required action where applicable, to ensure oops data
gets written to assigned mtd device.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
---
 drivers/mtd/mtdcore.c   | 3 +++
 include/linux/mtd/mtd.h | 6 ++++++
 2 files changed, 9 insertions(+)

Comments

Richard Weinberger May 17, 2019, 8:08 a.m. UTC | #1
On Thu, May 16, 2019 at 6:42 PM Kamal Dasu <kdasu.kdev@gmail.com> wrote:
>
> Added a flag to indicate a panic_write so that low level drivers can
> use it to take required action where applicable, to ensure oops data
> gets written to assigned mtd device.
>
> Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
> ---
>  drivers/mtd/mtdcore.c   | 3 +++
>  include/linux/mtd/mtd.h | 6 ++++++
>  2 files changed, 9 insertions(+)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 76b4264..a83decd 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1138,6 +1138,9 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
>                 return -EROFS;
>         if (!len)
>                 return 0;
> +       if (!mtd->oops_panic_write)
> +               mtd->oops_panic_write = true;
> +

You can set the flag unconditionally.
If it is set, it will stay so, and setting it again, won't hurt.

>         return mtd->_panic_write(mtd, to, len, retlen, buf);
>  }
>  EXPORT_SYMBOL_GPL(mtd_panic_write);
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 677768b..791c34d 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -330,6 +330,12 @@ struct mtd_info {
>         int (*_get_device) (struct mtd_info *mtd);
>         void (*_put_device) (struct mtd_info *mtd);
>
> +       /*
> +        * flag indicates a panic write, low level drivers can take appropriate
> +        * action if required to ensure writes go through
> +        */
> +       bool oops_panic_write;
> +

Maybe we find a better name for it.
panic_write_triggered?
Richard Weinberger June 17, 2019, 10:15 p.m. UTC | #2
On Fri, May 17, 2019 at 10:08 AM Richard Weinberger
<richard.weinberger@gmail.com> wrote:
>
> On Thu, May 16, 2019 at 6:42 PM Kamal Dasu <kdasu.kdev@gmail.com> wrote:
> >
> > Added a flag to indicate a panic_write so that low level drivers can
> > use it to take required action where applicable, to ensure oops data
> > gets written to assigned mtd device.
> >
> > Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
> > ---
> >  drivers/mtd/mtdcore.c   | 3 +++
> >  include/linux/mtd/mtd.h | 6 ++++++
> >  2 files changed, 9 insertions(+)
> >
> > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> > index 76b4264..a83decd 100644
> > --- a/drivers/mtd/mtdcore.c
> > +++ b/drivers/mtd/mtdcore.c
> > @@ -1138,6 +1138,9 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
> >                 return -EROFS;
> >         if (!len)
> >                 return 0;
> > +       if (!mtd->oops_panic_write)
> > +               mtd->oops_panic_write = true;
> > +
>
> You can set the flag unconditionally.
> If it is set, it will stay so, and setting it again, won't hurt.
>
> >         return mtd->_panic_write(mtd, to, len, retlen, buf);
> >  }
> >  EXPORT_SYMBOL_GPL(mtd_panic_write);
> > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> > index 677768b..791c34d 100644
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -330,6 +330,12 @@ struct mtd_info {
> >         int (*_get_device) (struct mtd_info *mtd);
> >         void (*_put_device) (struct mtd_info *mtd);
> >
> > +       /*
> > +        * flag indicates a panic write, low level drivers can take appropriate
> > +        * action if required to ensure writes go through
> > +        */
> > +       bool oops_panic_write;
> > +
>
> Maybe we find a better name for it.
> panic_write_triggered?

ping?
I'm happy with the overall approach.
So let's target the upcoming merge window.
Can you please sort my two comments out? :-)
Miquel Raynal July 1, 2019, 7:14 a.m. UTC | #3
Hi Kamal,

Kamal Dasu <kdasu.kdev@gmail.com> wrote on Thu, 16 May 2019 12:41:46
-0400:

> Added a flag to indicate a panic_write so that low level drivers can
> use it to take required action where applicable, to ensure oops data
> gets written to assigned mtd device.
> 
> Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
> ---

Applied to nand/next, thanks.

Miquèl
diff mbox series

Patch

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 76b4264..a83decd 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1138,6 +1138,9 @@  int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 		return -EROFS;
 	if (!len)
 		return 0;
+	if (!mtd->oops_panic_write)
+		mtd->oops_panic_write = true;
+
 	return mtd->_panic_write(mtd, to, len, retlen, buf);
 }
 EXPORT_SYMBOL_GPL(mtd_panic_write);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 677768b..791c34d 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -330,6 +330,12 @@  struct mtd_info {
 	int (*_get_device) (struct mtd_info *mtd);
 	void (*_put_device) (struct mtd_info *mtd);
 
+	/*
+	 * flag indicates a panic write, low level drivers can take appropriate
+	 * action if required to ensure writes go through
+	 */
+	bool oops_panic_write;
+
 	struct notifier_block reboot_notifier;  /* default mode before reboot */
 
 	/* ECC status information */