mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav <adeep@lexina.in>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	Arseniy Krasnov <avkrasnov@salutedevices.com>
Cc: Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	oxffffaa@gmail.com, kernel@sberdevices.ru,
	linux-mtd@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] mtd: rawnand: meson: handle OOB buffer according OOB layout
Date: Fri, 24 Nov 2023 13:14:38 +0300	[thread overview]
Message-ID: <608cf897-55b3-4ccd-b99f-2ebba8bbf17f@lexina.in> (raw)
In-Reply-To: <20231124100657.245d258f@xps-13>

Hi, Miquel!

24/11/2023 12.06, Miquel Raynal wrote:
> Hi Arseniy,
> 
> avkrasnov@salutedevices.com wrote on Fri, 24 Nov 2023 10:50:54 +0300:
> 
>> Hello all, 2 weeks from 9.11, please ping
> 
> I'm waiting for Viacheslav.

We discussed this update with Arseniy. My suggestion was based on the 
difference in patch from the algorithms used in amlogic u-boot.  Arseniy 
claims that everything works for them.

Unfortunately, I don't have the devices available to test this.

> 
>>
>> Thanks, Arseniy
>>
>>
>> On 09.11.2023 12:09, Arseniy Krasnov wrote:
>>> Hello, thanks for review!
>>>
>>> On 09.11.2023 11:06, Viacheslav Bocharov wrote:
>>>> Hi!
>>>>
>>>> On Thu, 2023-11-09 at 08:39 +0300, Arseniy Krasnov wrote:
>>>>> In case of MTD_OPS_AUTO_OOB mode, MTD/NAND layer fills/reads OOB buffer
>>>>> according current OOB layout so we need to follow it in the driver.
>>>>>
>>>>> Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
>>>>> ---
>>>>>   drivers/mtd/nand/raw/meson_nand.c | 4 ++--
>>>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
>>>>> index 561d46d860b7..0d4d358152d7 100644
>>>>> --- a/drivers/mtd/nand/raw/meson_nand.c
>>>>> +++ b/drivers/mtd/nand/raw/meson_nand.c
>>>>> @@ -510,7 +510,7 @@ static void meson_nfc_set_user_byte(struct nand_chip *nand, u8 *oob_buf)
>>>>>   	__le64 *info;
>>>>>   	int i, count;
>>>>>   
>>>>> -	for (i = 0, count = 0; i < nand->ecc.steps; i++, count += 2) {
>>>>> +	for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (2 + nand->ecc.bytes)) {
>>>>>   		info = &meson_chip->info_buf[i];
>>>>>   		*info |= oob_buf[count];
>>>>>   		*info |= oob_buf[count + 1] << 8;
>>>> Seems something wrong with your logic here.
>>>> I think this code should most likely look like this:
>>>>
>>>> for (i = 0, count = 0; i < nand->ecc.steps; i++, count += nand->ecc.bytes) {
>>>>      info = &meson_chip->info_buf[i];
>>>>      *info |= oob_buf[count];
>>>>      if (nand->ecc.bytes > 1)
>>>>        *info |= oob_buf[count + 1] << 8;
>>>> }
>>>
>>> For 64 bytes OOB and 512 bytes ECC this driver reports free areas as:
>>>
>>> AA AA BB BB BB BB BB BB BB BB BB BB BB BB BB BB
>>> AA AA BB BB BB BB BB BB BB BB BB BB BB BB BB BB
>>> AA AA BB BB BB BB BB BB BB BB BB BB BB BB BB BB
>>> AA AA BB BB BB BB BB BB BB BB BB BB BB BB BB BB
>>>
>>> where AA is free byte(user byte), BB - ECC codes. So to access user bytes
>>> we need bytes 0,1,16,17,32,33,48,49. nand->ecc.bytes == 14, so 'count' is
>>> increased at 16 every iteration, so i guess this is correct.
>>>
>>> WDYT?
>>>
>>> Thanks, Arseniy
>>>    
>>>>
>>>>   
>>>>> @@ -523,7 +523,7 @@ static void meson_nfc_get_user_byte(struct nand_chip *nand, u8 *oob_buf)
>>>>>   	__le64 *info;
>>>>>   	int i, count;
>>>>>   
>>>>> -	for (i = 0, count = 0; i < nand->ecc.steps; i++, count += 2) {
>>>>> +	for (i = 0, count = 0; i < nand->ecc.steps; i++, count += (2 + nand->ecc.bytes)) {
>>>>>   		info = &meson_chip->info_buf[i];
>>>>>   		oob_buf[count] = *info;
>>>>>   		oob_buf[count + 1] = *info >> 8;
>>>> And there:
>>>>
>>>> for (i = 0, count = 0; i < nand->ecc.steps; i++, count += nand->ecc.bytes) {
>>>>      info = &meson_chip->info_buf[i];
>>>>      oob_buf[count] = *info;
>>>>      if (nand->ecc.bytes > 1)
>>>>          oob_buf[count + 1] = *info >> 8;
>>>> }
>>>>
>>>>
>>>> This is more similar to the behavior of similar functions in the proprietary U-Boot.
>>>>
>>>> --
>>>> Viacheslav Bocharov
>>>>   
> 
> 
> Thanks,
> Miquèl

--
Viacheslav Bocharov

  reply	other threads:[~2023-11-24 10:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09  5:39 Arseniy Krasnov
2023-11-09  8:06 ` Viacheslav Bocharov
2023-11-09  9:09   ` Arseniy Krasnov
2023-11-24  7:50     ` Arseniy Krasnov
2023-11-24  9:06       ` Miquel Raynal
2023-11-24 10:14         ` Viacheslav [this message]
2023-11-30 10: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=608cf897-55b3-4ccd-b99f-2ebba8bbf17f@lexina.in \
    --to=adeep@lexina.in \
    --cc=avkrasnov@salutedevices.com \
    --cc=jbrunet@baylibre.com \
    --cc=kernel@sberdevices.ru \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=neil.armstrong@linaro.org \
    --cc=oxffffaa@gmail.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®