• David Lechner's avatar
    spi: axi-spi-engine: move message compile to optimize_message · 7dba2adb
    David Lechner authored
    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: default avatarDavid Lechner <dlechner@baylibre.com>
    Link: https://msgid.link/r/20240219-mainline-spi-precook-message-v2-4-4a762c6701b9@baylibre.comReviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    7dba2adb
spi-axi-spi-engine.c 18.2 KB