Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4577750rdb; Tue, 12 Dec 2023 03:48:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUxUtcxJwyP/oYQBU2nqYnilX783Ms4QFj+ki/gNWfafxMnG2CniHUyFYqgx0cp/isI3si X-Received: by 2002:a17:90a:cb05:b0:288:966b:9f48 with SMTP id z5-20020a17090acb0500b00288966b9f48mr2849561pjt.8.1702381704735; Tue, 12 Dec 2023 03:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702381704; cv=none; d=google.com; s=arc-20160816; b=BkBmlZv2LsqO387OkbMM+zZGPI0/2cWy5KyFGQcYaXqcygpahxl14Q/HDemY8oD80N /y9uL3kHVzOSl0/pCRKSkSVvMMRBRE+K0b+zWp0q44G1RrickVG+vXJRIE2KcmIKrqGW 5fOlLk8DZIa13wLoJbaZH0ulfZXoZbYpZ3yQO+vVcPOfcpvBrCJdSJgHT9d5GQinZ876 kZ3VcMr80oagEuOR2Rd07YUwqf6RRf00Bt42dYhp9zhD0UqQ4LJ+y9087O7YPnK2YRM6 VrsobGMaBVkOIqsv/2NpwEfZb9O6n3uACP/OwzSnHjaKAAksMlurIZvfh05eE09hTzZR O1oA== 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=18cMvIpKnWefOXPIaX9kfxG8ToDYw05L7LgKYZLZLBA=; fh=+xnIrZETjLqHvO6MX0Uf3EHdQKlvg55yvrXxE/aw/xo=; b=MytIWz2ujsWXacEPYpT31dcpamOuk4oX9vPflyz35agJrf1wLzDInkSn80ths77z1A S58P9Orf0yBsrCjuuqKPJqJVc8W2ZE3XP70Hm3c4ws8U/XvaRqiIr8bjFFT66QpJE1Wp 7ONBNTZUT0Ez1NHpEOSOZUt2fcA+gT9ECdAYepbQlxoP5TmFt4ZFa/MZx3tSZI1puBGA XgxTRI13NqyyU9Gc/xlDBgQ0pXi73+CzXy0jWowdhdaEuXLY41aXH3zJZjdlJpLhQjEI nHlC2FD7Ca7jmWHE3yE3xSrXnhlzmOjtkuj0B5HgNAFa956VMuUGratQKkqFTIi47pAW bVIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id pv7-20020a17090b3c8700b00286abddfe10si8013636pjb.8.2023.12.12.03.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 03:48:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7E5C580A73E1; Tue, 12 Dec 2023 03:48:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbjLLLsO (ORCPT + 99 others); Tue, 12 Dec 2023 06:48:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232383AbjLLLsN (ORCPT ); Tue, 12 Dec 2023 06:48:13 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ADDCDB for ; Tue, 12 Dec 2023 03:48:19 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rD1FF-0006p6-5q; Tue, 12 Dec 2023 12:48:13 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rD1FE-00FKLC-PE; Tue, 12 Dec 2023 12:48:12 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rD1FE-001bJi-Fs; Tue, 12 Dec 2023 12:48:12 +0100 Date: Tue, 12 Dec 2023 12:48:12 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Sean Young Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 4/6] pwm: Make it possible to apply PWM changes in atomic context Message-ID: <20231212114812.afzgjiunzc6druov@pengutronix.de> References: <57f48330eb606356e86be17f85253f0e3d6ab104.1702369869.git.sean@mess.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wotwwsshk5kuseg6" Content-Disposition: inline In-Reply-To: <57f48330eb606356e86be17f85253f0e3d6ab104.1702369869.git.sean@mess.org> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 03:48:23 -0800 (PST) --wotwwsshk5kuseg6 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Sean, On Tue, Dec 12, 2023 at 08:34:03AM +0000, Sean Young wrote: > +/** > + * pwm_apply_might_sleep() - atomically apply a new state to a PWM device > + * Cannot be used in atomic context. > + * @pwm: PWM device > + * @state: new state to apply > + */ > +int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state= *state) > +{ > + int err; > + > + /* > + * Some lowlevel driver's implementations of .apply() make use of > + * mutexes, also with some drivers only returning when the new > + * configuration is active calling pwm_apply_might_sleep() from atomic = context > + * is a bad idea. So make it explicit that calling this function might > + * sleep. > + */ > + might_sleep(); > + > + if (IS_ENABLED(CONFIG_PWM_DEBUG) && pwm->chip->atomic) { > + /* > + * Catch any drivers that have been marked as atomic but > + * that will sleep anyway. > + */ > + non_block_start(); > + err =3D pwm_apply_unchecked(pwm, state); > + non_block_end(); > + } else { > + err =3D pwm_apply_unchecked(pwm, state); > + } > + > /* > * only do this after pwm->state was applied as some > * implementations of .get_state depend on this > */ > - pwm_apply_debug(pwm, state); > + if (!err) > + pwm_apply_debug(pwm, state); It's easier to keep that in pwm_apply_unchecked(), isn't it? Then pwm_apply_atomic() also benefits from the checks. I'm not so happy with the function name of pwm_apply_unchecked(), but I don't have a good suggestion either. Probably I'd have chosen __pam_apply(), but that's probably subjective. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --wotwwsshk5kuseg6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmV4SHsACgkQj4D7WH0S /k74ygf/d/ALSfb+yMsRUGqLtZbQ7QFlbxZ7Xdahj4u3XgKiwSJwV5WlK8qFsm0T Pd7U8STpUt+HJggcHMTOmPYd18XmSZOkX86VPlDLbVFXAGTE9jpy15ll9VLw5vFm AqBdeFm81hYOkHvi+9oEkaw6kXhRNlLoGmpxkhWkW7RE2lx+M7I9C/KghvfSJiss o77C2/Ak8dhPq1b0c9Nc5DsFQ02QZ7QTujr/eAbPPhmDNv188GKlA7AzTBaGdzEd pP01de0tkFB/DDJRsD64YZ2T7UOzzv4RlQGtNVokEpxG8UYLpqhfC5SPjt02Slqz AgOY1Y5o7nXSqD6vq9KIFUL7kezbNA== =rd9i -----END PGP SIGNATURE----- --wotwwsshk5kuseg6--