From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F1BDC77B73 for ; Wed, 19 Apr 2023 15:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yLqPgDdCNNaEUtPSo+uDlPcdOSnUaE4v+tKQlN0eobg=; b=s9UE1mrDtq6TCFgn016IAK1Fsw 8WtOT/peFaZFzbcJPDO1H29T6i3MFxtNwEtDcjdpNN6vDjBmps40RNLDQCZIXAB36LH70ih+cMePP 7XAePrAmm17cJ3QA60uAdLZf/JqoDkiSb+YPCNeEENkfoAnwiW/W21VLLukdNILrcXV3bmyrS1HiI njrfHxTus9VZ8Rue1y6jmhFg0qKZBY2szPVtOpgy+ZqA+ArJKrk3qcg8XdL4IRU4nItakVGHeKtTG ThBihBSuwAJvVSJzTX/F/Ax0feXjO4bKB006GThWGq+zhCWO6DikjDfhaDmvGF8MlO80oBQY7hC/9 DS+bX2cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppAAU-005p8t-1M; Wed, 19 Apr 2023 15:56:26 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppAAR-005p8B-1I for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 15:56:24 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C4B6764092; Wed, 19 Apr 2023 15:56:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B6C6C433D2; Wed, 19 Apr 2023 15:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681919782; bh=nvxf91IZA13U9SiA5t6TZYEJqcyil96kcEWzpNxXu14=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gD1P+NCUTLvEthQmNMDGFVXxkRgXw0BrpxWV13ruufTKw7J0cIwFV88kLEdD0PBZA iIxux7K0TfFvgXUXMZT+v78W8zXKG6l5I3CKbUGclWuCDmOJFxHzlUUsS9Mr/IJeJT dsGNn1mPkYvDFMEcylhvo9ogJavWEodQBMMrILwpQCRyzhauVjl2wExBHRkuFcF+cn AUWPF52ZIHUOFLdgX6O1DMMV6ReR19fpG43rOmplpCyVkIYNgC+W/mT0CQdb5hTP4S 50zDONfIEtuiN0eeGeg6kBCq4zDfnWF8FAoQ+cHlvUJ2v8VIFwyA6Pgj+ejV7eWgnJ k7E1PZcbH3W/g== Date: Wed, 19 Apr 2023 17:56:17 +0200 From: Andi Shyti To: Jaewon Kim Cc: Krzysztof Kozlowski , Mark Brown , Andi Shyti , Alim Akhtar , linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chanho Park Subject: Re: [PATCH v2 3/4] spi: s3c64xx: add sleep during transfer Message-ID: <20230419155617.gobedupbdmdaj4kz@intel.intel> References: <20230419060639.38853-1-jaewon02.kim@samsung.com> <20230419060639.38853-4-jaewon02.kim@samsung.com> <9d2e2bda-4213-35d0-55d7-827bad9b13a1@samsung.com> MIME-Version: 1.0 In-Reply-To: <9d2e2bda-4213-35d0-55d7-827bad9b13a1@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_085623_538071_7E66777E X-CRM114-Status: GOOD ( 23.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============7345800821652840144==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============7345800821652840144== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lpnfxvg6q5y66f32" Content-Disposition: inline --lpnfxvg6q5y66f32 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Jaewon, > >> In polling mode, the status register is constantly read to check trans= fer > >> completion. It cause excessive CPU usage. > >> So, it calculates the SPI transfer time and made it sleep. > >> > >> Signed-off-by: Jaewon Kim > >> --- > >> 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_sp= i_driver_data *sdd, > >> u32 cpy_len; > >> u8 *buf; > >> int ms; > >> + u32 tx_time; > >> + > >> + /* sleep during signal transfer time */ > >> + status =3D readl(regs + S3C64XX_SPI_STATUS); > >> + if (RX_FIFO_LVL(status, sdd) < xfer->len) { > >> + tx_time =3D (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? >=20 > Yes, I already test it. >=20 > Throughput was the same, CPU utilization decreased to 30~40% from 100%. >=20 > Tested board is ExynosAutov9 SADK. >=20 >=20 > > > >> =20 > >> /* millisecs to xfer 'len' bytes @ 'cur_speed' */ > >> ms =3D 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 =3D ...' and just use ms without declaring any tx_time. Andi --lpnfxvg6q5y66f32 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQScDfrjQa34uOld1VLaeAVmJtMtbgUCZEAPIQAKCRDaeAVmJtMt bl9sAQD2KwYXJUe6dy2fLex4Y9UuGAihcSgb/Wa9N975crk9jwD+JUTSU1epIcx1 qB02nuF53TZR5uR0n1e5gKLxHeCCdgc= =45qL -----END PGP SIGNATURE----- --lpnfxvg6q5y66f32-- --===============7345800821652840144== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============7345800821652840144==--