Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp483525rbb; Sat, 24 Feb 2024 08:46:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW6uIoMtG/5VL4ketk+yd/iHfsWk/n7ntMsvDiRNoOzWde9Op5F+KbvxrMqnwpL+0G7rcO7QiBXdoxbQbKIhpihEkT64ntP5kGhPnZYSQ== X-Google-Smtp-Source: AGHT+IFHu0meNEA1Ixpa2VQ/raMuTk+OCMbsVKziFQGGR9NxXGCpAatQUxvp6pVTdzICSzMvRbh0 X-Received: by 2002:a17:902:f690:b0:1dc:5dc0:9ba with SMTP id l16-20020a170902f69000b001dc5dc009bamr3480720plg.26.1708793184979; Sat, 24 Feb 2024 08:46:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708793184; cv=pass; d=google.com; s=arc-20160816; b=SUfC749DYg7R2WnpWhiwqKws9skuMj6Ghjtqmy1dvzitPhTvZlen4Ip42iI3idaabP XrCLZrS4GUEQcoP1QOLgzpApcrEFqmyjfUHyOMjnTi2hNKqAPDxBli+S+saKSro/qH4w e0FhnbKIYhX9W96ARUjw0CcyrAL/JcirTMMYCUJDaO2IQ3xnuHWEP+3f2I1YsM94QBPJ W9n0KHtqRyAXhrXsxqwx59VirHHDlT6qjiIgKxczHoKbUVW4lyA3LvaDhirJn4fV6U6n oWpS2UPorjx5UJUtbB7EgXlrxhNbuu9BA3TXs9P9Xb04zfefqBDaSDC3EIEfWAlK3hJc Zseg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=j+777g5zISrLheyjDSlv4VlVZGSPd/Xv7fzsqdQlPbA=; fh=myIfp5tOnTt1AThiPeO8alwqqrU/Bxpzh7s0b6bjsJA=; b=KpaAo5OYAUB/E7+GdG1zO+BpsEbRVHZPdi8qu+a8bXxO+nBry472nV5dbKuVSyhK7m RTz6Ni7jOAXqwn5Xah/dH65q9jLEZ5hjaCddKttzCaxnTUPXUSk0QheElI1aPTr23BOo uhpOp1i+vYWfZwEDGJWU/wgcV51pYLJgaqwtW/5joqxr7eJy9/irHdpTv6Q8Um3EM0My 4If6dOYm9b9Pr+i0S+RTT43IFNtjhijfZcSVWmRrQmzKCVQDojqtn7KgOMjyD1A+y+r3 56yXMZc18uYyA9PM4J5Bm4NgNt6H4NQmlNgy5OCWBFr5WZhsumEvZmJrHfeJFxqt8pao nIiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCpS1cF2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79741-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79741-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g7-20020a170902740700b001db730d3f16si976768pll.621.2024.02.24.08.46.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 08:46:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79741-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCpS1cF2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79741-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79741-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7297A2831EC for ; Sat, 24 Feb 2024 16:46:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CAB6140BFE; Sat, 24 Feb 2024 16:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sCpS1cF2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAA1A14B820; Sat, 24 Feb 2024 16:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708793174; cv=none; b=Z3RBXwPp6T930hdCrCicnCat3GrhFU1anxNwJ9chmJcoJmJGo4/IMmECwOIXCtizfMbN7YcW/788lkThbGNuYB7ztOShZT53gxS67jMQdxMiEyrvvoV0muIdm60pE8qkyNLQ/Pagj5gi5MMgRwRSxomB1huFJZO+4Fa/iTj241I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708793174; c=relaxed/simple; bh=WaKeKGy3+AF4oMDKya6UkKp1ld9MGGhzhz+ajHDtjFc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=npl+UfB6Yc2AIUkwYtr5CXdJL3kd41ir4pBotqk2uTUzQrjIWy9FC/HpnFhCI+1WqKh50W84Hnn4m0cOohqTO+uLypNxMh8pE9vj6BGvNzys3d11cNIo830RlbYkUeA6BO+4TRqq6K+XZWlfX9n4XrNpyFBUTi1yG0l+Eb3ZUWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sCpS1cF2; arc=none smtp.client-ip=10.30.226.201 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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; >