diff mbox series

[v2] mtd: rawnand: marvell: Clean the controller state before each operation

Message ID 20190408083145.13178-1-miquel.raynal@bootlin.com
State Accepted
Delegated to: Miquel Raynal
Headers show
Series [v2] mtd: rawnand: marvell: Clean the controller state before each operation | expand

Commit Message

Miquel Raynal April 8, 2019, 8:31 a.m. UTC
Since the migration of the driver to stop using the legacy
->select_chip() hook, there is nothing deselecting the target anymore,
thus the selection is not forced at the next access. Ensure the ND_RUN
bit and the interrupts are always in a clean state.

Cc: Daniel Mack <daniel@zonque.org>
Cc: stable@vger.kernel.org
Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---

Changes in v2:
* Also include the reset of the interrupts each time
  marvell_nfc_select_target() is called.

 drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Daniel Mack April 8, 2019, 4:50 p.m. UTC | #1
Hi Miquel,

On 8/4/2019 10:31 AM, Miquel Raynal wrote:
> Since the migration of the driver to stop using the legacy
> ->select_chip() hook, there is nothing deselecting the target anymore,
> thus the selection is not forced at the next access. Ensure the ND_RUN
> bit and the interrupts are always in a clean state.

Thanks a lot for this. I can confirm that this solves my problem. Awesome :)

> Cc: Daniel Mack <daniel@zonque.org>
> Cc: stable@vger.kernel.org
> Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Tested-by: Daniel Mack <daniel@zonque.org>


Best regards,
Daniel



> ---
> 
> Changes in v2:
> * Also include the reset of the interrupts each time
>   marvell_nfc_select_target() is called.
> 
>  drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index f38e5c1b87e4..d984538980e2 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -722,12 +722,6 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
>  	struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
>  	u32 ndcr_generic;
>  
> -	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
> -		return;
> -
> -	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
> -	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
> -
>  	/*
>  	 * Reset the NDCR register to a clean state for this particular chip,
>  	 * also clear ND_RUN bit.
> @@ -739,6 +733,12 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
>  	/* Also reset the interrupt status register */
>  	marvell_nfc_clear_int(nfc, NDCR_ALL_INT);
>  
> +	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
> +		return;
> +
> +	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
> +	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
> +
>  	nfc->selected_chip = chip;
>  	marvell_nand->selected_die = die_nr;
>  }
>
Boris Brezillon April 14, 2019, 8:50 a.m. UTC | #2
On Mon,  8 Apr 2019 10:31:45 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Since the migration of the driver to stop using the legacy
> ->select_chip() hook, there is nothing deselecting the target anymore,  
> thus the selection is not forced at the next access. Ensure the ND_RUN
> bit and the interrupts are always in a clean state.
> 
> Cc: Daniel Mack <daniel@zonque.org>
> Cc: stable@vger.kernel.org
> Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
> 
> Changes in v2:
> * Also include the reset of the interrupts each time
>   marvell_nfc_select_target() is called.
> 
>  drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index f38e5c1b87e4..d984538980e2 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -722,12 +722,6 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
>  	struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
>  	u32 ndcr_generic;
>  
> -	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
> -		return;
> -
> -	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
> -	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
> -
>  	/*
>  	 * Reset the NDCR register to a clean state for this particular chip,
>  	 * also clear ND_RUN bit.
> @@ -739,6 +733,12 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
>  	/* Also reset the interrupt status register */
>  	marvell_nfc_clear_int(nfc, NDCR_ALL_INT);
>  
> +	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
> +		return;
> +
> +	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
> +	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
> +
>  	nfc->selected_chip = chip;
>  	marvell_nand->selected_die = die_nr;
>  }
Daniel Mack April 28, 2019, 12:20 p.m. UTC | #3
On 14/4/2019 10:50 AM, Boris Brezillon wrote:
> On Mon,  8 Apr 2019 10:31:45 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
>> Since the migration of the driver to stop using the legacy
>> ->select_chip() hook, there is nothing deselecting the target anymore,  
>> thus the selection is not forced at the next access. Ensure the ND_RUN
>> bit and the interrupts are always in a clean state.
>>
>> Cc: Daniel Mack <daniel@zonque.org>
>> Cc: stable@vger.kernel.org
>> Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
>> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> 
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

Has this one been queued in any tree yet?



Thanks,
Daniel




> 
>> ---
>>
>> Changes in v2:
>> * Also include the reset of the interrupts each time
>>   marvell_nfc_select_target() is called.
>>
>>  drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
>> index f38e5c1b87e4..d984538980e2 100644
>> --- a/drivers/mtd/nand/raw/marvell_nand.c
>> +++ b/drivers/mtd/nand/raw/marvell_nand.c
>> @@ -722,12 +722,6 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
>>  	struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
>>  	u32 ndcr_generic;
>>  
>> -	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
>> -		return;
>> -
>> -	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
>> -	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
>> -
>>  	/*
>>  	 * Reset the NDCR register to a clean state for this particular chip,
>>  	 * also clear ND_RUN bit.
>> @@ -739,6 +733,12 @@ static void marvell_nfc_select_target(struct nand_chip *chip,
>>  	/* Also reset the interrupt status register */
>>  	marvell_nfc_clear_int(nfc, NDCR_ALL_INT);
>>  
>> +	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
>> +		return;
>> +
>> +	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
>> +	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
>> +
>>  	nfc->selected_chip = chip;
>>  	marvell_nand->selected_die = die_nr;
>>  }
>
Richard Weinberger April 28, 2019, 1:07 p.m. UTC | #4
Daniel,

Am Sonntag, 28. April 2019, 14:20:49 CEST schrieb Daniel Mack:
> On 14/4/2019 10:50 AM, Boris Brezillon wrote:
> > On Mon,  8 Apr 2019 10:31:45 +0200
> > Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> > 
> >> Since the migration of the driver to stop using the legacy
> >> ->select_chip() hook, there is nothing deselecting the target anymore,  
> >> thus the selection is not forced at the next access. Ensure the ND_RUN
> >> bit and the interrupts are always in a clean state.
> >>
> >> Cc: Daniel Mack <daniel@zonque.org>
> >> Cc: stable@vger.kernel.org
> >> Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
> >> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> >> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > 
> > Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> 
> Has this one been queued in any tree yet?

Isn't it visible in linux-next?
I was about to send a final PR to Linus later today.

Thanks,
//richard
Miquel Raynal April 29, 2019, 9 a.m. UTC | #5
Hi Richard,

Richard Weinberger <richard@nod.at> wrote on Sun, 28 Apr 2019 15:07:40
+0200:

> Daniel,
> 
> Am Sonntag, 28. April 2019, 14:20:49 CEST schrieb Daniel Mack:
> > On 14/4/2019 10:50 AM, Boris Brezillon wrote:  
> > > On Mon,  8 Apr 2019 10:31:45 +0200
> > > Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> > >   
> > >> Since the migration of the driver to stop using the legacy  
> > >> ->select_chip() hook, there is nothing deselecting the target anymore,    
> > >> thus the selection is not forced at the next access. Ensure the ND_RUN
> > >> bit and the interrupts are always in a clean state.
> > >>
> > >> Cc: Daniel Mack <daniel@zonque.org>
> > >> Cc: stable@vger.kernel.org
> > >> Fixes: b25251414f6e00 ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
> > >> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> > >> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>  
> > > 
> > > Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>  
> > 
> > Has this one been queued in any tree yet?  
> 
> Isn't it visible in linux-next?
> I was about to send a final PR to Linus later today.
> 

Indeed the patch is missing in 20190426 -next. 


Thanks,
Miquèl
Richard Weinberger April 29, 2019, 8:39 p.m. UTC | #6
----- Ursprüngliche Mail -----
> Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> An: "richard" <richard@nod.at>
> CC: "Daniel Mack" <daniel@zonque.org>, "Boris Brezillon" <boris.brezillon@collabora.com>, "David Woodhouse"
> <dwmw2@infradead.org>, "Brian Norris" <computersforpeace@gmail.com>, "Marek Vasut" <marek.vasut@gmail.com>, "Tudor
> Ambarus" <Tudor.Ambarus@microchip.com>, "Vignesh Raghavendra" <vigneshr@ti.com>, "linux-mtd"
> <linux-
>> Isn't it visible in linux-next?
>> I was about to send a final PR to Linus later today.
>> 
> 
> Indeed the patch is missing in 20190426 -next.

Bad timing on my side I fear, now it is in -next. :-)

Thanks,
//richard

P.s: Yay, mail works again! My laptop had "issues".
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index f38e5c1b87e4..d984538980e2 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -722,12 +722,6 @@  static void marvell_nfc_select_target(struct nand_chip *chip,
 	struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
 	u32 ndcr_generic;
 
-	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
-		return;
-
-	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
-	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
-
 	/*
 	 * Reset the NDCR register to a clean state for this particular chip,
 	 * also clear ND_RUN bit.
@@ -739,6 +733,12 @@  static void marvell_nfc_select_target(struct nand_chip *chip,
 	/* Also reset the interrupt status register */
 	marvell_nfc_clear_int(nfc, NDCR_ALL_INT);
 
+	if (chip == nfc->selected_chip && die_nr == marvell_nand->selected_die)
+		return;
+
+	writel_relaxed(marvell_nand->ndtr0, nfc->regs + NDTR0);
+	writel_relaxed(marvell_nand->ndtr1, nfc->regs + NDTR1);
+
 	nfc->selected_chip = chip;
 	marvell_nand->selected_die = die_nr;
 }