From patchwork Tue May 2 06:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13228550 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 CC825C77B7E for ; Tue, 2 May 2023 06:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229569AbjEBGup (ORCPT ); Tue, 2 May 2023 02:50:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233635AbjEBGul (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 F18AB3A9F 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 20230502065027epoutp012e0a1287b5b5ac947ae5b9a470cf6631~bQOKDS1SH2708627086epoutp01D for ; Tue, 2 May 2023 06:50:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230502065027epoutp012e0a1287b5b5ac947ae5b9a470cf6631~bQOKDS1SH2708627086epoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683010227; bh=/zhDcDts5LBX2HV/3UzZnXw4YVjg9uzB6LOd9LsN6rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YSLTli2ccnyF0XCiccrYSVijYzIU3y3bJXBAj2Hegl68T1IaAJACxw8eIMKGPYbYZ CmwcSf8jTFPIzc3/YVHoa2h1tlJ+69u1Fw0S+Di62TvfXtpbuZTW5SZUNBMAIX2PVD Zgtsp5eUDKWeBmKfaYXvBT1LTeKtdlXQPhpO3Qes= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230502065026epcas2p3c3bbced9152859a716e6d108432f7e32~bQOJiEnwJ1371613716epcas2p3O; Tue, 2 May 2023 06:50:26 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.100]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Q9W1F6vkzz4x9Q6; Tue, 2 May 2023 06:50:25 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 39.9B.08199.1B2B0546; Tue, 2 May 2023 15:50:25 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20230502065025epcas2p4143c8ff3d44b7676ea8667c14618f2cd~bQOIKsCsr1117211172epcas2p4A; 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 20230502065025epsmtrp200b9f15f59b5d2422a3f2ee79378198c~bQOIJ-j0d2944229442epsmtrp2M; Tue, 2 May 2023 06:50:25 +0000 (GMT) X-AuditID: b6c32a47-e99fd70000002007-fd-6450b2b1a730 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E2.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 20230502065025epsmtip13f5f5d62791d4d87df09e34b99a140c0~bQOIAexil1675316753epsmtip1U; 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 1/3] spi: s3c64xx: change polling mode to optional Date: Tue, 2 May 2023 15:28:11 +0900 Message-Id: <20230502062813.112434-2-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+NgFnrHKsWRmVeSWpSXmKPExsWy7bCmqe7GTQEpBu/maVo8mLeNzWLxj+dM FlMfPmGzuLxf22JHwxFWi72vt7JbbHp8jdXi8q45bBYzzu9jsmj8eJPdgcvj+pJPzB6bVnWy edy5tofNY/OSeo++LasYPT5vkgtgi8q2yUhNTEktUkjNS85PycxLt1XyDo53jjc1MzDUNbS0 MFdSyEvMTbVVcvEJ0HXLzAE6TEmhLDGnFCgUkFhcrKRvZ1OUX1qSqpCRX1xiq5RakJJTYF6g V5yYW1yal66Xl1piZWhgYGQKVJiQndGwZwNzwQq+itlnr7E1MP7i7mLk5JAQMJFYsXotaxcj F4eQwA5GiTnH70E5nxglzv9oZYZwvjFK7H7zggWmZdWtdnaIxF5GiUfL1rGCJIQEPjJKvP/m AmKzCWhLfF+/GGyUiMBiRokFV3eCdTAL3GCU6H6zGWyUsICrxMLrVxhBbBYBVYmG26/A4rwC dhL7L8xkglgnL7F6wwFmEJtTwF7iXlML2FQJgUfsEucu90MVuUi0TvrGCGELS7w6voUdwpaS +PxuLxuEnS3RPv0PK4RdIXFxw2youLHErGftQL0cQNdpSqzfpQ9iSggoSxy5BXYOswCfRMfh v+wQYV6JjjYhiEY1iftTz0ENkZGYdGQl1DEeEgtvdzBCwmQSo8TOm5ITGOVmIcxfwMi4ilEs taA4Nz212KjAGB5jyfm5mxjBCU/LfQfjjLcf9A4xMnEwHmKU4GBWEuH9UOiXIsSbklhZl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GpHj///WWqs1d17ez29Lv9ToHxluWmQTVbrm6WTTMvPTIb8T POPzK93vqit4n3v4TZiLl/WvitCiM/F+G/rZbyaJxNUnOth2RO9m3aG01CiEmf+/n1nlFIvp q9MOqpabrcyS+P3TZuoi+2V1kvEpW6/XLJq1R0at51S8Q2rY8r89FrmbRA0THsZM+nMjTM09 OnV3y4ePbzvvv7jmlZe06/RDb5aaiP9yGsc7dsa+ynhwViHwP9OhNsVH9RHqOzaH511ZwR0f sb9tL5cZa9OHPQ8urd78x/BO6m3Tuo/cx3c3Xrq9ZuLtciWW4oxEQy3mouJEAAg5wce+AgAA X-CMS-MailID: 20230502065025epcas2p4143c8ff3d44b7676ea8667c14618f2cd X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230502065025epcas2p4143c8ff3d44b7676ea8667c14618f2cd References: <20230502062813.112434-1-jaewon02.kim@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Previously, Polling mode was supported as quirk for SOC without DMA. To provide more flexible support for polling mode, it changed to polling mode when the 'dmas' property is not present in the devicetree, rather than using a quirk. Signed-off-by: Jaewon Kim Reviewed-by: Krzysztof Kozlowski --- drivers/spi/spi-s3c64xx.c | 4 ++-- include/linux/platform_data/spi-s3c64xx.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 71d324ec9a70..66ac94022a1b 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -19,7 +19,6 @@ #include #define MAX_SPI_PORTS 12 -#define S3C64XX_SPI_QUIRK_POLL (1 << 0) #define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1) #define AUTOSUSPEND_TIMEOUT 2000 @@ -116,7 +115,7 @@ #define S3C64XX_SPI_TRAILCNT S3C64XX_SPI_MAX_TRAILCNT #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) -#define is_polling(x) (x->port_conf->quirks & S3C64XX_SPI_QUIRK_POLL) +#define is_polling(x) (x->cntrlr_info->polling) #define RXBUSY (1<<2) #define TXBUSY (1<<3) @@ -1068,6 +1067,7 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) } sci->no_cs = of_property_read_bool(dev->of_node, "no-cs-readback"); + sci->polling = !of_property_present(dev->of_node, "dmas"); return sci; } diff --git a/include/linux/platform_data/spi-s3c64xx.h b/include/linux/platform_data/spi-s3c64xx.h index 5df1ace6d2c9..cb7b8ddc899f 100644 --- a/include/linux/platform_data/spi-s3c64xx.h +++ b/include/linux/platform_data/spi-s3c64xx.h @@ -35,6 +35,7 @@ struct s3c64xx_spi_info { int src_clk_nr; int num_cs; bool no_cs; + bool polling; int (*cfg_gpio)(void); }; 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: 13228549 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 44A18C7EE25 for ; Tue, 2 May 2023 06:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233632AbjEBGuo (ORCPT ); Tue, 2 May 2023 02:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbjEBGuk (ORCPT ); Tue, 2 May 2023 02:50:40 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23D7230D6 for ; Mon, 1 May 2023 23:50:31 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230502065027epoutp04587310fe5f5e8aaddef84f0c8fe467af~bQOKAVahG2382823828epoutp04_ for ; Tue, 2 May 2023 06:50:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230502065027epoutp04587310fe5f5e8aaddef84f0c8fe467af~bQOKAVahG2382823828epoutp04_ 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 V5yYW1yal66Xl1piZWh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t7JbbHp8jdXi8q45bBYzzu9jsmj8eJPdgcvj+pJPzB6bVnWy edy5tofNY/OSeo++LasYPT5vkgtgi+KySUnNySxLLdK3S+DK+Po4tuAhV8W7o4tZGxjvcXQx cnJICJhIzP92khHEFhLYzSix7HgpRFxGYvmzPjYIW1jifssRVoia94wSt2Yog9hsAtoS39cv BopzcYgILGWUeLznMQuIwyxwj1Hi5aRvTCBVwgL2Esdvn2IBsVkEVCXWXr0AFucVsJNYfXM3 E8QGeYnVGw4wg9icQPX3mlqgttlJXOn9yjqBkW8BI8MqRsnUguLc9NxiwwLDvNRyveLE3OLS vHS95PzcTYzgwNTS3MG4fdUHvUOMTByMhxglOJiVRHg/FPqlCPGmJFZWpRblxxeV5qQWH2KU 5mBREue90HUyXkggPbEkNTs1tSC1CCbLxMEp1cBUcVa10fXQJFaB/98DVeuyp68tW7VIT26m a4Tj/sZLcWFG7ju8DhaKut+xYP8+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-spi@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); From patchwork Tue May 2 06:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13228548 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 374B4C77B7E for ; Tue, 2 May 2023 06:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233640AbjEBGul (ORCPT ); Tue, 2 May 2023 02:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233620AbjEBGug (ORCPT ); Tue, 2 May 2023 02:50:36 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002F33C3E for ; Mon, 1 May 2023 23:50:30 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230502065027epoutp032fb03e580e879995ae613893c16bb2c6~bQOJ57RJi3162831628epoutp03X for ; Tue, 2 May 2023 06:50:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230502065027epoutp032fb03e580e879995ae613893c16bb2c6~bQOJ57RJi3162831628epoutp03X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683010227; bh=iIRgxo8LLemVChWFJdSsgwuysWdI19wNyv7rZYtGkSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PCQ1KuGFfLF8K9cVeOvuUbOxD+ewhcaq/KB3QtLU1WEkFNxXj3jprb/VoKkS6DRgD RvEwx4ovjvSoagy6LORm0fOaNiYa8qTHMOpya+rMlRNMsHkpPd0EjPCiD7GRVm6Whu zksNjG68zXl8n98EK8+CMsB8OLU4bMXMJ8Mm3rlc= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230502065026epcas2p19d3c4a9ffab80125389881468bf943f4~bQOJbeGiJ1499014990epcas2p13; Tue, 2 May 2023 06:50:26 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.102]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Q9W1F6Yxlz4x9Pr; Tue, 2 May 2023 06:50:25 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id E6.37.03265.1B2B0546; Tue, 2 May 2023 15:50:25 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230502065025epcas2p34507ffad60b32e091ff0efeced9bc12f~bQOIUJipz2143821438epcas2p3l; Tue, 2 May 2023 06:50:25 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230502065025epsmtrp22a83b3b5088516b42321064eba2fca70~bQOITgfi72944229442epsmtrp2O; Tue, 2 May 2023 06:50:25 +0000 (GMT) X-AuditID: b6c32a45-465ff70000020cc1-a6-6450b2b11727 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id D5.F9.28392.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 20230502065025epsmtip1c6c2a0abc02ed57c2f18f0b465f0f417~bQOIJZaUO1675316753epsmtip1V; 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 3/3] spi: s3c64xx: support interrupt based pio mode Date: Tue, 2 May 2023 15:28:13 +0900 Message-Id: <20230502062813.112434-4-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+NgFnrHKsWRmVeSWpSXmKPExsWy7bCmue7GTQEpBtdaTCwezNvGZrH4x3Mm i6kPn7BZXN6vbbGj4Qirxd7XW9ktNj2+xmpxedcc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cYfFzkzzNAmWXhMy5PWm74mprxln7 LnpMmv1ndcOPSUosxRmJhlrMRcWJADigx3MBBAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNLMWRmVeSWpSXmKPExsWy7bCSnO7GTQEpBpc7pS0ezNvGZrH4x3Mm i6kPn7BZXN6vbbGj4Qirxd7XW9ktNj2+xmpxedccNosZ5/cxWTR+vMnuwOVxfcknZo9NqzrZ PO5c28PmsXlJvUffllWMHp83yQWwRXHZpKTmZJalFunbJXBlTL3SxlKwW73i/PttzA2M8+W7 GDk5JARMJJrePmDtYuTiEBLYwSgx9/sZFoiEjMTyZ31sELawxP2WI1BF7xklHt0F6eDkYBPQ lvi+fjFYQkRgKaPE4z2PWUAcZoF7jBIvJ31jAqkSFnCTePzuPVgHi4CqRHPHBjCbV8BO4v6E 5YwQK+QlVm84wAxicwrYS9xragGrEQKqudL7lXUCI98CRoZVjJKpBcW56bnFhgVGeanlesWJ ucWleel6yfm5mxjB4amltYNxz6oPeocYmTgYDzFKcDArifB+KPRLEeJNSaysSi3Kjy8qzUkt PsQozcGiJM57oetkvJBAemJJanZqakFqEUyWiYNTqoHJ3XCzzvuUPeI/+wUq7e9vXXYr8flN po0KFtVO6+0rOIKnaq867HLxZ+vy2qWvbq4uDVwtkJNQIKDiYNtfa3rNNIrfbxr7OaG5no6N 7XqRLcoTVXnSg6YJXlA/zZVrz26vrb1/t9Jv5me8dWsK33L4cntrO35cc0TaIfGJ+68DNpL+ PnybUv/Uu7aFebvZmpwN60p+O71CJlziAffd2JuWshMvZdWJzZuVv/e+sMlzLh8ml8dT1zvU 2Bl3V9kxB3Bf3XI8a45c5/PpyZf0Pu28sH76X870mboPK6pqph3boz7Z/2j8Xrvlu+7Gc4k/ vHbtO7frptnLPmhuSptdrOnCm762bsLsuGS5kx4dK5RYijMSDbWYi4oTAa9gPaC+AgAA X-CMS-MailID: 20230502065025epcas2p34507ffad60b32e091ff0efeced9bc12f X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230502065025epcas2p34507ffad60b32e091ff0efeced9bc12f References: <20230502062813.112434-1-jaewon02.kim@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Support interrupt based pio mode to optimize cpu usage. When transmitting data size is larget than 32 bytes, operates with interrupt based pio mode. By using the FIFORDY INT, an interrupt can be triggered when the desired size of data has been received. Using this, we can support interrupt based pio mode. Signed-off-by: Jaewon Kim Reported-by: Marek Szyprowski Tested-by: Marek Szyprowski --- drivers/spi/spi-s3c64xx.c | 66 ++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 2a8304678df9..323c6da9730b 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -58,6 +58,8 @@ #define S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD (1<<17) #define S3C64XX_SPI_MODE_BUS_TSZ_WORD (2<<17) #define S3C64XX_SPI_MODE_BUS_TSZ_MASK (3<<17) +#define S3C64XX_SPI_MODE_RX_RDY_LVL GENMASK(16, 11) +#define S3C64XX_SPI_MODE_RX_RDY_LVL_SHIFT 11 #define S3C64XX_SPI_MODE_SELF_LOOPBACK (1<<3) #define S3C64XX_SPI_MODE_RXDMA_ON (1<<2) #define S3C64XX_SPI_MODE_TXDMA_ON (1<<1) @@ -114,6 +116,8 @@ #define S3C64XX_SPI_TRAILCNT S3C64XX_SPI_MAX_TRAILCNT +#define S3C64XX_SPI_POLLING_SIZE 32 + #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) #define is_polling(x) (x->cntrlr_info->polling) @@ -552,7 +556,7 @@ static int s3c64xx_wait_for_dma(struct s3c64xx_spi_driver_data *sdd, } static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, - struct spi_transfer *xfer) + struct spi_transfer *xfer, bool use_irq) { void __iomem *regs = sdd->regs; unsigned long val; @@ -573,6 +577,12 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, if (RX_FIFO_LVL(status, sdd) < xfer->len) usleep_range(time_us / 2, time_us); + if (use_irq) { + val = msecs_to_jiffies(ms); + if (!wait_for_completion_timeout(&sdd->xfer_completion, val)) + return -EIO; + } + val = msecs_to_loops(ms); do { status = readl(regs + S3C64XX_SPI_STATUS); @@ -735,10 +745,13 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, void *rx_buf = NULL; int target_len = 0, origin_len = 0; int use_dma = 0; + bool use_irq = false; int status; u32 speed; u8 bpw; unsigned long flags; + u32 rdy_lv; + u32 val; reinit_completion(&sdd->xfer_completion); @@ -759,17 +772,46 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, sdd->rx_dma.ch && sdd->tx_dma.ch) { use_dma = 1; - } else if (xfer->len > fifo_len) { + } else if (xfer->len >= fifo_len) { tx_buf = xfer->tx_buf; rx_buf = xfer->rx_buf; origin_len = xfer->len; - target_len = xfer->len; - if (xfer->len > fifo_len) - xfer->len = fifo_len; + xfer->len = fifo_len - 1; } do { + /* transfer size is greater than 32, change to IRQ mode */ + if (xfer->len > S3C64XX_SPI_POLLING_SIZE) + use_irq = true; + + if (use_irq) { + reinit_completion(&sdd->xfer_completion); + + rdy_lv = xfer->len; + /* Setup RDY_FIFO trigger Level + * RDY_LVL = + * fifo_lvl up to 64 byte -> N bytes + * 128 byte -> RDY_LVL * 2 bytes + * 256 byte -> RDY_LVL * 4 bytes + */ + if (fifo_len == 128) + rdy_lv /= 2; + else if (fifo_len == 256) + rdy_lv /= 4; + + val = readl(sdd->regs + S3C64XX_SPI_MODE_CFG); + val &= ~S3C64XX_SPI_MODE_RX_RDY_LVL; + val |= (rdy_lv << S3C64XX_SPI_MODE_RX_RDY_LVL_SHIFT); + writel(val, sdd->regs + S3C64XX_SPI_MODE_CFG); + + /* Enable FIFO_RDY_EN IRQ */ + val = readl(sdd->regs + S3C64XX_SPI_INT_EN); + writel((val | S3C64XX_SPI_INT_RX_FIFORDY_EN), + sdd->regs + S3C64XX_SPI_INT_EN); + + } + spin_lock_irqsave(&sdd->lock, flags); /* Pending only which is to be done */ @@ -791,7 +833,7 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, if (use_dma) status = s3c64xx_wait_for_dma(sdd, xfer); else - status = s3c64xx_wait_for_pio(sdd, xfer); + status = s3c64xx_wait_for_pio(sdd, xfer, use_irq); if (status) { dev_err(&spi->dev, @@ -830,8 +872,8 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, if (xfer->rx_buf) xfer->rx_buf += xfer->len; - if (target_len > fifo_len) - xfer->len = fifo_len; + if (target_len >= fifo_len) + xfer->len = fifo_len - 1; else xfer->len = target_len; } @@ -1001,6 +1043,14 @@ static irqreturn_t s3c64xx_spi_irq(int irq, void *data) dev_err(&spi->dev, "TX underrun\n"); } + if (val & S3C64XX_SPI_ST_RX_FIFORDY) { + complete(&sdd->xfer_completion); + /* No pending clear irq, turn-off INT_EN_RX_FIFO_RDY */ + val = readl(sdd->regs + S3C64XX_SPI_INT_EN); + writel((val & ~S3C64XX_SPI_INT_RX_FIFORDY_EN), + sdd->regs + S3C64XX_SPI_INT_EN); + } + /* Clear the pending irq by setting and then clearing it */ writel(clr, sdd->regs + S3C64XX_SPI_PENDING_CLR); writel(0, sdd->regs + S3C64XX_SPI_PENDING_CLR);