linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Mark Brown" <broonie@kernel.org>,
	"Martin Sperl" <kernel@martin.sperl.org>,
	"David Jander" <david@protonic.nl>,
	"Michael Hennerich" <michael.hennerich@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Alain Volmat" <alain.volmat@foss.st.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org,
	"Julien Stephan" <jstephan@baylibre.com>
Subject: Re: [PATCH v2 3/5] spi: stm32: move splitting transfers to optimize_message
Date: Sat, 24 Feb 2024 16:45:58 +0000	[thread overview]
Message-ID: <20240224164558.02c08dd6@jic23-huawei> (raw)
In-Reply-To: <20240219-mainline-spi-precook-message-v2-3-4a762c6701b9@baylibre.com>

On Mon, 19 Feb 2024 16:33:20 -0600
David Lechner <dlechner@baylibre.com> wrote:

> Since splitting transfers was moved to spi_optimize_message() in the
> core SPI code, we now need to use the optimize_message callback in the
> STM32 SPI driver to ensure that the operation is only performed once
> when spi_optimize_message() is used by peripheral drivers explicitly.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Trivial comment inline. Otherwise LGTM
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

There are changes to when this happens wrt to locking but I think those
are all positive as the bus lock is held for less time and there
is nothing in here that needs that lock held.
> ---
> 
> v2 changes: none
> 
>  drivers/spi/spi-stm32.c | 28 ++++++++++++++++------------
>  1 file changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
> index c32e57bb38bd..e4e7ddb7524a 100644
> --- a/drivers/spi/spi-stm32.c
> +++ b/drivers/spi/spi-stm32.c
> @@ -1118,6 +1118,21 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> +static int stm32_spi_optimize_message(struct spi_message *msg)
> +{
> +	struct spi_controller *ctrl = msg->spi->controller;
> +	struct stm32_spi *spi = spi_controller_get_devdata(ctrl);
> +
> +	/* On STM32H7, messages should not exceed a maximum size set
If you spin a v3, this isn't in keeping with local comment style.

	/*
 	 * On...

> +	 * later via the set_number_of_data function. In order to
> +	 * ensure that, split large messages into several messages
> +	 */
> +	if (spi->cfg->set_number_of_data)
> +		return spi_split_transfers_maxwords(ctrl, msg, spi->t_size_max);
> +
> +	return 0;
> +}
> +
>  /**
>   * stm32_spi_prepare_msg - set up the controller to transfer a single message
>   * @ctrl: controller interface
> @@ -1163,18 +1178,6 @@ static int stm32_spi_prepare_msg(struct spi_controller *ctrl,
>  		!!(spi_dev->mode & SPI_LSB_FIRST),
>  		!!(spi_dev->mode & SPI_CS_HIGH));
>  
> -	/* On STM32H7, messages should not exceed a maximum size setted
> -	 * afterward via the set_number_of_data function. In order to
> -	 * ensure that, split large messages into several messages
> -	 */
> -	if (spi->cfg->set_number_of_data) {
> -		int ret;
> -
> -		ret = spi_split_transfers_maxwords(ctrl, msg, spi->t_size_max);
> -		if (ret)
> -			return ret;
> -	}
> -
>  	spin_lock_irqsave(&spi->lock, flags);
>  
>  	/* CPOL, CPHA and LSB FIRST bits have common register */
> @@ -2180,6 +2183,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
>  	ctrl->max_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_min;
>  	ctrl->min_speed_hz = spi->clk_rate / spi->cfg->baud_rate_div_max;
>  	ctrl->use_gpio_descriptors = true;
> +	ctrl->optimize_message = stm32_spi_optimize_message;
>  	ctrl->prepare_message = stm32_spi_prepare_msg;
>  	ctrl->transfer_one = stm32_spi_transfer_one;
>  	ctrl->unprepare_message = stm32_spi_unprepare_msg;
> 


  reply	other threads:[~2024-02-24 16:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 22:33 [PATCH v2 0/5] spi: add support for pre-cooking messages David Lechner
2024-02-19 22:33 ` [PATCH v2 1/5] spi: add spi_optimize_message() APIs David Lechner
2024-02-20 10:50   ` Nuno Sá
2024-02-24 16:36   ` Jonathan Cameron
2024-02-24 18:15   ` Markus Elfring
2024-02-24 20:09   ` Markus Elfring
2024-02-26 13:48   ` Mark Brown
2024-02-19 22:33 ` [PATCH v2 2/5] spi: move splitting transfers to spi_optimize_message() David Lechner
2024-02-20 10:52   ` Nuno Sá
2024-02-19 22:33 ` [PATCH v2 3/5] spi: stm32: move splitting transfers to optimize_message David Lechner
2024-02-24 16:45   ` Jonathan Cameron [this message]
2024-02-19 22:33 ` [PATCH v2 4/5] spi: axi-spi-engine: move message compile " David Lechner
2024-02-20 10:45   ` Nuno Sá
2024-02-24 16:51   ` Jonathan Cameron
2024-02-19 22:33 ` [PATCH v2 5/5] iio: adc: ad7380: use spi_optimize_message() David Lechner
2024-02-20 10:41   ` Nuno Sá
2024-02-24 16:57   ` Jonathan Cameron
2024-02-27 16:36     ` David Lechner
2024-02-26 19:16 ` (subset) [PATCH v2 0/5] spi: add support for pre-cooking messages Mark Brown
2024-06-28  9:49 ` Oleksij Rempel
2024-06-28 10:16   ` Marc Kleine-Budde
2024-06-28 15:27     ` David Lechner
2024-06-28 17:47       ` Oleksij Rempel
2024-07-01  6:55       ` Oleksij Rempel
2024-06-28 12:17   ` Mark Brown

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=20240224164558.02c08dd6@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=broonie@kernel.org \
    --cc=david@protonic.nl \
    --cc=dlechner@baylibre.com \
    --cc=jstephan@baylibre.com \
    --cc=kernel@martin.sperl.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.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).