From patchwork Mon Apr 29 14:05:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC9B6C04FFE for ; Mon, 29 Apr 2024 14:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GO3zvncvbwVu0UxND26khw2SGO0/U0tJjuaxTWKIOBc=; b=yU45PRWhmh1Y0B bktDdzCgG9zUxn3JbAPW6CLD3e7f3ebcjdeuFZfSnLMpnWJVsOZkPh7QJtUlqDu3qj0B/KGEZMAxv g/LoMp7Q9P+4ChhqsUx/DEzbhCKyC2Lkf8noAr1WlA47ckFVccgJUnTYWFDbBRR3XJ69B531uXylA 5BK8LJ23jf6R1Ic4vS6W47h4PQOzFTWSVJJ353FkDxxHWc9uihWZmgEvDiMaDVGGXMvEoWt503Ibd ST/Yn7QBTWpQdCQ8BmQlBJ8OAHrvl3CrrgLGyt8HmqOP8oNjMg6lArnVZBvsrSGpk8W8DQRJgDYoh ihKx2TqWdxs7GOobPtlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdw-000000033OS-1rKs; Mon, 29 Apr 2024 14:06:08 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdj-000000033KU-1oGb for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:05:56 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-518a56cdbcfso7074152e87.2 for ; Mon, 29 Apr 2024 07:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399552; x=1715004352; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v7PwnHMKHYTfq+/GlcRBAJxV8k/M8+pq8KDTTyHcZEg=; b=f3yBkS/PJYqV3UB6Qk58UznFmd44LrBd6+ey6TDknTFpqXavP1Fu7OcDfVXS4Lgdmw YP0KwqCW8pkGzaviW4xvS9VVivyYWGA6EjuubPKkGFSOnaycIzcLXpEdiDkLsCys6jPB pBtSw7TuHzdxzLq5aRKaWmzK869+A6JVl+T0D+1KDCIEj1bY/JHXobFhY2bIsj+XCnWK q02qz3+sF0QmW76XMYDrszGaYLj04K5y3NfB64rHf25JULyjegallGC9i2MFMVuZ7u4B de5e4IUOaQvBwSuHxVBgtjopVDRbAb7uDJ4lZVQVnQzXBpd95JoJzQJYZPaPiC1kXlMn xqeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399552; x=1715004352; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v7PwnHMKHYTfq+/GlcRBAJxV8k/M8+pq8KDTTyHcZEg=; b=gLJUFSqy0LT8FgOSiDPy+LLHCL+rFjB31TGBlKbLM6q9CApTjfZshZEjOHqxSzx4zT QLj9PNT7lWxt1ECE37jREnBIc99TQwfUWnFDZ8RaZgcKcbqglxQ7ZFy/KHCx1Fm+BoRD MiBmnZZDNPE8po6cTgeV55jlpS8Y9NTcsOfRUB0lkL+jQUkwiURy/JpI+YlTuFAMhmBH UwEyjeTPoR1ocEWB816EVCjVHV8uBB2Ncm5OwkEboaYnrJEGIR43QLOVFjUQwxx8Fgpo SPUv706jfrZfxpCJXTwlQwQQ06cY32gtsFsCVAcx//seG9ezv5UCZFmcPg4sjsWRuZL5 xiHg== X-Forwarded-Encrypted: i=1; AJvYcCXgPdswsibhV1tLN1osM1Iqpn7evKtB3fMqdqG6PmJCNdLk1VfQzPlOI8F3mMbqwfKZRWTRbZSAKm4wTRv5y8ASUgGjf/PAiRgrDvrSLpOgag/sPPQ= X-Gm-Message-State: AOJu0YxTzJ2NPXmpiSLETlqh95C9xYD8G8OxHZNlpSXzxqF0JFpjinMw rXmWu0Q3+WHNL9imqOqcOl0htS2vk79lfzHJX1izZ0aK5DqMOAs1IsMSj7rC5Ew= X-Google-Smtp-Source: AGHT+IFR8cvupOz4nvn65URl6ZTQLfP1foLQ6aQMTVOSVqjXElBksfqqnj9dzeKq2OEC3TicFEDdMA== X-Received: by 2002:a05:651c:211b:b0:2d8:d972:67e3 with SMTP id a27-20020a05651c211b00b002d8d97267e3mr10312447ljq.5.1714399552449; Mon, 29 Apr 2024 07:05:52 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:52 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] pmdomain: core: Enable s2idle for CPU PM domains on PREEMPT_RT Date: Mon, 29 Apr 2024 16:05:26 +0200 Message-Id: <20240429140531.210576-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_070555_494661_6ED1ACCC X-CRM114-Status: GOOD ( 17.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To allow a genpd provider for a CPU PM domain to enter a domain-idle-state during s2idle on a PREEMPT_RT based configuration, we can't use the regular spinlock, as they are turned into sleepable locks on PREEMPT_RT. To address this problem, let's convert into using the raw spinlock, but only for genpd providers that have the GENPD_FLAG_CPU_DOMAIN bit set. In this way, the lock can still be acquired/released in atomic context, which is needed in the idle-path for PREEMPT_RT. Do note that the genpd power-on/off notifiers may also be fired during s2idle, but these are already prepared for PREEMPT_RT as they are based on the raw notifiers. However, consumers of them may need to adopt accordingly to work properly on PREEMPT_RT. Signed-off-by: Ulf Hansson --- drivers/pmdomain/core.c | 47 ++++++++++++++++++++++++++++++++++++++- include/linux/pm_domain.h | 5 ++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 342779464c0d..abd3c069df8b 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -117,6 +117,48 @@ static const struct genpd_lock_ops genpd_spin_ops = { .unlock = genpd_unlock_spin, }; +static void genpd_lock_raw_spin(struct generic_pm_domain *genpd) + __acquires(&genpd->raw_slock) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&genpd->raw_slock, flags); + genpd->raw_lock_flags = flags; +} + +static void genpd_lock_nested_raw_spin(struct generic_pm_domain *genpd, + int depth) + __acquires(&genpd->raw_slock) +{ + unsigned long flags; + + raw_spin_lock_irqsave_nested(&genpd->raw_slock, flags, depth); + genpd->raw_lock_flags = flags; +} + +static int genpd_lock_interruptible_raw_spin(struct generic_pm_domain *genpd) + __acquires(&genpd->raw_slock) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&genpd->raw_slock, flags); + genpd->raw_lock_flags = flags; + return 0; +} + +static void genpd_unlock_raw_spin(struct generic_pm_domain *genpd) + __releases(&genpd->raw_slock) +{ + raw_spin_unlock_irqrestore(&genpd->raw_slock, genpd->raw_lock_flags); +} + +static const struct genpd_lock_ops genpd_raw_spin_ops = { + .lock = genpd_lock_raw_spin, + .lock_nested = genpd_lock_nested_raw_spin, + .lock_interruptible = genpd_lock_interruptible_raw_spin, + .unlock = genpd_unlock_raw_spin, +}; + #define genpd_lock(p) p->lock_ops->lock(p) #define genpd_lock_nested(p, d) p->lock_ops->lock_nested(p, d) #define genpd_lock_interruptible(p) p->lock_ops->lock_interruptible(p) @@ -2069,7 +2111,10 @@ static void genpd_free_data(struct generic_pm_domain *genpd) static void genpd_lock_init(struct generic_pm_domain *genpd) { - if (genpd->flags & GENPD_FLAG_IRQ_SAFE) { + if (genpd->flags & GENPD_FLAG_CPU_DOMAIN) { + raw_spin_lock_init(&genpd->raw_slock); + genpd->lock_ops = &genpd_raw_spin_ops; + } else if (genpd->flags & GENPD_FLAG_IRQ_SAFE) { spin_lock_init(&genpd->slock); genpd->lock_ops = &genpd_spin_ops; } else { diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 772d3280d35f..670392ecd076 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -194,8 +194,11 @@ struct generic_pm_domain { spinlock_t slock; unsigned long lock_flags; }; + struct { + raw_spinlock_t raw_slock; + unsigned long raw_lock_flags; + }; }; - }; static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) From patchwork Mon Apr 29 14:05:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD3A9C19F53 for ; Mon, 29 Apr 2024 14:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S/XGbQ1wVElp7U5+BfpPoe66EyC5AHvxIt19U14Vx8c=; b=MXtNaScOtkrc0d bmT8A4s3+wppqPGonE8xnzPAIYau93W0g1beUIiOVUNKcxNffh6rG54/IMwWvL/psdvY2YlcUAQTH ez2/nSpGEyIpSpg4G1F4NrCxGo8Xhe405F1IQBS7w+FyDZqM9B8AKHDyvfoN1ydyL5iEYzLP/gMta 9zt/b3qjVOAR+1nbPxNkSA+fL0DhFji9HRWFbnYc8OgHMNW2/bcSNn5tzAvi4udddeCKno9vAF+/f jV8LtfSMIEST3nSimNPpoQV+/gk4ADzjiSKHOTOwgqv5Qpz8sXB8ZwJ1VQlGs14JHtlf83sJaD2fR 7VYA/ycv5DGi2/Tv4JQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdx-000000033Oq-0txO; Mon, 29 Apr 2024 14:06:09 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdl-000000033LA-2Vqb for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:05:58 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d8a24f8a3cso55086051fa.1 for ; Mon, 29 Apr 2024 07:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399556; x=1715004356; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NhlwXdsIIQqTLzsLYWWuKXNc3rr4XrNJUhlJgkxDb2g=; b=SKSerwK8qpkA9gBpzOIX3uK54XKoZDjNG11BmdTKd6FM0Rv3BjFS72qrEL6bxuE6kt hoXaFw0WSL5bS02RNAXd+L2T0+Vi8ibXpeYCdBhD47zoFWB3pQbQOlNKPbzqVx3mVuPm b1IYq9iPiZON8p8OM+39lijSKgmujE8CdKwH0YTORJnNiso42ZIMeF+epoQ63M6a5EzM in1gCUj5oMLvJElsLVqmbt7TI73imqSgISzUBvMmlR35omAzPl7t4s5TuPKoJlYxd+ZZ Dv5xDQLaIR9Z8BSBi+T6+O3C+wNAsR9TlA/14xHqEHCUajIYYIx4DCH96wtbJtewQCm7 FX0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399556; x=1715004356; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NhlwXdsIIQqTLzsLYWWuKXNc3rr4XrNJUhlJgkxDb2g=; b=PL5hS8hvy6SxgC7CnAOLPLnoYV7+sIZwh4vOzZ/Kq/rSd1q5iod7L2QQ7vZc+iy96V rYzhMsKwJu27bXQYT9oXisxphOZy58bEkZohGsE3Vfc2YwAAKEYrwpohARyjNWumadtM zscCcevUCdUjKdIpykRofQsr5EBIA7fqFdcy4Ukn/J/YCeZHFeF3x0bkxS9BPPNPZcu+ eynX2s6z1Ff/9f2brsKFC22tFwUihg5YscMJky+bk2bCl+RKcIcU3hFcvIGnvNK2bo6e r75FCEN8DKLTEAClRkS4+OI3BbJduR/uwkg3/X8WNeGxW9yMsubla8sA3bfU/fMqRRwy D5xw== X-Forwarded-Encrypted: i=1; AJvYcCV6F8uws12ja0qWA93VYUSkiYNsAVzfTIFsFvLhU4G36ZXjEHYiPi0dkHcb8WkElx6ImmfgWh9vJtlI7/s1JdT0y8H/7+7JU59rY9kg2E1VXE9ayT0= X-Gm-Message-State: AOJu0YyZfKu5jfDsqdapBCqXudma6cSRYOyhCSHC7wG7wP3EG6xQJAnw 7t61woUeHuaEhZw9foFe+u6tNYEl+VT6XUhaBQTp0pvR1mcbCxYxpNvEZOaLLeg= X-Google-Smtp-Source: AGHT+IHPdwyXQU3aNRNl39I+1zVVIQFncsJfd0yL3gfsj/5GlxoblfJ4b4uEsKSkTrkhND9uPVuJKw== X-Received: by 2002:a05:651c:221b:b0:2e0:752c:1f2e with SMTP id y27-20020a05651c221b00b002e0752c1f2emr2172687ljq.1.1714399553969; Mon, 29 Apr 2024 07:05:53 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:53 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] pmdomain: core: Don't hold the genpd-lock when calling dev_pm_domain_set() Date: Mon, 29 Apr 2024 16:05:27 +0200 Message-Id: <20240429140531.210576-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_070557_711995_34A27EC9 X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is no need to hold the genpd-lock, while assigning the dev->pm_domain. In fact, it becomes a problem on a PREEMPT_RT based configuration as the genpd-lock may be a raw spinlock, while the lock acquired through the call to dev_pm_domain_set() is a regular spinlock. To fix the problem, let's simply move the calls to dev_pm_domain_set() outside the genpd-lock. Signed-off-by: Ulf Hansson --- drivers/pmdomain/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index abd3c069df8b..1e3f8dea4654 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -1726,7 +1726,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, genpd_lock(genpd); genpd_set_cpumask(genpd, gpd_data->cpu); - dev_pm_domain_set(dev, &genpd->domain); genpd->device_count++; if (gd) @@ -1735,6 +1734,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); genpd_unlock(genpd); + dev_pm_domain_set(dev, &genpd->domain); out: if (ret) genpd_free_dev_data(dev, gpd_data); @@ -1791,12 +1791,13 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, genpd->gd->max_off_time_changed = true; genpd_clear_cpumask(genpd, gpd_data->cpu); - dev_pm_domain_set(dev, NULL); list_del_init(&pdd->list_node); genpd_unlock(genpd); + dev_pm_domain_set(dev, NULL); + if (genpd->detach_dev) genpd->detach_dev(genpd, dev); From patchwork Mon Apr 29 14:05:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52B0BC4345F for ; Mon, 29 Apr 2024 14:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=saOJlNu25YP7+qMPxxY25944A9FA3qQTnbUDYojJ9cA=; b=EPt+Y3ffQzYw+u MFsbaiSlRabNyf96InW8Z0hyJli4A6w4uvt+n860YXfncEWqlGUX1hEAOuAF3TjglJ8bkLEayK7gR imOqhToxdFt75EMgM5fD3srkzEqMyZ5Zj4T/0Hnhftg+F6jpklkTi3tYME86H9/X5Y67cqrXs+GnU fHTwm4HEVvARu04Fv+658XHe8DEoo9tj8ot6Ij+4Of6/eCnYUVZugL4VtmnrRoIfmZLPGP9wdS8sL 9tLQl3QvcJtm1+1PFXDXKo7SE7nhpLDlrO7CW3qHHebUytPI6v1ISLtYfFxuJiAcrDjovTE48vwGz rdUEi/tqjAGt9+g3pgow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdx-000000033PI-3foO; Mon, 29 Apr 2024 14:06:09 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdn-000000033LQ-3VUn for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:06:01 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2db13ca0363so71650331fa.3 for ; Mon, 29 Apr 2024 07:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399557; x=1715004357; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AW5irYe0gjQq7lL2yVFdE32QB/2sja742dgELwuFIJk=; b=RSzM17bF5LElOomwitQbZWbmFlUOIiqnutfXjd8SKyYKJZLxYfyS5QEmjhOX9STENU 5xDRDQ7fZuRKKPZ3xhPrJnBcwlYLoLCYpujpARGiL5QThnfs6Ft+vlJUvsVIIlRRbmFS IvbT+8/1kJHvAj6bFwgrzhwikjIx9oqWniKraR9R0PqsKdVbqlBwtZZfMt5BJ2pqEyp9 Rz0VRng0nG1gxWERm93fS0j/bgiRNln9EnvgOqfZEm/pKrO4CzwcF3TQXSt8LDGJDn9W feI4rhAhPVnRlSegfsR+yzNcd7bfzcYXC4EESaXzpuWMYbaXvBvQchQ/VyLUnz9nCkD5 w7Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399557; x=1715004357; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AW5irYe0gjQq7lL2yVFdE32QB/2sja742dgELwuFIJk=; b=wizuymrYcQq8542mLx4SjTPu0GhNf4qN02zjSz2fIjV0nawy5z7ooW6e52CCLaUv94 YxrRjjo/KCJBqpXI6A7xEDQJkQhdQ+lZWeON3m1pSlS3KankA6O0YiphlTuRSImrYC16 xx2qYIsR4q0ct+rDBfhC+j53ct3ZVogwAuLtgccLm3D5TsbMB+rskWMQhM1kY/5F+2xH OTwRN2mx3ogRG+hfK5ZuXu8DgmWv4ujCxeUfHk2X48binYk7G/909S4xS1+x8QkFYTfq /52NcY7U3Yx4VWM6W0ceLfE9wnBlK0dxwql5nm3mmFnjlD256q3rnyYzY2pnXkEDWemL 0i3A== X-Forwarded-Encrypted: i=1; AJvYcCXQoKSDDgJeS0jV1YrMqLEmAToKwDa/G5xMLnd2R2GLdgbJDk90KnzM5C/GrNNcTNdFsasRf6LEi4TD9fhF/E8nvdodZevp/6d8y0962hokz1IBDTE= X-Gm-Message-State: AOJu0Yz3kqUV6m1IYjsYryr/Lewt5owpz05QwiAtc0kJncAbgsEn8lgQ DfsI0CojUUTuLj+udP11gp1W0ASsM/lzLDNIHuhggtC79NjLmEjaQvJo3aEaT1A= X-Google-Smtp-Source: AGHT+IGF1UWUkvnjVr7+ybR1e2V30LVUypzK2Fkn+AyO/pGbJIHureio72OUBUaKULp0nWYCZstvjA== X-Received: by 2002:a2e:730c:0:b0:2d8:5af9:90c5 with SMTP id o12-20020a2e730c000000b002d85af990c5mr8482506ljc.39.1714399557079; Mon, 29 Apr 2024 07:05:57 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:56 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] cpuidle: psci-domain: Enable system-wide suspend on PREEMPT_RT Date: Mon, 29 Apr 2024 16:05:28 +0200 Message-Id: <20240429140531.210576-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_070600_015126_0F357FCD X-CRM114-Status: GOOD ( 15.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The domain-idle-states are currently disabled on a PREEMPT_RT based configuration for the cpuidle-psci-domain. To enable them to be used for system-wide suspend and in particular during s2idle, let's set the GENPD_FLAG_RPM_ALWAYS_ON instead of GENPD_FLAG_ALWAYS_ON for the corresponding genpd provider. In this way, the runtime PM path remains disabled in genpd for its attached devices, while powering-on/off the PM domain during system-wide suspend becomes allowed. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index fae958794339..ea28b73ef3fb 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -67,12 +67,16 @@ static int psci_pd_init(struct device_node *np, bool use_osi) /* * Allow power off when OSI has been successfully enabled. - * PREEMPT_RT is not yet ready to enter domain idle states. + * On a PREEMPT_RT based configuration the domain idle states are + * supported, but only during system-wide suspend. */ - if (use_osi && !IS_ENABLED(CONFIG_PREEMPT_RT)) + if (use_osi) { pd->power_off = psci_pd_power_off; - else + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + pd->flags |= GENPD_FLAG_RPM_ALWAYS_ON; + } else { pd->flags |= GENPD_FLAG_ALWAYS_ON; + } /* Use governor for CPU PM domains if it has some states to manage. */ pd_gov = pd->states ? &pm_domain_cpu_gov : NULL; From patchwork Mon Apr 29 14:05:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD5C9C25B10 for ; Mon, 29 Apr 2024 14:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=T0ScCMQCUEvoTGlubbLIveHSrHsV8BHgnNQVdlqZAig=; b=rBzvhlwUYyivtw QWMy/V2O646j7kkK9w2YtRvpX48r/PYl6wBYSIDpQc9H/ttS/HVIqNDHnWu1AUN4MRipZr89o4w2B f1rx+XKL6azzRCRh/J5OQ71hM3GU/xRBf94BXGt3d9/6JGvPYTX72M4ibB+q85do6q6zqWbj2MWe/ 55jC91w56iXb+okIBi981//KCiEFYkYxFz40URUw/HZIYi6B8j46Y/+U8Y5vQR6CQQU52fGeSoZ4V 6R2ts8uwBkVOihSrgGBRlRsS0xAiRUkkLPeSXWgw1pzVLKLeIamckMSJZl6Mfxl6wn/cfA3XcHtPg xT/5knYVNHXMpYe/uHjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdy-000000033Pw-2Uw9; Mon, 29 Apr 2024 14:06:10 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdo-000000033M0-44z6 for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:06:02 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2df83058d48so30621051fa.1 for ; Mon, 29 Apr 2024 07:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399558; x=1715004358; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ryk8Yjnwcb/TeAS/NSYC6eu7KpbQ2RMUyBm2Fm6rA9s=; b=ubD6zre8BLgUOM0O5y3J9aLFj+t4CsP7aXzciur1vJJRFWbrkIzipmAQ4lz8Fg3ygr jpbOQTF+tVggYQwuNIaPeYijZVTrTHKexwjIxWVKfnAvt0GFrm4yjwQttcv5xfD8HNiw 1QdYgrwoj+bLAEeKCNOygYFrKiw7mD+IHukEc+ojIoUmplJYLs/2/nIUdmyL+xw6upPe R8nvVW85DWh9kc/1Kz7IEtkR4L0k8JuV+eZOKJT1bsIA5/4EeEwZ2y4Ze8TnUs+9zjUJ 53lz9prAc4WSrKI3N4tof/35sL5Dgv5kfZgVhq7b+xKih4gvEhpOQKhiw31YRcPp55WL +9OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399558; x=1715004358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ryk8Yjnwcb/TeAS/NSYC6eu7KpbQ2RMUyBm2Fm6rA9s=; b=bfykzopMHTW4ov71jIdCnq+G6FHCGJReEP049wImb9XUAEUrifzfotDFRLBbOY+WlP fqeGPkAchCwDWx6im37lgai7ChcqeQqkXYc0C26SX8sFdWvtt+POIItf4Ii+uqNW1xJs 1cZNKubHWP5UhGeB9OuXaNRzqF5WSyWzfHbtfw00nxdy0kky144XZY2RwNk3KFqmaY2H iGz8KFonBZSqxZBFI4Ncl7ugiHaxnrnHsQg4UuaQAp7XUQOfjjsmrBnRecUDb9uxZrJq hZAbnXfgrj4eYPaecsz+6vN4jPceeHYp73Ee4s+x2exa+fp4KbzEo6JkqpZnKSXxzdzQ U9bg== X-Forwarded-Encrypted: i=1; AJvYcCWnFgOpAIjpvOxmNWlhFu6Zu+2iJ5/2H+mftw3RfTrE3P9lKJJ5hNtFFfVMAEkVgfQIm9C3CQ6WBguK1OTAW9XnPhZY3cZg6zHPPJNIm0xwsbpd9rw= X-Gm-Message-State: AOJu0YyrqDkORn+O7FI2DwXF1Z5RoMx3+oS6WKgmyx6togQ8juPWohxY WPumJ39pXtaV1H1tfXA9i2LnQAMyiKIMPNAIVr1PTfF3d/g71gQo409Ybw+WRyA= X-Google-Smtp-Source: AGHT+IHXIApKuUwmhZVbv+qbGSSWrutGduBAYZPG18WJ+SF5X8KY8BLp8xAT7YhpWiZQaddV7NhglA== X-Received: by 2002:a2e:be08:0:b0:2e0:2661:77fc with SMTP id z8-20020a2ebe08000000b002e0266177fcmr3590162ljq.39.1714399558442; Mon, 29 Apr 2024 07:05:58 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:58 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] cpuidle: psci: Drop redundant assignment of CPUIDLE_FLAG_RCU_IDLE Date: Mon, 29 Apr 2024 16:05:29 +0200 Message-Id: <20240429140531.210576-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_070601_069360_132C650F X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When using the hierarchical topology and PSCI OSI-mode we may end up overriding the deepest idle-state's ->enter|enter_s2idle() callbacks, but there is no point to also re-assign the CPUIDLE_FLAG_RCU_IDLE for the idle-state in question, as that has already been set when parsing the states from DT. See init_state_node(). Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 782030a27703..d82a8bc1b194 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -234,7 +234,6 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv, * of a shared state for the domain, assumes the domain states are all * deeper states. */ - drv->states[state_count - 1].flags |= CPUIDLE_FLAG_RCU_IDLE; drv->states[state_count - 1].enter = psci_enter_domain_idle_state; drv->states[state_count - 1].enter_s2idle = psci_enter_s2idle_domain_idle_state; psci_cpuidle_use_cpuhp = true; From patchwork Mon Apr 29 14:05:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46D70C04FFE for ; Mon, 29 Apr 2024 14:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4v61oNLN1Lj7Aqb0ZajK6g3668KFU9q90n5xn8MOfZQ=; b=M7FftxnyYy65dZ 7iY8fHpsoucU995sOjkhP8P8M1whZGw8Nm4noPUiZyaKqaSWeiG2hqw2a+s3k+FCKoC+2SoT2MoYZ 8k3GGHayHCohWm4FgmJTagT68JkijsVnHFN4Qjo4GoHcQead0QueAKfQT82hBEsC//oSVCc2IUtJz 5z7i0cepJfg/X5N9FgU05WhSU6264KFZ04pqPtgJe2coINVAHr/54yBJuSuTsCiOc5rBjNe30Vjnm As2Rk9aZWeyYZRp16Fkd5BZrVtLGeEqQSIJmcVGELxMaiSYRZ6oCBnbqmOJWxhCKwnoign/PAH256 mTmRxWiDS3c1sZtTvKAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdz-000000033Qk-3Ci1; Mon, 29 Apr 2024 14:06:11 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rdr-000000033MY-0Dk8 for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:06:04 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2dd041acff1so51666411fa.1 for ; Mon, 29 Apr 2024 07:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399560; x=1715004360; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PRW2Pq+Tdw9L+sqrvYL/hlPVkk69kmUaGQ7JliOeiWk=; b=dx4Zh4/CE+FUznrr9v762ehM5qotcWuLXMv9ThMr/bPwuyg5ata3LT9XR/rTUshzTS C6BGf06S1ToEIHFrieXP0tV/aSsgjyFeAQDHvYtaPiuiZUC/YcR85XVemdCAGo8wx8DV 0MO7kBTlp/3yQ7m57TboQh7t5WLMere795FiaoaDUmoIODkq7DB1zHxotFVOVueXCGsN fG9xbFQxYa0BBt/m66D6kVoNxnUgI6yjH3+6/6pkhwz/LMfE5fcXKPiHnve5bzt6GXNn 8iptPB9/kYQrC363WtrhPrkjbMUYsEkq1YvI6K8cfTnJ/MGC7CKbGm1tx3R6CawoXosZ McPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399560; x=1715004360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PRW2Pq+Tdw9L+sqrvYL/hlPVkk69kmUaGQ7JliOeiWk=; b=GNjf37JgOzmgou4Nt+cXXKUOFUVIFGs8UGXJu8tsgjWXZ6WZDYQIuQLTPYgoj04x4M pi9OZpKTNjBakvpdfL3tFmNHtmA1K8euB3tbZJZixUJa35ikdpgiQSzRsydHsuNz2WI3 13AMVtzcmr9uizrSVC/N5QjJrTtqizkSz85U2MI1OuE/K2nXxgKLbnSmcTZPJEYjAD2z ZXVTczq3UtJODphBPRJXkuhWeKxSjXoaw8/NtuHmYURni80HhmCuAqfJHWWtYotbxMKW 0AIqi8nBYGXk1TGDiOOd54lHzhHZjpc6x33TBmzcDdcYLJCRFFgwkw9R9h1Tfy8R+GDk epZg== X-Forwarded-Encrypted: i=1; AJvYcCU8gJTMwsRQR9S3Y8iKVfSUbHskLxKPoeeDOa3Gw93npkQnKZ7LETDywIeplCVhaUWKUGQrAVWPDcv+fhB7t0FshgaUVMAvRFKo1s93RlNCxCRYOpc= X-Gm-Message-State: AOJu0YzArJTkKAitAbvPLWrzsLEufsNsUnGDMG0vHkMNYkpjQ9q0/M0C RNaiM+hdwQ6rIHoEMiRAlutZYr1zUmHWprGOO7+Cwocr1wPVAItiFJUK70tl7+o= X-Google-Smtp-Source: AGHT+IGIsr9yUsbk31OY7Zps8MJ+0AvyGsEZBZ8WqFFN1lmQJPsxbIeDmm4LCdu93BtCTFbs9IJWAA== X-Received: by 2002:a2e:a26c:0:b0:2df:b0c4:3ede with SMTP id k12-20020a2ea26c000000b002dfb0c43edemr4066331ljm.19.1714399559743; Mon, 29 Apr 2024 07:05:59 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:59 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] cpuidle: psci: Enable the hierarchical topology for s2ram on PREEMPT_RT Date: Mon, 29 Apr 2024 16:05:30 +0200 Message-Id: <20240429140531.210576-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_070603_147998_EEC8803C X-CRM114-Status: GOOD ( 18.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The hierarchical PM domain topology are currently disabled on a PREEMPT_RT based configuration. As a first step to enable it to be used, let's try to attach the CPU devices to their PM domains on PREEMPT_RT. In this way the syscore ops becomes available, allowing the PM domain topology to be managed during s2ram. For the moment let's leave the support for CPU hotplug outside PREEMPT_RT, as it's depending on using runtime PM. For s2ram, this isn't a problem as all CPUs are managed via the syscore ops. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index d82a8bc1b194..ad6ce9fe12b4 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -37,6 +37,7 @@ struct psci_cpuidle_data { static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); +static bool psci_cpuidle_use_syscore; static bool psci_cpuidle_use_cpuhp; void psci_set_domain_state(u32 state) @@ -166,6 +167,12 @@ static struct syscore_ops psci_idle_syscore_ops = { .resume = psci_idle_syscore_resume, }; +static void psci_idle_init_syscore(void) +{ + if (psci_cpuidle_use_syscore) + register_syscore_ops(&psci_idle_syscore_ops); +} + static void psci_idle_init_cpuhp(void) { int err; @@ -173,8 +180,6 @@ static void psci_idle_init_cpuhp(void) if (!psci_cpuidle_use_cpuhp) return; - register_syscore_ops(&psci_idle_syscore_ops); - err = cpuhp_setup_state_nocalls(CPUHP_AP_CPU_PM_STARTING, "cpuidle/psci:online", psci_idle_cpuhp_up, @@ -222,13 +227,16 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv, if (!psci_has_osi_support()) return 0; - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - return 0; - data->dev = dt_idle_attach_cpu(cpu, "psci"); if (IS_ERR_OR_NULL(data->dev)) return PTR_ERR_OR_ZERO(data->dev); + psci_cpuidle_use_syscore = true; + + /* The hierarchical topology is limited to s2ram on PREEMPT_RT. */ + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + return 0; + /* * Using the deepest state for the CPU to trigger a potential selection * of a shared state for the domain, assumes the domain states are all @@ -312,6 +320,7 @@ static void psci_cpu_deinit_idle(int cpu) struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); dt_idle_detach_cpu(data->dev); + psci_cpuidle_use_syscore = false; psci_cpuidle_use_cpuhp = false; } @@ -408,6 +417,7 @@ static int psci_cpuidle_probe(struct platform_device *pdev) goto out_fail; } + psci_idle_init_syscore(); psci_idle_init_cpuhp(); return 0; From patchwork Mon Apr 29 14:05:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13647064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49FA7C4345F for ; Mon, 29 Apr 2024 14:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ixExnNTFdmatwYUz4UpnRXu+YhfGyVjJqVj4wNkagu8=; b=ieOZmFHNiqlMVZ GNsdw+CA8tp4BQRAP6MgitAgy9VRi0yXuZLvxL8sPsfhIML0KQRLQbj8gMVhsH7OHKKa/2za8j3a2 Zxny1W9BJVAQtZRA4xBZuagtj2McZNG1E1NK7z5wSgt0nhKNU+SbP8WscGJsPvqUa7Zylf6e6NrXk 90rwYh42OMiCSwT6zrYfDhG4ZzPfJjw0bT+ljpt9ixkOth/QWeQCQd+9NMQr0zrCbqGPcjPUnPZSi OOYWPwDWFC1ogHYidt/tXkdQez+8KGF6cxWwoAuQCfb96n6DgXWTh970nFAOAP4UPuvGpLOovT5FU MxVmr5Xy6UCuFsJHkyjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Re1-000000033SO-32jl; Mon, 29 Apr 2024 14:06:13 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Rds-000000033Mv-08Ad for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 14:06:05 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2e01d666c88so14244511fa.2 for ; Mon, 29 Apr 2024 07:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714399561; x=1715004361; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IDwOmSA7MQ7+zytHkA+laGeE0LQljf7L1jWo+P70lko=; b=ke8coQYdp739fike/kHyzV6J1F5FlRrQuwG2nL85nUuyVov2RUPg4ao4leDotxBGws VA5Wym2CBWtDj5FGkYNebPJvuTwNQ4TtWFSAkBKbxoJVBulNgENWOLsJjFoTsmKnLnHQ kOPsN1GsToAFFvJB9f5c5qCiQQLF1QRQ9MhHLPX1npg6lU9l7DlGJo8Y8uJOqgEqYTlo fD1/ZNNoF0sjir1e6n0LBz2benM8CEaghU6owX4KtjzbBJGkWAyTuI28YtU4gVSNRuBo PaeVdXb1IIl7/OdWo4/uo1kar6/BnzipiuK/cMVX5TyNRtrYG9BNk+L6bNsPozoUIz5u gmDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714399561; x=1715004361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IDwOmSA7MQ7+zytHkA+laGeE0LQljf7L1jWo+P70lko=; b=S5Pf3J+mMB8wcuhYV2mFoW3mBPVYOF080q3WBwJ/ojDKJO/G1MU1YqFmt4GT0KLyy6 vBxqutT3iCLcZn8/He9rctjFcMswA1hjaon98DOUiCH0Nu3d82BlCKpK+Tgwx9yYcBMx OScDA1vZATM+Wreudc5jiXPBWxIBBpHfzQohYwP3Dck3hUMdv8kH5QTzxVKFAWkzPxN5 CQTQRWZxAyD8Ea1KnS782BOlO3QaqKBSzLZClCx5Zy7skDn1y77TArFhcN0c44CLencN bdSvKNl3a7uBFQ+AK/GpKAtHlVZh/tVPKYluOl+7HjBrPxPnr5+EPc5NKuMHAlhnJUDq 7B8w== X-Forwarded-Encrypted: i=1; AJvYcCVjLXKCKzSsS7JLo+8jzSh6iWfoVsh2862V68+McLV253Kg4AYZnUJzlRIPzMA/frYSU805Yd/JcTuUwaGLgn+F075NRvt/qYC27hOGUBJ8ESONf5s= X-Gm-Message-State: AOJu0YwxCBnB1PrxHUDbLPJQFxBtVcrZDdTmeqUHKdNEfr9nxbeT3yxj 2C9kRVYoIhpwXdihsp5GoI0N+gbBsFXhl0XioLSGcl0dQKNCZVhXYtmnPjTZA10= X-Google-Smtp-Source: AGHT+IHp/AQbEYZZdpmQu1KIboKwTFnhRTHy3IUitMBtdTfQEIp1e8p8oPGMBXNXjtBT0xrYq8GO+w== X-Received: by 2002:a2e:93d5:0:b0:2dd:6d67:3064 with SMTP id p21-20020a2e93d5000000b002dd6d673064mr6309727ljh.28.1714399560822; Mon, 29 Apr 2024 07:06:00 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id l5-20020a2e9085000000b002d7095bf808sm3636733ljg.128.2024.04.29.07.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:06:00 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Nikunj Kela , Prasad Sodagudi , Maulik Shah , Daniel Lezcano , Krzysztof Kozlowski , Ulf Hansson , linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] cpuidle: psci: Enable the hierarchical topology for s2idle on PREEMPT_RT Date: Mon, 29 Apr 2024 16:05:31 +0200 Message-Id: <20240429140531.210576-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240429140531.210576-1-ulf.hansson@linaro.org> References: <20240429140531.210576-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_070604_101851_DBAA9554 X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To enable the domain-idle-states to be used during s2idle on a PREEMPT_RT based configuration, let's allow the re-assignment of the ->enter_s2idle() callback to psci_enter_s2idle_domain_idle_state(). Similar to s2ram, let's leave the support for CPU hotplug outside PREEMPT_RT, as it's depending on using runtime PM. For s2idle, this means that an offline CPU's PM domain will remain powered-on. In practise this may lead to that a shallower idle-state than necessary gets selected, which shouldn't be an issue (besides wasting power). Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index ad6ce9fe12b4..2562dc001fc1 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -233,18 +233,17 @@ static int psci_dt_cpu_init_topology(struct cpuidle_driver *drv, psci_cpuidle_use_syscore = true; - /* The hierarchical topology is limited to s2ram on PREEMPT_RT. */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - return 0; - /* * Using the deepest state for the CPU to trigger a potential selection * of a shared state for the domain, assumes the domain states are all - * deeper states. + * deeper states. On PREEMPT_RT the hierarchical topology is limited to + * s2ram and s2idle. */ - drv->states[state_count - 1].enter = psci_enter_domain_idle_state; drv->states[state_count - 1].enter_s2idle = psci_enter_s2idle_domain_idle_state; - psci_cpuidle_use_cpuhp = true; + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { + drv->states[state_count - 1].enter = psci_enter_domain_idle_state; + psci_cpuidle_use_cpuhp = true; + } return 0; }