[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230419155617.gobedupbdmdaj4kz@intel.intel>
Date: Wed, 19 Apr 2023 17:56:17 +0200
From: Andi Shyti <andi.shyti@...nel.org>
To: Jaewon Kim <jaewon02.kim@...sung.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Mark Brown <broonie@...nel.org>, Andi Shyti <andi@...zian.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,
Chanho Park <chanho61.park@...sung.com>
Subject: Re: [PATCH v2 3/4] spi: s3c64xx: add sleep during transfer
Hi Jaewon,
> >> In polling mode, the status register is constantly read to check transfer
> >> completion. It cause excessive CPU usage.
> >> So, it calculates the SPI transfer time and made it sleep.
> >>
> >> Signed-off-by: Jaewon Kim <jaewon02.kim@...sung.com>
> >> ---
> >> drivers/spi/spi-s3c64xx.c | 8 ++++++++
> >> 1 file changed, 8 insertions(+)
> >>
> >> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> >> index 886722fb40ea..cf3060b2639b 100644
> >> --- a/drivers/spi/spi-s3c64xx.c
> >> +++ b/drivers/spi/spi-s3c64xx.c
> >> @@ -561,6 +561,14 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd,
> >> u32 cpy_len;
> >> u8 *buf;
> >> int ms;
> >> + u32 tx_time;
> >> +
> >> + /* sleep during signal transfer time */
> >> + status = readl(regs + S3C64XX_SPI_STATUS);
> >> + if (RX_FIFO_LVL(status, sdd) < xfer->len) {
> >> + tx_time = (xfer->len * 8 * 1000 * 1000) / sdd->cur_speed;
> >> + usleep_range(tx_time / 2, tx_time);
> >> + }
> > Did you actually check the delays introduced by it? Is it worth?
>
> Yes, I already test it.
>
> Throughput was the same, CPU utilization decreased to 30~40% from 100%.
>
> Tested board is ExynosAutov9 SADK.
>
>
> >
> >>
> >> /* millisecs to xfer 'len' bytes @ 'cur_speed' */
> >> ms = xfer->len * 8 * 1000 / sdd->cur_speed;
> > You have now some code duplication so this could be combined.
you could put the 'if' under the 'ms = ...' and just use ms
without declaring any tx_time.
Andi
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists