Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp383694ybl; Thu, 15 Aug 2019 19:45:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvNu79PbsfWFg3XQaJQ8yrI0jjVHpB5pnVP2s7ITeowVM21BvldjT4kL6e4yibfIDnKa9C X-Received: by 2002:a17:902:bb8e:: with SMTP id m14mr7103440pls.107.1565923550839; Thu, 15 Aug 2019 19:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565923550; cv=none; d=google.com; s=arc-20160816; b=DaG2RtpeBmCwUKUPYOKT+pw5+8X/pMh6loDUhiUxLqYmpuQqenepxnc+5bDaOCvuhH /a4Onmn3kOoZHJgqdN/1jmid48ujfw216DbE9gqcVdcuRo21THh7BFhN0hrN76kvH9D6 onZeX1z3qfGs2IP+r+2TDIVfBXZe/3taumiO6XXAwtiWirAzbKpz6PrS+wWZdiqsPWaw fc2eUrq0Ga2HvLLPdnro8lzXqudMWgAEZcIlrOX3DAsyU0csi633ZntwFGTC86zdgKPU K9T7zQMXda6zbVb6+3H39WLEn9PWiVttkw7eIkYnVeMTXlt15o4zslmR2vz6YReVXX+z z7aw== 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=+xxMFkHduGl/YnweSnS+CCEsvHgI5hIedjwyYopy/r4=; b=WOvrYi3RaK/vY17f3S0wZeaige9TUA2kF5zEvEj0GkANMqs2AducS6FwotOdH4YDv+ zOggDs4gFPiH2WwN3O7j3WfDga4JvuFI8ZLkyxSOGjI4WxinZhH9++a6JK4QN+Dz/1x3 wdf+wJD3gLwpim5NS0mAewyA07/RR7nz0DmiEFSINXEs/QJIXHY2VgmXnvftVRqGerW7 RkRZWs2cQqT9ZhtvjKhx9c0LKGejeGyxYVcba+wMk9nnO3lYDKAkMNZ7XhYojTZgelAV O2iaB++H4+xkwea799a2rTjjBmyOr+SIYGpDO9vRedw2DUsU0epiDRgG900Qi/yf5hwm uQ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L9X99WO4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si3119474pla.75.2019.08.15.19.45.35; Thu, 15 Aug 2019 19:45:50 -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=@linaro.org header.s=google header.b=L9X99WO4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbfHPCoz (ORCPT + 99 others); Thu, 15 Aug 2019 22:44:55 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:40406 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbfHPCoy (ORCPT ); Thu, 15 Aug 2019 22:44:54 -0400 Received: by mail-ot1-f66.google.com with SMTP id c34so8333712otb.7 for ; Thu, 15 Aug 2019 19:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=+xxMFkHduGl/YnweSnS+CCEsvHgI5hIedjwyYopy/r4=; b=L9X99WO4U8rxOGr9EoFeXcW3682v1aQkZaARsZrUhT56dgE03wuJIGisPfMYKd9KEI CNcPOYHnzs5KFP7Com3Y0t0QgMyUmgmC5QG0xnu+/vPqK3FofzVrMGFshDYa/A0sRDaQ YYjEF4Ut+Ih2PT+TKRh1ruQVKCYNtCjDeD955rpdVLghrz8DITk62UnJpdO8pC2iwE6K EvJI4bsQsvzt9iP0qwovGVkx1Z93XWYAg44woGhowizkowyVfIss1uLqYPjtra6wYkRu Fa+5oYe+nVz0zBaGyLdjObkGLsnDWnwJT0PPMvHBFfj3+nbxIShxQxzejBnvTzBZDMBy 9GHw== 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=+xxMFkHduGl/YnweSnS+CCEsvHgI5hIedjwyYopy/r4=; b=fV0ReKi00bNFQhdyvwUasGFY3n4g6muKvdd5mPN2dMipy8VQlXHAf87Dbd+dGjOie9 LSDderoEEchPD2+9BkLqYX51qczFk/K1jfNzTU+Z8xLTiNCUAhDn8OPiKRRx5wGH9N5a odHHcUSygOvK7FIxQtB8QZuhMIi8Og/Lv6C/zUlXkAs1cNvNTZzkVOYrFiNWRQRe9Pgw mO5Sam3GxlKcdtwASLJDPDozKR4ZbHOhLaXTs2rh2Ee4mMyqQ4yJ9cVBM3RcmqrIu14i C8s/3Mwu9v/ZWRTUfV1iPCf94bwXDKXD7Y5rE7kLkk5rKVN8og/aZXLmqtaWGaoYgL/7 7pFw== X-Gm-Message-State: APjAAAWnWZ6Nao4YjbgYHRIW2OQ1ZTZMdvF14VKKfqein2D0WRKxChzh wK9nZ/M4HPYo24yCsCkcCGQpinenrSsHBUJxpNXj3Q== X-Received: by 2002:a05:6830:1e05:: with SMTP id s5mr5380435otr.247.1565923493222; Thu, 15 Aug 2019 19:44:53 -0700 (PDT) MIME-Version: 1.0 References: <65a34dd943b0260bfe45ec76dcf414a67e5d8343.1565785291.git.baolin.wang@linaro.org> <446eb284a096a1fd8998765669b1c9a2f78d7d22.1565785291.git.baolin.wang@linaro.org> <20190814150304.x44lalde3cwp67ge@pengutronix.de> <20190815061540.763ue2ogkvuyhzcu@pengutronix.de> <20190815085452.2cipewq3l3krnwzv@pengutronix.de> <20190815101147.azbbjcvafwjx67wc@pengutronix.de> <20190815122518.hzy57s635ubohywh@pengutronix.de> In-Reply-To: <20190815122518.hzy57s635ubohywh@pengutronix.de> From: Baolin Wang Date: Fri, 16 Aug 2019 10:44:41 +0800 Message-ID: Subject: Re: [PATCH v3 2/2] pwm: sprd: Add Spreadtrum PWM support To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= Cc: Mark Rutland , linux-pwm@vger.kernel.org, Vincent Guittot , DTML , Chunyan Zhang , LKML , Rob Herring , Thierry Reding , kernel@pengutronix.de, Orson Zhai 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 Thu, 15 Aug 2019 at 20:25, Uwe Kleine-K=C3=B6nig wrote: > > On Thu, Aug 15, 2019 at 07:05:53PM +0800, Baolin Wang wrote: > > On Thu, 15 Aug 2019 at 18:11, Uwe Kleine-K=C3=B6nig > > wrote: > > > > > > Hello, > > > > > > On Thu, Aug 15, 2019 at 05:34:02PM +0800, Baolin Wang wrote: > > > > On Thu, 15 Aug 2019 at 16:54, Uwe Kleine-K=C3=B6nig > > > > wrote: > > > > > On Thu, Aug 15, 2019 at 04:16:32PM +0800, Baolin Wang wrote: > > > > > > On Thu, 15 Aug 2019 at 14:15, Uwe Kleine-K=C3=B6nig > > > > > > wrote: > > > > > > > On Thu, Aug 15, 2019 at 11:34:27AM +0800, Baolin Wang wrote: > > > > > > > > On Wed, 14 Aug 2019 at 23:03, Uwe Kleine-K=C3=B6nig > > > > > > > > wrote: > > > > > > > > > On Wed, Aug 14, 2019 at 08:46:11PM +0800, Baolin Wang wro= te: > > > > > > > > > > + * To keep the maths simple we're always using MO= D =3D SPRD_PWM_MOD_MAX. > > > > > > > > > > > > > > > > > > Did you spend some thoughts about how wrong your period c= an get because > > > > > > > > > of that "lazyness"? > > > > > > > > > > > > > > > > > > Let's assume a clk rate of 100/3 MHz. Then the available = period lengths > > > > > > > > > are: > > > > > > > > > > > > > > > > > > PRESCALE =3D 0 -> period =3D 7.65 =C2=B5s > > > > > > > > > PRESCALE =3D 1 -> period =3D 15.30 =C2=B5s > > > > > > > > > ... > > > > > > > > > PRESCALE =3D 17 -> period =3D 137.70 =C2=B5s > > > > > > > > > PRESCALE =3D 18 -> period =3D 145.35 =C2=B5s > > > > > > > > > > > > > > > > > > So the error can be up to (nearly) 7.65 =C2=B5s (or in ge= neral > > > > > > > > > > > > > > > > Yes, but for our use case (pwm backlight), the precision ca= n meet our > > > > > > > > requirement. Moreover, we usually do not change the period,= just > > > > > > > > adjust the duty to change the back light. > > > > > > > > > > > > > > Is this a license requirement for you SoC to only drive a bac= klight with > > > > > > > the PWM? The idea of having a PWM driver on your platform is = that it can > > > > > > > also be used to control a step motor or a laser. > > > > > > > > > > > > Not a license requirement. Until now we have not got any higher > > > > > > precision requirements, and we've run this driver for many year= s in > > > > > > our downstream kernel. > > > > > > > > > > I understood that you're not ambitious to do something better tha= n "it > > > > > worked for years". > > > > > > > > How do you know that? > > > > > > I showed you how you could match the requested PWM output better and > > > you refused telling it worked for years and the added precision isn't > > > necessary for a backlight. > > > > Please I said the reason, it is not that I do not want a better > > precision. The problem is we do not know how much precision to be > > asked by users if no use case > > I don't understand the problem here. If you are asked for period =3D > 145340 ns and configure the hardware to yield 137700 ns in reply to that > but you could provide 144780 ns I don't understand why you need a use > case as 144780 ns is objectively better than 137700 ns. A better match You are wrong, we will provide 145350 ns with DIV_ROUND_CLOSEST_ULL()., which is better than your 144780. > has only upsides, it doesn't hurt people how don't care about a few > micro seconds in the one or the other direction. OK, your CPU needs a > few more cycles to find the better configuration but that's a poor > argument. With only a backlight as use case you could even hardcode > PRESCALE =3D 0 without any problems and have the needed calculations a bi= t > cheaper. > > > > > What I mean is use DIV_ROUND_CLOSEST_ULL we can get a nearer value = to > > > > the requested like above example. > > > > > > But given that it's unclear if 137700 ns or 145350 ns is better when > > > 145340 ns was requested this is not a strong argument to use > > > DIV_ROUND_CLOSEST_ULL. With the global picture for the pwm framework = in > > > mind it is sensible to request the same rounding from all drivers to = get > > > a consistent behaviour. And I believe the maths with rounding down is > > > easier than when rounding up or nearest. That's why I argue in this > > > direction. > > > > Let's wait for Thierry's suggestion to get a consensus firstly. > > OK. I'm not sure you want to wait until Thierry and I agree on a > solution here though :-) > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | > Industrial Linux Solutions | http://www.pengutronix.de/ = | --=20 Baolin Wang Best Regards