From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59A60C48BF6 for ; Sat, 24 Feb 2024 16:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j99EoM1pHNh4y1qkZAdw2+yGwUi+b64qgQM2OkTqwKo=; b=T1Ay3gLCnpIV6j AVk/v4CkVx/qYMM9cchbTssvWMXHgg657JhYoJP983rYX90LGeCF/oryErai1vg7eAOPV5ej7govM agNAXvzsdjONgxWp7/GBr3HMBkteADkMaJM1X7qAcH+wT0WRPVpx4arm4YFi3gG6WYZjejjrEcj4L EgFeNN1P1r+A31yoQA4NBl+Y4TNdzZ6L2MxeVPddFaeFnPgVdyTYSeZNuah9Cq5gpyj4PoM8/46nK 52Kx2Oqa46GpB1X82V3zeMxxolDkLHlJKf75KOW3wbGEvsdySOhmdblu85AU4vWG7eNCG9p9+u0bL oQGcYDWtPybJz6TJLRSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdvAY-0000000DG01-3qsD; Sat, 24 Feb 2024 16:46:34 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdvAF-0000000DFwb-2U4N for linux-arm-kernel@lists.infradead.org; Sat, 24 Feb 2024 16:46:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C189260670; Sat, 24 Feb 2024 16:46:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A26BAC433C7; Sat, 24 Feb 2024 16:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708793173; bh=WaKeKGy3+AF4oMDKya6UkKp1ld9MGGhzhz+ajHDtjFc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sCpS1cF2awDasZbSEsLJF6vVo4oVuvqCFRX13QH+EjHLvT/ZZdg3IIsXWlcUEeq97 EKsyA12cR4Rv/ozAsb9nnfotGtHc6Ud575Lz2ExhqHXxjbn9DK0M6xMue5cjdQVOvl xm2L+4SchwINHBhZdpCfOjG6i+al2GhLrp5iASavPkefQqaGFzxIs4Bb2w2hNyZYE9 yiUazsnN3yt9mkVadOdOtj8xNhPu97mCE+OpKlR5VyQUmKNoVLGgZ8yP3P6HiTGYxc V8BwkAGT8dhp03Z6ss49FiKfZRq4YsjOWtHHj1+e7SMUUkugmebvxq6rX+KnVyltuy QGJAQ6eD8k0Bg== Date: Sat, 24 Feb 2024 16:45:58 +0000 From: Jonathan Cameron To: David Lechner Cc: Mark Brown , Martin Sperl , David Jander , Michael Hennerich , Nuno =?UTF-8?B?U8Oh?= , Alain Volmat , Maxime Coquelin , Alexandre Torgue , 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 Subject: Re: [PATCH v2 3/5] spi: stm32: move splitting transfers to optimize_message Message-ID: <20240224164558.02c08dd6@jic23-huawei> In-Reply-To: <20240219-mainline-spi-precook-message-v2-3-4a762c6701b9@baylibre.com> References: <20240219-mainline-spi-precook-message-v2-0-4a762c6701b9@baylibre.com> <20240219-mainline-spi-precook-message-v2-3-4a762c6701b9@baylibre.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240224_084629_677443_5AA5E376 X-CRM114-Status: GOOD ( 25.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 19 Feb 2024 16:33:20 -0600 David Lechner 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 Trivial comment inline. Otherwise LGTM Reviewed-by: Jonathan Cameron 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; > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel