fpga: microchip-spi: move SPI I/O buffers out of stack
authorIvan Bornyakov <i.bornyakov@metrotek.ru>
Fri, 30 Dec 2022 09:29:20 +0000 (12:29 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:34 +0000 (09:33 +0100)
commite9ed12b8c7f7a9c587a0243a29d89d2674e85e0e
tree2d81d9b8fd73fd043bba85112769c37830446c73
parentd937ab794b8d432bdd024ec76b1bbdd1184579fe
fpga: microchip-spi: move SPI I/O buffers out of stack

[ Upstream commit 1da53d23a41c5f77963984d8da5623ed56918ada ]

As spi-summary doc says:
 > I/O buffers use the usual Linux rules, and must be DMA-safe.
 > You'd normally allocate them from the heap or free page pool.
 > Don't use the stack, or anything that's declared "static".

Replace spi_write() with spi_write_then_read(), which is dma-safe for
on-stack buffers. Use cacheline aligned buffers for transfers used in
spi_sync_transfer().

Although everything works OK with stack-located I/O buffers, better
follow the doc to be safe.

Fixes: 5f8d4a900830 ("fpga: microchip-spi: add Microchip MPF FPGA manager")
Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20221230092922.18822-2-i.bornyakov@metrotek.ru
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/fpga/microchip-spi.c