mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe Kerello <christophe.kerello@st.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: <richard@nod.at>, <vigneshr@ti.com>,
	<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH] mtd: rawnand: stm32_fmc2: fix broken ECC
Date: Fri, 30 Oct 2020 09:31:25 +0100	[thread overview]
Message-ID: <d3073938-e714-6b5d-1dc9-36887b11de46@st.com> (raw)
In-Reply-To: <20201030091905.111aa7a4@xps13>

Hi Miquel,

On 10/30/20 9:19 AM, Miquel Raynal wrote:
> Hi Christophe,
> 
> Christophe Kerello <christophe.kerello@st.com> wrote on Thu, 29 Oct
> 2020 17:38:12 +0100:
> 
>> Since commit d7157ff49a5b ("mtd: rawnand: Use the ECC framework user
>> input parsing bits"), ECC are broken in FMC2 driver in case of
>> nand-ecc-step-size and nand-ecc-strength are not set in the device tree.
>> The default user configuration set in FMC2 driver is lost when
>> rawnand_dt_init function is called. To avoid to lose the default user
>> configuration, it is needed to move it in the new user_conf structure.
>>
>> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
>> Fixes: d7157ff49a5b ("mtd: rawnand: Use the ECC framework user input parsing bits")
>> ---
>>   drivers/mtd/nand/raw/stm32_fmc2_nand.c | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
>> index b31a581..dc86ac9 100644
>> --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
>> +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
>> @@ -1846,6 +1846,7 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>>   	struct resource *res;
>>   	struct mtd_info *mtd;
>>   	struct nand_chip *chip;
>> +	struct nand_device *nanddev;
>>   	struct resource cres;
>>   	int chip_cs, mem_region, ret, irq;
>>   	int start_region = 0;
>> @@ -1952,10 +1953,11 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
>>   	chip->options |= NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE |
>>   			 NAND_USES_DMA;
>>   
>> -	/* Default ECC settings */
>> +	/* Default ECC user settings */
>>   	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
>> -	chip->ecc.size = FMC2_ECC_STEP_SIZE;
>> -	chip->ecc.strength = FMC2_ECC_BCH8;
>> +	nanddev = mtd_to_nanddev(mtd);
>> +	nanddev->ecc.user_conf.step_size = FMC2_ECC_STEP_SIZE;
>> +	nanddev->ecc.user_conf.strength = FMC2_ECC_BCH8;
>>   
>>   	/* Scan to find existence of the device */
>>   	ret = nand_scan(chip, nand->ncs);
> 
> Sorry for breaking the driver with this change, but now I think we
> should have all ECC related bits in ->attach() instead of ->probe().
> The ->attach() hook is called during the nand_scan() operation and at
> this point the chip's requirements/layout are known (not before). I
> know that certain controllers don't really care about that, here your
> simply hardcode these two fields and you don't need to know anything
> about the chip's properties. But as a bid to harmonize all drivers with
> the target of a generic ECC engine in mind, I think it's now time to
> move these three lines (chip->ecc.* = ...) at the top of ->attach().
> Also, these fields should have been populated by the core so perhaps
> the best approach is to check if the user requirements are synced with
> the controller's capabilities and error out otherwise?
> 
> We plan to send a fixes PR for -rc2, if the v2 arrives today I'll
> integrate it.

Ok. Issue is that the controller is initialized when 
stm32_fmc2_nfc_select_chip is called. This function will be called 
before the ->attach() hook, when the first command will be sent to the 
NAND device (reset command). So, moving the default ECC initialization
needs probably more modifications in the driver.
I will try to send a v2 today.

Regards,
Christophe Kerello.

> 
> Thanks,
> Miquèl
> 

  reply	other threads:[~2020-10-30  9:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 16:38 Christophe Kerello
2020-10-30  8:19 ` Miquel Raynal
2020-10-30  8:31   ` Christophe Kerello [this message]
2020-10-30  8:36     ` Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3073938-e714-6b5d-1dc9-36887b11de46@st.com \
    --to=christophe.kerello@st.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®