Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3769351pxf; Mon, 29 Mar 2021 10:51:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/Kq1sLr9f5aRprKjqRP2gLNFQg92xAMplkq6BjFu+y05LxBdNp9m1eFkeE+dBLGWYx5eg X-Received: by 2002:aa7:d448:: with SMTP id q8mr29786746edr.345.1617040309231; Mon, 29 Mar 2021 10:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617040309; cv=none; d=google.com; s=arc-20160816; b=JVsjgwMhyguT/LaCsb3V17mWTj/Rn1InCpo7mWHj79Dli4OCu1f26J6Uwb0DBI2BE+ aBBXAi0eSeWEMKwdAwgiaInYFZyBluXU8sOnowH7sXjxfY8SKhHeYBDrmCFLLax0oe+W 0wQkS61frvdBYf4YZ3xZKYcHT5j5aK7Vuonj7AkdisZPvrOKwJTXQ1datgOOZBsCW98Z is04ldJZ2mALYRqwE0kGBYBTl+N/LH5AUKhnMy6ndfLfZPafuBwBfXE2dIVT30g1Y2L0 9UPipBgzbKWF5P4BTgODo3fAu+zYucVhrWq75XUo315vD+oMuHl6oV8tvaUy/Af1U10S JgAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ijacTnr89K2LqTj1HjS9s6/+BtK1IWUbbU6czoXnXho=; b=tjISk5xva10b3bzCkFRyrwT9fmv7J0QVHjNRr7dehLw5xYs6J6F7c+x+veRYhzwz8P I90R4EikLaqcgfGzTS5FqXc/0NIjOK8aN7QNczL5nypwu3HYF1QWq2id2edVuPqFG3HN K4d57kmDfNRmShhbBkdL6IQF7FJBheWhGuJnoET2/N3NbRa9/KWCyiTZKrYMJS9d5gnm 9OxowfmENy+weuvvI1jqYcqnKFGQFEkf1mSduO1e10Qw4FlEwB+9GFVZS32XwhT2qGOL FE2RkOBEHcEVCEU/HhBP/lUyyDGqCZ34/vJZSkKY0sA4nntOXYXzdm0UKMvkrRkRRADM IWcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si12886951ejv.381.2021.03.29.10.51.26; Mon, 29 Mar 2021 10:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbhC2RuB (ORCPT + 99 others); Mon, 29 Mar 2021 13:50:01 -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--