Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1027578pxa; Sat, 22 Aug 2020 08:23:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0UIF6pVwjRi2U7CD6MKMQwnKspyj7Q/prNiOcrj4CD5hFf7l4miqqm8Eb1SP1jT/cxrgU X-Received: by 2002:a17:906:d8ca:: with SMTP id re10mr7488314ejb.382.1598109797056; Sat, 22 Aug 2020 08:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598109797; cv=none; d=google.com; s=arc-20160816; b=Vg/2KH4vldtBD4mKRU9QsPFywhg5lands+ILYoKiHwS0+ipPbkwmMuAb9anVEOCrIa hOCWI6SzAU9Qw6wrp4D1ASXZtZczrcqhORKPoeLVL7h/xHRqN4hxxgQy6gmJveauXUDI cnMOD6ysvkx/YxxVmkOId+rXnWzWhIAuMOmwjAUu0XElvsPkg4s+eENbmx7jMU1b5zik Ta/bq17nYuUoMTWhX2D1Q9oSObfQtMEo2rucygFGCE2ICVgrx9vsdt19ZZUsMjvnj/nI xi31OH3v1WVr8PHnARC7wxdZ52tmXqHq1bbeWlQOvmwDfxCEy3wTcnicAoWZBj4FhtVp ovFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=6enseNefIYCoSc9Z/eFgNoSzH2vP44sXuQdpzeOFiK8=; b=XDfC5BHpwlfSfQwqNWt7MlKpAfSYO/lLSahJHeMTm8VmTILTMO9M/UPi6AvoMeeExr wmoyerfEAKvIS88WEU07NO+yrkZNZ//qTHab3LHouvvMICNdzfIzu7AW0SznSaJPwryj 5x8tGMNmvzwEDdnq9Hp5OUX9COVxs6S5xwS26YqV06js2ofbwRJReTdyPX/9DtAxofxX E432So2OhSV+fe3WCl0ykLAx0c+7g+0K0fE63fTzr351uFSYAG/AGnlvusLhNimts1IY yQLuT5jc1d+oLRnPkh21zHmYmU5LrS0YSa5tjrlbDiaV/GrcvcIS/WKZ+6KYRkTLATBF EsJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si3454554edr.10.2020.08.22.08.22.53; Sat, 22 Aug 2020 08:23:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728138AbgHVPSr convert rfc822-to-8bit (ORCPT + 99 others); Sat, 22 Aug 2020 11:18:47 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39827 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727807AbgHVPSp (ORCPT ); Sat, 22 Aug 2020 11:18:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id a5so4567744wrm.6; Sat, 22 Aug 2020 08:18:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=fPurPcq4qIlsFmVZToY8qZyZV/HXm+35zPSjztTMBbk=; b=RnHBy8FoT6Z6vtdD4wKfJaNHSVPsg4CvGvsOy/FAascPpMTGFY438NYgVrT+clquCY 5zKgykQGAXd3WLMcDv7b1Zp8KxvuF3PjAvgEnjF/q+WQLatvdJvPDmlFimLpQRDBz4Pg 03zomDg/gzdAFQtdFz8nkRQpaRYUIBXwipjXjQeTgy3lx5s9mpyCjTi4dpiFlF/H3+Q2 ZB7FeFnsFVkMG0f1UZJy4lJjjKDVSVq6qc8juoyfiz0P/wCzZ9pIyR2EocrmEvYFSGEY RVjZWdmW1uyh98Vj4C4cHGrgSjbx+ZYsSiFb4rfZNdrGYSzLkSSGBd5HBb8wYHhBAVES uqPw== X-Gm-Message-State: AOAM532T1qkDrwy7WF7qxKlxDF5r5xu4gTNrpPgTxb522aW1o15+gHFT 6ZbymATerxUhDdTuSkEHjcg= X-Received: by 2002:adf:fac8:: with SMTP id a8mr7477185wrs.368.1598109523037; Sat, 22 Aug 2020 08:18:43 -0700 (PDT) Received: from kozik-lap ([194.230.155.216]) by smtp.googlemail.com with ESMTPSA id m16sm10738841wrr.71.2020.08.22.08.18.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Aug 2020 08:18:42 -0700 (PDT) Date: Sat, 22 Aug 2020 17:18:19 +0200 From: Krzysztof Kozlowski To: Tomasz Figa Cc: =?utf-8?Q?=C5=81ukasz?= Stelmach , Kukjin Kim , Andi Shyti , Mark Brown , linux-spi@vger.kernel.org, linux-samsung-soc , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Linux Kernel Mailing List , Marek Szyprowski , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH v2 7/9] spi: spi-s3c64xx: Ensure cur_speed holds actual clock value Message-ID: <20200822151819.GA13668@kozik-lap> References: <20200821161401.11307-1-l.stelmach@samsung.com> <20200821161401.11307-8-l.stelmach@samsung.com> <20200822124325.GF20423@kozik-lap> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 22, 2020 at 04:52:40PM +0200, Tomasz Figa wrote: > On Sat, Aug 22, 2020 at 2:43 PM Krzysztof Kozlowski wrote: > > > > On Fri, Aug 21, 2020 at 06:13:59PM +0200, Ɓukasz Stelmach wrote: > > > cur_speed is used to calculate transfer timeout and needs to be > > > set to the actual value of (half) the clock speed for precise > > > calculations. > > > > If you need this only for timeout calculation just divide it in > > s3c64xx_wait_for_dma(). > > Division is not the point of the patch. The point is that > clk_set_rate() that was originally there doesn't guarantee that the > rate is set exactly. Unfortunately onlt that point of timeout is mentioned in commit msg. If the correction of timeout was not the point of the patch, then describe the real point... > The rate directly determines the SPI transfer > speed and thus the driver needs to use the rate that was actually set > for further calculations. Yep, makes sense. > > > Otherwise why only if (cmu) case is updated? > > Right, the !cmu case actually suffers from the same problem. The code > divides the parent clock rate with the requested speed to obtain the > divider to program into the register. This is subject to integer > rounding, so (parent / (parent / speed)) doesn't always equal (speed). It is not only this problem. The meaning of cur_speed is now changed. For !cmu_case this the requested in trasnfer SPI bus clock frequency, for cmu_case this is now real src_clk frequency. It's getting slightly messier. > > > > > You are also affecting here not only timeout but > > s3c64xx_enable_datapath() which is not mentioned in commit log. In other > > words, this looks wrong. > > Actually this is right and fixes one more problem, which I didn't spot > when looking at this code when I suggested the change (I only spotted > the effects on timeout calculation). The rounding error might have > caused wrong configuration there, because e.g. 30000000 Hz could be > requested and rounded to 28000000 Hz. The former is a threshold for > setting the S3C64XX_SPI_CH_HS_EN bit, but the real frequency wouldn't > actually require setting it. Wrong is here describing one thing and doing much more. Best regards, Krzysztof