spi: axi-spi-engine: move message compile to optimize_message
authorDavid Lechner <dlechner@baylibre.com>
Mon, 19 Feb 2024 22:33:21 +0000 (16:33 -0600)
committerMark Brown <broonie@kernel.org>
Mon, 26 Feb 2024 13:55:12 +0000 (13:55 +0000)
commit7dba2adb063bcf7a293eacb88980e0975b1fb1fd
treead308f46ee9df62f0c201a25b918ccb94088f778
parentc2bcfe7c6edf418d5adf731a7d60a8abd81e952f
spi: axi-spi-engine: move message compile to optimize_message

In the AXI SPI Engine driver, compiling the message is an expensive
operation. Previously, it was done per message transfer in the
prepare_message hook. This patch moves the message compile to the
optimize_message hook so that it is only done once per message in
cases where the peripheral driver calls spi_optimize_message().

This can be a significant performance improvement for some peripherals.
For example, the ad7380 driver saw a 13% improvement in throughput
when using the AXI SPI Engine driver with this patch.

Since we now need two message states, one for the optimization stage
that doesn't change for the lifetime of the message and one that is
reset on each transfer for managing the current transfer state, the old
msg->state is split into msg->opt_state and spi_engine->msg_state. The
latter is included in the driver struct now since there is only one
current message at a time that can ever use it and it is in a hot path
so avoiding allocating a new one on each message transfer saves a few
cpu cycles and lets us get rid of the prepare_message callback.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://msgid.link/r/20240219-mainline-spi-precook-message-v2-4-4a762c6701b9@baylibre.com
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-axi-spi-engine.c