Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp887820lqh; Thu, 28 Mar 2024 23:01:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViWSUbnMGa3KCEvR4McuZMpi9JKKzVKCzvqjjNgITwUqGARLy/8PW764H5/DexM1qfkGpiW6e4jK1CsVVZybYc4aPQuD93PO+g21+0/w== X-Google-Smtp-Source: AGHT+IFKfVv6A3tPA6mAMRlMcaywwuMSnSKKtd/Q4xxxjuG2WNbvhLQJYhBlrBr1BoEKyWUS1yFZ X-Received: by 2002:a17:902:f7cb:b0:1e0:d11c:7c3a with SMTP id h11-20020a170902f7cb00b001e0d11c7c3amr1298921plw.36.1711692098477; Thu, 28 Mar 2024 23:01:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711692098; cv=pass; d=google.com; s=arc-20160816; b=KK8iNu5WA80m+sWR7ZGa4cKH73fou9O1WenQoCMitM/T4S6FqeYf5F9llVyj6nhMDz Nng/BUIUyHpT0pwdR9L6vWjUsyOWehgcjTAq9IcnOU4QUc+bDN9uT0Tkb83anEstbBXN of2VZpVPeHQ1rIad8jHcxEHgSm8qWvGG0q8zpdwpTjb0b4bmwnv8tz6w4ONcpdQ9NeIB RyDx3Rfjkxi5+zxVkxoh/mZbDDBaXF4RE/YvjVHCM9q7JFzvkYDE2zqFAITwV5frVmIp JIbB+DBM5L+Ixg5o3Sv/wIWsM9IpYEdNBBs72tI7P2C+hUKUnZNn1E9Sx+A+sD+S/xpJ zffg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=1jZQnJj79swR2183Bur6/x2Cdu0g+Xgm+SPz3uqZYcg=; fh=ejy6R/13SzUHvDi+8kCNjUyHHe+LVmgJGhQfmEsUzyY=; b=Yb0C1nxfJ+heAeT6eZIsF3alEkXTS0HMbEpWiKQ+ZBJ1YjIlJuxj+H6jeUYciI7PRu CCz33dYeYOrys4L6XhzlKfDvyO/y2SIHTaH6HKww2xCMHRTCq796iGDcRxGCK+Z5yeXZ zvavULtD9ESTMK7R3M3+CHXzOa/yC53Ai4SRJOIb7u632DO8fGbg7XAm1V6LEs0B30HL a9ljxAsqL55jotNxP7cBgRnB0NuHqrlt6jUXbCUI1E+syEl9NrQ/LcqaVPVl1jqF1vQW cqf4lhameF9b16vmuqnGou61erTkyCFqGS5L+HcghkH96aUVCwguAVItwKUcKoDFe0yq nWKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1MmE03Z; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-124178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124178-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 e7-20020a170902784700b001e0e2c3f0b9si2892832pln.246.2024.03.28.23.01.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 23:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124178-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=@linaro.org header.s=google header.b=g1MmE03Z; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-124178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124178-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 D93CC289182 for ; Fri, 29 Mar 2024 06:01:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A10AF3D984; Fri, 29 Mar 2024 06:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g1MmE03Z" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20283D388 for ; Fri, 29 Mar 2024 06:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711692092; cv=none; b=fmlvPQbarZuIeVGiYbadpCfuYfU+X0QY9WlM9/3qQ83QmL6sXWWsC0ka1V60Qvr0uEmBlcEpbzyuEl60DkQB2e9+FDpeEXRQiOGOxjGS9Kf4Op9l8uVuGrRscgT0Kd8/cd42+L5VS46ZkhGpJ9De76lzEJ9fxImIE7SUnwfi550= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711692092; c=relaxed/simple; bh=eYhRwcbx0XWwpVC/UC0BiSKNkbAvIb8jgfQM087pM8E=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ya0Opgl4c5RM0LdVttEmwxuHPpo9E56aWLKYeRjWrN5A9ElvtgMr8P4/J7SYiNkMZTqbj2o1oE20LFkYXMcK9S1dF3YimtAwJwaxruVRuCM0aIs4ggoLsfYqKAStGpdL0Tylh4KTvTi1SWTMFpmJT2ejXXtLWWCgjiejhvz0GaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=g1MmE03Z; arc=none smtp.client-ip=209.85.219.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-dd10ebcd702so1704872276.2 for ; Thu, 28 Mar 2024 23:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711692088; x=1712296888; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1jZQnJj79swR2183Bur6/x2Cdu0g+Xgm+SPz3uqZYcg=; b=g1MmE03ZKyVxqTLg0LUNlhY9/dNPztW5qAuPDUSXyrtBWRnfaLzUw+3aCWLxY6jKui xs1bO0F4UWzIQ6CRT/nSUV+YdHNYVub7U5Bxd4Xd6MX28lJVeG1+WZYGv3g2ceeuvwUQ 0sqo7oyzr8VT9BkDBCkLVypO+kuVOUSUvDFUAMjaxCOUAqLVRB3webm0AUmt/OU/pS+2 mKEAS1BYTrCwv6KE/mUlnWChBD0e4+1VyKc/O3jBNrItbpTkrsQNhpPozQsL1i7ckTLD w3ScDZ+bEKXsezCeKTCX4x9AGO2CUiWRJ9YzcwXHMSeLB0zHP3bgU/Ih2rsK8oGhdq+K WQjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711692088; x=1712296888; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1jZQnJj79swR2183Bur6/x2Cdu0g+Xgm+SPz3uqZYcg=; b=vPyoa80A4Nbq0dRzJtkGUyvDKU16EK2RQsCGlFUu7JZNJISWG2fRqaD7XT1fETIE+6 lAMeZ3fE8H9nZqE5OB7BuWnB7pSxLDjwVIT3AxtBHCqM4XU49u9CryLLq6lskwvlb7IP EKzAo2B6PDkS9XRbpoFx68NofFXoOP+FKze9HYtNix/uCu43oAveDEcqpbDqNsQ9r8Ru FfOM1kDYjbqaMCpEApMyNTSYnOfBEkmoBwzwIh3sHA7dFCZQETecQmeEUAIY7cFNspPr JxQbUgHWzDFYQOD2QHl6hGTqfI2w1FN7uH1AIG1VicD5hOQUVxO/N4FXh24atP3CK3ex qtOw== X-Forwarded-Encrypted: i=1; AJvYcCU5tHjjTg1JO1dZnP4Dx4Zcl4jZioTXmqKfuG7VfPABbp8DqUxRaoerWu617nKwv4daXdEYlwPqCn/B++kZ2UK1KRtjK17wz0Q3YDG1 X-Gm-Message-State: AOJu0YwzW8gjXuVtnB8yVUAGuSBpazWxoTYl2OH+5fUAJip9uBBbOZyi k2s5hQiJn2IShA60cCzWTAAE4QzM6FWAZ/bzoXakgaj8RtP1tjVoWHcjr9ZTzFfkMyGrL2ZQUo9 UY56u42mPvVucWMsvvck+qrFHKZ7Cx3un1aTMEQ== X-Received: by 2002:a25:6d86:0:b0:dc2:2d75:5fde with SMTP id i128-20020a256d86000000b00dc22d755fdemr1372219ybc.29.1711692087927; Thu, 28 Mar 2024 23:01:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327033041.83625-1-jaewon02.kim@samsung.com> <63355869-e679-7226-7719-36b62169db7e@samsung.com> In-Reply-To: <63355869-e679-7226-7719-36b62169db7e@samsung.com> From: Sam Protsenko Date: Fri, 29 Mar 2024 01:01:16 -0500 Message-ID: Subject: Re: [PATCH] spi: s3c64xx: Use DMA mode from fifo size To: Jaewon Kim Cc: Andi Shyti , Mark Brown , Krzysztof Kozlowski , Alim Akhtar , linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 29, 2024 at 12:53=E2=80=AFAM Jaewon Kim wrote: > > Hi Sam, > > Thanks for your review. > > > On 3/29/24 02:58, Sam Protsenko wrote: > > On Tue, Mar 26, 2024 at 10:35=E2=80=AFPM Jaewon Kim wrote: > >> The SPI data size is smaller than FIFO, it operates in PIO mode, > > Spelling: "The" -> "If the" > > Thanks, I will fix it v2. > > >> and if it is larger than FIFO mode, DMA mode is selected. > >> > >> If the data size is the same as the FIFO size, it operates in PIO mode > >> and data is separated into two transfer. In order to prevent, > > Nit: "transfer" -> "transfers", "prevent" -> "prevent it" > > Thanks, I will fix it v2. > > >> DMA mode must be used from the case of FIFO and data size. > >> > > You probably mean this code (it occurs two times in the driver): > > > > xfer->len =3D fifo_len - 1; > > > > Can you please elaborate on why it's done this way? Why can't we just > > do "xfer->len =3D fifo_len" and use the whole FIFO for the transfer > > instead? I don't understand the necessity to split the transfer into > > two chunks if its size is of FIFO length -- wouldn't it fit into FIFO > > in that case? (I'm pretty sure this change is correct, just want to > > understand how exactly it works). > > In IRQ mode(S3C64XX_SPI_MODE_RX_RDY_LVL enable), TxOverrun/RxUnderrun > irq occurs when FIFO is full. > > To avoid FIFO full, it is transmitted in a smaller size than > fifo_len.(fifo-len - 1) > > However, in case of "fifo_len =3D=3D data size" "fifo_len - 1" byte + "1" > byte were transmitted separately. > > This problem can be solved by starting DMA transmission start size from > fifo_len. > Thanks for the explanation! Please feel free to add: Reviewed-by: Sam Protsenko > >> Fixes: 1ee806718d5e ("spi: s3c64xx: support interrupt based pio mode") > > Just wonder if that fixes some throughput regression, or something > > worse (like failed transfers when the transfer size is the same as > > FIFO size)? > > It is not a critical issue, but When I look at the actual waveform, it > seems strange that only the last 1-byte is transmitted separately. > > I thought it was "Fixes", but if not, I will remove it. > No no, I was just curious. "Fixes" is fine with me. > >> Signed-off-by: Jaewon Kim > >> --- > >> drivers/spi/spi-s3c64xx.c | 6 +++--- > >> 1 file changed, 3 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c > >> index 9fcbe040cb2f..81ed5fddf83e 100644 > >> --- a/drivers/spi/spi-s3c64xx.c > >> +++ b/drivers/spi/spi-s3c64xx.c > >> @@ -430,7 +430,7 @@ static bool s3c64xx_spi_can_dma(struct spi_control= ler *host, > >> struct s3c64xx_spi_driver_data *sdd =3D spi_controller_get_de= vdata(host); > >> > >> if (sdd->rx_dma.ch && sdd->tx_dma.ch) > >> - return xfer->len > sdd->fifo_depth; > >> + return xfer->len >=3D sdd->fifo_depth; > >> > >> return false; > >> } > >> @@ -826,11 +826,11 @@ static int s3c64xx_spi_transfer_one(struct spi_c= ontroller *host, > >> return status; > >> } > >> > >> - if (!is_polling(sdd) && (xfer->len > fifo_len) && > >> + if (!is_polling(sdd) && xfer->len >=3D fifo_len && > >> sdd->rx_dma.ch && sdd->tx_dma.ch) { > >> use_dma =3D 1; > >> > > Would be nice to remove this empty line, while at it. > Good, I will remove it also. > >> - } else if (xfer->len >=3D fifo_len) { > >> + } else if (xfer->len > fifo_len) { > > Below in the same function I can see similar code: > > > > if (target_len >=3D fifo_len) > > xfer->len =3D fifo_len - 1; > > > > Shouldn't that 'if' condition be fixed too? Or it's ok as it is? (Just > > noticed it by searching, not sure myself, hence asking). > > You are correct. This 'if' condition should not have been modified. > > >> tx_buf =3D xfer->tx_buf; > >> rx_buf =3D xfer->rx_buf; > >> origin_len =3D xfer->len; > >> -- > >> 2.43.2 > >> > >> > > Thanks > > Jaewon Kim >