From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7665FC433E0 for ; Mon, 29 Mar 2021 17:50:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C7A461981 for ; Mon, 29 Mar 2021 17:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbhC2RuD (ORCPT ); Mon, 29 Mar 2021 13:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbhC2Rtm (ORCPT ); Mon, 29 Mar 2021 13:49:42 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F52AC061574 for ; Mon, 29 Mar 2021 10:49:42 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQw1C-0002b8-IN; Mon, 29 Mar 2021 19:49:38 +0200 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lQw1C-00006I-8d; Mon, 29 Mar 2021 19:49:38 +0200 Date: Mon, 29 Mar 2021 19:49:38 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Clemens Gruber Cc: linux-pwm@vger.kernel.org, Thierry Reding , linux-kernel@vger.kernel.org, kernel@pengutronix.de, Sven Van Asbroeck Subject: Re: [PATCH v6 6/7] pwm: pca9685: Restrict period change for prescaler users Message-ID: <20210329174938.rwosdunyh7oh2eus@pengutronix.de> References: <20210329125707.182732-1-clemens.gruber@pqgruber.com> <20210329125707.182732-6-clemens.gruber@pqgruber.com> <20210329171559.rfelpt42shlebct5@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7ieox3mgktdvdj4p" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --7ieox3mgktdvdj4p Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Clemens, On Mon, Mar 29, 2021 at 07:33:56PM +0200, Clemens Gruber wrote: > On Mon, Mar 29, 2021 at 07:15:59PM +0200, Uwe Kleine-K=F6nig wrote: > > On Mon, Mar 29, 2021 at 02:57:06PM +0200, Clemens Gruber wrote: > > > @@ -330,14 +345,22 @@ static int pca9685_pwm_apply(struct pwm_chip *c= hip, struct pwm_device *pwm, > > > =20 > > > if (!state->enabled || duty < 1) { > > > pca9685_pwm_set_duty(pca, pwm->hwpwm, 0); > > > + clear_bit(pwm->hwpwm, pca->prescaler_users); > >=20 > > Hmm, so if "my" channel runs at say > >=20 > > .duty_cycle =3D 2539520 ns > > .period =3D 5079040 ns > >=20 > > and I call pwm_apply_state(mypwm, { .duty_cycle =3D 0, .period =3D 5079= 040, > > enabled =3D true }); it might happen that another channel modifies the > > period and I won't be able to return to the initial setting. >=20 > Yes, that's correct. >=20 > But that also applies to PWMs set to 100%: >=20 > pwm_apply_state(mypwm, { .duty_cycle =3D 5079040, .period =3D 5079040, > enabled =3D true }); >=20 > As this sets the full ON bit and does not use the prescaler, with the > current code, another channel could modify the period and you wouldn't > be able to return to the initial setting of 50%. >=20 > > So I think it's sensible to only clear the user bit if the PWM is > > disabled, but not if it is configured for duty_cycle =3D 0. > >=20 > > Does this make sense? >=20 > With both cases in mind, you are suggesting we block modifications of > the prescaler if other PWMs are enabled and not if other PWMs are using > the prescaler? That sounds sensible, yes. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --7ieox3mgktdvdj4p Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmBiEy4ACgkQwfwUeK3K 7AmVqQgAnXHgi4x1oDNkU2hntC7XH6V44j7YbBK8XJdrPakCQxox87TyeN6FW2UU MdMXB97BptkFFGGAoMXSW2FDVb4tveP+2Gx0fWktrFsBWv6PGirpYFb6Qce7et92 mC8xgMriptKvNjjyy28KQZ2twe9soa15pMaEaYdJr+brTDC2wumVitUKilZu5zA4 5evah2w8uVuq5lluAZSImdvc30pIGNw+jpAB0TBUrhdhbjsHLTaO4HUiPcBJx74P 4jsp/94ZKAcm2m4Lbl8jrziUUDLJlWYpo8H9aTrHI9WtvCwbdtEeYQA+Kvp3r/lA To5DkGlRhkBJiyENEU1U78dXsmGWhA== =WAJL -----END PGP SIGNATURE----- --7ieox3mgktdvdj4p--