From: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Ray Liu <ray.liu@airoha.com>, Mark Brown <broonie@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Andreas Gnau <andreas.gnau@iopsys.eu>
Subject: Re: [PATCH RESEND v5 13/13] spi: airoha: buffer must be 0xff-ed before writing
Date: Thu, 2 Oct 2025 01:13:06 +0300 [thread overview]
Message-ID: <d13c09b5-5e9e-4d79-b94b-f3464831fefc@iopsys.eu> (raw)
In-Reply-To: <7909d937-aa93-44bf-a4d3-12849a14fdf4@collabora.com>
On 01.10.2025 14:30, AngeloGioacchino Del Regno wrote:
> Il 30/09/25 04:26, Mikhail Kshevetskiy ha scritto:
>> During writing, the entire flash page (including OOB) will be updated
>> with the values from the temporary buffer, so we need to fill the
>> untouched areas of the buffer with 0xff value to prevent accidental
>> data overwriting.
>>
>> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
>> ---
>> drivers/spi/spi-airoha-snfi.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/spi/spi-airoha-snfi.c
>> b/drivers/spi/spi-airoha-snfi.c
>> index 437ab6745b1a..57b1950e853f 100644
>> --- a/drivers/spi/spi-airoha-snfi.c
>> +++ b/drivers/spi/spi-airoha-snfi.c
>> @@ -776,6 +776,7 @@ static ssize_t airoha_snand_dirmap_write(struct
>> spi_mem_dirmap_desc *desc,
>> return -EOPNOTSUPP;
>> }
>> + memset(txrx_buf, 0xff, bytes);
>
> As you are refactoring this a bit, reading the function isn't
> straightforward
> without applying the series locally.
>
> It looks like you're filling the entire txrx_buf with 0xff.
>
> While that will work for sure, for the sake of performance you should
> change this
> to memset(0xff) only the portions of buffer that the next memcpy call
> will not
> overwrite, avoiding to effectively write twice to that buffer.
>
> Is there any reason why you didn't do just that?
>
> ...also because, your commit message really looks like saying what I'm
> proposing
> to do here.
>
In the worst case 2 memset() operations must be done:
1) memset() of buffer head with non-rounded size
2) memset() of buffer tail with unaligned beginning address and
non-rounded size
In summary it could be slower than a single memset() of buffer with
aligned boundaries.
But anyway the difference will be small.
Anyway, I fix this in next version.
Regards,
Mikhail
> Cheers,
> Angelo
>
>> memcpy(txrx_buf + offs, buf, len);
>> err = airoha_snand_set_mode(as_ctrl, SPI_MODE_DMA);
>
>
next prev parent reply other threads:[~2025-10-01 22:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-30 2:26 [PATCH RESEND v5 00/13] spi: airoha: driver fixes & improvements Mikhail Kshevetskiy
2025-09-30 2:26 ` [PATCH RESEND v5 01/13] spi: airoha: return an error for continuous mode dirmap creation cases Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 02/13] spi: airoha: remove unnecessary restriction length Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 03/13] spi: airoha: add support of dual/quad wires spi modes to exec_op() handler Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 04/13] spi: airoha: remove unnecessary switch to non-dma mode Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 05/13] spi: airoha: switch back to non-dma mode in the case of error Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 06/13] spi: airoha: fix reading/writing of flashes with more than one plane per lun Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 07/13] spi: airoha: unify dirmap read/write code Mikhail Kshevetskiy
2025-09-30 2:26 ` [PATCH RESEND v5 08/13] spi: airoha: support of dualio/quadio flash reading commands Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 09/13] spi: airoha: avoid setting of page/oob sizes in REG_SPI_NFI_PAGEFMT Mikhail Kshevetskiy
2025-09-30 2:26 ` [PATCH RESEND v5 10/13] spi: airoha: reduce the number of modification of REG_SPI_NFI_CNFG and REG_SPI_NFI_SECCUS_SIZE registers Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 11/13] spi: airoha: set custom sector size equal to flash page size Mikhail Kshevetskiy
2025-10-01 11:34 ` AngeloGioacchino Del Regno
2025-09-30 2:26 ` [PATCH RESEND v5 12/13] spi: airoha: avoid reading flash page settings from SNFI registers during driver startup Mikhail Kshevetskiy
2025-09-30 2:26 ` [PATCH RESEND v5 13/13] spi: airoha: buffer must be 0xff-ed before writing Mikhail Kshevetskiy
2025-10-01 11:30 ` AngeloGioacchino Del Regno
2025-10-01 22:13 ` Mikhail Kshevetskiy [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-09-17 21:58 [PATCH RESEND v5 00/13] spi: airoha: driver fixes & improvements Mikhail Kshevetskiy
2025-09-17 21:58 ` [PATCH RESEND v5 13/13] spi: airoha: buffer must be 0xff-ed before writing Mikhail Kshevetskiy
2025-09-04 14:23 [PATCH RESEND v5 00/13] spi: airoha: driver fixes & improvements Mikhail Kshevetskiy
2025-09-04 14:23 ` [PATCH RESEND v5 13/13] spi: airoha: buffer must be 0xff-ed before writing Mikhail Kshevetskiy
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=d13c09b5-5e9e-4d79-b94b-f3464831fefc@iopsys.eu \
--to=mikhail.kshevetskiy@iopsys.eu \
--cc=andreas.gnau@iopsys.eu \
--cc=andy@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=ray.liu@airoha.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;
as well as URLs for NNTP newsgroup(s).