Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp590856imm; Wed, 6 Jun 2018 02:45:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIMoHZu+AY9dsHg4cQrGCwb55DS+pocl/E+SQKNOKWvVBnC8D+Q6fAyMXrprnG9waoTTll7 X-Received: by 2002:a65:47c8:: with SMTP id f8-v6mr1985818pgs.430.1528278331474; Wed, 06 Jun 2018 02:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528278331; cv=none; d=google.com; s=arc-20160816; b=e5i9Gk5qbz9Luf3WLyYfZgnV6VDjeWOVY/3ompcTCE0cof6bLfvde1mN0dQm9cPGAF egV9GPQ4qDwS102H7gcuFbHBEB9p0kbOtUSTN21VHs85MotCeuDxb8j/E4gl56FJpGJP IHOu6MS9WyqdW7Xv57q/jmeXL5OYpI794tEQBSmV/LAzJKfOhdgA79I3BD2HGAA13+3M OnILEt9CvsBeQA3lvT4PHv9YHp81ILvshUbn5J7uKj2fGqwD6kNE7HTTqAn62OOBg79I eDDkYJE8/mk/OWJHj2wkeg/UDce5RAg+HHp2drhQ2SRSgBFWC1L/psRZEtwUD8Nm2O43 VMYw== 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=tCqMUqWihCgVJnSElcZb7qd3RFB8o5UeOb4jatoalpk=; b=Tq1ovutlT906c8VO9VcIU2e4zq4poZfO10iDwTfVBXWuVJC7Th++bKedMBr1/VvYTV xfYiJs/yO4/AfZ/NBw3OywiTetsq4QCqK5znkYzmzoScd/KGrBXD/ux0QlR9+G0NtfSD eeuBnpQkAFWlJrVJzmv/wau2AjaExBFar98yVgOvsJa1rPsCHgvi4vhng8IKh6tlnkEt qnI8cxQ99YWmGRIU7pW4gDmrsZXC7JqqyOaaSDAm4nWjPHJIaMNBT3Tt/4LEYd7rxS/H R1yN6V6vVtd8MIsUntJWLUqFLq8gLB2DXnzzt7pCCs2mYHp06QbKbef9I5nAatFe5Iw6 h9Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KX6Y9A9c; 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 38-v6si52249630plc.446.2018.06.06.02.45.17; Wed, 06 Jun 2018 02:45:31 -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=KX6Y9A9c; 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 S932643AbeFFJoc (ORCPT + 99 others); Wed, 6 Jun 2018 05:44:32 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:34272 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932631AbeFFJoa (ORCPT ); Wed, 6 Jun 2018 05:44:30 -0400 Received: by mail-wr0-f195.google.com with SMTP id a12-v6so5550257wro.1; Wed, 06 Jun 2018 02:44:29 -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=tCqMUqWihCgVJnSElcZb7qd3RFB8o5UeOb4jatoalpk=; b=KX6Y9A9cnMWRzlw1w2w1XE6/rihelruEq1yfdf4Zfe1UF6/4vEbX9zrj9R+7XifXG0 k9J0guIQaKbRE7NyM7WM7vuO8jD0CASAu0JfyXqDXs69ph1O18QlVmbyc+4q3nKOuY36 jbgJIKXoWlEB9BBXMlaREDUmHHdVjb5ujjHbWiY/YqpFVX24KC7Ca4Y2bn82Rd26PMMw wRxNriLyn+da3nEyXx11Ui1Ot2WAZqoXyjVzohmIth6ah8g1xk3mVWxQ/LHOp7EPgD2y qqBISBUILsxgi8QKx/OYHfx9fqdPbxH1wfU2F+dWIoumrAvXOWGK3DGU9B1zcfqsNsNT Ekqw== 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=tCqMUqWihCgVJnSElcZb7qd3RFB8o5UeOb4jatoalpk=; b=Jxl35Nk0YyuxK4Ti1/wulIERoHMYrJftHax4mVllETttgVh9Y7edUtqWXVtSYGjqmd wy21OBucFR5aNJLxeZDwcp02W5EyZvPqjWfwZCxVfa/6yQi1IvrTDd3mL1T1cPrABBuJ ARMsLNkEwHBhWzOdtOgkwdXfs0STrKgw7TPOexWiEFEmHLS9mvFSOhpY/onvs/C2kMiF YNrp/DTYdeWbpI1KyOWQYoplmZd+eVX32aCJrZDG3TyWQFt1HoE/oATyF43KHRLqgv5f 3ysWpsbwhVUKFQQdwzCR90bNRkS22NtpvXnwpvuZRebFj9YZCsrTuCj8wREhMJcgxeOo dl/Q== X-Gm-Message-State: APt69E1OROeu3gqlOGyBGeev+mgPrVe56upG0fKjLXEcoXq5V5R0gHiA 12nXNxTlSfAMf65U1lrSV9o= X-Received: by 2002:adf:ee91:: with SMTP id b17-v6mr1851032wro.21.1528278268967; Wed, 06 Jun 2018 02:44:28 -0700 (PDT) Received: from localhost (pD9E510DD.dip0.t-ipconnect.de. [217.229.16.221]) by smtp.gmail.com with ESMTPSA id q7-v6sm48556316wrf.0.2018.06.06.02.44.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Jun 2018 02:44:27 -0700 (PDT) Date: Wed, 6 Jun 2018 11:44:26 +0200 From: Thierry Reding To: Tom Hebb Cc: linux-arm-kernel@vger.kernel.org, Antoine Tenart , sebastian.hesselbarth@gmail.com, jszhang@marvell.com, "open list:PWM SUBSYSTEM" , open list Subject: Re: [PATCH RESEND] pwm: berlin: Don't use broken prescaler values Message-ID: <20180606094426.GI11810@ulmo> References: <20180605091002.GB20649@ulmo> <75f1a632-80c3-1d99-8405-01fa9a4c2616@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HkMjoL2LAeBLhbFV" Content-Disposition: inline In-Reply-To: <75f1a632-80c3-1d99-8405-01fa9a4c2616@gmail.com> 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 --HkMjoL2LAeBLhbFV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 05, 2018 at 12:48:51PM -0400, Tom Hebb wrote: > On 06/05/2018 05:10 AM, Thierry Reding wrote: > > On Mon, Jun 04, 2018 at 02:32:41PM -0400, Thomas Hebb wrote: > >> Six of the eight prescaler values available for Berlin PWM are not true > >> prescalers but rather internal shifts that throw away the high bits of > >> TCNT. Currently, we attempt to use those high bits, leading to erratic > >> behavior. Restrict the prescaler configurations we select to only the > >> two that respect the full range of TCNT. > >> > >> Tested on BG2CD. > >> > >> Signed-off-by: Thomas Hebb > >> --- > >> drivers/pwm/pwm-berlin.c | 45 ++++++++++++++++++++++------------------ > >> 1 file changed, 25 insertions(+), 20 deletions(-) > >=20 > > Antoine, Jisheng, > >=20 > > can you guys review this patch? I'm personally on the fence about this, > > even if we can technically do the shift in software, I don't necessarily > > see a reason why we can't "offload" to the hardware. > >=20 > > Thierry >=20 > Sorry if my commit message was unclear: this patch doesn't just > arbitrarily change the hw/sw division of responsibility. The driver in > its current state is broken (at least on BG2CD), and this patch > implements a fix. >=20 > The reason the middle six prescaler values are useless is because they > do not actually slow down the clock. Instead, they emulate slowing down > the clock by internally multiplying TCNT. >=20 > This would be a fine trick, if not for the fact that the internal TCNT > value has no extra bits beyond the 16 already exposed to software by 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 actually > increases the driver's 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 > Let me know if any of this is still unclear, or if you'd like me to > revise the commit message. Perfect, the above, with slight adaptations, would make a great commit message. =3D) Thierry --HkMjoL2LAeBLhbFV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlsXrPoACgkQ3SOs138+ s6GzxBAAj5Rgz9llkOkAO+xElptmSy+xjPnJ19nza0IIyS7y49dzz58ygvm5jzbA ayS1kbldwx2UXao0lkSmU8YWkT28KC7RPv5BC6g0vE0Th1OgcKhousPCr159J8i3 BDi4TRGXsxLsegySklO89CJIK0Qsrzqok0A7TDDilGKtBAo35Bcoeg1lj32/sWic c2EOJorKsm17nR6bPzcNIh8U3OM9bV2TUsps9EyR0i3M4NF+uT1iy4EnYMxKFGBA jOjX6RqxlD0dG0ZcGeWGcQyMKoDPY5U0QAF0xSE5FHjPxPQOykkP+3zPbwE66oDG J53ry8PDuJdXXPzcwUdeqaZOBxby6skyfKq8elPTIuw+MhpyRtG0HEu0c5qQ6ecf BFVbsJ7rcshhDb6U+TdJvYegVGKNBxZmppXPay2U0JvrtrYo057BAEprzKg3HpEA nSad4jy3G5C4sxe4bSR44H15GlEZ4UpajCEidkkMst0BHcBf/zohkACQbiKpRkrJ L0IESJOR5EVmHhxMMlmby4cHNrZHjLtGVJBCGvmcAwSpBde44xhRYg5qi141G7IS Prz33/O7HOE7zz3EoBMybA/8H0qIsqvABduTtdFuK8RWVcjL5TE6CvSyFe4ZzEJZ Rs0C3wvZ1YgQRc9eEb1fdxD5B9XhzLQ8GNvUdkYiQxK7Yxi+BXk= =19hr -----END PGP SIGNATURE----- --HkMjoL2LAeBLhbFV--