Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp751317imm; Mon, 9 Jul 2018 09:58:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcwU7baHlil6eP0pG8LE0Rc/AynSvWo8cf6y97zM9oyK/YFE83H0c6F2O0jWA9KEY34VBIr X-Received: by 2002:a62:2414:: with SMTP id r20-v6mr22103142pfj.108.1531155506014; Mon, 09 Jul 2018 09:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531155505; cv=none; d=google.com; s=arc-20160816; b=rWNUJkcsFltWJPfwCWWdnoLOSx5MH/DVus5MBuVC0C/xSA85nZLmikI+Wr7alIX3TB K+qX7+A5pcJzdUVeBXaXhdoI8Fy7Gr0arVYV0P6mWuvAMJQK1hHAzCRXRpVLhiatbIsG 5pYanXrW1fMHSm0OA2gitlnRFgABWxZgcC7y493aA3jV+bP2i8gGGsEEK38aczQ1fOZX 6MZR0ETSfSk5N0AxXotzaTF/aR8caoNAtdSG6w36bvtO3z55hBS6Ic7eflFEd/aCK3Us yBtXoJVzVdnjEQn9cZEJGmKqtzmqJcS0GZBrUpm8cF4gfEAba3WqTiGi+4KwU1Bs8ovN BjPA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=rHAT1z3Do7xU0E0LFP+OeSiSci9wAPuwPE2eEw5zjJY=; b=FMCnLFxFWcVTuKlPfxPCw/yilVK6qDps7foagd3yTPTd2H2UJFrYEnb01lh4Q20JIa RGjLyWwCpddW/hJah22W+hXt+PwD8vg51wdQZd20FNvyUmsBP9ieXuaNY76cWdfz6/ws AWzb45mHO/pQo+rivtEazCUsuBLYprRcIOTI9l0BplCNJClTlxnjBkquky7hpNJB1qwY CAEX3C6dZuFgBHJRmN/wEZXqZ2mJFpXaBo3o2OPDJ4MprcPu7wJ+mzcbSP/lB+GGbkzi B9ES9F2pDEvdSKXOVnlovo625hJlybcieW/RhLhLGI3Yjw36WgLdveFoS5KNhQDDDORW yb7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UBc1gltK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20-v6si13554961pga.70.2018.07.09.09.58.11; Mon, 09 Jul 2018 09:58:25 -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=@gmail.com header.s=20161025 header.b=UBc1gltK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933495AbeGIQ5a (ORCPT + 99 others); Mon, 9 Jul 2018 12:57:30 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43592 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932755AbeGIQ52 (ORCPT ); Mon, 9 Jul 2018 12:57:28 -0400 Received: by mail-wr1-f68.google.com with SMTP id b15-v6so11728292wrv.10; Mon, 09 Jul 2018 09:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rHAT1z3Do7xU0E0LFP+OeSiSci9wAPuwPE2eEw5zjJY=; b=UBc1gltKFEae5sh3acc2e1TwKTt31lFLBQZttTow71lbSVmddTeZ1E3bLhVZX5OqOa NOBbODKpV7V2KN9ulFABrtMHEaQFwVb1KwKskVCCaWPyf0MxT64vVVPNbzuCKPeyLw4F CPG/MIORwknKohC0jz9G43pr1WMKv0V10b/SD5qUXt3+NjWsdWgpLsa1NvYU7ADLSaI5 a7K2yy1AocATmxNdDc54AyOWF73+Xz0ECjRJPwOq7zqJ4+kEXVjbiu0/qTf4x3aQDAU/ xS23OE/ZUzE5V20bGz/UHwT9GSt7m+TzM6nWywXjDtyCkI2Dc3+Urs3Tg7fBdj1mtBkN YpKQ== 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:in-reply-to:user-agent; bh=rHAT1z3Do7xU0E0LFP+OeSiSci9wAPuwPE2eEw5zjJY=; b=Ou9FSy46r0Cf7N1uVDEdSUs4KssAt4re9ka7mqg9j0XS7Xa0L6XxM3e1hYhKp0SAtD 7s20jnhIo9SONs6LMEWZTtXR65I5YR0qn4GRUA99ikhW8ifCmFW8pM2cSKl0sy63ajV2 CYvuwjqyf+599gbBZUEV/sftC3gAEbEn4/GZ1MpPbuvG6m5aB5CliT9YmoDQUaIKa163 fGMcyZbqpnLnkS0M0LvHQ3CxppN6DmGEwqPp/xhuTSuWbDWoWU5Uxvo76oQXJH281S9s VZGzlq7yXHFBHQVUKw6CJPr7L1Y6rD3Qbo4oET0dgmOcDktQL0bJbcxkXsxPnCyuX/a+ V+1A== X-Gm-Message-State: APt69E0DA05hFPEd/hYADSwLvwx696CYi2ZK7l9wI3lvaNojnpfh91Yc wCh0TCL/3RPVLcfimI+1FHg= X-Received: by 2002:adf:8796:: with SMTP id b22-v6mr16075885wrb.92.1531155446681; Mon, 09 Jul 2018 09:57:26 -0700 (PDT) Received: from localhost (pD9E51B8F.dip0.t-ipconnect.de. [217.229.27.143]) by smtp.gmail.com with ESMTPSA id o4-v6sm28897042wra.3.2018.07.09.09.57.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jul 2018 09:57:25 -0700 (PDT) Date: Mon, 9 Jul 2018 18:57:24 +0200 From: Thierry Reding To: Thomas Hebb Cc: linux-kernel@vger.kernel.org, Antoine Tenart , sebastian.hesselbarth@gmail.com, Jisheng.Zhang@synaptics.com, "open list:PWM SUBSYSTEM" Subject: Re: [PATCH v2] pwm: berlin: Don't use broken prescaler values Message-ID: <20180709165724.GB26651@ulmo> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="St7VIuEGZ6dlpu13" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --St7VIuEGZ6dlpu13 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 06, 2018 at 01:42:10PM -0400, Thomas Hebb wrote: > The Berlin PWM driver is currently broken on at least BG2CD. The > symptoms manifest as a very non-linear and erratic mapping from the duty > cycle configured in software to the duty cycle produced by hardware. >=20 > The cause of the bug is software's configuration of the prescaler, and > in particular its usage of the six prescaler values between the minimum > value of 1 and the maximum value of 4096. As it turns out, these six > values do not actually slow down the PWM clock; rather, they emulate > slowing down the clock by internally multiplying the value of TCNT. >=20 > This would be a fine trick, if not for the fact that the internal, > scaled TCNT value has no extra bits beyond the 16 already exposed to > software in the register. What this means is that, for a prescaler of 4, > the software must ensure that the top two bits of TCNT are not set, > because hardware will chop them off; for a prescaler of 8, the top three > bits must not be set, and so forth. Software does not currently ensure > this, resulting in a TCNT several orders of magnitude lower than > intended any time one of those six prescalers are selected. >=20 > Because hardware chops off the high bits in its internal shift, the > middle six prescalers don't actually allow *anything* that the first > doesn't. In fact, they are strictly worse than the first, since the > internal shift of TCNT prevents software from setting the low bits, > decreasing the resolution, without providing any extra high bits. >=20 > By skipping the useless prescalers entirely, this patch both fixes the > driver's behavior and increases its performance (since, when the 4096 > prescaler is selected, it now does only a single shift rather than the > seven successive divisions it did before). >=20 > Tested on BG2CD. >=20 > Signed-off-by: Thomas Hebb > --- > drivers/pwm/pwm-berlin.c | 45 ++++++++++++++++++++++------------------ > 1 file changed, 25 insertions(+), 20 deletions(-) Applied, thanks. Thierry --St7VIuEGZ6dlpu13 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAltDk/QACgkQ3SOs138+ s6GzSg/+JeatRGdrJmsErClcFd4iadL/LxRhrcxR+qX12x/xu1eaVmqdxhTIUDW/ BD2ZwnNIeTs8cDsBEgc2M2Y3+40Qc5XKY6sk/IHHHI4Dkid0dW6PAK+fwpE+nyY+ 9UAg2oVG7e5NO7T93SDF4iZdUFYMFve1EHPdayacf+BaLSAHfQSTfNq9EPgShIqq f9xSNXheIW20D26NNjVxFqXAQzxXDO4+tTNHZC8qyTr9Eulk0MZCjkBzh49COeCw fpumSqUrohGkBu6RkEgjAYwsIRZzT/mW+SGsOCQOBU5NfYuRsRl4h4jP7dEQXFBU LIRmbzFaJYVkFMhsT5P9XMcw/sAeSegpV/9YuKMS/7IH4UWN0S+YIVjN0mGWFt45 8UE/S9c3C2zLMEtEFetAX+c+lg2xFWI46Jg+JPGtvuI1YFZ71xU6IWajK+ugK5ie GwtrGY/V1Q9S45R+18Ypau4mUIPovX7i3HrtFtCNxpceEC9TIfrbi33f1QFdpNSE sRWP699As3Qp7E9p4tdl6XpssC3GhohyvMNdBnr9D97gjtbp+ZC8bUDEhr0mMumb vdoC5B34gXUpW9yWwrQQzVWT4d8D9Q1HdR+rXhvI720uiAyqukedZgV1evM1lMN+ VqHCqQ+mFU644jHWKAuMoOW638Gr1UDreQcGLExNW7u4zlp7hGc= =jPBn -----END PGP SIGNATURE----- --St7VIuEGZ6dlpu13--