Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10744799rwr; Fri, 12 May 2023 12:18:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KzVjUtNC/n01gGyMYHXB8sZbkFuDA0lDbAbjHmEcx8COCmRj2LoZGwcFMjE/NyclSFeV3 X-Received: by 2002:a05:6a20:12cc:b0:104:873:c3be with SMTP id v12-20020a056a2012cc00b001040873c3bemr6491860pzg.12.1683919095507; Fri, 12 May 2023 12:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683919095; cv=none; d=google.com; s=arc-20160816; b=TSIaiJ8J1ZPU5ujgnrQbT6KzpeJum3xcfxtkCbYm+IyGY1sSopvrMJhAI7ytFtvbEU hDCYhBWmyFPu7tl1kzzpQemjn09x5AMH1iqjiDHcBXfuLUEuLPCar9cNpJCYrxHVYHdp CLyBRTneF3g5dM0l9VgncmS3VbH6iXEpgZ8wjVvdf6wuif/as9eGBFp5B1T5bXC0qyrr 2ShEuSgroIF4iGzF5qHBRMeqFKdliSzJnusPPP7O4dYbXbNjgJUSxjlvMHp3HtZ8G5r+ tXJQAdxNoV1f61yR6Ve2qIgrQd7URW1BEUp6cflK6Iq63Oq5um/P078zuKIIBNwYrQip 8IAQ== 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=rh1tQCkytRXbmByO7cfqZjRDtpCj67ousfGxCB9/NYU=; b=Rl6MQNDTSf0Q3tVwnSYEyGhWu2vJYmXAb0/PIictebA0E2NyXyVE5n+/V2KqRFVNSJ nl4KlcUFzk37p7EF28qMxwqT8QxunAiQBp43ufbEGZgBoOhM64y1sr3nhLsHg+yd3ZQH LYpUZYGQdwqPo+pExU4vDLik56XfF7ATpKNTPrABT1YaghLpGWFAg1TfdxP6EbEiUzrk v+fL97/J7blSBjC6s6NK9P2unHz+/7ggh6CvMUgfb8iZCjrc062Qpv4zmmHn8ZM8LE86 Wd8pSzZq61Ja7hi/v6N8ORg4GzIBuQyy4Y3BfdkynPCIIJ/y+QO8ef1Ci6GEyolQoxYD S0Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020aa79a46000000b006478fe28452si8528211pfj.27.2023.05.12.12.18.00; Fri, 12 May 2023 12:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239160AbjELStg (ORCPT + 99 others); Fri, 12 May 2023 14:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbjELStf (ORCPT ); Fri, 12 May 2023 14:49:35 -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 2A6EC5585 for ; Fri, 12 May 2023 11:49:34 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pxXpX-0004Ty-Ri; Fri, 12 May 2023 20:49:27 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pxXpW-0031s5-UK; Fri, 12 May 2023 20:49:26 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pxXpV-003odu-IK; Fri, 12 May 2023 20:49:25 +0200 Date: Fri, 12 May 2023 20:49:25 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Johan Hovold Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH] driver core: Call pm_runtime_put_sync() only after device_remove() Message-ID: <20230512184925.d7w3j4r7oajtpsxi@pengutronix.de> References: <20230511073428.10264-1-u.kleine-koenig@pengutronix.de> <20230511103923.hvibdyo5ges4bab2@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nbpmey6zhsjg25lq" Content-Disposition: inline In-Reply-To: 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 --nbpmey6zhsjg25lq Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 12, 2023 at 09:40:01AM +0200, Johan Hovold wrote: > On Thu, May 11, 2023 at 04:44:25PM +0200, Rafael J. Wysocki wrote: > > On Thu, May 11, 2023 at 1:48=E2=80=AFPM Johan Hovold = wrote: >=20 > > > No, this seems like very bad idea and even violates the documentation > > > which clearly states that the usage counter is balanced before calling > > > remove() so that drivers can use pm_runtime_suspend() to put devices > > > into suspended state. > >=20 > > I missed that, sorry. > >=20 > > > There's is really no good reason to even try to change as this is in = no > > > way a fast path. > >=20 > > Still, I think that while the "put" part needs to be done before > > device_remove(), the actual state change can be carried out later. > >=20 > > So something like > >=20 > > pm_runtime_put_noidle(dev); > >=20 > > device_remove(dev); > >=20 > > pm_runtime_suspend(dev); > >=20 > > would generally work, wouldn't it? >=20 > No, as drivers typically disable runtime pm in their remove callbacks, > that pm_runtime_suspend() would amount to a no-op (and calling the > driver pm ops post unbind and the driver having freed its data would > not work either). However if a driver author also cares for the CONFIG_PM=3Dn case, calling pm_runtime_suspend() doesn't have the intended effect and so it's unfortunately complicated to rely on runtime-pm to power down your device and you have to do it by hand anyhow (unless you let your driver depend on CONFIG_PM). So I'm not convinced that "A driver can call pm_runtime_suspend() to power down" is a useful thing to have. In the end something like 72362dcdf654 ("can: mcp251xfd: mcp251xfd_unregister(): simplify runtime PM handling") might be an approach. But IMHO it's more complicated than it should be and honestly I'm not sure if it's safe and correct this way. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | Industrial Linux Solutions | https://www.pengutronix.de/ | --nbpmey6zhsjg25lq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmReijQACgkQj4D7WH0S /k658ggAsjeo7koFj/nx0LObSxTtW1vC0fPsg5HchvVtxqz0ao1nfod+ObPuJiTW hLsNGqOClxHV7e3W4zddJBm5dP39jPENLn5AOlCfYx2Z5S597ASE8WO/Rj34/RNq v60rAe/FwHq8ymexsT4NFV62YY7PtLM4NLldmoc3uffZfTWzm0vLlQMFHlurXUHe bJFBQqwNzQIOqlz0hzb8U4CKPZm+jv9RO6V2DSQKi4Sde/08tK9mY70N86P/cbOV 9LOAys+3svuHLNzWNk8tXtUFbZVmzCiQ8laI5WKDDNAIo6tTXEB2Oo9yaIv/XVkR 2fYQFjGfs4P7iBoI37KpcAZ6LM5mzQ== =Atyz -----END PGP SIGNATURE----- --nbpmey6zhsjg25lq--