Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] mtd: set mtd partition panic write flag
@ 2019-10-21 19:32 Kamal Dasu
  2019-11-05 19:03 ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Kamal Dasu @ 2019-10-21 19:32 UTC (permalink / raw)
  To: linux-mtd
  Cc: Vignesh Raghavendra, Kamal Dasu, Richard Weinberger,
	linux-kernel, Marek Vasut, bcm-kernel-feedback-list,
	Miquel Raynal, Brian Norris, David Woodhouse

Check mtd panic write flag and set the mtd partition panic
write flag so that low level drivers can use it to take
required action to ensure oops data gets written to assigned
mtd partition.

Fixes: 9f897bfdd8 ("mtd: Add flag to indicate panic_write")
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
---
 drivers/mtd/mtdpart.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 7328c066c5ba..b4f6479abeda 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -159,6 +159,10 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
 		size_t *retlen, const u_char *buf)
 {
 	struct mtd_part *part = mtd_to_part(mtd);
+
+	if (mtd->oops_panic_write)
+		part->parent->oops_panic_write = true;
+
 	return part->parent->_panic_write(part->parent, to + part->offset, len,
 					  retlen, buf);
 }
-- 
2.17.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: set mtd partition panic write flag
  2019-10-21 19:32 [PATCH] mtd: set mtd partition panic write flag Kamal Dasu
@ 2019-11-05 19:03 ` Miquel Raynal
  2019-11-05 23:03   ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2019-11-05 19:03 UTC (permalink / raw)
  To: Kamal Dasu
  Cc: Vignesh Raghavendra, Richard Weinberger, linux-kernel,
	Marek Vasut, bcm-kernel-feedback-list, linux-mtd, Brian Norris,
	David Woodhouse

Hi Kamal,

Richard, something to look into below :)

Kamal Dasu <kdasu.kdev@gmail.com> wrote on Mon, 21 Oct 2019 15:32:52
-0400:

> Check mtd panic write flag and set the mtd partition panic
> write flag so that low level drivers can use it to take
> required action to ensure oops data gets written to assigned
> mtd partition.

I feel there is something wrong with the current implementation
regarding partitions but I am not sure this is the right fix. Is this
something you detected with some kind of static checker or did you
actually experience an issue?

In the commit log you say "check mtd (I suppose you mean the
master) panic write flag and set the mtd partition panic write flag"
which makes sense, but in reality my understanding is that you do the
opposite: you check mtd->oops_panic_write which is the partitions'
structure, and set part->parent->oops_panic_write which is the master's
flag.

Also, I am not sure if it is worth checking anything, why not just set
mtd->oops_panic_write in this function?

Same comment for the -already existing- condition in mtd_panic_write.
As soon as we are in these functions, we know there is a panic, right?
So why checking if the bit is already set before forcing it?

> 
> Fixes: 9f897bfdd8 ("mtd: Add flag to indicate panic_write")
> Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
> ---
>  drivers/mtd/mtdpart.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 7328c066c5ba..b4f6479abeda 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -159,6 +159,10 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
>  		size_t *retlen, const u_char *buf)
>  {
>  	struct mtd_part *part = mtd_to_part(mtd);
> +
> +	if (mtd->oops_panic_write)
> +		part->parent->oops_panic_write = true;
> +
>  	return part->parent->_panic_write(part->parent, to + part->offset, len,
>  					  retlen, buf);
>  }

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: set mtd partition panic write flag
  2019-11-05 19:03 ` Miquel Raynal
@ 2019-11-05 23:03   ` Richard Weinberger
  2019-11-11 20:35     ` Kamal Dasu
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2019-11-05 23:03 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Vignesh Raghavendra, Kamal Dasu, linux-kernel, Marek Vasut,
	bcm-kernel-feedback-list, linux-mtd, Brian Norris,
	David Woodhouse

----- Ursprüngliche Mail -----
> Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> An: "Kamal Dasu" <kdasu.kdev@gmail.com>
> CC: "linux-mtd" <linux-mtd@lists.infradead.org>, "bcm-kernel-feedback-list" <bcm-kernel-feedback-list@broadcom.com>,
> "linux-kernel" <linux-kernel@vger.kernel.org>, "David Woodhouse" <dwmw2@infradead.org>, "Brian Norris"
> <computersforpeace@gmail.com>, "Marek Vasut" <marek.vasut@gmail.com>, "richard" <richard@nod.at>, "Vignesh Raghavendra"
> <vigneshr@ti.com>
> Gesendet: Dienstag, 5. November 2019 20:03:44
> Betreff: Re: [PATCH] mtd: set mtd partition panic write flag

> Hi Kamal,
> 
> Richard, something to look into below :)

I'm still recovering from a bad cold. So my brain is not fully working ;)
 
> Kamal Dasu <kdasu.kdev@gmail.com> wrote on Mon, 21 Oct 2019 15:32:52
> -0400:
> 
>> Check mtd panic write flag and set the mtd partition panic
>> write flag so that low level drivers can use it to take
>> required action to ensure oops data gets written to assigned
>> mtd partition.
> 
> I feel there is something wrong with the current implementation
> regarding partitions but I am not sure this is the right fix. Is this
> something you detected with some kind of static checker or did you
> actually experience an issue?
> 
> In the commit log you say "check mtd (I suppose you mean the
> master) panic write flag and set the mtd partition panic write flag"
> which makes sense, but in reality my understanding is that you do the
> opposite: you check mtd->oops_panic_write which is the partitions'
> structure, and set part->parent->oops_panic_write which is the master's
> flag.

IIUC the problem happens when you run mtdoops on a mtd partition.
The the flag is only set for the partition instead for the master.

So the right fix would be setting the parent's oops_panic_write in
mtd_panic_write().
Then we don't have to touch mtdpart.c

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: set mtd partition panic write flag
  2019-11-05 23:03   ` Richard Weinberger
@ 2019-11-11 20:35     ` Kamal Dasu
  0 siblings, 0 replies; 4+ messages in thread
From: Kamal Dasu @ 2019-11-11 20:35 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Vignesh Raghavendra, linux-kernel, Marek Vasut,
	bcm-kernel-feedback-list, Miquel Raynal, linux-mtd, Brian Norris,
	David Woodhouse

Richard,

On Tue, Nov 5, 2019 at 6:03 PM Richard Weinberger <richard@nod.at> wrote:
>
> ----- Ursprüngliche Mail -----
> > Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> > An: "Kamal Dasu" <kdasu.kdev@gmail.com>
> > CC: "linux-mtd" <linux-mtd@lists.infradead.org>, "bcm-kernel-feedback-list" <bcm-kernel-feedback-list@broadcom.com>,
> > "linux-kernel" <linux-kernel@vger.kernel.org>, "David Woodhouse" <dwmw2@infradead.org>, "Brian Norris"
> > <computersforpeace@gmail.com>, "Marek Vasut" <marek.vasut@gmail.com>, "richard" <richard@nod.at>, "Vignesh Raghavendra"
> > <vigneshr@ti.com>
> > Gesendet: Dienstag, 5. November 2019 20:03:44
> > Betreff: Re: [PATCH] mtd: set mtd partition panic write flag
>
> > Hi Kamal,
> >
> > Richard, something to look into below :)
>
> I'm still recovering from a bad cold. So my brain is not fully working ;)

Thanks for reviewing this. Hope you are feeling better now.

>
> > Kamal Dasu <kdasu.kdev@gmail.com> wrote on Mon, 21 Oct 2019 15:32:52
> > -0400:
> >
> >> Check mtd panic write flag and set the mtd partition panic
> >> write flag so that low level drivers can use it to take
> >> required action to ensure oops data gets written to assigned
> >> mtd partition.
> >
> > I feel there is something wrong with the current implementation
> > regarding partitions but I am not sure this is the right fix. Is this
> > something you detected with some kind of static checker or did you
> > actually experience an issue?
> >
> > In the commit log you say "check mtd (I suppose you mean the
> > master) panic write flag and set the mtd partition panic write flag"
> > which makes sense, but in reality my understanding is that you do the
> > opposite: you check mtd->oops_panic_write which is the partitions'
> > structure, and set part->parent->oops_panic_write which is the master's
> > flag.
>
> IIUC the problem happens when you run mtdoops on a mtd partition.
> The the flag is only set for the partition instead for the master.
>
> So the right fix would be setting the parent's oops_panic_write in

How do I get access to the parts parent in the core ?. Maybe I am
missing something.

> mtd_panic_write().
> Then we don't have to touch mtdpart.c
>
> Thanks,
> //richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21 19:32 [PATCH] mtd: set mtd partition panic write flag Kamal Dasu
2019-11-05 19:03 ` Miquel Raynal
2019-11-05 23:03   ` Richard Weinberger
2019-11-11 20:35     ` Kamal Dasu

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git