Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp490739rwr; Wed, 19 Apr 2023 09:06:42 -0700 (PDT) X-Google-Smtp-Source: AKy350b99sJf/ATE1821N5fSuQlTmflRq54MooY2K9tJFqHjLvlw2teddgoAcxCDH0jZS2G0p556 X-Received: by 2002:a17:90a:5a82:b0:23f:83de:7e4a with SMTP id n2-20020a17090a5a8200b0023f83de7e4amr3464284pji.7.1681920402301; Wed, 19 Apr 2023 09:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681920402; cv=none; d=google.com; s=arc-20160816; b=EXfg3t4pHHOZK6jQa5aK4XkFSHCTvH++cORWIZb0kALzijHIgL2zS9Q71/wQFLjGoy MSb7iB38Gtrt/ePVi1yBjxEF0C9tPSr1Ryek9HJw2vW4Tnd9PX2/VD5aMEeZYpNtcKaj YSjF6MvBBEQgapEtyW1rKyoNXL9G5OTA0ff8ZphGEEYSPfVvOw0DT1QJAhInQXrEdEJK YcC7Cx809Ae5V6qW9+eBwqPvwL70CYxn4OWil+B+Ch8D6EV2NKmK27i2pOvMwpDQ983I 672Z/Ggkz7vpPckaRrIxvAHqMvqxWa6i2Hw4KrD2aYQW+2OHgtQ7vSUJu0McWD0LG1ty FAtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j8lxUxIGyKXooA3sAvfsXIhOIe8B4yi2DsolzbHMSvQ=; b=Vq6H4GTBNLuxeTlve6y+xDRSh+GxpLq00wcyCahAI8GjTLkpt2sUDhcwAF3ua6I+fj E46xflB8QfBKQxJhNAykDNjl9yvnacMSu5EXWVczPQdnDSivtwrSd0jcZ3u7/LWlCUSM cDT+8LoZ9Kr3TG7luhsq6C7+q8lNhsc/U5+RnP2rVCZ37tvWCavHPDAx6YQV7UIMiZng L0PJ0DhxWjdEKjAesRe9CvO6kdpT/A7RLZWDZ5xdlKESHzjC4R6hCi1IFXTywCI5rhFY z7XMAkPs2OjX+22aXTlD5ULQOVoa6V/9ZwKFfeFlngLv+VZNkc4cOW4m4BBXTYVtzzuq j/0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gD1P+NCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk17-20020a17090b4a1100b0022c9cb7662csi2204625pjb.159.2023.04.19.09.06.19; Wed, 19 Apr 2023 09:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gD1P+NCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233693AbjDSP4Z (ORCPT + 99 others); Wed, 19 Apr 2023 11:56:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233025AbjDSP4Y (ORCPT ); Wed, 19 Apr 2023 11:56:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3EA2721; Wed, 19 Apr 2023 08:56:23 -0700 (PDT) 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 CE9DE64093; 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 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lpnfxvg6q5y66f32" Content-Disposition: inline In-Reply-To: <9d2e2bda-4213-35d0-55d7-827bad9b13a1@samsung.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --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--