Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp8907rwb; Thu, 12 Jan 2023 02:48:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXunGW2WOM4/rE4IZFk9cPlaUvzznS6uYCIjBaIfM781/txc5AV/6ir27QZEjlSCznM9vsrC X-Received: by 2002:a17:907:900b:b0:84d:4e4e:2c7b with SMTP id ay11-20020a170907900b00b0084d4e4e2c7bmr10082932ejc.30.1673520487064; Thu, 12 Jan 2023 02:48:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673520487; cv=none; d=google.com; s=arc-20160816; b=WccbwCSclfOM0Apchxi7HUK88Vq1hNC+NmH5OMW5QnhI5a3xiFX9aCmbXkOUGxtpKW mVi2h/apYqPpcBPmWiOFhkVrZPVFy9JaryEWj3ajnGfHTg6Za2rO87x2dxHKK9iaoj+k TqzG2K9iK07MdCFPD41h6hAUN3WTusw3FE2wNf2P0lYn6gJSeq5FWotQxlDV2LdmLLPU T3dK7auqbcY1qni7/Lugr2gta1+Uvvu0jxex16VUJ/89hF4i2OtIJqNEPXf8ExR7dOfg Q/f+B5kXO1LWcUkx0TF+syLc8CsyCpTAahKs0DSHQkgHXwQNT9Mq+LGf8uWVHbzhy27g BfSA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=34ygEy1+GS0Y/qu3m/B5kUuzoRWt1oEYp4NuIKDOfqY=; b=POoJte7+Vuijd4POBCtXgBumADceDGotSGmPi6ZiUsC/dCC4byduVnMAYyTSOMUa5X yXcEARdFzLoX9IoloGavQEBvalKL63emqSCKdVWoNjr4CwjNXEAN9HDU52RW1L8GM61R Vv3cNGG6rsO/q1qdXWVfsQzGUkFHooPW/st6NYmEns422RvTSScSCv5kVnYfRzRYO3tZ P+7IB/Ez/M0bTbkfdPNNEST+5ZjwahepLp04mN+/T+eNq1252m++jd2H40j9rgOuxSYZ O3RHOcEctrThBbXU7MJN63eqFFfG4RRw97Tzp2n7yOeIedaMytl9zkjBjZi1M07tQu6j 2TBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Uy3MOEEd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="8I/zqzp3"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170906654500b00842f9a2a844si13726353ejn.229.2023.01.12.02.47.55; Thu, 12 Jan 2023 02:48:07 -0800 (PST) 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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Uy3MOEEd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="8I/zqzp3"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229781AbjALKkG (ORCPT + 49 others); Thu, 12 Jan 2023 05:40:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239944AbjALKiy (ORCPT ); Thu, 12 Jan 2023 05:38:54 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A06A5A448; Thu, 12 Jan 2023 02:33:01 -0800 (PST) Date: Thu, 12 Jan 2023 11:32:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673519580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34ygEy1+GS0Y/qu3m/B5kUuzoRWt1oEYp4NuIKDOfqY=; b=Uy3MOEEdxIX5mg+VrtgEzoJZGRwbT/EYIUGW3M5gs4VXaf9ZH19kCW2Pr0L58TYEEfPzOS NrGRLqvmqtl7uLz6VARLu+A5YwX6e6288ukUyBDL9SrCR2owQUgLM2G2B22EPN4VkI2T5R ggs3DO2viFcgIUh2YXKZNEvQAYWkhsOn/4jPsMqTe/1cP7kNz+9y4TFPYOHLezoowN8xHF 6WlozPfs/Qfh8j6KviLoYwfXFT2lDH0o9D8MdwB0B+N6DD60TYO5llYDoCqtkPmUwNcDFG S8cB1UMjYdPg4IbmYhtvR9X735C+ZsU6NeLTicwio2+bYnrOnFfy9bKtr69nBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673519580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34ygEy1+GS0Y/qu3m/B5kUuzoRWt1oEYp4NuIKDOfqY=; b=8I/zqzp3u/8aTJZeP1Ni7RVtF+/L3mzeJMhGFzxBwi1H+CHnN0CurxqB08sdhdDyry5F9e wgObcssitOZxPzAw== From: Sebastian Andrzej Siewior To: Krzysztof Kozlowski Cc: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Kevin Hilman , Ulf Hansson , Daniel Lezcano , Lorenzo Pieralisi , Sudeep Holla , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Adrien Thierry , Brian Masney , linux-rt-users@vger.kernel.org Subject: Re: [PATCH v2 1/5] PM: domains: Add GENPD_FLAG_RT_SAFE for PREEMPT_RT Message-ID: References: <20221219151503.385816-1-krzysztof.kozlowski@linaro.org> <20221219151503.385816-2-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20221219151503.385816-2-krzysztof.kozlowski@linaro.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 On 2022-12-19 16:14:59 [+0100], Krzysztof Kozlowski wrote: > Realtime kernels with PREEMPT_RT must use raw_spinlock_t for domains > which are invoked from CPU idle (thus from atomic section). Example is > cpuidle PSCI domain driver which itself is PREEMPT_RT safe, but is being > called as part of cpuidle. I think it needs to be clarified what PREEMPT_RT safe means. PSCI is an external interface which does not inform us what it does and how long the operation will take. The ACPI table for instance populate several idle states and their entry/exit time. Then you can decide if and when an entry/exit latency of 500us is PREEMPT_RT safe. > Add a flag allowing a power domain provider to indicate it is RT safe. > The flag is supposed to be used with existing GENPD_FLAG_IRQ_SAFE. >=20 > Cc: Adrien Thierry > Cc: Brian Masney > Cc: linux-rt-users@vger.kernel.org > Signed-off-by: Krzysztof Kozlowski >=20 =E2=80=A6 > index 1cd41bdf73cf..0a1600244963 100644 > --- a/include/linux/pm_domain.h > +++ b/include/linux/pm_domain.h > @@ -61,6 +61,14 @@ > * GENPD_FLAG_MIN_RESIDENCY: Enable the genpd governor to consider its > * components' next wakeup when determining the > * optimal idle state. > + * > + * GENPD_FLAG_RT_SAFE: When used with GENPD_FLAG_IRQ_SAFE, this informs > + * genpd that its backend callbacks, ->power_on|off(), > + * do not use other spinlocks. They might use > + * raw_spinlocks or other pre-emption-disable > + * methods, all of which are PREEMPT_RT safe. Note Please use spinlock_t and raw_spinlock_t. Wouldn't it be better to write "preemption" instead "pre-emption"? The important part is probably that once a raw_spinlock_t has been acquired, it is not possible to invoke any function that acquries sleeping locks (which includes memory allocations). While even without that flag it is possible to invoke a function which disables and enables preemption on its own. > + * that, a genpd having this flag set, requires its > + * masterdomains to also have it set. This could be verified upon registration, no? It might be worth noting that preemption-off section during PM operations contribute to the system's max latency. Depending on how low the operation is, it may or may not be a problem. The ->power_on|off() refers to the sate of the component, right? > */ > #define GENPD_FLAG_PM_CLK (1U << 0) > #define GENPD_FLAG_IRQ_SAFE (1U << 1) Sebastian