From patchwork Tue May 2 06:28:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13228547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D71AC7EE2C for ; Tue, 2 May 2023 06:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233677AbjEBGup (ORCPT ); Tue, 2 May 2023 02:50:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233639AbjEBGul (ORCPT ); Tue, 2 May 2023 02:50:41 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6DB1997 for ; Mon, 1 May 2023 23:50:30 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230502065027epoutp017c747c8a66310599721055a112ad89eb~bQOKAw3HD2683226832epoutp01e for ; Tue, 2 May 2023 06:50:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230502065027epoutp017c747c8a66310599721055a112ad89eb~bQOKAw3HD2683226832epoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683010227; bh=SKfZujidrsTqsYmF1eZVH0aLq7NMqVnKheBQjJ2VIT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOvpUuFLrM7+fGPaobuPDVrjG+QIFxmHBL7Yx2TT2tuhk5Pu3gR5pZFl5z5Rf1RRD ZulRz7pfI0pN5Hn+SSwZ65iavFuou+hFtaUM7FIM6SgF1rjZa3doBAJDYSPIo0IDv4 wrtLvhEpOATWEN3KTzkzhg8Xju2FA9E+sq66hQuI= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230502065026epcas2p4d46573700cde0ba3673be225a1a0a5a3~bQOJhDFLB1117111171epcas2p4G; Tue, 2 May 2023 06:50:26 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.102]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Q9W1F6vpxz4x9QK; Tue, 2 May 2023 06:50:25 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id F9.9B.08199.1B2B0546; Tue, 2 May 2023 15:50:25 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20230502065025epcas2p11549db7400e6707c61bbb1cff1b22252~bQOIQqA191499014990epcas2p10; Tue, 2 May 2023 06:50:25 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230502065025epsmtrp237e89755b46524fb8662ca8adafd175e~bQOIP-WLO2944229442epsmtrp2N; Tue, 2 May 2023 06:50:25 +0000 (GMT) X-AuditID: b6c32a47-c29ff70000002007-fe-6450b2b1d88d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 34.C8.27706.1B2B0546; Tue, 2 May 2023 15:50:25 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.55]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230502065025epsmtip1aed5ec98fa8945164cb1bf16b0809bfe~bQOIE3KSD1524115241epsmtip1m; Tue, 2 May 2023 06:50:25 +0000 (GMT) From: Jaewon Kim To: Krzysztof Kozlowski , Andi Shyti , Mark Brown , Alim Akhtar Cc: linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chanho Park , Jaewon Kim Subject: [PATCH v3 2/3] spi: s3c64xx: add sleep during transfer Date: Tue, 2 May 2023 15:28:12 +0900 Message-Id: <20230502062813.112434-3-jaewon02.kim@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230502062813.112434-1-jaewon02.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPKsWRmVeSWpSXmKPExsWy7bCmue7GTQEpBuemG1s8mLeNzWLxj+dM FlMfPmGzuLxf22JHwxFWi72vt7JbbHp8jdXi8q45bBYzzu9jsmj8eJPdgcvj+pJPzB6bVnWy edy5tofNY/OSeo++LasYPT5vkgtgi8q2yUhNTEktUkjNS85PycxLt1XyDo53jjc1MzDUNbS0 MFdSyEvMTbVVcvEJ0HXLzAE6TEmhLDGnFCgUkFhcrKRvZ1OUX1qSqpCRX1xiq5RakJJTYF6g V5yYW1yal66Xl1piZWhgYGQKVJiQnfH1cWzBQ66Kd0cXszYw3uPoYuTkkBAwkTj99zxzFyMX h5DADkaJ3Y93QTmfGCWO/OlkgXC+MUo0zHvGCNMy/9tJRojEXkaJGasboZyPjBLLbneDVbEJ aEt8X7+YFSQhIrCYUWLB1Z3sIA6zwA1Gie43m1lAqoQF7CWO3z4FZrMIqEqsvXqBCcTmFbCT WH1zNxPEPnmJ1RsOMIPYnED195pawKZKCNxjl7jR9xrqKBeJ849eskHYwhKvjm9hh7ClJD6/ 2wsVz5Zon/6HFcKukLi4YTZU3Fhi1rN2oDkcQNdpSqzfpQ9iSggoSxy5BXYaswCfRMfhv+wQ YV6JjjYhiEY1iftTz0ENkZGYdGQl1MUeEr8uzIAG3SRGiSUv1zBOYJSbhbBgASPjKkax1ILi 3PTUYqMCY3iUJefnbmIEpzwt9x2MM95+0DvEyMTBeIhRgoNZSYT3Q6FfihBvSmJlVWpRfnx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8+f7rg6+vZZ068eXPTIP30+7B0WcYmm508tx4n3Sg9+3vJ v7OL1LjnnHgzfxKjjtK9sMxFlWudptzdsaRY+gGPaJzMR5UwnYW3pFdsmJNW/s7u6R8ppfO6 kQUBR9sEtdsPVIk9/huwuCU05kjEPL2inkdVFk2PA7oXLxNS99J7npIS9+iRh4lwjP3ZxuIj K4pFRN90ernmiR8+PE+4ZsJenfQt738dvRkixf5a7JTRLo50ryKGjA2nzzuq28yq1FWft/+x pqfP0XeGD72Ddll07/+qvYjN0Fc+SFWmkq1KeoYSS3FGoqEWc1FxIgDX9jshuwIAAA== X-CMS-MailID: 20230502065025epcas2p11549db7400e6707c61bbb1cff1b22252 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230502065025epcas2p11549db7400e6707c61bbb1cff1b22252 References: <20230502062813.112434-1-jaewon02.kim@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org 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 Reviewed-by: Krzysztof Kozlowski --- drivers/spi/spi-s3c64xx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 66ac94022a1b..2a8304678df9 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -561,11 +561,18 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, u32 cpy_len; u8 *buf; int ms; + unsigned long time_us; - /* millisecs to xfer 'len' bytes @ 'cur_speed' */ - ms = xfer->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);