lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 28 Mar 2024 12:58:07 -0500
From: Sam Protsenko <semen.protsenko@...aro.org>
To: Jaewon Kim <jaewon02.kim@...sung.com>
Cc: Andi Shyti <andi.shyti@...nel.org>, Mark Brown <broonie@...nel.org>, 
	Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>, Alim Akhtar <alim.akhtar@...sung.com>, 
	linux-spi@...r.kernel.org, linux-samsung-soc@...r.kernel.org, 
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] spi: s3c64xx: Use DMA mode from fifo size

On Tue, Mar 26, 2024 at 10:35 PM Jaewon Kim <jaewon02.kim@...sung.com> wrote:
>
> The SPI data size is smaller than FIFO, it operates in PIO mode,

Spelling: "The" -> "If the"

> 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"

> 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 = fifo_len - 1;

Can you please elaborate on why it's done this way? Why can't we just
do "xfer->len = 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).

> 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)?

> Signed-off-by: Jaewon Kim <jaewon02.kim@...sung.com>
> ---
>  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_controller *host,
>         struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
>
>         if (sdd->rx_dma.ch && sdd->tx_dma.ch)
> -               return xfer->len > sdd->fifo_depth;
> +               return xfer->len >= sdd->fifo_depth;
>
>         return false;
>  }
> @@ -826,11 +826,11 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host,
>                         return status;
>         }
>
> -       if (!is_polling(sdd) && (xfer->len > fifo_len) &&
> +       if (!is_polling(sdd) && xfer->len >= fifo_len &&
>             sdd->rx_dma.ch && sdd->tx_dma.ch) {
>                 use_dma = 1;
>

Would be nice to remove this empty line, while at it.

> -       } else if (xfer->len >= fifo_len) {
> +       } else if (xfer->len > fifo_len) {

Below in the same function I can see similar code:

            if (target_len >= fifo_len)
                xfer->len = 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).

>                 tx_buf = xfer->tx_buf;
>                 rx_buf = xfer->rx_buf;
>                 origin_len = xfer->len;
> --
> 2.43.2
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ