Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1779239imc; Mon, 11 Mar 2019 23:55:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxJ96Tntpdy6TG/+g72tn93k1BoPaWMFWOrmqBsltdxdhIu19zP6HGFQNFxcQQtsPWwYPl X-Received: by 2002:a17:902:e60e:: with SMTP id cm14mr38118040plb.192.1552373708406; Mon, 11 Mar 2019 23:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552373708; cv=none; d=google.com; s=arc-20160816; b=JoqO6Ou2NWbDlf7EomHtkAs/NKpZ/eKmr15HDZ4Tl1kAg+LY12voS7Tn5I6m4EkJs5 FCRsyHvfZGdTzSviSN0WOCoKaEq8xCGGxxjS48pLifQpFA55Nx4Qqz71CRjPKZnkSMct Ktex6Y12FpiVW7zdiB9AjknJjaR2FxRVo9ZyxCdRzD7BRP3/ZC7Ib86b+obsWcDCarQV qrroJv/TYoj5fTHc+osJPBJI2F6eVQJ6qk1VstPa8FUuCuo6lZkgut0hnSV5ybxnfGV+ 0vfvXwTJSQTEen0jzVcE1KFFckUI+t7ARsM++rOwfuSz3Gk1qIcNHps1sXNBGCQ1K4FW pxeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6xisYs80ssI8KWvqpJCloMNnHCixE15ZiurfRfZv50w=; b=A145yKUWEqA0drcyfkE4ZuuSHOAnrDwlSLeZAHIS40CsAN2SwzQyCgEPEbzn5ewyab uULmguYxOlW6FLseVZS2TP3NVEX0PfRyZG9Q8KIe5UMi0erfB3WhZcukWZzaaD3yK/wb JQSKf01ryL06u9wI97ao3kfN63uS/YCEmelXpuQeZ4Upv6mubeVyIznRQjiGHz90cLFr tJaKjqfSt8jg5lrnyMCX1/I1eEfd50e+KxTFvhKzHOjnYxgYdcNV4gKLK6oLgUXQD3sc pmA8ZfW/z3cYW1pa3Sdhm4k3+Zl6gEEozExpY7d8OK4dzpke59sa+6zs2+8jpstQRqNv 19+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=lLDMEqBs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si2061224pgq.125.2019.03.11.23.54.52; Mon, 11 Mar 2019 23:55:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=lLDMEqBs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727223AbfCLGxS (ORCPT + 99 others); Tue, 12 Mar 2019 02:53:18 -0400 Received: from mail-lf1-f47.google.com ([209.85.167.47]:42728 "EHLO mail-lf1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfCLGxR (ORCPT ); Tue, 12 Mar 2019 02:53:17 -0400 Received: by mail-lf1-f47.google.com with SMTP id p1so1166123lfk.9 for ; Mon, 11 Mar 2019 23:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6xisYs80ssI8KWvqpJCloMNnHCixE15ZiurfRfZv50w=; b=lLDMEqBsXVftMfldjou+NzRmWFT4xHrEMy8EPknp+fpKYBvyQUrydO+M2qDhb6xlPl FzP4vNOubB3X4MW+Ao3L6cMWBK+EKIPlKN0YNoAKCb8leKU4U/B9DqabU4ssrMsh7xxi ZjGoeiy7W/0on3Ez+2wQIBWCdJyArlZwve15FOnFvWxGwYZjpg6ME2Q3s9AGRJc7LgLV dWGyCAXbzhAuoV0aX2hFHYYChLtnsyCT/45emAgdIzfgNuqvV2ThOus9dDA/JVWeSF2Z Xq8UbDTKcmcxoGgtvI50ypvEGIhSjvHo4SYGgCe7FbcF20I/31X1Nl7sVhpsiyrSt7Ft Mh1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6xisYs80ssI8KWvqpJCloMNnHCixE15ZiurfRfZv50w=; b=lg9P2LQVYVAeOVOKdPEjKDawePo1z3SGyvCoELKm9hfqk2/03lTvfpsjV17fTRJ8hp eVQHPjTCNuA1BFfzkubU1lOs8KfaZl3Ej4nnuD4Or1nyzduck1p6AFtXHyo3J/lU0d75 lv/DeMs/KfRovXJtYhI7FFXeLZrtnREDi6acLtpSEBiGIh51JRyaglngU2+nZEHW5rw8 oWosuEoXzJGK5UiSUY/aEBp/mXckKsWnMwajYo6HW/Qw58JaBkoTpHSoB8mKAlszoVQ6 pY3Na8ftai7lbNSzHpA49y360h3z7I6tmOn2xXKi7kzZTosXeB629NSWDQZinVuc/EiN I//Q== X-Gm-Message-State: APjAAAVOFEvnbTZyxj9Bd7F4qjXyz4NFRGOabatuFoEgfnlhrnAcRzK2 qtTtCtlGkodnDlFTRsoIFJX6FsRVQwdJPODyv6i0ZQ== X-Received: by 2002:a19:9e8b:: with SMTP id h133mr13321038lfe.167.1552373595165; Mon, 11 Mar 2019 23:53:15 -0700 (PDT) MIME-Version: 1.0 References: <1551437599-29509-1-git-send-email-yash.shah@sifive.com> <1551437599-29509-3-git-send-email-yash.shah@sifive.com> <20190307152745.kaiv6q4ygf2apmuv@pengutronix.de> <20190308115726.smgooacsr37fmxwg@pengutronix.de> <20190311132922.iowselp7qvmroiaa@pengutronix.de> In-Reply-To: <20190311132922.iowselp7qvmroiaa@pengutronix.de> From: Yash Shah Date: Tue, 12 Mar 2019 12:22:38 +0530 Message-ID: Subject: Re: [PATCH v8 2/2] pwm: sifive: Add a driver for SiFive SoC PWM To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= Cc: mark.rutland@arm.com, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, Palmer Dabbelt , linux-kernel@vger.kernel.org, robh+dt@kernel.org, Sachin Ghadi , Thierry Reding , kernel@pengutronix.de, Paul Walmsley , linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 11, 2019 at 6:59 PM Uwe Kleine-K=C3=B6nig wrote: > > Hello, > > On Mon, Mar 11, 2019 at 05:10:17PM +0530, Yash Shah wrote: > > On Fri, Mar 8, 2019 at 5:27 PM Uwe Kleine-K=C3=B6nig > > wrote: > > > On Fri, Mar 08, 2019 at 04:59:36PM +0530, Yash Shah wrote: > > > > On Thu, Mar 7, 2019 at 8:57 PM Uwe Kleine-K=C3=B6nig > > > > wrote: > > > > > > + if (state->period !=3D cur_state.period) { > > > > > > > > > > Did you test this with more than one consumer? For sure the follo= wing > > > > > should work: > > > > > > > > > > pwm1 =3D pwm_get(.. the first ..); > > > > > pwm_apply_state(pwm1, { .enabled =3D true, .period =3D 10= 000000, .... }); > > > > > > > > > > pwm2 =3D pwm_get(.. the second ..); > > > > > pwm_apply_state(pwm2, { .enabled =3D true, .period =3D 10= 000000, .... }); > > > > > > > > > > but for the second pwm_apply_state() run state->period is likely = not > > > > > exactly 10000000. > > > > > > > > Yes, I have tested multiple consumers using sysfs interface. It is = working. > > > > > > Can you provide details about your testing here? What is the parent c= lk > > > rate? Which settings did you test? Can you confirm my claim that the > > > above sequence would fail or point out my error in reasoning? > > > > > > > I have tested on HiFive Unleashed board using sysfs interface. > > Parent clk rate is around 512 Mhz. > > I have tested scenarios as you mentioned above with various period and > > duty_cycle values. > > > > After considering your below suggestion, > > | To get the result independent of the prior configuration you better = use > > | the real targeted period length as input instead of the last configu= red > > | approximation > > I will introduce approx_period feild, which will be used as the > > targeted period length. > > Also, in pwm_sifive_get_state, I will make below change > > - state->period =3D pwm->real_period; > > + state->period =3D pwm->approx_period. > > So with this change in place, I believe the cur_state.period for the > > second pwm_apply_state() above (pwm2) will be exactly 10000000 > > I don't understand your intention completely. Just send a new patch > round, then I will gladly take another look. I was planning to go with above-mentioned change but then I realized that pwm state should always reflect the current hardware state, so I have dropped the above idea. Coming back to your concern on | if (state->period !=3D cur_state.period) { It is not failing for the scenario you mentioned but failing for another way around. pwm1 =3D pwm_get(.. the first ..); pwm_apply_state(pwm1, { .enabled =3D true, .period =3D 10000000, .= ... }); pwm2 =3D pwm_get(.. the second ..); pwm_apply_state(pwm2, { .enabled =3D true, .period =3D 20000000, .= ... }); The pwm2 should get an error for period mismatch but with v8 patch, it is not getting any error. I am sending a v9 patch which has the fix for this. With v9 changes, I have tested all scenarios and it is working fine. > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | > Industrial Linux Solutions | http://www.pengutronix.de/ = |