From: Jaewon Kim Date: Tue, 2 May 2023 06:28:12 +0000 (+0900) Subject: spi: s3c64xx: add sleep during transfer X-Git-Tag: v6.5-rc1~170^2~51^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3456674f54d3cfdedb28ce8a3db2b6f975392ac8;p=thirdparty%2Flinux.git spi: s3c64xx: add sleep during transfer In polling mode, the status register is continuously read to check data transfer completion. It can cause excessive CPU usage. To reduce this, we can calculate the transfer time and put the sleep during transfer. When test on ExynosAuto9 SADK board, throughput remained the same, but 100% CPU utilization decreased to 40%. Signed-off-by: Jaewon Kim len * 8 * 1000 / sdd->cur_speed; + /* microsecs to xfer 'len' bytes @ 'cur_speed' */ + time_us = (xfer->len * 8 * 1000 * 1000) / sdd->cur_speed; + ms = (time_us / 1000); ms += 10; /* some tolerance */ + /* sleep during signal transfer time */ + status = readl(regs + S3C64XX_SPI_STATUS); + if (RX_FIFO_LVL(status, sdd) < xfer->len) + usleep_range(time_us / 2, time_us); + val = msecs_to_loops(ms); do { status = readl(regs + S3C64XX_SPI_STATUS);