Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2048987ybl; Thu, 15 Aug 2019 05:49:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeOI9hsz32OQ8nxWrXZhhF2xvElSPXIOCTzFXy2E/sb9SrdJWyM79OJnELem/bihrbzkgi X-Received: by 2002:a62:83c9:: with SMTP id h192mr5113108pfe.57.1565873362018; Thu, 15 Aug 2019 05:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565873362; cv=none; d=google.com; s=arc-20160816; b=B0Vi7CSxcJ9Uxdx3vZ3luZXKxmJX+oBIv0txlwEOSO9Xj/AR0ATcIk+rakYcG43cZv J9gXhBUBETr/O3euwYe1tzvbujY7H0M1nlfBx+weE+Ha4e8jDEsXQViz8i6UaLLLwnJp lK2bxbF+O0ZLSvBMX8+rRcntwvblnWXZ4U+dBYRtzrF9LyJNgcu2VWUOgcNWMpn08bw4 3L38Fec9jTbEY74k5YEIX0dX6lV3olWcWXFMghpNiMHupIUUoQ06Dw/JrzpzxJf63Spn haRgiCKMSJQIf1XfL0JLJF4eJS0jSmSBAvJtHSW8BEUFnbu5Csr34R0DtJwLkwLDoIua oKGA== 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=ycVlBv4IvsXlLvqKcFGimLngjnl/Wzzxbp+q8mtQog0=; b=yTFG1SlxpG7xaz0r0IYmU57W3n+wBZp+0qoOmqYZ0Ntf6rRjdkuJuyfglJdNi0qNNc n/946TapzZ5VMUIg5Xlz3aEo2T//jMgKBC6WLTEPlvd14CHp7aGYnPDqUJnwOutFsa34 +6eFEj/W1GIm/FBke6jha55EBHvPHGHuKL0PahnSIDc0G3aNXa0xoRN5IQDVw+AbobX6 0H6qkCnSbuPNyqVf0LZRcgsjIoXKQhY2VFVU+93kf6IJL0I+OxbvFXJzH0OIX7laIFw0 W3EUeh6ZqXJRTcpvdVrl4ZgHyuWZg7K0xpCqyAO59vi4ID9XR5nArfkwrU+Skgf2fzx6 XZkA== ARC-Authentication-Results: i=1; mx.google.com; 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 i189si1758495pge.253.2019.08.15.05.49.06; Thu, 15 Aug 2019 05:49:21 -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; 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 S1731621AbfHOMZY (ORCPT + 99 others); Thu, 15 Aug 2019 08:25:24 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:42881 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbfHOMZY (ORCPT ); Thu, 15 Aug 2019 08:25:24 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hyEoh-0007oQ-Sm; Thu, 15 Aug 2019 14:25:19 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hyEog-0001Xb-UV; Thu, 15 Aug 2019 14:25:18 +0200 Date: Thu, 15 Aug 2019 14:25:18 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Baolin Wang Cc: Mark Rutland , linux-pwm@vger.kernel.org, Vincent Guittot , DTML , Chunyan Zhang , LKML , Rob Herring , Thierry Reding , kernel@pengutronix.de, Orson Zhai Subject: Re: [PATCH v3 2/2] pwm: sprd: Add Spreadtrum PWM support Message-ID: <20190815122518.hzy57s635ubohywh@pengutronix.de> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 15, 2019 at 07:05:53PM +0800, Baolin Wang wrote: > On Thu, 15 Aug 2019 at 18:11, Uwe Kleine-K?nig > 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?nig > > > 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?nig > > > > > 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?nig > > > > > > > wrote: > > > > > > > > On Wed, Aug 14, 2019 at 08:46:11PM +0800, Baolin Wang wrote: > > > > > > > > > + * To keep the maths simple we're always using MOD = SPRD_PWM_MOD_MAX. > > > > > > > > > > > > > > > > Did you spend some thoughts about how wrong your period can get because > > > > > > > > of that "lazyness"? > > > > > > > > > > > > > > > > Let's assume a clk rate of 100/3 MHz. Then the available period lengths > > > > > > > > are: > > > > > > > > > > > > > > > > PRESCALE = 0 -> period = 7.65 ?s > > > > > > > > PRESCALE = 1 -> period = 15.30 ?s > > > > > > > > ... > > > > > > > > PRESCALE = 17 -> period = 137.70 ?s > > > > > > > > PRESCALE = 18 -> period = 145.35 ?s > > > > > > > > > > > > > > > > So the error can be up to (nearly) 7.65 ?s (or in general > > > > > > > > > > > > > > Yes, but for our use case (pwm backlight), the precision can 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 backlight 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 years in > > > > > our downstream kernel. > > > > > > > > I understood that you're not ambitious to do something better than "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 = 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 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 = 0 without any problems and have the needed calculations a bit 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?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |