[PATCH v6 13/13] spi: airoha: buffer must be 0xff-ed before writing

Mikhail Kshevetskiy posted 13 patches 4 months, 1 week ago
There is a newer version of this series
[PATCH v6 13/13] spi: airoha: buffer must be 0xff-ed before writing
Posted by Mikhail Kshevetskiy 4 months, 1 week ago
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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c
index 437ab6745b1a..8408aee9c06e 100644
--- a/drivers/spi/spi-airoha-snfi.c
+++ b/drivers/spi/spi-airoha-snfi.c
@@ -776,7 +776,11 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem_dirmap_desc *desc,
 		return -EOPNOTSUPP;
 	}
 
+	if (offs > 0)
+		memset(txrx_buf, 0xff, offs);
 	memcpy(txrx_buf + offs, buf, len);
+	if (bytes > offs + len)
+		memset(txrx_buf + offs + len, 0xff, bytes - offs - len);
 
 	err = airoha_snand_set_mode(as_ctrl, SPI_MODE_DMA);
 	if (err < 0)
-- 
2.51.0
Re: [PATCH v6 13/13] spi: airoha: buffer must be 0xff-ed before writing
Posted by AngeloGioacchino Del Regno 4 months, 1 week ago
Il 02/10/25 00:23, 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>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Re: [PATCH v6 13/13] spi: airoha: buffer must be 0xff-ed before writing
Posted by Mikhail Kshevetskiy 4 months ago
Is there any chances get it merged to linux-6.18?

Regards,
Mikhail Kshevetskiy

On 02.10.2025 10:44, AngeloGioacchino Del Regno wrote:
> Il 02/10/25 00:23, 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>
>
> Reviewed-by: AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com>
>
>