From patchwork Thu Nov 29 17:46:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84A211057 for ; Thu, 29 Nov 2018 17:48:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EDCC29028 for ; Thu, 29 Nov 2018 17:48:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 615852F073; Thu, 29 Nov 2018 17:48:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0A85C29028 for ; Thu, 29 Nov 2018 17:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n1NXSTYUjdGLo1lZxducsN4u+WLm1UXcD2M6xA3PL8k=; b=hymFKSt0bi9EEYyA9a3n5NS5r9 uBvHO80q57OJ2guMbEoP9oL52g0FgJR7/SFwmCb7/a6dq0ujW69WCwqZCSbDxJre3V4SlGxqHIpwF Q7dag/ydwcQp8YEGke1mQfBDKySLyWQ9EwnsQgYWrNhH2ZCIDgegxVoBLMyw/zZsbPut208c8uKgR 5CsONL1N+phk+jmU1BZV+YlPhpGbsIMVML4sWi4k/xCM2/UwHQGjWNjDdwtJiI9S0LoKSKbBt4EGF idKmun98O3st/VXu4F82Lz9n2RYBbmWII+r22UdIqlwj9bYlFdpjjNE7yEefhppmY1p/AJxY6o+Dx FzLCKI1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQQi-0002Jr-28; Thu, 29 Nov 2018 17:48:48 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPK-00016h-SV for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:26 +0000 Received: by mail-lf1-x143.google.com with SMTP id f23so2076469lfc.13 for ; Thu, 29 Nov 2018 09:47:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2OFzyl7DYqM+TKMo2yE9Sged+x4IOY1BMaINc0irzbk=; b=WF/uDC6cto89UDdfBnGrf81NlzZ26+j7fWxzr3FcUZ6bWkeWgWVSaZuoeSFwtlCJcl ngNYcGXO/yOYk1SP4DlEzNaHgCCudJxCxzVB9V/lGel5iAWprOmMJl3y0UydtSlM96+S vrGMzuCnis/xZHu8BwGfiah6JjJ2lyvNiNMLE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2OFzyl7DYqM+TKMo2yE9Sged+x4IOY1BMaINc0irzbk=; b=cVpmIsi5xvmlVYb21U++PvP8CvESAqNBgKqmwqqxGjU47IFdf+xxXFHmrXPDoZK6rg u3/EmcizGfmRgDno4JWeFxxZAQZoJUUudCf0xiaTisPNoiyAQRvzuO1mh7+OiJV20Iov DK7THyHb6pw/g7IaIL+Ytjpg3VaVmnNc1GtXWXd7CtLxN8P3Fa2uV0H+850/e679+Dkd 4UtS5q/J1UMZcJENgfnaJ8zPX+Ntpt/Q7mx2XrNmMXPTc/+Mc/2EXPMJh6GiwMmJZ8Ww FrlJkHjGQg++/pULZ9D2NANwF2z5KB4V1iNv6EkTAjXSovu5JE348+7Vv2qx39p7ci7C JOqQ== X-Gm-Message-State: AA+aEWZxjtTupBZ3tZFhZmysbGcStwqP1Aag4VOZPF+7/dKo73e8YBT0 McsnPSNZQnarpyPVqtL+pb2NFg== X-Google-Smtp-Source: AFSGD/WcONLGmNXYECO9oNRUxrjzh2zAGhw9wIqkXq80q8IdpwQYFhZTN3X/sVmIELfDUDxcx4LF2Q== X-Received: by 2002:a19:2c92:: with SMTP id s140mr1622412lfs.42.1543513630200; Thu, 29 Nov 2018 09:47:10 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:09 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 01/27] PM / Domains: Add generic data pointer to genpd_power_state struct Date: Thu, 29 Nov 2018 18:46:34 +0100 Message-Id: <20181129174700.16585-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094723_034544_4C3B33E7 X-CRM114-Status: GOOD ( 19.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Let's add a data pointer to the genpd_power_state struct, to allow a genpd backend driver to store per state specific data. In order to introduce the pointer, we also need to adopt how genpd frees the allocated data for the default genpd_power_state struct, that it may allocate at pm_genpd_init(). More precisely, let's use an internal genpd flag to understand when the states needs to be freed by genpd. When freeing the states data in genpd_remove(), let's also clear the corresponding genpd->states pointer and reset the genpd->state_count. In this way, a genpd backend driver becomes aware of when there is state specific data for it to free. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Update the patch allow backend drivers to free the states specific data during genpd removal. Due to this added complexity, I decided to keep the patch separate, rather than fold it into the patch that makes use of the new void pointer, which was suggested by Rafael. - Claim authorship of the patch as lots of changes has been done since the original pick up from Lina Iyer. --- drivers/base/power/domain.c | 8 ++++++-- include/linux/pm_domain.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7f38a92b444a..e27b91d36a2a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1620,7 +1620,7 @@ static int genpd_set_default_power_state(struct generic_pm_domain *genpd) genpd->states = state; genpd->state_count = 1; - genpd->free = state; + genpd->free_state = true; return 0; } @@ -1736,7 +1736,11 @@ static int genpd_remove(struct generic_pm_domain *genpd) list_del(&genpd->gpd_list_node); genpd_unlock(genpd); cancel_work_sync(&genpd->power_off_work); - kfree(genpd->free); + if (genpd->free_state) { + kfree(genpd->states); + genpd->states = NULL; + genpd->state_count = 0; + } pr_debug("%s: removed %s\n", __func__, genpd->name); return 0; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 3b5d7280e52e..f9e09bd4152c 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -69,6 +69,7 @@ struct genpd_power_state { s64 residency_ns; struct fwnode_handle *fwnode; ktime_t idle_time; + void *data; }; struct genpd_lock_ops; @@ -110,7 +111,7 @@ struct generic_pm_domain { struct genpd_power_state *states; unsigned int state_count; /* number of states */ unsigned int state_idx; /* state that genpd will go to when off */ - void *free; /* Free the state that was allocated for default */ + bool free_state; /* Free the state that was allocated for default */ ktime_t on_time; ktime_t accounting_time; const struct genpd_lock_ops *lock_ops; From patchwork Thu Nov 29 17:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5217617F0 for ; Thu, 29 Nov 2018 17:48:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 340352DA4C for ; Thu, 29 Nov 2018 17:48:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 227B22D404; Thu, 29 Nov 2018 17:48:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D9842AF53 for ; Thu, 29 Nov 2018 17:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hbjFVp8IIX2AhOg9z3n8qHp+ayN0YhKep0QerJIju8o=; b=gFz+Vsji3mSl5OFbeje7Hb7NR8 63bjXVNvTwesSWihmd46h84D8YGfIlxwupxtR2GJ2C93Isv5WaM2HH1LyepOX0Qgz9xEJ7CNnuYdK ozi5psMB83lXtvmLweqc1GOkTol7cgEdk7Hr2U4ymH7KX6IaMKj3jm/44mPjbiZhSTS2hKgcYYKNE JsRha8DjS7NB8LU0IXKBcjxFTqwHSsjYagNdV7xFsull3xv6elh6l2fSVIwrDLpZ3L+ZUeLA7ewuO TGZtGvryl+C42sgfWXVh2So52VydhKX6Fq3npyT8YcuX92HK7rF29XQmXU4KJHQn9aY8ccateQITd uDrA/+1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQQP-00020z-6K; Thu, 29 Nov 2018 17:48:29 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPM-00016l-16 for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:26 +0000 Received: by mail-lj1-x244.google.com with SMTP id x85-v6so2545798ljb.2 for ; Thu, 29 Nov 2018 09:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ugu70vqPSlvoBLQ0yLsWszKKKu9c1+r7G0LXkXDasSo=; b=J809RAX0UkMu+oLMCaHu/7lOJNiEpEYmhO3qRVV9ftWuS4GfGVd+0if+GWha2/5HqE GZmEskLLvfk/z1AJ92479NwriRYoDlF8rcgLIHKVAJsnFrJVsYlsullZUC/H/hI00kkE v0FxvLoWmWM4G0XceCHO1vyL0sm4zfZbOPLvc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ugu70vqPSlvoBLQ0yLsWszKKKu9c1+r7G0LXkXDasSo=; b=JB2BM3XUlCBKv5byqvUZTUdAQe4Mf3VE4m3O0YA+a0Kab6WKbnaqszWpQLQgjVILOS rx8gpYiDsiH2wslLViM+0eoNsv+e96kefQ4WnOEP81imXGDEJkaGPlc7KznR7TZRrx4P vTb61DTVOizVcHgkvEVYpL1tiVQk++4kf/KL7/bzhXGaKFp6I7Y4oJqtuwlzMYIRqs+i pCGKmjEro2CbLd6JTc067ffMr0Spw/tg/q9po7w40wJG/B3HS85H9IE5dnrLMO6XUKQh iNwWqihJxPro6iuEf17Pxc6FfXsAKENTGHfiWrUu43n6Xo//dXGxBAFCjLLhjKSHOXzj X6Lg== X-Gm-Message-State: AA+aEWZL3trTWb+wOK/S/XFu7ZyMUCTDEfp8Abr6u2PlZ7T3dqGPsmSz 4MdqIH2kNaKpVpNnG8DDE6wfrg== X-Google-Smtp-Source: AFSGD/UGrlC0yFSw5PotUaeTrNwrutDGPc8atRm/uVrLmAUkuQfNCdn0P/EV8WXivwKFjQxVz0hZDA== X-Received: by 2002:a2e:1b47:: with SMTP id b68-v6mr1536355ljb.104.1543513631925; Thu, 29 Nov 2018 09:47:11 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:11 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 02/27] PM / Domains: Add support for CPU devices to genpd Date: Thu, 29 Nov 2018 18:46:35 +0100 Message-Id: <20181129174700.16585-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094724_068093_3B8874B4 X-CRM114-Status: GOOD ( 24.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To enable a device belonging to a CPU to be attached to a PM domain managed by genpd, let's do a few changes to it, as to make it convenient to manage the specifics around CPUs. To be able to quickly find out what CPUs that are attached to a genpd, which typically becomes useful from a genpd governor as following changes is about to show, let's add a cpumask to the struct generic_pm_domain. At the point when a CPU device gets attached to a genpd, let's update its cpumask. Moreover, let's also propagate changes to the cpumask upwards in the topology to the master PM domains. In this way, the cpumask for a genpd hierarchically reflects all CPUs attached to the topology below it. Finally, let's make this an opt-in feature, to avoid having to manage CPUs and the cpumask for a genpd that doesn't need it. For that reason, let's add a new genpd configuration bit, GENPD_FLAG_CPU_DOMAIN. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Don't allocate the cpumask when not used. - Simplify the code that updates the cpumask. - Document the GENPD_FLAG_CPU_DOMAIN. --- drivers/base/power/domain.c | 66 ++++++++++++++++++++++++++++++++++++- include/linux/pm_domain.h | 13 ++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e27b91d36a2a..c3ff8e395308 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "power.h" @@ -126,6 +127,7 @@ static const struct genpd_lock_ops genpd_spin_ops = { #define genpd_is_irq_safe(genpd) (genpd->flags & GENPD_FLAG_IRQ_SAFE) #define genpd_is_always_on(genpd) (genpd->flags & GENPD_FLAG_ALWAYS_ON) #define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP) +#define genpd_is_cpu_domain(genpd) (genpd->flags & GENPD_FLAG_CPU_DOMAIN) static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev, const struct generic_pm_domain *genpd) @@ -1377,6 +1379,56 @@ static void genpd_free_dev_data(struct device *dev, dev_pm_put_subsys_data(dev); } +static void __genpd_update_cpumask(struct generic_pm_domain *genpd, + int cpu, bool set, unsigned int depth) +{ + struct gpd_link *link; + + if (!genpd_is_cpu_domain(genpd)) + return; + + list_for_each_entry(link, &genpd->slave_links, slave_node) { + struct generic_pm_domain *master = link->master; + + genpd_lock_nested(master, depth + 1); + __genpd_update_cpumask(master, cpu, set, depth + 1); + genpd_unlock(master); + } + + if (set) + cpumask_set_cpu(cpu, genpd->cpus); + else + cpumask_clear_cpu(cpu, genpd->cpus); +} + +static void genpd_update_cpumask(struct generic_pm_domain *genpd, + struct device *dev, bool set) +{ + int cpu; + + if (!genpd_is_cpu_domain(genpd)) + return; + + for_each_possible_cpu(cpu) { + if (get_cpu_device(cpu) == dev) { + __genpd_update_cpumask(genpd, cpu, set, 0); + return; + } + } +} + +static void genpd_set_cpumask(struct generic_pm_domain *genpd, + struct device *dev) +{ + genpd_update_cpumask(genpd, dev, true); +} + +static void genpd_clear_cpumask(struct generic_pm_domain *genpd, + struct device *dev) +{ + genpd_update_cpumask(genpd, dev, false); +} + static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, struct gpd_timing_data *td) { @@ -1398,6 +1450,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) goto out; + genpd_set_cpumask(genpd, dev); + dev_pm_domain_set(dev, &genpd->domain); genpd->device_count++; @@ -1459,6 +1513,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, if (genpd->detach_dev) genpd->detach_dev(genpd, dev); + genpd_clear_cpumask(genpd, dev); dev_pm_domain_set(dev, NULL); list_del_init(&pdd->list_node); @@ -1686,11 +1741,18 @@ int pm_genpd_init(struct generic_pm_domain *genpd, if (genpd_is_always_on(genpd) && !genpd_status_on(genpd)) return -EINVAL; + if (genpd_is_cpu_domain(genpd) && + !zalloc_cpumask_var(&genpd->cpus, GFP_KERNEL)) + return -ENOMEM; + /* Use only one "off" state if there were no states declared */ if (genpd->state_count == 0) { ret = genpd_set_default_power_state(genpd); - if (ret) + if (ret) { + if (genpd_is_cpu_domain(genpd)) + free_cpumask_var(genpd->cpus); return ret; + } } else if (!gov) { pr_warn("%s : no governor for states\n", genpd->name); } @@ -1736,6 +1798,8 @@ static int genpd_remove(struct generic_pm_domain *genpd) list_del(&genpd->gpd_list_node); genpd_unlock(genpd); cancel_work_sync(&genpd->power_off_work); + if (genpd_is_cpu_domain(genpd)) + free_cpumask_var(genpd->cpus); if (genpd->free_state) { kfree(genpd->states); genpd->states = NULL; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f9e09bd4152c..5a4673605d22 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -16,6 +16,7 @@ #include #include #include +#include /* * Flags to control the behaviour of a genpd. @@ -42,11 +43,22 @@ * GENPD_FLAG_ACTIVE_WAKEUP: Instructs genpd to keep the PM domain powered * on, in case any of its attached devices is used * in the wakeup path to serve system wakeups. + * + * GENPD_FLAG_CPU_DOMAIN: Instructs genpd that it should expect to get + * devices attached, which may belong to CPUs or + * possibly have subdomains with CPUs attached. + * This flag enables the genpd backend driver to + * deploy idle power management support for CPUs + * and groups of CPUs. Note that, the backend + * driver must then comply with the so called, + * last-man-standing algorithm, for the CPUs in the + * PM domain. */ #define GENPD_FLAG_PM_CLK (1U << 0) #define GENPD_FLAG_IRQ_SAFE (1U << 1) #define GENPD_FLAG_ALWAYS_ON (1U << 2) #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) +#define GENPD_FLAG_CPU_DOMAIN (1U << 4) enum gpd_status { GPD_STATE_ACTIVE = 0, /* PM domain is active */ @@ -93,6 +105,7 @@ struct generic_pm_domain { unsigned int suspended_count; /* System suspend device counter */ unsigned int prepared_count; /* Suspend counter of prepared devices */ unsigned int performance_state; /* Aggregated max performance state */ + cpumask_var_t cpus; /* A cpumask of the attached CPUs */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, From patchwork Thu Nov 29 17:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAF3B17F0 for ; Thu, 29 Nov 2018 17:48:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5A252F36A for ; Thu, 29 Nov 2018 17:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C67A72F512; Thu, 29 Nov 2018 17:48:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 645132F36A for ; Thu, 29 Nov 2018 17:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3w6w6IUL4bMWKYujpA4ncTf1djAaFIpEzFS8Ejf3WQM=; b=H++aTNv8TXU8FpWfc8XkobMyCd h3WUaT2xOcgxGZ71OCbgg1LAK7FmAe0eHIDHD+OvWsVGCXInlRkIvirxTeVi2GyCcQI1N7P79kblT AxCbXlnEDrhBwjIlWPafht3FZu2E8tNfsIaIdnP+RjinH1gtqR69Is2gMi7Uco231pLJZH0ElgX01 +uNRMb0viZL9J1AOdZE6AEN4X6pL6+S+euSJITGLjoMgD34CCEe1zGA5Ugaes+BGb5V1QeIklCSUp aIB56n/9xvOXKYoWZHjbSD5wbRHfK6PVzvwiQb4Ved/iu32RneW8q47FyhTrIH/bjGnTM9Rq69VLa XO+pMajw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQQ9-0001ns-Vm; Thu, 29 Nov 2018 17:48:13 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPK-00016m-Lw for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:25 +0000 Received: by mail-lf1-x144.google.com with SMTP id i26so2122473lfc.0 for ; Thu, 29 Nov 2018 09:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=CxUDChM/RBvhrA31XzUsCNP+4FezP+eXEflQmQnd54XH4DLPYar6y05JtbZh1VkOR9 SkqR/CZFgNzntsxd4Oe81r1RyldMKKKEpGM2IwKlpysWwwEyVbXW691jkPCx5rLzQP/r x2cpT4wVVole1llA1ynH/xIBV8qW3U8BBRoCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=We8CaGvJmbhYNYzrL7xua655X98bhiXXYfxMtnIUbcg=; b=ber2S9rx+hrrlcthy4TFLyF3SmuSy2VMU+aYCvm4raOrHXZ95VCV+PonbrbKTq+dLi NvZIIvWNl+cPXsxkkj651MxiZDsx5ELgk8CIhU3zFu/l35ubussDI4o++cnFaP430sgY WrX2c6Qm0dznkESQGCBXWaR5IfbnY1/F6UsHWt81NICoRYbJZbwzvcq9EesqQFuaUtIu p/Ff10kA2W4DBhbdtNmbj/dE8VbPEj9uJ4JenndzZ9S2VAPA7FwajuIFD0Wh5bOaRxSX TauhZhqL3Tr/avSihvxUsIOkk+zFEpbhT/hZ2/ZpwT5tnQaPJ2OxeyBq4my6FNuAYWP9 y9CA== X-Gm-Message-State: AA+aEWadg2PouC5495XsUVRPMQeN7u7AJLI6wmvmleLb8RUFFpFDhpvA Ag1uLWaE+jvgshLy6QWYi4dEuA== X-Google-Smtp-Source: AFSGD/X5ijktJZyrJe4NVc5D4Xj3iZjspHtp3e2YPqQ10kRYH3SesOqeSLOZT9YaqgkfpSVEiZRWsQ== X-Received: by 2002:a19:6806:: with SMTP id d6mr1607974lfc.48.1543513633779; Thu, 29 Nov 2018 09:47:13 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:13 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 03/27] timer: Export next wakeup time of a CPU Date: Thu, 29 Nov 2018 18:46:36 +0100 Message-Id: <20181129174700.16585-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094722_733552_E46C2B12 X-CRM114-Status: GOOD ( 15.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Frederic Weisbecker , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Thomas Gleixner , "Raju P . L . S . S . S . N" , Ingo Molnar , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Knowing the sleep duration of CPUs, is known to be needed while selecting the most energy efficient idle state for a CPU or a group of CPUs. However, to be able to compute the sleep duration, we need to know at what time the next expected wakeup is for the CPU. Therefore, let's export this information via a new function, tick_nohz_get_next_wakeup(). Following changes make use of it. Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Lina Iyer Cc: Frederic Weisbecker Cc: Ingo Molnar Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes in v10: - Updated function header of tick_nohz_get_next_wakeup(). --- include/linux/tick.h | 8 ++++++++ kernel/time/tick-sched.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/tick.h b/include/linux/tick.h index 55388ab45fd4..e48f6b26b425 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -125,6 +125,7 @@ extern bool tick_nohz_idle_got_tick(void); extern ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next); extern unsigned long tick_nohz_get_idle_calls(void); extern unsigned long tick_nohz_get_idle_calls_cpu(int cpu); +extern ktime_t tick_nohz_get_next_wakeup(int cpu); extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time); extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time); @@ -151,6 +152,13 @@ static inline ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next) *delta_next = TICK_NSEC; return *delta_next; } + +static inline ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + /* Next wake up is the tick period, assume it starts now */ + return ktime_add(ktime_get(), TICK_NSEC); +} + static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 69e673b88474..7a9166506503 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1089,6 +1089,19 @@ unsigned long tick_nohz_get_idle_calls(void) return ts->idle_calls; } +/** + * tick_nohz_get_next_wakeup - return the next wake up of the CPU + * @cpu: the particular CPU to get next wake up for + * + * Called for idle CPUs only. + */ +ktime_t tick_nohz_get_next_wakeup(int cpu) +{ + struct clock_event_device *dev = per_cpu(tick_cpu_device.evtdev, cpu); + + return dev->next_event; +} + static void tick_nohz_account_idle_ticks(struct tick_sched *ts) { #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE From patchwork Thu Nov 29 17:46:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D28C818B8 for ; Thu, 29 Nov 2018 17:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDF9B2F36A for ; Thu, 29 Nov 2018 17:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B17912F427; Thu, 29 Nov 2018 17:49:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36E082F3CE for ; Thu, 29 Nov 2018 17:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=DWwiyghC/FDXzaoeEL9W8BT5P7mkhHzK8C8kLn6x/NE=; b=G03rzrMu1HDN1HEyuZ++Zr1AgK Ui7NvOsw44iNFrvDd7V4GKyD9zRVlMfq2BPMiFICBO14GXhQT+gg50NxIBgfrsoyjyfEEtFYEvEsE HLAbHUtW/8+8XmVAwpp8zN5S7rji7tSinSTmnN4j+BAsgvuh/vXlifRv7igrIUbXKdYDm+7jAVD3i 8enX1uTcH8dMbv2ZZ0pe1RgCI/Bt+0J0xN/eBZsjo8r/JuNHYlneW8019l6PSLUYs8Ed2ULfsDpTO 6/ufp1p7oJ0I7ZTL9AMMmPGMEtz5NiSrRf9UeADpWJwj9P2TcPuTj7I4p/xhffT2zlQGUJbrMBBVU OimyYu2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQRM-0002yp-Qs; Thu, 29 Nov 2018 17:49:28 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPP-00016o-EC for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:31 +0000 Received: by mail-lj1-x241.google.com with SMTP id c19-v6so2529975lja.5 for ; Thu, 29 Nov 2018 09:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LzzPQT8slGTRdAVsQgdHTCQbGTst2gOxOptahoBqO9s=; b=dILkK4RWalKTSDKmHx8vHWZzFrLAYdDwsijfwltyCZ5q81SUkAbXChhyYAH690o8uT YXrNqbelHdj7mx78PYx8fMaH0V6BiqOJPLNifA9NX2ReN9IupraVd9AnS3YdarHdguIV vPW5aGAjRw2YW+/7qfV8LJFKjibK4f+JLgKNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LzzPQT8slGTRdAVsQgdHTCQbGTst2gOxOptahoBqO9s=; b=UgvXbrhE2/g2WUltIGHGzhoc783oN/qBvvum2bN64Vb9DFQy6fkvwrT+XLa6QHXJ3T RU8mK5igFo/b16kPb8qonwnCjyS+sMJGtkkKZwZ2n2z0yHA0iNwiGizcWzbbwtk0l6F1 YsuzuZ9EdCf/pyP7I9evdZtXnXfhmBGaYfCvQilm/sxnu2iCwyMMGLAEiZar/8m06rzK 3i+pKua64WQ0592oLP0G5doi5rzKdVT+/gYSHK3omQO8uQOmHlF4IMyggPuc/DodXILj p7xcxlrmT2voKzFNEzPVwBIEKSZ6TWwsAmtq/9iO2IJnn5uZ5GlKrK1L/32iCroGX3eG wcTw== X-Gm-Message-State: AA+aEWYVtipYoihIQh0XSkTZnALvmk7r27yrB/SMFRXI+6Qfff1Y0Qei wTUs6JXBaNkHHIpokbjBgYwcTQ== X-Google-Smtp-Source: AFSGD/XpXCMxYWmRpXFvesL23Sbaaj0TtiVDelVwR/zWUS9DrajaWZlFr/9hlupx5uyQBOILggxyJQ== X-Received: by 2002:a2e:9849:: with SMTP id e9-v6mr1748886ljj.9.1543513635515; Thu, 29 Nov 2018 09:47:15 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:14 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 04/27] PM / Domains: Add genpd governor for CPUs Date: Thu, 29 Nov 2018 18:46:37 +0100 Message-Id: <20181129174700.16585-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094728_009746_BF18587C X-CRM114-Status: GOOD ( 24.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Frederic Weisbecker , Tony Lindgren , linux-arm-msm@vger.kernel.org, Thomas Gleixner , "Raju P . L . S . S . S . N" , Ingo Molnar , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As it's now perfectly possible that a PM domain managed by genpd contains devices belonging to CPUs, we should start to take into account the residency values for the idle states during the state selection process. The residency value specifies the minimum duration of time, the CPU or a group of CPUs, needs to spend in an idle state to not waste energy entering it. To deal with this, let's add a new genpd governor, pm_domain_cpu_gov, that may be used for a PM domain that have CPU devices attached or if the CPUs are attached through subdomains. The new governor computes the minimum expected idle duration time for the online CPUs being attached to the PM domain and its subdomains. Then in the state selection process, trying the deepest state first, it verifies that the idle duration time satisfies the state's residency value. It should be noted that, when computing the minimum expected idle duration time, we use the information from tick_nohz_get_next_wakeup(), to find the next wakeup for the related CPUs. Future wise, this may deserve to be improved, as there are more reasons to why a CPU may be woken up from idle. Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Lina Iyer Cc: Frederic Weisbecker Cc: Ingo Molnar Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Fold in patch that extended the new genpd CPU governor to cope with QoS constraints, as to avoid confusion. - Simplified the code according to suggestions from Rafael. --- drivers/base/power/domain_governor.c | 61 +++++++++++++++++++++++++++- include/linux/pm_domain.h | 3 ++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 99896fbf18e4..61a7c3c03c98 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include static int dev_update_qos_constraint(struct device *dev, void *data) { @@ -211,8 +214,10 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) struct generic_pm_domain *genpd = pd_to_genpd(pd); struct gpd_link *link; - if (!genpd->max_off_time_changed) + if (!genpd->max_off_time_changed) { + genpd->state_idx = genpd->cached_power_down_state_idx; return genpd->cached_power_down_ok; + } /* * We have to invalidate the cached results for the masters, so @@ -237,6 +242,7 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) genpd->state_idx--; } + genpd->cached_power_down_state_idx = genpd->state_idx; return genpd->cached_power_down_ok; } @@ -245,6 +251,54 @@ static bool always_on_power_down_ok(struct dev_pm_domain *domain) return false; } +static bool cpu_power_down_ok(struct dev_pm_domain *pd) +{ + struct generic_pm_domain *genpd = pd_to_genpd(pd); + ktime_t domain_wakeup, cpu_wakeup; + s64 idle_duration_ns; + int cpu, i; + + /* Validate dev PM QoS constraints. */ + if (!default_power_down_ok(pd)) + return false; + + if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) + return true; + + /* + * Find the next wakeup for any of the online CPUs within the PM domain + * and its subdomains. Note, we only need the genpd->cpus, as it already + * contains a mask of all CPUs from subdomains. + */ + domain_wakeup = ktime_set(KTIME_SEC_MAX, 0); + for_each_cpu_and(cpu, genpd->cpus, cpu_online_mask) { + cpu_wakeup = tick_nohz_get_next_wakeup(cpu); + if (ktime_before(cpu_wakeup, domain_wakeup)) + domain_wakeup = cpu_wakeup; + } + + /* The minimum idle duration is from now - until the next wakeup. */ + idle_duration_ns = ktime_to_ns(ktime_sub(domain_wakeup, ktime_get())); + if (idle_duration_ns <= 0) + return false; + + /* + * Find the deepest idle state that has its residency value satisfied + * and by also taking into account the power off latency for the state. + * Start at the state picked by the dev PM QoS constraint validation. + */ + i = genpd->state_idx; + do { + if (idle_duration_ns >= (genpd->states[i].residency_ns + + genpd->states[i].power_off_latency_ns)) { + genpd->state_idx = i; + return true; + } + } while (--i >= 0); + + return false; +} + struct dev_power_governor simple_qos_governor = { .suspend_ok = default_suspend_ok, .power_down_ok = default_power_down_ok, @@ -257,3 +311,8 @@ struct dev_power_governor pm_domain_always_on_gov = { .power_down_ok = always_on_power_down_ok, .suspend_ok = default_suspend_ok, }; + +struct dev_power_governor pm_domain_cpu_gov = { + .suspend_ok = default_suspend_ok, + .power_down_ok = cpu_power_down_ok, +}; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 5a4673605d22..969a9b36c0db 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -116,6 +116,7 @@ struct generic_pm_domain { s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; bool cached_power_down_ok; + bool cached_power_down_state_idx; int (*attach_dev)(struct generic_pm_domain *domain, struct device *dev); void (*detach_dev)(struct generic_pm_domain *domain, @@ -195,6 +196,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; +extern struct dev_power_governor pm_domain_cpu_gov; #else static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) @@ -238,6 +240,7 @@ static inline int dev_pm_genpd_set_performance_state(struct device *dev, #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) +#define pm_domain_cpu_gov (*(struct dev_power_governor *)(NULL)) #endif #ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP From patchwork Thu Nov 29 17:46:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 069C61057 for ; Thu, 29 Nov 2018 17:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E41902F36A for ; Thu, 29 Nov 2018 17:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D77842F544; Thu, 29 Nov 2018 17:47:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 334BD2F36A for ; Thu, 29 Nov 2018 17:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=00TX3QVwlTr0njIQLGJ5iF4WqvfSFqx/3Ui8M6hcBAM=; b=jmDEODE1KYI75iXpYvWJ8tixbA 5spHC5Ly/Zbywy44cjKyigB0JD/jvEryfMvCS1ipSy3Ne/jWbZyUrx5T2itgWClFHiW8eUREgwgKx uYv1ZV/VQ03bCc5F4kCL2y6MypjeHgVI6ojYm74pOVk5Q0MRadofmqobkoGZX6cW/HxvGxNV9+tcc X69CXpJtC7k+2D4AECcRNuCjgEd2yc5Fgq/vhNMfhrQ7NafO+U8TGwIpfgM8jf2V2/DVnT6NBdkWu pCkkL4bSXWeyt3eMFJydAv7NlzcAlJFDQ/U+IeCzUGmyN1CeXiGZX0p6scU0dozqF4hle1x95729r UEhdEuNg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPa-0001Jy-ES; Thu, 29 Nov 2018 17:47:38 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPK-00016t-Lv for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:24 +0000 Received: by mail-lf1-x144.google.com with SMTP id c16so2096575lfj.8 for ; Thu, 29 Nov 2018 09:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wHLi6pu6OM2Azv5/kwu0Ob81t5zQUxyFdokpJxjiCqo=; b=Vyz98YECSi26BpZm6Fp/koCfwpQEh6q8wR8+PqOvcBGBXMSORNNtVp8FIuvTmApdcA spVnS5Ly4vqUn8gMTVIymJbdrSm8Q5GZxfWR3dHMwGi4ZSC/6CFOisGBsLX4Cpc7HN+J /E9X/oXoPnaWxskiSk/Mkicq7TZn5s598XYVM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wHLi6pu6OM2Azv5/kwu0Ob81t5zQUxyFdokpJxjiCqo=; b=I8RsAS9z/Rx+RvypDWfof7aH4XOWKIMaNZZCsJRy7RiMRHntaV6QmhB9n1fnB4SGx1 mK4MPcEcCZdhjbTCJitCXtdCsRRUIArzkeUp5HHZUu5awz3prB1dH6HkvIX700y6fxls pv6OUDEDKraUdyvLyGzWAwN3URor1awODL2nZE0Fm4VqzIz66X2oAncgUAwThc7lwq9t LTBw+jqAXKAShDWmpOLLhMg6qCo9iTdz/YvrpJKYsvDO3Fo4fhWdCTkfEHHqmJY2FEDD NOFun5NjWdgze5D6T5JeoTNI3Y2txPy41YGMlzj2P+DNMLTL3wo8U99BQdHfiDkk8UhR SwCQ== X-Gm-Message-State: AA+aEWaPnlDXUUnFNJzzsqARXLKRUMrYtAGh3P/fdCgPISQEWnrJWXBu 4D6tfPmOrEXSwJD9/j+e9kGxwQ== X-Google-Smtp-Source: AFSGD/W7C32Dqw7iLR/IU7LYrqadO8+82qTRlLuRMFSRsZK67JfSbWWo94wTBDjlbA9G3WID43cSSw== X-Received: by 2002:a19:f204:: with SMTP id q4mr1713196lfh.133.1543513637387; Thu, 29 Nov 2018 09:47:17 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:16 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 05/27] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Thu, 29 Nov 2018 18:46:38 +0100 Message-Id: <20181129174700.16585-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094722_730635_64385C4B X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Update DT bindings to represent hierarchical CPU and CPU PM domain idle states for PSCI. Also update the PSCI examples to clearly show how flattened and hierarchical idle states can be represented in DT. Cc: Lina Iyer Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson Reviewed-by: Rob Herring Reviewed-by: Sudeep Holla --- Change in V10: - Clarified that the new hierarchical representation is orthogonal to OS-initiated vs platform-coordinated PSCI CPU suspend mode. - Clarified the representation for "arm,psci-suspend-param" in regards to the flattened vs hierarchical model. - Added power-domain-names property to the CPU nodes, as to avoid future churns, if ever multiple power-domains specifiers. --- .../devicetree/bindings/arm/psci.txt | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/psci.txt b/Documentation/devicetree/bindings/arm/psci.txt index a2c4f1d52492..e6d3553c8df8 100644 --- a/Documentation/devicetree/bindings/arm/psci.txt +++ b/Documentation/devicetree/bindings/arm/psci.txt @@ -105,7 +105,173 @@ Case 3: PSCI v0.2 and PSCI v0.1. ... }; +ARM systems can have multiple cores sometimes in hierarchical arrangement. +This often, but not always, maps directly to the processor power topology of +the system. Individual nodes in a topology have their own specific power states +and can be better represented in DT hierarchically. + +For these cases, the definitions of the idle states for the CPUs and the CPU +topology, must conform to the domain idle state specification [3]. The domain +idle states themselves, must be compatible with the defined 'domain-idle-state' +binding [1], and also need to specify the arm,psci-suspend-param property for +each idle state. + +DT allows representing CPUs and CPU idle states in two different ways - + +The flattened model as given in Example 1, lists CPU's idle states followed by +the domain idle state that the CPUs may choose. Note that the idle states are +all compatible with "arm,idle-state". Additionally, for the domain idle state +the "arm,psci-suspend-param" represents a superset of the CPU's idle state. + +Example 2 represents the hierarchical model of CPUs and domain idle states. +CPUs define their domain provider in their psci DT node. The domain controls +the power to the CPU and possibly other h/w blocks that would enter an idle +state along with the CPU. The CPU's idle states may therefore be considered as +the domain's idle states and have the compatible "arm,idle-state". Such domains +may also be embedded within another domain that may represent common h/w blocks +between these CPUs. The idle states of the CPU topology shall be represented as +the domain's idle states. Note that for the domain idle state, the +"arm,psci-suspend-param" represents idle states hierarchically. + +In PSCI firmware v1.0, the OS-Initiated mode is introduced. However, the +flattened vs hierarchical DT representation is orthogonal to the OS-Initiated +vs the platform-coordinated PSCI CPU suspend modes, thus should be considered +independent of each other. + +The hierarchical representation helps and makes it easy to implement OSI mode +and OS implementations may choose to mandate it. For the default platform- +coordinated mode, both representations are viable options. + +Example 1: Flattened representation of CPU and domain idle states + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53", "arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + cpu-idle-states = <&CPU_PWRDN>, <&CLUSTER_RET>, + <&CLUSTER_PWRDN>; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + cpu-idle-states = <&CPU_PWRDN>, <&CLUSTER_RET>, + <&CLUSTER_PWRDN>; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1000011>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x1000031>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; + }; + + psci { + compatible = "arm,psci-0.2"; + method = "smc"; + }; + +Example 2: Hierarchical representation of CPU and domain idle states + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + CPU0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53", "arm,armv8"; + reg = <0x0>; + enable-method = "psci"; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x0000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000010>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-power-down { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000030>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; + }; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + domain-idle-states = <&CPU_PWRDN>; + power-domains = <&CLUSTER_PD>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + domain-idle-states = <&CPU_PWRDN>; + power-domains = <&CLUSTER_PD>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; + }; + [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/arm/idle-states.txt [2] Power State Coordination Interface (PSCI) specification http://infocenter.arm.com/help/topic/com.arm.doc.den0022c/DEN0022C_Power_State_Coordination_Interface.pdf +[3]. PM Domains description + Documentation/devicetree/bindings/power/power_domain.txt From patchwork Thu Nov 29 17:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 344241057 for ; Thu, 29 Nov 2018 17:47:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E8382F512 for ; Thu, 29 Nov 2018 17:47:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 127AD2F54E; Thu, 29 Nov 2018 17:47:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4E3E2F512 for ; Thu, 29 Nov 2018 17:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ny9TC4iOhRklHyaT0O9UACIXdhbDAqDABVAURkRmNIA=; b=Y0GyocKMxN0Pr9iEOayfwqlCC8 ykAMQwNXqndInudWEUQmF0iA3U9LALNjnaFajXJeZN1yBymGe4DFxuu2IM+KXVJ5TRUMhK0rZK47o whjwMUd+40thyVFyxIXw5HlOVV7AzsbpIKMb7csUoLUBJCL9/R/uHYK75vtabNLXJ9h75NuueGBhK +erX/klszCwPEcuXaX04gjxnBpF8Jok+Du7Jr4CAj4/nq9V50DTxzrkaVOS/GyZ5XqMV0i47ylXVi d9BTyUyrV6gvH7+4lU8AidQsg0AU5p3PydO6QDCOQvqp9Se0f1ObvBSqee+CU6T1jtZuMqn5moh4X a/Vazdgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPO-00018m-Mn; Thu, 29 Nov 2018 17:47:26 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPK-00016u-MN for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:24 +0000 Received: by mail-lf1-x144.google.com with SMTP id a16so2110314lfg.3 for ; Thu, 29 Nov 2018 09:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ypw3E2cISa9isgMf/o7XITSEw9/wZqS4XM12LoMTkow=; b=kQ6AMKNVLBIpJnHJzhxVxBdeq6p4dRybfKd57cLFV+11FP5f2nQ2zAotum0p+il6Iz Iu7IU385nMt69p6FNuUzimW1rcCMaGJIqXsH8MraCfMA4Cd+Bk9a2R6nL72vE6dH/Cfp jQdnCajc65WnxPqJTNJ8OVFtAPOEQ2cqKOa5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ypw3E2cISa9isgMf/o7XITSEw9/wZqS4XM12LoMTkow=; b=OxCQpzD9AW01IQgFSIRF3Zpe73pmheJz89/UCpmjfR8fnQn/oOR6d9i2k7JubxQLDc Q5a6qYVocFzG5nwyxHl6zt+ILnI2qRcVlpcP0pyeb9Fn3eNc6YEWiMyTkKYQrmj9nYOU tzrrr+ULtEIHAofi64oJ5cSjLjX+uhnpABtvy9Tn7wDsAvUoVllJgu/g1U9tGf1/fhak 5E8H0UZK7vEifoD5ucs/TXdW5OPNtRaFi1RI7eUP0QMzrIxbGWLpGvvT5UeZ32BNkCMV VgSbwxrll+kBxsZqXO4cQekvBlgs82CVXDzDYrVJSUOF8o4tLigfTf9VnOtT+ojhKh3V v/og== X-Gm-Message-State: AA+aEWYUBo59gehSAH7+3QZQlvmFb592ShETRZo3p4fBUHuDJrVaTBP3 OMII5a3lmuzWJl0FmpBrUXNQnw== X-Google-Smtp-Source: AFSGD/WGJvop+182h8FNuMwezP92yqweV+YNjAIn/s145RayhnjXYyQ8qAfoLBs5uYoyAD30ooBrkw== X-Received: by 2002:a19:6a13:: with SMTP id u19mr1590988lfu.46.1543513639324; Thu, 29 Nov 2018 09:47:19 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:18 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 06/27] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Thu, 29 Nov 2018 18:46:39 +0100 Message-Id: <20181129174700.16585-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094722_743248_E95F28A8 X-CRM114-Status: GOOD ( 20.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , Rob Herring , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The CPU's idle state nodes are currently parsed at the common cpuidle DT library, but also when initializing back-end data for the arch specific CPU operations, as in the PSCI driver case. To avoid open-coding, let's introduce of_get_cpu_state_node(), which takes the device node for the CPU and the index to the requested idle state node, as in-parameters. In case a corresponding idle state node is found, it returns the node with the refcount incremented for it, else it returns NULL. Moreover, for ARM, there are two generic methods, to describe the CPU's idle states, either via the flattened description through the "cpu-idle-states" binding [1] or via the hierarchical layout, using the "power-domains" and the "domain-idle-states" bindings [2]. Hence, let's take both options into account. [1] Documentation/devicetree/bindings/arm/idle-states.txt [2] Documentation/devicetree/bindings/arm/psci.txt Cc: Rob Herring Cc: devicetree@vger.kernel.org Cc: Lina Iyer Suggested-by: Sudeep Holla Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Rob Herring Reviewed-by: Daniel Lezcano --- Changes in v10: - None. --- drivers/of/base.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/of.h | 8 ++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 09692c9b32a7..8f6974a22006 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -429,6 +429,41 @@ int of_cpu_node_to_id(struct device_node *cpu_node) } EXPORT_SYMBOL(of_cpu_node_to_id); +/** + * of_get_cpu_state_node - Get CPU's idle state node at the given index + * + * @cpu_node: The device node for the CPU + * @index: The index in the list of the idle states + * + * Two generic methods can be used to describe a CPU's idle states, either via + * a flattened description through the "cpu-idle-states" binding or via the + * hierarchical layout, using the "power-domains" and the "domain-idle-states" + * bindings. This function check for both and returns the idle state node for + * the requested index. + * + * In case and idle state node is found at index, the refcount incremented for + * it, so call of_node_put() on it when done. Returns NULL if not found. + */ +struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index) +{ + struct of_phandle_args args; + int err; + + err = of_parse_phandle_with_args(cpu_node, "power-domains", + "#power-domain-cells", 0, &args); + if (!err) { + struct device_node *state_node = + of_parse_phandle(args.np, "domain-idle-states", index); + + of_node_put(args.np); + return state_node; + } + + return of_parse_phandle(cpu_node, "cpu-idle-states", index); +} +EXPORT_SYMBOL(of_get_cpu_state_node); + /** * __of_device_is_compatible() - Check if the node matches given constraints * @device: pointer to node diff --git a/include/linux/of.h b/include/linux/of.h index a5aee3c438ad..f9f0c65c095c 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -348,6 +348,8 @@ extern const void *of_get_property(const struct device_node *node, int *lenp); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); extern struct device_node *of_get_next_cpu_node(struct device_node *prev); +extern struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index); #define for_each_property_of_node(dn, pp) \ for (pp = dn->properties; pp != NULL; pp = pp->next) @@ -762,6 +764,12 @@ static inline struct device_node *of_get_next_cpu_node(struct device_node *prev) return NULL; } +static inline struct device_node *of_get_cpu_state_node(struct device_node *cpu_node, + int index) +{ + return NULL; +} + static inline int of_n_addr_cells(struct device_node *np) { return 0; From patchwork Thu Nov 29 17:46:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C70E213AD for ; Thu, 29 Nov 2018 17:55:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B353E2F4F4 for ; Thu, 29 Nov 2018 17:55:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0FFD2F544; Thu, 29 Nov 2018 17:55:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 434042F4F4 for ; Thu, 29 Nov 2018 17:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yybPxWZO/KhBW1OTZNYSuBN6cavTXHL+guLGe75HPSA=; b=u6tyVU6NdKwNurIb0nRwZa+7Nn 5OP66kv25NZNZ3p+fV2i3arZxRWgLSSpcp08AThxiy5HnK79H6YwqawL2ip2hdc/jzhjgkJJkDm+U vLelILiLRoKDhA5PSUPLPmfvSThEUdiuyUpRGNpqt+RLu5Av/HPK2cgxuQZYv3NkGHijnwk6MAePj AllT2gieuU1//aVdU6u2pea8935mFif1/qXMweADLN/fWTh7QevMvAOa68oJ2FkCzXZwQFRbg/FxO N3Jtu0NFA3dGgNxSCtzwAJFmQ0Zwj88H+XpCH+uAPgABq2Lmfa0FU8kIZmiSBNKAbjDuqYq0gMVUt Jr8IlX8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQWm-0000Gg-P3; Thu, 29 Nov 2018 17:55:04 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPU-00016v-IX for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:38 +0000 Received: by mail-lf1-x144.google.com with SMTP id f23so2076922lfc.13 for ; Thu, 29 Nov 2018 09:47:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GHVkWH3PSWyA/cWKlkRJqeV/OFZetQXn2GZtzBG/OUI=; b=Bd0qIXUoNE817ai3HRpnThklH0wMCE/mlCss7tY0ZMJQu/RMVZP851QMoOYySBQEd2 mEQ06t46GXwZVqcrZtRsDj/admhdsTMjYhu6F8WdNMNgeuZYdXY+iLagQIw3oe87sTki s/tCdK3NWK58gBap3Uzx1VWgQBXoftGQryias= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GHVkWH3PSWyA/cWKlkRJqeV/OFZetQXn2GZtzBG/OUI=; b=t8q6pzFe6puH5W2bfhlW3gikH2v+SFksXIV44J0nSpnSaow2rwzxAOMFBKf0zho799 BQSCCV9fN2jM/RWhqt0D5ktSPxQKBwYsXrCKPIOtoOAmpsPLIjcGOIf1D/6nsbllJPMb jAI0DEsGrN2oR2VtWrvoAOI7+0E8fQMSzbmV+cYThS0fH1wlrOWlIcV7OYnJ/YUablEr 3I7slguOHcow3i8+docEGrlvzV5Gf1tKvTgfxidkF0GRHZY7x5RrODePM9KF8Uu3rAm5 LXB+C28ix75kU0ypAwK6xSi/J68pcWtkkujlJWzN7hFQXspM86tdn6N82DHwoIgq1oP2 +65g== X-Gm-Message-State: AA+aEWbqaGrs3LM8BI6zb1TuC+iOopeNG0/uiWU9FZHKawL+tQDRmCSD wE3wdul30kEi5GWqvHPjM6cWdA== X-Google-Smtp-Source: AFSGD/UDRbZWKmQpM2ZYNMWO+bDSpejpjTcM2x/gl7uSYN52LEkq5NFPz8ifaAHNr7UXis+YGI7bDA== X-Received: by 2002:a19:d90c:: with SMTP id q12mr1603187lfg.24.1543513641080; Thu, 29 Nov 2018 09:47:21 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:20 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 07/27] cpuidle: dt: Support hierarchical CPU idle states Date: Thu, 29 Nov 2018 18:46:40 +0100 Message-Id: <20181129174700.16585-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094732_753232_8C14672B X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout during parsing and validating of the CPU's idle states. This is simply done by calling the new OF helper, of_get_cpu_state_node(). Cc: Lina Iyer Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson Reviewed-by: Daniel Lezcano --- Changes in v10: - None. --- drivers/cpuidle/dt_idle_states.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index 53342b7f1010..13f9b7cd32d1 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -118,8 +118,7 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx, for (cpu = cpumask_next(cpumask_first(cpumask), cpumask); cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) { cpu_node = of_cpu_device_node_get(cpu); - curr_state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - idx); + curr_state_node = of_get_cpu_state_node(cpu_node, idx); if (state_node != curr_state_node) valid = false; @@ -176,7 +175,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv, cpu_node = of_cpu_device_node_get(cpumask_first(cpumask)); for (i = 0; ; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); if (!state_node) break; From patchwork Thu Nov 29 17:46:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FBD413AD for ; Thu, 29 Nov 2018 17:55:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C5BC2F4E0 for ; Thu, 29 Nov 2018 17:55:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F69D2F537; Thu, 29 Nov 2018 17:55:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E1742F4E0 for ; Thu, 29 Nov 2018 17:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EtWYxgvbulAPZjWYc+3xSLqyedib10X8YmWQHvPiKL4=; b=gERWKbyCcwKauDBGZvNvI6kg55 +9d1r83I59s0kjSPzwrZIgvPXEId9wC0W3Yjv6NzFEoccJ5+A7dEEMliBRqh+HabE7pFqqnA2+c4T axhUf4dwdf1Dhdh5yWg/sbXz+oYPi7VXWnwH23SWR3JqogEbaERAE7IAOA98INnpNHGLSn8p/4Gw2 buNYrh+1mFtCQCQoe8L4T7K4YLglgUNo1fs0Y7PwV1Wb/GftrTAOkK/tQq4QO6MzojwVsVo0Xbhfu v2W4GcZ+szcDyssjTo63kuVU6QLVppM9kwqVIMF9yn+TpXFUcZy2WMsaFCpxAJ3v7aE4FCfO59JEx Zlb5mGtg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQWl-0000CI-O3; Thu, 29 Nov 2018 17:55:03 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPM-00017z-Fb for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:26 +0000 Received: by mail-lj1-x244.google.com with SMTP id l15-v6so2520120lja.9 for ; Thu, 29 Nov 2018 09:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2+/Zg5CnveDZt6Y9DJWaO1vjEPhkATmRTkbujkSrrhk=; b=iEOSQK3L6vH/uOYYq+9t3pvIzAUY7UHAKzKIcFHnTZJEOxlNO/oikkLhR4EVwmumAc IR1XEudU9idovUSdmo1vxpLNMJEHWCjwyfFGtbZ0CeTN9dbq/4hh3UC4Wc9zpBltMazF G0dFliU25cJCtVXS/hBWoMX5uPYpX9qscltpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2+/Zg5CnveDZt6Y9DJWaO1vjEPhkATmRTkbujkSrrhk=; b=AQnlCoQrnl6d0M/mUFwViQDU+LwV+DtpH5gwaHXN3U30Yr29daQrMQuXeofHJEqU85 HCeGEfiN9MdqPvUlMEwjdCrgsJMLX6aYrh0AOyqeTpxZAxHd5i3MC3oZJM/81hW2ZpiB d+BlAzFeChLFn+0PA5qnHM9vYNQY54b809D3MWh5qZVYNbEh9vPjbh6jiFODDymBN8Ww Vi1nSDwRG9SDdP/l1JWHSy2b0Ai05NJY+22KhF3tIL6KCwLgUFjLGu6fbjLJx2qdsOWZ lhrdfDMsaHGuCAi8XbwQALK75MWj/PuaeiR6fnl0L5dCtRAn/2dKOhpGLirmDo4+wKyz goSA== X-Gm-Message-State: AA+aEWYPk8L6332zXlr7F0vRRc4hXAlla1sNZjdwzZxPj0MwpQ4ja/I9 eVDCtb1s2KW1p/j+5NricYxz+g== X-Google-Smtp-Source: AFSGD/Xvkon2TF8iGxwU58DFFLy/SGEybzfzgTkfgjGfzUCOI7vqWKeP0Zb6u3Yyoq4tmsx3lkVgMA== X-Received: by 2002:a2e:97d7:: with SMTP id m23-v6mr1886895ljj.18.1543513642839; Thu, 29 Nov 2018 09:47:22 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:22 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 08/27] ARM/ARM64: cpuidle: Let back-end init ops take the driver as input Date: Thu, 29 Nov 2018 18:46:41 +0100 Message-Id: <20181129174700.16585-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094724_808675_8F677BA2 X-CRM114-Status: GOOD ( 23.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Brown , Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , Will Deacon , linux-kernel@vger.kernel.org, Lina Iyer , Russell King , Tony Lindgren , Catalin Marinas , linux-arm-msm@vger.kernel.org, Andy Gross , "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To allow arch back-end init ops to operate on the cpuidle driver for the corresponding CPU, let's pass along a pointer to the struct cpuidle_driver* and forward it the relevant layers of callbacks for ARM/ARM64. Following changes for the PSCI firmware driver starts making use of this. Cc: Lina Iyer Cc: Daniel Lezcano Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: David Brown Signed-off-by: Ulf Hansson --- Changes in v10: - New patch! I am seeking an ack from relevant maintainers. Please ping me if you need further information about the hole series. Thanks! Ulf Hanssson --- arch/arm/include/asm/cpuidle.h | 4 ++-- arch/arm/kernel/cpuidle.c | 5 +++-- arch/arm64/include/asm/cpu_ops.h | 4 +++- arch/arm64/include/asm/cpuidle.h | 6 ++++-- arch/arm64/kernel/cpuidle.c | 6 +++--- drivers/cpuidle/cpuidle-arm.c | 2 +- drivers/firmware/psci.c | 7 ++++--- drivers/soc/qcom/spm.c | 3 ++- include/linux/psci.h | 4 +++- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h index 6b2ff7243b4b..bee0a7847733 100644 --- a/arch/arm/include/asm/cpuidle.h +++ b/arch/arm/include/asm/cpuidle.h @@ -32,7 +32,7 @@ struct device_node; struct cpuidle_ops { int (*suspend)(unsigned long arg); - int (*init)(struct device_node *, int cpu); + int (*init)(struct cpuidle_driver *, struct device_node *, int cpu); }; struct of_cpuidle_method { @@ -47,6 +47,6 @@ struct of_cpuidle_method { extern int arm_cpuidle_suspend(int index); -extern int arm_cpuidle_init(int cpu); +extern int arm_cpuidle_init(struct cpuidle_driver *drv, int cpu); #endif diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c index fda5579123a8..43778c9b373d 100644 --- a/arch/arm/kernel/cpuidle.c +++ b/arch/arm/kernel/cpuidle.c @@ -122,6 +122,7 @@ static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu) /** * arm_cpuidle_init() - Initialize cpuidle_ops for a specific cpu + * @drv: the drv to be initialized * @cpu: the cpu to be initialized * * Initialize the cpuidle ops with the device for the cpu and then call @@ -137,7 +138,7 @@ static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu) * -ENXIO if the HW reports a failure or a misconfiguration, * -ENOMEM if the HW report an memory allocation failure */ -int __init arm_cpuidle_init(int cpu) +int __init arm_cpuidle_init(struct cpuidle_driver *drv, int cpu) { struct device_node *cpu_node = of_cpu_device_node_get(cpu); int ret; @@ -147,7 +148,7 @@ int __init arm_cpuidle_init(int cpu) ret = arm_cpuidle_read_ops(cpu_node, cpu); if (!ret) - ret = cpuidle_ops[cpu].init(cpu_node, cpu); + ret = cpuidle_ops[cpu].init(drv, cpu_node, cpu); of_node_put(cpu_node); diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index 8f03446cf89f..8db870c29f1b 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -19,6 +19,8 @@ #include #include +struct cpuidle_driver; + /** * struct cpu_operations - Callback operations for hotplugging CPUs. * @@ -58,7 +60,7 @@ struct cpu_operations { int (*cpu_kill)(unsigned int cpu); #endif #ifdef CONFIG_CPU_IDLE - int (*cpu_init_idle)(unsigned int); + int (*cpu_init_idle)(struct cpuidle_driver *, unsigned int); int (*cpu_suspend)(unsigned long); #endif }; diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h index 3c5ddb429ea2..3fd3efb61649 100644 --- a/arch/arm64/include/asm/cpuidle.h +++ b/arch/arm64/include/asm/cpuidle.h @@ -4,11 +4,13 @@ #include +struct cpuidle_driver; + #ifdef CONFIG_CPU_IDLE -extern int arm_cpuidle_init(unsigned int cpu); +extern int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu); extern int arm_cpuidle_suspend(int index); #else -static inline int arm_cpuidle_init(unsigned int cpu) +static inline int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu) { return -EOPNOTSUPP; } diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c index f2d13810daa8..aaf9dc5cb87a 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/arch/arm64/kernel/cpuidle.c @@ -18,13 +18,13 @@ #include #include -int arm_cpuidle_init(unsigned int cpu) +int arm_cpuidle_init(struct cpuidle_driver *drv, unsigned int cpu) { int ret = -EOPNOTSUPP; if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend && cpu_ops[cpu]->cpu_init_idle) - ret = cpu_ops[cpu]->cpu_init_idle(cpu); + ret = cpu_ops[cpu]->cpu_init_idle(drv, cpu); return ret; } @@ -51,7 +51,7 @@ int arm_cpuidle_suspend(int index) int acpi_processor_ffh_lpi_probe(unsigned int cpu) { - return arm_cpuidle_init(cpu); + return arm_cpuidle_init(NULL, cpu); } int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 3a407a3ef22b..39413973b21d 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -106,7 +106,7 @@ static int __init arm_idle_init_cpu(int cpu) * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ - ret = arm_cpuidle_init(cpu); + ret = arm_cpuidle_init(drv, cpu); /* * Allow the initialization to continue for other CPUs, if the reported diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index c80ec1d03274..878c4dcf0118 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -270,7 +270,8 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); -static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) +static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, + struct device_node *cpu_node, int cpu) { int i, ret, count = 0; u32 *psci_states; @@ -371,7 +372,7 @@ static int __maybe_unused psci_acpi_cpu_init_idle(unsigned int cpu) } #endif -int psci_cpu_init_idle(unsigned int cpu) +int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) { struct device_node *cpu_node; int ret; @@ -390,7 +391,7 @@ int psci_cpu_init_idle(unsigned int cpu) if (!cpu_node) return -ENODEV; - ret = psci_dt_cpu_init_idle(cpu_node, cpu); + ret = psci_dt_cpu_init_idle(drv, cpu_node, cpu); of_node_put(cpu_node); diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c index 53807e839664..6e967f0a8608 100644 --- a/drivers/soc/qcom/spm.c +++ b/drivers/soc/qcom/spm.c @@ -208,7 +208,8 @@ static const struct of_device_id qcom_idle_state_match[] __initconst = { { }, }; -static int __init qcom_cpuidle_init(struct device_node *cpu_node, int cpu) +static int __init qcom_cpuidle_init(struct cpuidle_driver *drv, + struct device_node *cpu_node, int cpu) { const struct of_device_id *match_id; struct device_node *state_node; diff --git a/include/linux/psci.h b/include/linux/psci.h index 8b1b3b5935ab..4f29a3bff379 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -20,9 +20,11 @@ #define PSCI_POWER_STATE_TYPE_STANDBY 0 #define PSCI_POWER_STATE_TYPE_POWER_DOWN 1 +struct cpuidle_driver; + bool psci_tos_resident_on(int cpu); -int psci_cpu_init_idle(unsigned int cpu); +int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); enum psci_conduit { From patchwork Thu Nov 29 17:46:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAC461057 for ; Thu, 29 Nov 2018 17:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C60892F36A for ; Thu, 29 Nov 2018 17:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA2AA2F3D7; Thu, 29 Nov 2018 17:49:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5ABC12F36A for ; Thu, 29 Nov 2018 17:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wpCyxVLq+ow0Vh2JQfaHO4KOXz8wg+JSL7seiQ6ByAU=; b=gAAjtWjyGBxXntpd41VCAnE42L BBboI8W7NgKTh4RkpiYV7AZC6iWTgyW3bDFIBPX5EqRCxsoOydX3/GEsMzcSgSCF2mHoDJxFYFlZ1 /Yc6sHaPz6ZbPE3TP+NiOsdI/FZY+j6BcRE8YMqNSL5ySIoF/1v8zteCtLGjVsl4bFnpJM6ah6o8r WkH8VG+jijlIyMVX939WPWqIILKrtWOCvyVA8VvtaXRnS4N4ElqCEXHOP9zS9VJy9kBo7vzFsJkvT EgS2wkER7+T0iRCP+RlVmKgsNyOMfmGLSZuTuUGxwEpWpCPhqrHzmcrSmwkmgjPOriViC9GCHayGH QhK30Esw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQRc-0003ER-Qi; Thu, 29 Nov 2018 17:49:44 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPY-00018a-1l for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:39 +0000 Received: by mail-lf1-x142.google.com with SMTP id v5so2092721lfe.7 for ; Thu, 29 Nov 2018 09:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dp0PQcIi+zUdI+E0dzHo61J8R5OUIo/EKoKccuEIilM=; b=UUPUOmzV30i5PO9zvMREztRMxyjO7rKKKGHGxgUxbbNKp7L17G45IEtJssthGGI9UY ylBoMZ58cnK9zbNkVjimxzrsXDzHSakojsGDgDTcBcnCtKc1Nb0I7PbIZshLeXiNvjhT KfLPs7j++q88BRjRPMoylvizdXT+l61CVNJCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dp0PQcIi+zUdI+E0dzHo61J8R5OUIo/EKoKccuEIilM=; b=gzx1SurXPcaZWJFI1z804zg3m9AQO6kF3LfP8OlndygXgelir4Yg1UCp91Sju3aVE8 yVA3mUIKdtp8PBQpJHKZmZbS00j7YA65ni+Qi1B+PH4mE02HYNa+wT+kcJ0FjjQ8vrN6 aQ78DJo/K1x3sQIz9nZUnUbxoZtG4SRzpI6L+ucQ7dADwuPlgM+/xEWTd6zsBdsSJ5RN k1ZIr/Tzqvr6+Vwnmha6NpGaAfBgB7bJbWjPROHLajrI5Zczdr5hQA3y3F3wbc/y2Nu/ EZzaFUENh+O7Ez1+N4GKP/ZGoynfEeBzf2qFENeUXe3WeRQn8UEoZXDDBr67rnHYSRWj kEZQ== X-Gm-Message-State: AA+aEWbYFPohKDuAIEBz1Knq5L1FM6p+nyT9oy0netTBxT5ZRpSgJSkx /kGcg3//ZZ98TISHOZ2XzUCArA== X-Google-Smtp-Source: AFSGD/VWpTqo4C23yt/lmHu25wNvC57+9LIAW6U9eKbcXDiz8NDvXMxHrl+QXjQp3jXWS6u14RllXQ== X-Received: by 2002:a19:6514:: with SMTP id z20mr1602816lfb.31.1543513644382; Thu, 29 Nov 2018 09:47:24 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:23 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 09/27] drivers: firmware: psci: Move psci to separate directory Date: Thu, 29 Nov 2018 18:46:42 +0100 Message-Id: <20181129174700.16585-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094736_415405_2CEE8F6C X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some following changes extends the PSCI driver with some additional new files. Let's avoid to continue cluttering the toplevel firmware directory and first move the PSCI files into a PSCI sub-directory. Suggested-by: Mark Rutland Signed-off-by: Ulf Hansson --- Changes in v10: - None. --- drivers/firmware/Kconfig | 15 +-------------- drivers/firmware/Makefile | 3 +-- drivers/firmware/psci/Kconfig | 13 +++++++++++++ drivers/firmware/psci/Makefile | 4 ++++ drivers/firmware/{ => psci}/psci.c | 0 drivers/firmware/{ => psci}/psci_checker.c | 0 6 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 drivers/firmware/psci/Kconfig create mode 100644 drivers/firmware/psci/Makefile rename drivers/firmware/{ => psci}/psci.c (100%) rename drivers/firmware/{ => psci}/psci_checker.c (100%) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 7273e5082b41..0400afb2fec7 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -5,20 +5,6 @@ menu "Firmware Drivers" -config ARM_PSCI_FW - bool - -config ARM_PSCI_CHECKER - bool "ARM PSCI checker" - depends on ARM_PSCI_FW && HOTPLUG_CPU && CPU_IDLE && !TORTURE_TEST - help - Run the PSCI checker during startup. This checks that hotplug and - suspend operations work correctly when using PSCI. - - The torture tests may interfere with the PSCI checker by turning CPUs - on and off through hotplug, so for now torture tests and PSCI checker - are mutually exclusive. - config ARM_SCMI_PROTOCOL bool "ARM System Control and Management Interface (SCMI) Message Protocol" depends on ARM || ARM64 || COMPILE_TEST @@ -258,6 +244,7 @@ config TI_SCI_PROTOCOL config HAVE_ARM_SMCCC bool +source "drivers/firmware/psci/Kconfig" source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/google/Kconfig" source "drivers/firmware/efi/Kconfig" diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 3158dffd9914..6670ebe21463 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -2,8 +2,6 @@ # # Makefile for the linux kernel. # -obj-$(CONFIG_ARM_PSCI_FW) += psci.o -obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o obj-$(CONFIG_ARM_SCPI_POWER_DOMAIN) += scpi_pm_domain.o obj-$(CONFIG_ARM_SDE_INTERFACE) += arm_sdei.o @@ -24,6 +22,7 @@ CFLAGS_qcom_scm-32.o :=$(call as-instr,.arch armv7-a\n.arch_extension sec,-DREQU obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/ +obj-y += psci/ obj-y += broadcom/ obj-y += meson/ obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ diff --git a/drivers/firmware/psci/Kconfig b/drivers/firmware/psci/Kconfig new file mode 100644 index 000000000000..26a3b32bf7ab --- /dev/null +++ b/drivers/firmware/psci/Kconfig @@ -0,0 +1,13 @@ +config ARM_PSCI_FW + bool + +config ARM_PSCI_CHECKER + bool "ARM PSCI checker" + depends on ARM_PSCI_FW && HOTPLUG_CPU && CPU_IDLE && !TORTURE_TEST + help + Run the PSCI checker during startup. This checks that hotplug and + suspend operations work correctly when using PSCI. + + The torture tests may interfere with the PSCI checker by turning CPUs + on and off through hotplug, so for now torture tests and PSCI checker + are mutually exclusive. diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile new file mode 100644 index 000000000000..1956b882470f --- /dev/null +++ b/drivers/firmware/psci/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +# +obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci/psci.c similarity index 100% rename from drivers/firmware/psci.c rename to drivers/firmware/psci/psci.c diff --git a/drivers/firmware/psci_checker.c b/drivers/firmware/psci/psci_checker.c similarity index 100% rename from drivers/firmware/psci_checker.c rename to drivers/firmware/psci/psci_checker.c From patchwork Thu Nov 29 17:46:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7B221057 for ; Thu, 29 Nov 2018 17:50:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A312C2F3F5 for ; Thu, 29 Nov 2018 17:50:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9759D2F48E; Thu, 29 Nov 2018 17:50:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0DBC32F3F5 for ; Thu, 29 Nov 2018 17:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=H7vd4VR+0J5FELyzZLeBRJ5Ovs+bvwvJAitPbtTv8Ns=; b=kRYZyWRuPXhtKOWWY394/zzHgi jVvnVEJY45GJzZGOspYfGANxbHXIzSu8ApcToI9PYq+fiDlnOsOFdzrrVhkmLQdJI0OJab3pL2XYB AFUU2IVIUb7IYyWz3FWPPVjjpxwTV1DnKD22Rj87w3UBKy/0Ycw8AzRmjCH8n+qAP4qzKmV7cBPoX qzYL0K+0Vjt9ZH+bGN9up3ceI+2mxnMRf9SGSDRCOpXVbtVHa5pkSex14fQy9ooC0SWvKXfgF3tdi A8plrxcylceNRUtKDhI8eFkM1+5tnvhlzYqejzEHE6ECaPGl+9jWnDvwfwCG1ojIjfZT/b6veolpD iYdnZR8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQSV-0005Ff-0a; Thu, 29 Nov 2018 17:50:39 +0000 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPZ-00018j-RP for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:48 +0000 Received: by mail-lf1-x141.google.com with SMTP id u18so2087883lff.10 for ; Thu, 29 Nov 2018 09:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BlcCn6JUkPvrmaJts0baXJ0tND3p8k02JN8jSxGv1B4=; b=LbDpQVTsDKH8Vlu8mCK1a/Q1So8giOTNrXCaxWic4ge8hs50DGuGqiu3yznF/H6DfO +aQ7qnYWh/XOAWTWRcJ69MBuJZNFn7LZR1kGuYEVa9jboM1knEsNrcqiNH7VfRM3ilvO gSEgA1FPTdTRPV2AKN8BL60FONcnUzCXet0/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BlcCn6JUkPvrmaJts0baXJ0tND3p8k02JN8jSxGv1B4=; b=letA1BUTQarzzg8VqRr7LJ8abNYIQw3JHghrT/MR/zDE7xgAIfmUKIkVsNhn3f9j+t eb1y2wVq9Kj+fsXfui5cnRk227GoPZOyTVzmP4C2r272/pcj+FqslKmcZzMrMqOPeXP2 OjbYLjhOZQh0hX64sYMGflS8ckVrAg7WQ8w9bAznqKtJ0r+ATx7ItS7rKlQ9MFj3lXpn PJcnTu1umVWU05J4pLN8ffEcrLmfzdxuPbaavDx8of2FC2xMG0AHjo4GBWkFxskSRBDw vYIfhCuSVJwl9svzGLdiO1+EuSezEL6F+TIYvMPrS06x+Lypk56JKBZueuaxowDgWUBS 9J5w== X-Gm-Message-State: AA+aEWbEceCJ16dKToWFswWmZXipf81rp89yGnLXvTNEllMiXn8NwBK7 e6DRQzT8oV1URQizV+gDHlKOxg== X-Google-Smtp-Source: AFSGD/XL0A9ZxXXbqP0IGeMxZKK3Hk3+2ZxFydPtpCZkLTo460VYANs3KWIUvoIrurCDJv1WpTGhcQ== X-Received: by 2002:a19:a60c:: with SMTP id p12mr1733898lfe.63.1543513645918; Thu, 29 Nov 2018 09:47:25 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:25 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 10/27] MAINTAINERS: Update files for PSCI Date: Thu, 29 Nov 2018 18:46:43 +0100 Message-Id: <20181129174700.16585-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094738_265866_79701D4F X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The files for the PSCI firmware driver were moved to a sub-directory, let's update MAINTAINERS to reflect that. Suggested-by: Mark Rutland Signed-off-by: Ulf Hansson --- Changes in v10: - None. --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 380e43f585d3..9805444711ab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11919,7 +11919,7 @@ M: Mark Rutland M: Lorenzo Pieralisi L: linux-arm-kernel@lists.infradead.org S: Maintained -F: drivers/firmware/psci*.c +F: drivers/firmware/psci/ F: include/linux/psci.h F: include/uapi/linux/psci.h From patchwork Thu Nov 29 17:46:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9AD217F0 for ; Thu, 29 Nov 2018 17:50:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6E942F4DC for ; Thu, 29 Nov 2018 17:50:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AFD12F4E1; Thu, 29 Nov 2018 17:50:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52A682F4DC for ; Thu, 29 Nov 2018 17:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xm6uDteAzlCiPIBLdG6zGJQF86S6TtFYIfpjjYNaVbk=; b=LPlCJAgHGTQdLwW5JvOPc5eha8 s1dp6SEYBsQ5kYAWB6SJDGM7+kCCqfbNP1vpn6p1qhK1N57cRcgLmYrPXKmi3YUaxbvOL05J0OpKX ZcsrOXEuznAyicQ60ZL5xePXjtK7THky8cBnLE8L58MisLswgkojSnofV5bOBQHSRHGrNMrPAN/7U xmVEnEb7Relil5+dfzKCU9VbljeKDdPse7DLd8mcbWkFNof908vtL7ZB50J5XaFTXBhB5eZ+q78sr D3Gz075hQ3nb7g0qE88OxSp2XeMfl0g/Jm/rCgdhGGze+FLaywcJceFEoepQE5q5tYaE4Qv1CtoKD 3nv1mkSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQSE-000523-I1; Thu, 29 Nov 2018 17:50:22 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPb-0001A3-6j for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:51 +0000 Received: by mail-lj1-x244.google.com with SMTP id s5-v6so2508327ljd.12 for ; Thu, 29 Nov 2018 09:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=kQS7vsEOYPpXGlZNXuLMFtfkofiQuooHy+fccXroI9o/TGMZsJLjCqyJCmBDcW+Pfm SSZXA94pqanu/v4Q8btPoMk0uRoASTgNiYRzQx/qxsxxc91rzycdnQXVJ/jkbznAH+qz ETf/KoqgfbjIQG0Nb/a4vedWuXg17lj8fgw/s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=qHegGXt5g93yApl7StUp0aHeGbOXZ0b7hN2yDali/lVRf7oRCAXU6y9xbMwmn0gmTF MMctby4K5q0lnAYzX8bueaIiryBNu05pTtt48OD8se+OtGfkFnvfA7YKtbxIhBlo+Q7L 7y8JQb+cRuAfWJ8drOx8MU9W+CtieStCJ6uX9mmOCbfKN/D9c5hxG/dsq09I8KTcrQvY STO6iDMFIg6BnErA6aNQO7y+77mB0nMYvOCLdtWCkOpZDSVN3bhMqlw7yk6Si5algpRA TgAQ+5vRZnC23Fgbm5+Tvs9CYxDjkftP0KJTfVV+hbZpP8g02XzG5tNruPS0yDTe3ij4 GjZw== X-Gm-Message-State: AA+aEWanNUHmr+A2+ZR/SYuDjrYBBrnvlzjyvDELJ6HdjK0FmZxTfDk6 +1cId9oYdABHZiENnKc41pF7Kw== X-Google-Smtp-Source: AFSGD/UXa2P2II/wtioQeASL+BRwTSaq76NVJ+o2O/6qKa9KM8ADvkUD6yNQjs/D3EcYdG3tnACO/Q== X-Received: by 2002:a2e:9a56:: with SMTP id k22-v6mr1711941ljj.17.1543513647571; Thu, 29 Nov 2018 09:47:27 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:26 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 11/27] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 29 Nov 2018 18:46:44 +0100 Message-Id: <20181129174700.16585-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094740_592238_D7BD2492 X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Let's split the psci_dt_cpu_init_idle() function into two functions, as to allow following changes to re-use some of the code. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - None. --- drivers/firmware/psci/psci.c | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 878c4dcf0118..d50b46a0528f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -270,10 +270,27 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static int psci_dt_parse_state_node(struct device_node *np, u32 *state) +{ + int err = of_property_read_u32(np, "arm,psci-suspend-param", state); + + if (err) { + pr_warn("%pOF missing arm,psci-suspend-param property\n", np); + return err; + } + + if (!psci_power_state_is_valid(*state)) { + pr_warn("Invalid PSCI power state %#x\n", *state); + return -EINVAL; + } + + return 0; +} + static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, int cpu) { - int i, ret, count = 0; + int i, ret = 0, count = 0; u32 *psci_states; struct device_node *state_node; @@ -292,29 +309,16 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, return -ENOMEM; for (i = 0; i < count; i++) { - u32 state; - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); + of_node_put(state_node); - ret = of_property_read_u32(state_node, - "arm,psci-suspend-param", - &state); - if (ret) { - pr_warn(" * %pOF missing arm,psci-suspend-param property\n", - state_node); - of_node_put(state_node); + if (ret) goto free_mem; - } - of_node_put(state_node); - pr_debug("psci-power-state %#x index %d\n", state, i); - if (!psci_power_state_is_valid(state)) { - pr_warn("Invalid PSCI power state %#x\n", state); - ret = -EINVAL; - goto free_mem; - } - psci_states[i] = state; + pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; From patchwork Thu Nov 29 17:46:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C716517F0 for ; Thu, 29 Nov 2018 17:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B68B72F536 for ; Thu, 29 Nov 2018 17:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB2472F538; Thu, 29 Nov 2018 17:55:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 500962F544 for ; Thu, 29 Nov 2018 17:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=u37J6G19OZdQVVGd1g5fYGVYRHgwDZC3qsRprDM74+8=; b=U93q5sDfngGg8GqtQPS92ghBkU ST2mTWEjVNFEmH/ik6Z+GhcKAJFdAEq3r/vqamxwqojwveRHLHWqqMEGbJ/kJ1Y6QVMWGgSGsUuWL 7rEw/xfWVgLDB/G52oRy1nSNRh/4FJPx3dkZkf80F6VrqOqSZcNSo3P5l7mzqSEoKtcjxh1C5hj6m vTa14rbl3FoIS3iRsuH4fev9E8LkcbA4usnUHYAOh5gtd4hYjuDLQBkNal+p+ZFUNdcB+xiTGbGOv lzSOdux2BV/wwLEDJ15FAQH9ExpNJhP+JymtKdZj8ZYFGUaURkN/o0KJoUNa4SPOIgbBOSWID2nv1 A5t+uRoQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQX2-0001Fb-Jq; Thu, 29 Nov 2018 17:55:20 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPY-0001Bz-1i for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:41 +0000 Received: by mail-lf1-x142.google.com with SMTP id n18so2101083lfh.6 for ; Thu, 29 Nov 2018 09:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZnU2zg5+wIbWo5O0mmqI6742JstHQYNw0KGOcLMkauw=; b=gc/mEof6FAHJILmhbUnZDwxeH3clqii9e4boH+PzYfTjHTpHvntzwcHeA4X/TZUQCO nEaYBT3n60JTTzq82pT8Jx8y3Ni2mBBoG8mGM8FR0XlTfs3oYJZ8Icwa0KV7QnJ8zC0z 1x2yIJkBRlAHnoX+Xfz8x50/nIvF5nR+udY6k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZnU2zg5+wIbWo5O0mmqI6742JstHQYNw0KGOcLMkauw=; b=M8Tu/6/5ac+d3KHscTYHzCsqUtGsrnqvSg/5FfhtxlTI1FbZ/SymX8HHxeUj6G2ph4 OOxWTqOv4UQLJ+o8ZGghUNXeivVLEhuB37HipmzrEIahV6B/D/eVnH/ct6DECNd/v6TD rx+HQ4bRarW1xrAcFvcNniR4Xtjx2eEt8Ol5AVpkVz6fsS4gbchyZD3Yfmn/iroPXIre JxEdr88WilZ/Grkg2o9/LF6BktlOYswKA8Fm4qPh+KmscLYe1ocgyU1Ml5QrsaMKPrT+ oLAiG5AtdaSx3ki7mtV1sjviib/sqWXsLDgXK0fHhSHM+q8jQ4Z87+o/aFRJij51n9f/ HDig== X-Gm-Message-State: AA+aEWYz7l8yjlV0E2gb+VsELVJp8jY3qrMIURf3tPLADdK8KxhKXkcj Aphn/g0D8yxWCFUKErk9Im6d7Q== X-Google-Smtp-Source: AFSGD/UfhHk4UsCzPn/eAc1UCLzaQXf6ETh/uaMawQcc+6G7rBPGahcf/FhFDVQ7YPe4Sfkg3pEBVQ== X-Received: by 2002:a19:a84e:: with SMTP id r75mr1697958lfe.45.1543513649619; Thu, 29 Nov 2018 09:47:29 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:29 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 12/27] drivers: firmware: psci: Simplify state node parsing Date: Thu, 29 Nov 2018 18:46:45 +0100 Message-Id: <20181129174700.16585-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094736_355097_F0B27F82 X-CRM114-Status: GOOD ( 17.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of iterating through all the state nodes in DT, to find out how many states that needs to be allocated, let's use the number already known by the cpuidle driver. In this way we can drop the iteration altogether. Signed-off-by: Ulf Hansson --- Changes in v10: - New patch. --- drivers/firmware/psci/psci.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index d50b46a0528f..cbfc936d251c 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -290,26 +290,20 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, int cpu) { - int i, ret = 0, count = 0; + int i, ret = 0, num_state_nodes = drv->state_count - 1; u32 *psci_states; struct device_node *state_node; - /* Count idle states */ - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - count))) { - count++; - of_node_put(state_node); - } - - if (!count) - return -ENODEV; - - psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); + psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + GFP_KERNEL); if (!psci_states) return -ENOMEM; - for (i = 0; i < count; i++) { + for (i = 0; i < num_state_nodes; i++) { state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + if (!state_node) + break; + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); @@ -319,6 +313,11 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + if (i != num_state_nodes) { + ret = -ENODEV; + goto free_mem; + } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; From patchwork Thu Nov 29 17:46:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B723513AD for ; Thu, 29 Nov 2018 17:55:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5A662F544 for ; Thu, 29 Nov 2018 17:55:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A00C2F546; Thu, 29 Nov 2018 17:55:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E73C2F544 for ; Thu, 29 Nov 2018 17:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=228ST6uDOUKpr6OZCE5ALMGbc7ERdexyu0uETAT4dJs=; b=nHwhzMt8l9SXBpyBw23XZntmCf PeVRsukuYgpP7MfjBOPXd2aRljgWe27in67imNLWCSFU9jFusWDNKef4gHp3W8f22Vz7u1DF56pV5 IdPIoTVxaxms6X82zV9sGrTfCtGiPGc6kRgVgk77xVIO/BIU17VYgfkVMq1ocJTciluyMxSMOSxsL ZAlaIIT/cMMB7kc+j4BVQsP8W8l7gOKgrxzvK+s2CWxVbtzBsfRLhmuVGQ8NetBVeVD/FoVlOTm6M 6cHSGBuzyEqY1P9Z7cVJzQshMeGyR3mEOuEr+zk/PSIYWzICYBvPrhtAoObtg8EproajWoi6M8t8Z 12mA5bXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQX3-0001YV-Rp; Thu, 29 Nov 2018 17:55:21 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPb-0001Di-6o for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:47 +0000 Received: by mail-lj1-x244.google.com with SMTP id z80-v6so2520744ljb.8 for ; Thu, 29 Nov 2018 09:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jX+qyQO49fWmt2xQpGUjw4NJQ/8bkzUinDH9qdTMnUA=; b=AlPyEsAyB5TTJCSeRQDcqsvnIKB/rMfm0oTmlQA7hqOgZ6aMDexyWveeYmPE2QdbmV BmJIUeVUEo68Z1RYBp5Q7w/uSp5wPfc9ZHJqQtiE1cMsCCV0zIMnnI1fU3CrzA3sf76y BhqVyyrcH5tH2VK3YAUp3EhPfLgCuB7n6fgBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jX+qyQO49fWmt2xQpGUjw4NJQ/8bkzUinDH9qdTMnUA=; b=GqkL3W32La9DtemHKClgHseF+vKrGWUjHCgJ05sSiY9OlMJZomrO+OC9Yn3kfNhlVp jFowo7yXV+SAKRXZViFMkK5H1z5YJuFUb1oiYewzkxUNUh5ery1D6gooDvGy2lJa4Dsn NUS+wgkPRoQ4BfcHxSm2pK0L0HwKgxwiaWLCLLRNqUa74Nec7PBz5gPPxgyzA79IbO1A SpHM1UJwqDYKGPDXnmJH9cjHaRRYoHQXNuDUuVaUrwbiI/aURsr0jffWeEocTGWfXriN M+Ej7eW7a/OGvGib847mzuOeODWPBWMxWzCiDZrbsNmRCPgMX9rIzbzJvngrvUWgR4+0 jkYg== X-Gm-Message-State: AA+aEWYrArr7oaDbNQJZcuzlKqWdwiTxuzvXHlDmyu9GTHvirRGb24xF +mCEKCVC9WsI6F2WlxRIw0r/Sw== X-Google-Smtp-Source: AFSGD/WMXNnYmUDhhw+Xfxe6yvJ/i67+Rv4G+K+ZK1l5/jdsO6I8LilxuZCD2yTIfDMQsHofrPEMgw== X-Received: by 2002:a2e:5b93:: with SMTP id m19-v6mr1512841lje.115.1543513651192; Thu, 29 Nov 2018 09:47:31 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:30 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 13/27] drivers: firmware: psci: Support hierarchical CPU idle states Date: Thu, 29 Nov 2018 18:46:46 +0100 Message-Id: <20181129174700.16585-14-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094740_117201_8ED9D6D8 X-CRM114-Status: GOOD ( 14.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer Currently CPU's idle states are represented in a flattened model, via the "cpu-idle-states" binding from within the CPU's device nodes. Support the hierarchical layout, simply by converting to calling the new OF helper, of_get_cpu_state_node(). Cc: Lina Iyer Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes in v10: - None. --- drivers/firmware/psci/psci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index cbfc936d251c..631e20720a22 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -300,7 +300,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, return -ENOMEM; for (i = 0; i < num_state_nodes; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); if (!state_node) break; From patchwork Thu Nov 29 17:46:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 825101057 for ; Thu, 29 Nov 2018 17:50:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EDE52F48E for ; Thu, 29 Nov 2018 17:50:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 633992F4F0; Thu, 29 Nov 2018 17:50:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0EBEB2F4DC for ; Thu, 29 Nov 2018 17:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+M8oWndSTOzPkmzi3l/BjVOVBcsF21F0Apwgo3AHFjs=; b=ifVh8SfSexWgZC7GLaBiEWujsl YDH6HJ0PbfKJMSdbLRWpx1/ycjoaanlpghvmkvI1wTIfiEnBkCLtlj05RMJwj5/Fhr8mL8QW8ZQaB AtrFWV7WaR1zcAlmTI+obv66+RQXoJ9Akm1tqojDE6xB8oiFPStQlym3coyLezDf9OjTazon7BmzO T1CJXygGQiQ7AwD+zrvzVBl0slV//dC6RW+zn43Id6YaZIe9pb0r9oiqdKqkIrgcUx8Ja2sdFSs0A 35k/5OVMMzzSes8uUBAng8EYTxFyVbjBMpA09/LwlWRjdH+OzJtRhTeRDF7pDhFIJOX5pYHgpxbCa xkI9rkRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQSm-0005Uv-A5; Thu, 29 Nov 2018 17:50:56 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPh-0001Fj-H4 for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:54 +0000 Received: by mail-lj1-x243.google.com with SMTP id c19-v6so2530819lja.5 for ; Thu, 29 Nov 2018 09:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rtb7ncC0WwEMpjQCLG7tBribMPasaZ8gXOaK80cYa2Y=; b=YO5P3hwGz2f1/PGj8M6IIJCJ+iADNSFbLBsUFJh+FZ0WQVq2L2h0C6vPtpjcJudSN+ 6iWdepfrH5LRe2GaGEODv4e8urAWb5kwAA/Ub/lmuunyphoDeHrSFmg1i0l5N5P4tPyE QD54E4ThDFkrMQtqrBqXe0ymN4yniaZGb4Swc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Rtb7ncC0WwEMpjQCLG7tBribMPasaZ8gXOaK80cYa2Y=; b=nJCH3/F0rLG2GbG2XN4sbwFx6J9kcqh7uPyas8fQxT8FyPI8e4wtD72T0Ks0YMLsAC heIrlTeeXnCrMXCQ94IQLMjhLaAw1Rhs6iAfxewMzyL/fjqusZQ4B3GugVEf60942XNX 642bSMPir4Oyq6i8an6JJeRN9hHiOvY8MkQCbZs7iI0f6ytP4kiT14VODDrE5AfPRE3m n6HUbVVyBfxBpAI8cyL6ClVVnrPbp4ErDiREzgUV9aM3sR4KiBoPyT5trPZbBneGc0k4 Ql3E0FeDLLgJkxj084IfrAwBp38VQaxWZ67vynzCvue7OhPBL2j38MTp8BcxxPkPPw3p C+uw== X-Gm-Message-State: AA+aEWYQYUsnujylWe2URc68dGvU0rEfczvhroQJwyA3kN/Y66VK4Glv FgrKrvxfg+D7s5lWDyvXIuk7Hg== X-Google-Smtp-Source: AFSGD/VLjWAQoPNsfdrAeTLoSV15h4LBoJmHssLv9tcjNYnWxIaJytuQxOgS2zsBwJGIgj+JV0GVVQ== X-Received: by 2002:a2e:131a:: with SMTP id 26-v6mr1850088ljt.107.1543513652968; Thu, 29 Nov 2018 09:47:32 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:32 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 14/27] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Thu, 29 Nov 2018 18:46:47 +0100 Message-Id: <20181129174700.16585-15-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094746_550710_463014B9 X-CRM114-Status: GOOD ( 16.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of having each psci init function taking care of the of_node_put(), let's deal with that from psci_dt_init(), as this enables a bit simpler error path for each psci init function. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson Acked-by: Mark Rutland Reviewed-by: Daniel Lezcano --- Changes in v10: - None. --- drivers/firmware/psci/psci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 631e20720a22..6bfa47cbd174 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -609,9 +609,9 @@ static int __init psci_0_2_init(struct device_node *np) int err; err = get_set_conduit_method(np); - if (err) - goto out_put_node; + return err; + /* * Starting with v0.2, the PSCI specification introduced a call * (PSCI_VERSION) that allows probing the firmware version, so @@ -619,11 +619,7 @@ static int __init psci_0_2_init(struct device_node *np) * can be carried out according to the specific version reported * by firmware */ - err = psci_probe(); - -out_put_node: - of_node_put(np); - return err; + return psci_probe(); } /* @@ -635,9 +631,8 @@ static int __init psci_0_1_init(struct device_node *np) int err; err = get_set_conduit_method(np); - if (err) - goto out_put_node; + return err; pr_info("Using PSCI v0.1 Function IDs from DT\n"); @@ -661,9 +656,7 @@ static int __init psci_0_1_init(struct device_node *np) psci_ops.migrate = psci_migrate; } -out_put_node: - of_node_put(np); - return err; + return 0; } static const struct of_device_id psci_of_match[] __initconst = { @@ -678,6 +671,7 @@ int __init psci_dt_init(void) struct device_node *np; const struct of_device_id *matched_np; psci_initcall_t init_fn; + int ret; np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); @@ -685,7 +679,10 @@ int __init psci_dt_init(void) return -ENODEV; init_fn = (psci_initcall_t)matched_np->data; - return init_fn(np); + ret = init_fn(np); + + of_node_put(np); + return ret; } #ifdef CONFIG_ACPI From patchwork Thu Nov 29 17:46:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0A2B17F0 for ; Thu, 29 Nov 2018 17:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDFB52F4DE for ; Thu, 29 Nov 2018 17:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C19A82F515; Thu, 29 Nov 2018 17:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5124D2F4DE for ; Thu, 29 Nov 2018 17:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uvbWRVHpDa41xFzvj+i+MsryJh5qG9H6n7ztzB0ranc=; b=mfJiOxIB5P0c9ZoiGRZ0ohee1p DkoqZauxC0teK6UI3Ea/NhjF9ixahOOQiOy3PV/pXJ415gKDDSuT7FnSAyNGN9aEtNaJCAr5an3wo 9IW/4gQDvB6jLCAKz1/lLKhHuonf4aAqAltQC7usYtZloDPczx3/7XJquoWSzlyAB4HnwTh3Tptk4 WhE7VYerHnqg1TwNgXAUuB+59L2rb6ablUNcneSBBdtmtSKbBjaIO0XsJseUeGZDCgoanWSNGI8rg dmjcrGlzO3K9Sx4WL+Tyr+RvV+gtXs1zEUhUuyT3dihg+2XLOG6VF6cSAjTyYrCTdAnbo3UNnlrzf UCvFeZag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQTX-0006C4-HP; Thu, 29 Nov 2018 17:51:43 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPi-0001HU-6p for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:57 +0000 Received: by mail-lj1-x241.google.com with SMTP id t9-v6so2522748ljh.6 for ; Thu, 29 Nov 2018 09:47:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RtdXqoS3gVAQPCLor+MB+aJuhRHlqOlmuJfNLhUnBd0=; b=HC6R7vkBxIVeReHiAW/l7VN+GiG5KttIpTe0k0AqV1hXefU42ypirVgAKNl6NVij5H txPNau3G5O/NCT/MuPS2rUKWtErXXmXXxcxlO5t0f/UEPJlhLfvbS7G+VZYr4xUJL7tJ ay4ymuPR6i7iB28pio0Hym1SmYgxxpasGofW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RtdXqoS3gVAQPCLor+MB+aJuhRHlqOlmuJfNLhUnBd0=; b=WnIzoD9b58iO7UlM3RolzRZvAXgm2mwFzLcgYhU3a46bB+FLt1t6d/NAEnRRjri4Kn gZA0fhVWMG3ecKy+ZoWrlPxUHEq42//atrhXirCuM9w4R7r05tcN757Hbk8HtJHlY0l1 t05VzI73E9/jeUpbcnQ3sbiIhqhoh6ohUmCqWpRC8wNX7eAh3EfuSYKJJI9HRK9En+m5 El9laeoClfdesYZvnZ5kgaPTzNqulcTzAGiTgWRW11F0xoXnW2Rhpj2LIqdE3yuSio6g Mq38SAcjwxfFNDFR/1fi+H1VlCRsIzZe5A2htjhOW0HYwF1ZCGDsmf9bqHMwsc2G350O rC/A== X-Gm-Message-State: AA+aEWZKzkURrorR4ZJGnRylJOs8nbELWORmlA+asITAPRdJ4bm2X8SH KHGoB/eoHo8rteIzbh0Pcq3M0w== X-Google-Smtp-Source: AFSGD/UoOMLd8KL9ke7+41ey3VhAhq3w0txzumISXYpr0GGW8iXSuRUe08J7o+7bUUEIF8A7rc1LPA== X-Received: by 2002:a2e:1241:: with SMTP id t62-v6mr1548248lje.171.1543513654558; Thu, 29 Nov 2018 09:47:34 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:33 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 15/27] drivers: firmware: psci: Announce support for OS initiated suspend mode Date: Thu, 29 Nov 2018 18:46:48 +0100 Message-Id: <20181129174700.16585-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094747_007206_DC4CD37F X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP PSCI firmware v1.0+, supports two different modes for CPU_SUSPEND. The Platform Coordinated mode, which is the default and mandatory mode, while support for the OS initiated mode is optional. This change introduces initial support for the OS initiated mode, in way that it adds the related PSCI bits from the spec and prints a message in the log to inform whether the mode is supported by the PSCI FW. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Daniel Lezcano --- Changes in v10: - None. --- drivers/firmware/psci/psci.c | 21 ++++++++++++++++++++- include/uapi/linux/psci.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 6bfa47cbd174..4f0cbc95e41b 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -95,6 +95,11 @@ static inline bool psci_has_ext_power_state(void) PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } +static inline bool psci_has_osi_support(void) +{ + return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; +} + static inline bool psci_power_state_loses_context(u32 state) { const u32 mask = psci_has_ext_power_state() ? @@ -659,10 +664,24 @@ static int __init psci_0_1_init(struct device_node *np) return 0; } +static int __init psci_1_0_init(struct device_node *np) +{ + int err; + + err = psci_0_2_init(np); + if (err) + return err; + + if (psci_has_osi_support()) + pr_info("OSI mode supported.\n"); + + return 0; +} + static const struct of_device_id psci_of_match[] __initconst = { { .compatible = "arm,psci", .data = psci_0_1_init}, { .compatible = "arm,psci-0.2", .data = psci_0_2_init}, - { .compatible = "arm,psci-1.0", .data = psci_0_2_init}, + { .compatible = "arm,psci-1.0", .data = psci_1_0_init}, {}, }; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index b3bcabe380da..581f72085c33 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -49,6 +49,7 @@ #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) +#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) @@ -97,6 +98,10 @@ #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) +#define PSCI_1_0_OS_INITIATED BIT(0) +#define PSCI_1_0_SUSPEND_MODE_PC 0 +#define PSCI_1_0_SUSPEND_MODE_OSI 1 + /* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0 #define PSCI_RET_NOT_SUPPORTED -1 From patchwork Thu Nov 29 17:46:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 789881057 for ; Thu, 29 Nov 2018 17:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 662B52F4E1 for ; Thu, 29 Nov 2018 17:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A8942F4FE; Thu, 29 Nov 2018 17:51:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F19B92F4E1 for ; Thu, 29 Nov 2018 17:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rZ4da0qqmTB4ErU9A8NrrogU18URfNiVKhc+Zkp6BXY=; b=BouVSnDceljltuxu8J1YvaRF0J M5e9egsxeOu7tU0IpsEnVn1PGwgQbl27b8O+BbvJKqAGdtbnXZh6J6KIWHYxD8HJ4epfxx41XmoiJ OwJJvR0f7i1kGBnWnFYrAYdnpzax83wy9FPjacRAmLakmzP8Di83BsMlJKHULEilOn4j02rfHbruw x+CngLtQCUZ6klk69uSEPpy7osFTwaalO5+PA+juK9+iJv5rH0+St7EMDPL/XgO9bD3tOK9ObxASx NbFVMhF4ISQKxrIGi7lKxUUq/nJGhbPA695NALvP959haavrxzB9LBCJoQGgyzTIVQPNokNZW7uig YVjda8kg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQTK-0005zp-3B; Thu, 29 Nov 2018 17:51:30 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPi-0001Ja-6x for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:58 +0000 Received: by mail-lj1-x241.google.com with SMTP id k19-v6so2511696lji.11 for ; Thu, 29 Nov 2018 09:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PgU1c1CxxtqSBW5JefCvIK+xCW7iLG8npYRcb1HuKE4=; b=B/5EWbX/4pIf3Oc3G2zdHEoTEbgIGKaLe3sWcikr1JnH0hv2gk3BnxwQr4TUdob0pS GBHcOVwcErj08YkbJF+3nI8Qeiz3paCDoblCXvk3zQCosYDQzVJJ3Zu2ag+TMhbtAuwy JVyxj/mbnkShjM0JtEpEnU0awLd8+vHoqWDi4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PgU1c1CxxtqSBW5JefCvIK+xCW7iLG8npYRcb1HuKE4=; b=bbeb+68DxXFWfhu7vLyyg88UYjZ2IJUyo6b7oKZf/TiPPXtTBk6rHbCve1n/QgTmam 2aunnjHeQLhv/3Vffi313qaY3k0Ds3PjL5XixaS+8/X0xPpMpAZhyU4BTVj3bz+/1ra0 tqTE1a5gXjhy7IbUbxhHhSLXZ6xWRq1OWWVqMTVINoll1KbtB7ETev9AE+WHrTrcnrBJ rwYGrffnWRH5NpUcOMufELElhE4l77UKW//3olGiACJzaNTweBR9YU08mAr2k0QtMqzG /CdTTowcMArCdPc5wgWMvqlfLm4gOySaIdfszpLG6Af0IeCA/VM8+FOU8VIiomGb2Zmj fNKQ== X-Gm-Message-State: AA+aEWZ7ZIocEh2jupYQqXnCkETXQSzYfGCJ9VepuasfBT62BzQWmam/ SKIiDPzwoRzfpfJjjnkfMKcHlw== X-Google-Smtp-Source: AFSGD/WczsUHri23WmBiaft8WE6DWc6NG5zksmRIXHH/fM1XFB8rrAvVA/6TldZECosGbxyL5A6+UQ== X-Received: by 2002:a2e:85d3:: with SMTP id h19-v6mr1678736ljj.82.1543513656433; Thu, 29 Nov 2018 09:47:36 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:35 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 16/27] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Thu, 29 Nov 2018 18:46:49 +0100 Message-Id: <20181129174700.16585-17-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094747_107366_F2AA72FB X-CRM114-Status: GOOD ( 17.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To enable the OS initiated mode, the CPU topology needs to be described using the hierarchical model in DT. When used, the idle state bits for the CPU are created by ORing the bits for PM domain's idle state. Let's prepare the PSCI driver to deal with this, via introducing a per CPU variable called domain_state and by adding internal helpers to read/write the value of the variable. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Use __this_cpu_read|write() rather than this_cpu_read|write(). --- drivers/firmware/psci/psci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 4f0cbc95e41b..8dbcdecc2ae4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -87,8 +87,19 @@ static u32 psci_function_id[PSCI_FN_MAX]; (PSCI_1_0_EXT_POWER_STATE_ID_MASK | \ PSCI_1_0_EXT_POWER_STATE_TYPE_MASK) +static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; +static inline u32 psci_get_domain_state(void) +{ + return __this_cpu_read(domain_state); +} + +static inline void psci_set_domain_state(u32 state) +{ + __this_cpu_write(domain_state, state); +} + static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -187,6 +198,8 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) fn = psci_function_id[PSCI_FN_CPU_ON]; err = invoke_psci_fn(fn, cpuid, entry_point, 0); + /* Clear the domain state to start fresh. */ + psci_set_domain_state(0); return psci_to_linux_errno(err); } @@ -409,15 +422,17 @@ int psci_cpu_init_idle(struct cpuidle_driver *drv, unsigned int cpu) static int psci_suspend_finisher(unsigned long index) { u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); - return psci_ops.cpu_suspend(state[index - 1], - __pa_symbol(cpu_resume)); + return psci_ops.cpu_suspend(composite_state, __pa_symbol(cpu_resume)); } int psci_cpu_suspend_enter(unsigned long index) { int ret; u32 *state = __this_cpu_read(psci_power_state); + u32 composite_state = state[index - 1] | psci_get_domain_state(); + /* * idle state index 0 corresponds to wfi, should never be called * from the cpu_suspend operations @@ -425,11 +440,14 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; - if (!psci_power_state_loses_context(state[index - 1])) - ret = psci_ops.cpu_suspend(state[index - 1], 0); + if (!psci_power_state_loses_context(composite_state)) + ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + /* Clear the domain state to start fresh when back from idle. */ + psci_set_domain_state(0); + return ret; } From patchwork Thu Nov 29 17:46:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E016717F0 for ; Thu, 29 Nov 2018 17:52:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDF602F4F6 for ; Thu, 29 Nov 2018 17:52:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C10692F4DE; Thu, 29 Nov 2018 17:52:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 37FD92F4DE for ; Thu, 29 Nov 2018 17:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=25tIrzHA+tQmWgns7HafSRrNGz15RJKpLJvmtj2rZAw=; b=hOZJ062IbsMkFpA39pr1XalGb2 13LpWpQoSaTu5wrb/atPFZTDZk9WsE3OADEVI3msqj7kYHNlvbw8hnn5zFgQK+ellSCkAZHQmx1Dk NeVRAtKUCJ6NE0vEtJPitqsUk1NmSYDl3M9+9RafCvBz42IiPYhTBOd4Ge4qHNSDR96gaDFi/o0PC EUWnXhICqPhx3KYaUkkgt2rozk+OlaSNIy96fGC/mh5EWkaAuHn8U22WkI5siwSW2HRtR+Cuv7YhU 1R7z4jkEMn7UsXhnC7IgEIAICzx9pZyCD9aRHKcCa2DVhdAjIuRuKdUq94Hlc9FZ50cmfyvxc+WCA 6YpvgdJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQTn-0006Vm-1W; Thu, 29 Nov 2018 17:51:59 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPm-0001Ls-09 for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:02 +0000 Received: by mail-lf1-x143.google.com with SMTP id c16so2097325lfj.8 for ; Thu, 29 Nov 2018 09:47:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0f5FNvFNr+ywaXHgyrdJbA+WYJaJrfnYBdOhsBxudf4=; b=XmLH+XoAJtA/XlML6wE1maPOYx/UgMy3QdCOO/C9Bbgo4OSb13ZU3C9qDH+QoTZRxf Rke2l20UnNvvrcOTsXud9ZDQpFCo249MLeMQtK5qGGiMWjG0Ge1brJ8dElp8nTQNPGnp p/t3f3qeclrknlZT72MhdAwxwbHzyXVyPCRQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0f5FNvFNr+ywaXHgyrdJbA+WYJaJrfnYBdOhsBxudf4=; b=SIHOhVfkQGRT5Q4nFSE7IZOfQ+ayqLVYQ4dpPnOUpFcf3O/3BLfCt/sETV+/VGKq2N oqP3LJS9W3vKNfx55Wz90MuMYcMTOBxXy8bRQf0t9Gc+3MsFsGQaM3fl1p8zdzwR8viO VyCWttTXcESAN68g3Mz+I2lHAL0+YfmIpy913FnHInWNSQA5Y9WsqA/SmCgM5/QU+JVD 26G7CHosgTZh/XxmBOmX8hmrk8ocGaHZFblOChW+r9MMYdVgbfx4gmmdy+/wWgbZNzSc 4iytSoJeQq3yZQkiSRldJTlkqtXgRW5ZorYON74TRRQ1V5Pnu0Zpp/3tcWdh/Ypfi5rV OqqQ== X-Gm-Message-State: AA+aEWa7t/nwh4oce1eWjDyjWCCtmjq68YWCDQdyMIiVVjnHp2uzyC9s MXOFOmEAPl+GHQdPMcjpuOKBug== X-Google-Smtp-Source: AFSGD/Wc/z4ksBJs3vHmhXh16mPBFgtQnbNX6FwOcO14wj444TX9p972mzxxNkllouBu8ScnYN8TbQ== X-Received: by 2002:a19:8fce:: with SMTP id s75mr1590227lfk.151.1543513658259; Thu, 29 Nov 2018 09:47:38 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:37 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 17/27] drivers: firmware: psci: Prepare to support PM domains Date: Thu, 29 Nov 2018 18:46:50 +0100 Message-Id: <20181129174700.16585-18-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094750_644326_2079CB84 X-CRM114-Status: GOOD ( 19.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Following changes are about to implement support for PM domains to PSCI. Those changes are mainly going to be implemented in a new separate file, hence a couple of the internal PSCI functions needs to be shared to be accessible. So, let's do that via adding new PSCI header file. Moreover, the changes deploying support for PM domains, needs to be able to switch the PSCI FW into the OS initiated mode. For that reason, let's add a new function that deals with this and share it via the new PSCI header file. Signed-off-by: Ulf Hansson --- Changes in v10: - New patch. Re-places the earlier patch: "drivers: firmware: psci: Share a few internal PSCI functions". --- drivers/firmware/psci/psci.c | 28 +++++++++++++++++++++------- drivers/firmware/psci/psci.h | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 drivers/firmware/psci/psci.h diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 8dbcdecc2ae4..623591b541a4 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -34,6 +34,8 @@ #include #include +#include "psci.h" + /* * While a 64-bit OS can make calls with SMC32 calling conventions, for some * calls it is necessary to use SMC64 to pass or return 64-bit values. @@ -90,23 +92,35 @@ static u32 psci_function_id[PSCI_FN_MAX]; static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; -static inline u32 psci_get_domain_state(void) +u32 psci_get_domain_state(void) { return __this_cpu_read(domain_state); } -static inline void psci_set_domain_state(u32 state) +void psci_set_domain_state(u32 state) { __this_cpu_write(domain_state, state); } +bool psci_set_osi_mode(void) +{ + int ret; + + ret = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + if (ret) + pr_warn("failed to enable OSI mode: %d\n", ret); + + return !ret; +} + static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK; } -static inline bool psci_has_osi_support(void) +bool psci_has_osi_support(void) { return psci_cpu_suspend_feature & PSCI_1_0_OS_INITIATED; } @@ -285,10 +299,7 @@ static int __init psci_features(u32 psci_func_id) psci_func_id, 0, 0); } -#ifdef CONFIG_CPU_IDLE -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); - -static int psci_dt_parse_state_node(struct device_node *np, u32 *state) +int psci_dt_parse_state_node(struct device_node *np, u32 *state) { int err = of_property_read_u32(np, "arm,psci-suspend-param", state); @@ -305,6 +316,9 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } +#ifdef CONFIG_CPU_IDLE +static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); + static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, int cpu) { diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h new file mode 100644 index 000000000000..7d9d38fd57e1 --- /dev/null +++ b/drivers/firmware/psci/psci.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PSCI_H +#define __PSCI_H + +struct device_node; + +bool psci_set_osi_mode(void); +u32 psci_get_domain_state(void); +void psci_set_domain_state(u32 state); +bool psci_has_osi_support(void); +int psci_dt_parse_state_node(struct device_node *np, u32 *state); + +#endif /* __PSCI_H */ From patchwork Thu Nov 29 17:46:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0F5317F0 for ; Thu, 29 Nov 2018 17:51:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC202F4E1 for ; Thu, 29 Nov 2018 17:51:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C20002F36A; Thu, 29 Nov 2018 17:51:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04E392F4E1 for ; Thu, 29 Nov 2018 17:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3VGheSLqVsOiq+4NM0X/B4jlvSA7mOhKE5e5ss73K+I=; b=mRF/hE0xNgJVK0V8yBPHoD2QNU /35B6xBzLKr31BXDKo4VYD8ZkObalhHnr4SSfLP0g0gLLWWxToLZY2gDrhUAfKeYOL8XqDLiKMF1e zf6ZCsCqP9e9VOQIXRJTX7ilvY2o3Mw78nvqGF/65BPKyEm3jX83Lq9xdupLUeN/nONigznd/p91+ MDzoCQV3x3jcUQ8v2m7LCd++I+3U8NFNjALMVZ/yA1A13FxhuhpsTkcI28rk1B/774WqVKr1P4FfI QLWDU+2QYyaIe5hc/BZOp/GTXGRiDEG20voFmMpMCAUGzphUQSXqdwRyoSMX05BmCNzMQtWB+WThw G6KMoMNA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQT0-0005iZ-4D; Thu, 29 Nov 2018 17:51:10 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPh-0001O9-Hl for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:54 +0000 Received: by mail-lj1-x243.google.com with SMTP id v1-v6so2548915ljd.0 for ; Thu, 29 Nov 2018 09:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e32vtX78zxUwZdARdRnc8l3DtzZQ8eqcggPXtqP0zBQ=; b=KEysZzFGJmbrVuXD6nyO5z9OhL9wjdJKpDDxNsGW3Xgb9aX/264Uhdj0nKKs97L4ox anBSD7NPURP8VxEu6uWdPd2fm6kavvkoA1uBrrGUDbRl4rI13BDoJqG6CbcElhabT+FI xOigQqnmHK5Shk2fhopOfyi7YxBVDwo69yhhI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e32vtX78zxUwZdARdRnc8l3DtzZQ8eqcggPXtqP0zBQ=; b=d+0g4q6m5lw0qIwjSeVLuuLebJB8qpt9IFqaNFKz1vTcGb+HdJEDNYkqlSYxxU3Hwt YS2YyQITO84GQC4gVaxBa6BjeePxM1qLBO2FSVzciMy5VTrac0sdX5ogE5RL330ZYTXp DE2PLmAPiWEqEJifnYz9sfFHOgAir6pZd8rAZYbEaYsjtonvQEj8+Q3UeSO1gUQ4ZJEK AwYGSNSra5rBBTodRxyfvDFunx1pqEM2jhT4R+HQ6VZ2GeUmrs2yctHkZTt85z4MD7lQ bfLjmti7ITGz3T718bM4uy32DXvAaTfkXv2N7ffrz3sLiCpfNoqZnUSMKsv26UjYfIM4 5iGA== X-Gm-Message-State: AA+aEWbxUKHWUwlkt/rugbf4D71rUjJut7PR8YSYqUpd2Dm4jpqNRh+I upDwXFNuSdPUevuGbMpuFErWuA== X-Google-Smtp-Source: AFSGD/XAh5uAfM3h1tYCGpFtPOIr3uABpAC4dKUb+fC3N4O4NUkkG8U5ov3ggi0lwmKgkwM1KtFTYQ== X-Received: by 2002:a2e:9f56:: with SMTP id v22-v6mr1708430ljk.114.1543513660054; Thu, 29 Nov 2018 09:47:40 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:39 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 18/27] drivers: firmware: psci: Add support for PM domains using genpd Date: Thu, 29 Nov 2018 18:46:51 +0100 Message-Id: <20181129174700.16585-19-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094746_540917_9B94EF20 X-CRM114-Status: GOOD ( 30.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the hierarchical CPU topology layout is used in DT, we need to setup the corresponding PM domain data structures, as to allow a CPU and a group of CPUs to be power managed accordingly. Let's enable this by deploying support through the genpd interface. Additionally, when the OS initiated mode is supported by the PSCI FW, let's also parse the domain idle states DT bindings as to make genpd responsible for the state selection, when the states are compatible with "domain-idle-state". Otherwise, when only Platform Coordinated mode is supported, we rely solely on the state selection to be managed through the regular cpuidle framework. If the initialization of the PM domain data structures succeeds and the OS initiated mode is supported, we try to switch to it. In case it fails, let's fall back into a degraded mode, rather than bailing out and returning an error code. Due to that the OS initiated mode may become enabled, we need to adjust to maintain backwards compatibility for a kernel started through a kexec call. Do this by explicitly switch to Platform Coordinated mode during boot. To try to initiate the PM domain data structures, the PSCI driver shall call the new function, psci_dt_init_pm_domains(). However, this is done from following changes. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in V10: - Enable the PM domains to be used for both PC and OSI mode. - Fixup error paths. - Move the management of kexec started kernels into this patch. - Rewrite changelog. --- drivers/firmware/psci/Makefile | 2 +- drivers/firmware/psci/psci.c | 7 +- drivers/firmware/psci/psci.h | 6 + drivers/firmware/psci/psci_pm_domain.c | 262 +++++++++++++++++++++++++ 4 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/psci/psci_pm_domain.c diff --git a/drivers/firmware/psci/Makefile b/drivers/firmware/psci/Makefile index 1956b882470f..ff300f1fec86 100644 --- a/drivers/firmware/psci/Makefile +++ b/drivers/firmware/psci/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 # -obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_FW) += psci.o psci_pm_domain.o obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 623591b541a4..19af2093151b 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -704,9 +704,14 @@ static int __init psci_1_0_init(struct device_node *np) if (err) return err; - if (psci_has_osi_support()) + if (psci_has_osi_support()) { pr_info("OSI mode supported.\n"); + /* Make sure we default to PC mode. */ + invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_PC, 0, 0); + } + return 0; } diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index 7d9d38fd57e1..8cf6d7206fab 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -11,4 +11,10 @@ void psci_set_domain_state(u32 state); bool psci_has_osi_support(void); int psci_dt_parse_state_node(struct device_node *np, u32 *state); +#ifdef CONFIG_CPU_IDLE +int psci_dt_init_pm_domains(struct device_node *np); +#else +static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } +#endif + #endif /* __PSCI_H */ diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c new file mode 100644 index 000000000000..d0dc38e96f85 --- /dev/null +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -0,0 +1,262 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PM domains for CPUs via genpd - managed by PSCI. + * + * Copyright (C) 2018 Linaro Ltd. + * Author: Ulf Hansson + * + */ + +#define pr_fmt(fmt) "psci: " fmt + +#include +#include +#include +#include +#include + +#include "psci.h" + +#ifdef CONFIG_CPU_IDLE + +struct psci_pd_provider { + struct list_head link; + struct device_node *node; +}; + +static LIST_HEAD(psci_pd_providers); +static bool osi_mode_enabled; + +static int psci_pd_power_off(struct generic_pm_domain *pd) +{ + struct genpd_power_state *state = &pd->states[pd->state_idx]; + u32 *pd_state; + u32 composite_pd_state; + + /* If we have failed to enable OSI mode, then abort power off. */ + if (psci_has_osi_support() && !osi_mode_enabled) + return -EBUSY; + + if (!state->data) + return 0; + + /* When OSI mode is enabled, set the corresponding domain state. */ + pd_state = state->data; + composite_pd_state = *pd_state | psci_get_domain_state(); + psci_set_domain_state(composite_pd_state); + + return 0; +} + +static int psci_pd_parse_state_nodes(struct genpd_power_state *states, + int state_count) +{ + int i, ret; + u32 psci_state, *psci_state_buf; + + for (i = 0; i < state_count; i++) { + ret = psci_dt_parse_state_node(to_of_node(states[i].fwnode), + &psci_state); + if (ret) + goto free_state; + + psci_state_buf = kmalloc(sizeof(u32), GFP_KERNEL); + if (!psci_state_buf) { + ret = -ENOMEM; + goto free_state; + } + *psci_state_buf = psci_state; + states[i].data = psci_state_buf; + } + + return 0; + +free_state: + while (i >= 0) { + kfree(states[i].data); + i--; + } + return ret; +} + +static int psci_pd_parse_states(struct device_node *np, + struct genpd_power_state **states, int *state_count) +{ + int ret; + + /* Parse the domain idle states. */ + ret = of_genpd_parse_idle_states(np, states, state_count); + if (ret) + return ret; + + /* Fill out the PSCI specifics for each found state. */ + ret = psci_pd_parse_state_nodes(*states, *state_count); + if (ret) + kfree(*states); + + return ret; +} + +static int psci_pd_init(struct device_node *np) +{ + struct generic_pm_domain *pd; + struct psci_pd_provider *pd_provider; + struct dev_power_governor *pd_gov; + struct genpd_power_state *states = NULL; + int i, ret = -ENOMEM, state_count = 0; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + goto out; + + pd_provider = kzalloc(sizeof(*pd_provider), GFP_KERNEL); + if (!pd_provider) + goto free_pd; + + pd->name = kasprintf(GFP_KERNEL, "%pOF", np); + if (!pd->name) + goto free_pd_prov; + + /* + * For OSI mode, parse the domain idle states and let genpd manage the + * state selection for those being compatible with "domain-idle-state". + */ + if (psci_has_osi_support()) { + ret = psci_pd_parse_states(np, &states, &state_count); + if (ret) + goto free_name; + } + + pd->name = kbasename(pd->name); + pd->power_off = psci_pd_power_off; + pd->states = states; + pd->state_count = state_count; + pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; + + /* Use governor for CPU PM domains if it has some states to manage. */ + pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; + + ret = pm_genpd_init(pd, pd_gov, false); + if (ret) + goto free_state; + + ret = of_genpd_add_provider_simple(np, pd); + if (ret) + goto remove_pd; + + pd_provider->node = of_node_get(np); + list_add(&pd_provider->link, &psci_pd_providers); + + pr_debug("init PM domain %s\n", pd->name); + return 0; + +remove_pd: + pm_genpd_remove(pd); +free_state: + for (i = 0; i < state_count; i++) + kfree(states[i].data); + kfree(states); +free_name: + kfree(pd->name); +free_pd_prov: + kfree(pd_provider); +free_pd: + kfree(pd); +out: + pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); + return ret; +} + +static void psci_pd_remove(void) +{ + struct psci_pd_provider *pd_provider, *it; + struct generic_pm_domain *genpd; + int i; + + list_for_each_entry_safe(pd_provider, it, &psci_pd_providers, link) { + of_genpd_del_provider(pd_provider->node); + + genpd = of_genpd_remove_last(pd_provider->node); + if (!IS_ERR(genpd)) { + for (i = 0; i < genpd->state_count; i++) + kfree(genpd->states[i].data); + kfree(genpd->states); + kfree(genpd); + } + + of_node_put(pd_provider->node); + list_del(&pd_provider->link); + kfree(pd_provider); + } +} + +static int psci_pd_init_topology(struct device_node *np) +{ + struct device_node *node; + struct of_phandle_args child, parent; + int ret; + + for_each_child_of_node(np, node) { + if (of_parse_phandle_with_args(node, "power-domains", + "#power-domain-cells", 0, &parent)) + continue; + + child.np = node; + child.args_count = 0; + + ret = of_genpd_add_subdomain(&parent, &child); + of_node_put(parent.np); + if (ret) { + of_node_put(node); + return ret; + } + } + + return 0; +} + +int psci_dt_init_pm_domains(struct device_node *np) +{ + struct device_node *node; + int ret, pd_count = 0; + + /* + * Parse child nodes for the "#power-domain-cells" property and + * initialize a genpd/genpd-of-provider pair when it's found. + */ + for_each_child_of_node(np, node) { + if (!of_find_property(node, "#power-domain-cells", NULL)) + continue; + + ret = psci_pd_init(node); + if (ret) + goto put_node; + + pd_count++; + } + + /* Bail out if not using the hierarchical CPU topology. */ + if (!pd_count) + return 0; + + /* Link genpd masters/subdomains to model the CPU topology. */ + ret = psci_pd_init_topology(np); + if (ret) + goto remove_pd; + + /* Try to enable OSI mode if supported. */ + if (psci_has_osi_support()) + osi_mode_enabled = psci_set_osi_mode(); + + pr_info("Initialized CPU PM domain topology\n"); + return pd_count; + +put_node: + of_node_put(node); +remove_pd: + if (pd_count) + psci_pd_remove(); + pr_err("failed to create CPU PM domains ret=%d\n", ret); + return ret; +} +#endif From patchwork Thu Nov 29 17:46:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47E371057 for ; Thu, 29 Nov 2018 17:52:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 361802F48E for ; Thu, 29 Nov 2018 17:52:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 296562F4F6; Thu, 29 Nov 2018 17:52:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A433F2F48E for ; Thu, 29 Nov 2018 17:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oKWxQCvREzPAoSqdeHUdXTtnXXO9jK5jdkl2/x1h0IU=; b=bRpjLOysxgPXmyvqvbURIQ+wRw wfGrUczpItOdRaKNwAeRDigamuCutLjoGiw0X/7LMJJ+haQ6cZK+GP69YyLxiMqN36vWIgsSHfdza bnPDYmCCXJLiHJEu+sXySD2pUo4h6jOWSakwsoxcLkQfy8nu+HnAwh0Qe3j0SVM0PUJyyzgEgHqMM VuiVej33AXDq9GgWCuEZM2Y/IIIQqq6UsgdXwfMR+XpowT0T8/9F/NKJdeclKUlIFpnsEl6Y5TyxY XX+aMq7VXgI8p7YCqqI1r7iGriSjU9BVP35T4dqP7qSAzDleq/0/CjO5aldBsmLS8EQaTR7BPeMqc VIn8qoLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQU1-0006kr-D8; Thu, 29 Nov 2018 17:52:13 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPp-0001Q4-Hf for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:06 +0000 Received: by mail-lj1-x244.google.com with SMTP id l15-v6so2520824lja.9 for ; Thu, 29 Nov 2018 09:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IgJavhFwHTt+c7Cc5oNvleI06smw6L91MXyG+WFxJOs=; b=CSiWZltnAlLzdpYUc1gNl1J+emspCgZO2e02blv0N8vsACNO2aEjoWM/zxVWgKFOrE 6vx2z6Ui/2c0Fuv5GGiX9/da15QuPJJAGfEcryeMjyxdE/mm8/xzUH6OjBPA8HcihktD Gm0ST9kFrA/gO8Sxpq05sccvaHDJ4FMgzyxFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IgJavhFwHTt+c7Cc5oNvleI06smw6L91MXyG+WFxJOs=; b=p0onn+XuXmD4YeUWF0jlskLQkxu1xsSZ3sKRI/X6kiVQR9zMZMLvMxe+/o7N7HLXV4 y9ugxnmBCIYxyMnO1gFn7NzjgKktVEi0JWkdmCW9jNsamvUyKErToVlCUTl+wRre1uOs JUYf75NzpwDAIB3Cqg5lgFwpRRL/dy5t3U0Jzq6JFgFb3TialKW9G0W8k6vaooMn2Z71 FtKy2PTQd6P6QWmpteJu91n+pVODvLrMQfAkYH2D4fGVdEvWH/4cf+4MzcM8UhkPfMr5 3vxchfWvCNLDl0AdWpFrKWlMTVgiJGDksSWde4ZCleaWUOB5tJfpTLGguuMlRQ3QvdUH odqQ== X-Gm-Message-State: AA+aEWbdiJXw34bx0nJQKya8VhgNVDveyW/uzIGWMM6JYCH5fLuyFlUB Hdmb0lUo9hlQmy9rmxBBXPFkYw== X-Google-Smtp-Source: AFSGD/UfIe05lJVzFSG/PvTzE4YY5lDne785Bt93puLTSNvnIF11d0n/xy28bKWTKOUrcHm1iyKeHg== X-Received: by 2002:a2e:9b15:: with SMTP id u21-v6mr1683452lji.29.1543513661629; Thu, 29 Nov 2018 09:47:41 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:41 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 19/27] drivers: firmware: psci: Add hierarchical domain idle states converter Date: Thu, 29 Nov 2018 18:46:52 +0100 Message-Id: <20181129174700.16585-20-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094754_050216_C6ED2961 X-CRM114-Status: GOOD ( 19.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the hierarchical CPU topology is used, but the OS initiated mode isn't supported, we rely solely on the regular cpuidle framework to manage the idle state selection. For this reason, introduce a new PSCI DT helper function, psci_dt_pm_domains_parse_states(), which converts the hierarchically described domain idle states, into regular flattened cpuidle states. During the conversion, let's also insert the converted states into the cpuidle driver's array of idle states, as to enables the cpuidle framework to manage them. Signed-off-by: Ulf Hansson --- Changes in v10: - New patch. --- drivers/firmware/psci/psci.h | 2 + drivers/firmware/psci/psci_pm_domain.c | 108 +++++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index 8cf6d7206fab..05af462cc96e 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -13,6 +13,8 @@ int psci_dt_parse_state_node(struct device_node *np, u32 *state); #ifdef CONFIG_CPU_IDLE int psci_dt_init_pm_domains(struct device_node *np); +int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index d0dc38e96f85..6c9d6a644c7f 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -14,6 +14,10 @@ #include #include #include +#include +#include + +#include #include "psci.h" @@ -97,6 +101,53 @@ static int psci_pd_parse_states(struct device_node *np, return ret; } +static int psci_pd_enter_pc(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx); +} + +static void psci_pd_enter_s2idle_pc(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + psci_pd_enter_pc(dev, drv, idx); +} + +static void psci_pd_convert_states(struct cpuidle_state *idle_state, + u32 *psci_state, struct genpd_power_state *state) +{ + u32 *state_data = state->data; + u64 target_residency_us = state->residency_ns; + u64 exit_latency_us = state->power_on_latency_ns + + state->power_off_latency_ns; + + *psci_state = *state_data; + do_div(target_residency_us, 1000); + idle_state->target_residency = target_residency_us; + do_div(exit_latency_us, 1000); + idle_state->exit_latency = exit_latency_us; + idle_state->enter = &psci_pd_enter_pc; + idle_state->enter_s2idle = &psci_pd_enter_s2idle_pc; + idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP; + + strncpy(idle_state->name, to_of_node(state->fwnode)->name, + CPUIDLE_NAME_LEN - 1); + strncpy(idle_state->desc, to_of_node(state->fwnode)->name, + CPUIDLE_NAME_LEN - 1); +} + +static bool psci_pd_is_provider(struct device_node *np) +{ + struct psci_pd_provider *pd_prov, *it; + + list_for_each_entry_safe(pd_prov, it, &psci_pd_providers, link) { + if (pd_prov->node == np) + return true; + } + + return false; +} + static int psci_pd_init(struct device_node *np) { struct generic_pm_domain *pd; @@ -259,4 +310,61 @@ int psci_dt_init_pm_domains(struct device_node *np) pr_err("failed to create CPU PM domains ret=%d\n", ret); return ret; } + +int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, + struct device_node *cpu_node, u32 *psci_states) +{ + struct genpd_power_state *pd_states; + struct of_phandle_args args; + int ret, pd_state_count, i, idx, psci_idx = drv->state_count - 2; + struct device_node *np = of_node_get(cpu_node); + + /* Walk the CPU topology to find compatible domain idle states. */ + while (np) { + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", 0, &args); + of_node_put(np); + if (ret) + return 0; + + np = args.np; + + /* Verify that the node represents a psci pd provider. */ + if (!psci_pd_is_provider(np)) { + of_node_put(np); + return 0; + } + + /* Parse for compatible domain idle states. */ + ret = psci_pd_parse_states(np, &pd_states, &pd_state_count); + if (ret) { + of_node_put(np); + return ret; + } + + i = 0; + idx = drv->state_count; + while (i < pd_state_count && idx < CPUIDLE_STATE_MAX) { + psci_pd_convert_states(&drv->states[idx + i], + &psci_states[idx - 1 + i], &pd_states[i]); + + /* + * In the hierarchical CPU topology the master PM domain + * idle state's DT property, "arm,psci-suspend-param", + * don't contain the bits for the idle state of the CPU. + * Take that into account here. + */ + psci_states[idx - 1 + i] |= psci_states[psci_idx]; + pr_debug("psci-power-state %#x index %d\n", + psci_states[idx - 1 + i], idx - 1 + i); + + kfree(pd_states[i].data); + i++; + } + drv->state_count += i; + kfree(pd_states); + } + + return 0; +} #endif From patchwork Thu Nov 29 17:46:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C635517F0 for ; Thu, 29 Nov 2018 18:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4AB22F59E for ; Thu, 29 Nov 2018 18:01:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6D702F5A9; Thu, 29 Nov 2018 18:01:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 345F32F59E for ; Thu, 29 Nov 2018 18:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=03wZpdG8bGQrb1ZPKjSsbdsKMysFk+x9U6rr8FDXUOs=; b=Zy/Yh+ge6FimYwhUhvhOuHs7wU TtVNu3V0MfQbrEysO1FkkGgsnssDu2p1d+eLtHqN/Z52/HrhJOULw4+geLTjyjYjUQkHAOK7DPbCn G1VqiRGfRiQU3sivUwvwr8a3BNVVC915DS7BggkWzoPXhhzo1Yh+nAE6e1z43a6cdxqowS5n/Hfhj I61B8skjhdG0mDdmFpQYx/ps74iNDi2Ix58UT+PvPjAg6+VnZ9JJVbbP02aNYRYiM/WQiHBzdX0J/ 0JmUt8E1gF4ahcryIs7bQUUnwRqBWGFfiBorbXD3KdpVTzbweHV+z0d2ZybsS9VWWC9joaZ7faPMS TyCmBDdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQd1-0006bb-FY; Thu, 29 Nov 2018 18:01:31 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQcc-0005uQ-0S for linux-arm-kernel@bombadil.infradead.org; Thu, 29 Nov 2018 18:01:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j+EEeIQ8OjgKMk3l12109V9jWSNPdJq8ZcmjQ3ZkaQ8=; b=liz5cM5eloAv2fezPHWmYEhR2 CQ+3w0b6fsy/0gQlDcSbDEYa+g41pKBEZGjyV7ZcCCjPTu0qhwU0+OIj0B+gW8Ue70zuc9BzW6R0D 1YtfNthfbJmy5kUC3HJkmDJCsvJQOsrvcvOZy8Jk23nUSbY7v06nYbN6tEbc0abQjRL33jj3gqz71 ajsToByryS976Q6J4bi1x/qZi7D62lhdVipAYZL6DVIMsFsJoRZEokkE4yNS1FUXMnOrB6jH749h6 n01yPh7GwvRAOMSN+K1usNzgEnrotIwq5ql8RP07PIcRoMM6Y5RetUL+KYXCqA0AzVF4r41aUUPbr yj1JGcKRw==; Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPr-00058t-EJ for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:47:57 +0000 Received: by mail-lj1-x242.google.com with SMTP id t9-v6so2523112ljh.6 for ; Thu, 29 Nov 2018 09:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j+EEeIQ8OjgKMk3l12109V9jWSNPdJq8ZcmjQ3ZkaQ8=; b=bvcYZ3GHOuNglPJo4PiEY9K7KfzwSQGeJ4tmewO/g/Yu3xWHquRm0tnoluQCIN8Gnb AjHWuHuSFdoKAwmZlQ+e2qP+HemBxddn0JGzfNKjQDsQr5Ab5t+zKWM5A1nR8dCKa2iZ ssMiBbaqHyQvPJYCg8Ipl6Gluutr4BDnX/nmw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j+EEeIQ8OjgKMk3l12109V9jWSNPdJq8ZcmjQ3ZkaQ8=; b=PQaCsBO+jlcbSjhJDNbAvyIQlCDLg9HEomCtEZOjP4Ec07RwhqhRV/NVsbkkt10g0q Bm6xexvhmCbN4x3mm06ThSvYqUcfzIZ4wN0QlN16gqt5cEkL+ISnxvC0TMAHTJhvcOvw dJLKv1T18L8fclDIjlQAFCaIbLjitUaM/4cl1szv7d1CK6aCa8kc/8+eIe0NTH0MuEw1 ez9qjzKqEt8v5i+DFzn8Py5UaVHVOPJ9OaVGxZ0+cWzPSS4geYZRmmt3cWAygkMgEKxZ 3WE1ECK62OoUT+o0CBXMt+eXGhWvG+cd+1b+EW78b4WjwJj64CO+dJbDManCihHyRrNh PBEA== X-Gm-Message-State: AA+aEWYKuq5xUv4G8LZcI/R2U1wTK1MZLCDOosQ+b+wyJZD2n7QT+KcR KkgZgBuB2ixGWE1CQSurQFvufA== X-Google-Smtp-Source: AFSGD/UGOq9K9BxR66pfI/HJC8oYOClHD0rw9Tx1kGcB89/sYAmm9Q3eO+0KlfFRBTfNVzRUVMCVOA== X-Received: by 2002:a2e:91d1:: with SMTP id u17-v6mr1720629ljg.160.1543513663478; Thu, 29 Nov 2018 09:47:43 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:42 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 20/27] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Thu, 29 Nov 2018 18:46:53 +0100 Message-Id: <20181129174700.16585-21-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_174755_479858_6E5441CF X-CRM114-Status: GOOD ( 19.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To be able to initiate the PM domain data structures, let's export a new init function, psci_dt_topology_init() and make it call psci_dt_init_pm_domains(). Following changes to the ARM64 code, invokes this new init function. At first glance, it may seem like feasible idea to hook into the existing psci_dt_init() function, instead of adding yet another init function for PSCI. However, this doesn't work because psci_dt_init() is called early in the boot sequence, which means allocating dynamic data structures isn't yet possible. Moreover, additional following changes need to understand whether the hierarchical PM domain topology has been successfully initialized, therefore let's store the result from the initialization attempt into an internal PSCI flag. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Simplified patch, by moving PSCI OSI related changes out into other more appropriate patches. - Add a flag to store the result of the PM domain initialization. - Updated and clarified changelog. --- drivers/firmware/psci/psci.c | 18 ++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 19af2093151b..5b481e91ccab 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -91,6 +91,7 @@ static u32 psci_function_id[PSCI_FN_MAX]; static DEFINE_PER_CPU(u32, domain_state); static u32 psci_cpu_suspend_feature; +static bool psci_dt_topology; u32 psci_get_domain_state(void) { @@ -741,6 +742,23 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + psci_dt_topology = ret > 0; + + of_node_put(np); + return ret; +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's diff --git a/include/linux/psci.h b/include/linux/psci.h index 4f29a3bff379..16beccccbbcc 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -55,8 +55,10 @@ extern struct psci_operations psci_ops; #if defined(CONFIG_ARM_PSCI_FW) int __init psci_dt_init(void); +int __init psci_dt_topology_init(void); #else static inline int psci_dt_init(void) { return 0; } +static inline int psci_dt_topology_init(void) { return 0; } #endif #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI) From patchwork Thu Nov 29 17:46:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A52317F0 for ; Thu, 29 Nov 2018 18:31:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CAFD2F675 for ; Thu, 29 Nov 2018 18:31:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FFC42F6C3; Thu, 29 Nov 2018 18:31:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 250E42F675 for ; Thu, 29 Nov 2018 18:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rwrHprbmeB4Fxv9ofLbpFEkqqLJ7O7kMKHSxSW8kZwo=; b=HNBwyIcjrb1daNdpaCxCKiwQ+W 8kYQGv9kv5sGf37BsgHEkN0nI70NKfyQyWR/nxvEB5N7Q71zjF2fDg9cgGzNsghSyC6YNCmCOGfzi jtQNQvKyQgPtP+CLcVfJHvujqBdF1khELWGaTD+VMMnlV3MOG5F2oJ5rRMv4t8/CyA4lFiCFFg2cv m5nNNSaIZ642AtF5JsuH4Kfq6wEVi5s2LVEjGZ2rSAJ1NLGTSG+ebK0/cf401DnqST2MJx1Wkyl7B ZM9Z8R9DCA3ubQvefZfR/MR4N73xk1Blp1KTI2bwmzGTxJTORqd7Sql6fnqj7zD/0KA0KNwMQMEfB 0CEiSZ4A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSR5y-00035k-Sa; Thu, 29 Nov 2018 18:31:26 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSR5w-00035b-Jm for linux-arm-kernel@bombadil.infradead.org; Thu, 29 Nov 2018 18:31:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3t2vyFxKLnIeRsykykXv6/9Q0Qsu6Nz8v2F0owXov5U=; b=qA8u7dp6N6MZZbu1BYOp0ie5F F17OZ6S9O6GqrylAwN07+GuBl9FgwrS3HWO5Nt2/N+RtxMf+oBxs/02ljfqa2+wn6RJnvacpunvPq r+0Oemtp3YgrEHG7PPTNn/fCAG8gpW7aRVoAN7f2cbmjaSlbZ96ranM+7NYrFqjFYjH5DuRxS/FNz YmDlfzBVaDwHyQo8RiZ7Bp6ZBFDIfN4917OpV5IJf1FsMtKzua6sl7uoqCKzy9u9ZQztqnBpavibc rzMkrq5UVTlfyfscIq6mQcoAcSUp2LhAYK8ASzT/XRnli8LWyxXCTjxMxxvDcpvki8HQXC8k1afmw CEXnOy2yA==; Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPu-0003oZ-NV for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:00 +0000 Received: by mail-lj1-x242.google.com with SMTP id c19-v6so2531395lja.5 for ; Thu, 29 Nov 2018 09:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3t2vyFxKLnIeRsykykXv6/9Q0Qsu6Nz8v2F0owXov5U=; b=E6m0EYylUq2Ibxx2zDTr+getdoAXAblt6NGSV5xnZi+anl5A9e/0htj8QZMpMF512l AiV1KScgBl/lv5TQptuE8nTGJrfWqH+rbUj9OP94f7ViYYpIkOCdbPfmx5cVlgvm0xTc KI2xBQgpTUrEt020geOSiKICiHi1PKWxfnZGs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3t2vyFxKLnIeRsykykXv6/9Q0Qsu6Nz8v2F0owXov5U=; b=A8kOqL8wNDywty0kKUrOi4Q/fEbZUEBIxMU5dqZNZoeCIH8YEnRnkRqe+6PeWGjf7N mj+HPL6V4dxE976K+3wJe/FXG6b9m/phIwQ9NcrhzLuDkasA/+g1z7FgvjsbkSpwqbAe pykQf7J4ucal+m2WEtJipRH3aLFHbk93jTa6cZclxg3/m55OEQG+ifVKcKQUIy9Msofr sJZaLi9IRIhiclugnWF1VLX5sO0OjMl8yz8lg3F/N9rHZcJjpAZlhsHJaa0QHtn1Yj+H Jdz+tuOKaGrAwUAT9RwCBDt7ptvtjNgjilZF3DATI088qQlSHTEduhavPQRqZG/xiwr3 gY9g== X-Gm-Message-State: AA+aEWbwtQiZDwBhipC0BK9zkRA1kuqJUfckXWyyBhM5qupMRzf47ozA 9KP5wr5Jtgp0aXJUYBFGQCH+4A== X-Google-Smtp-Source: AFSGD/UWoMttAcw7++cNF/9mzFJwLwWDB8IZ1w4ykCERuAaM1HAR5F/wdmCVK3YlklPIHBfdzF9PKg== X-Received: by 2002:a2e:1551:: with SMTP id 17-v6mr1736107ljv.68.1543513665097; Thu, 29 Nov 2018 09:47:45 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:44 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 21/27] drivers: firmware: psci: Add a helper to attach a CPU to its PM domain Date: Thu, 29 Nov 2018 18:46:54 +0100 Message-Id: <20181129174700.16585-22-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_124758_823214_C3E8A544 X-CRM114-Status: GOOD ( 18.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new PSCI DT helper function, psci_dt_attach_cpu(), which takes a CPU number as an in-parameter and attaches the CPU's struct device to its corresponding PM domain. Additionally, the helper prepares the CPU to be power managed via runtime PM, which is the last step needed to enable the interaction with the PM domain through the runtime PM callbacks. Signed-off-by: Ulf Hansson --- Changes in v10: - New patch: Replaces "PM / Domains: Add helper functions to attach/detach CPUs to/from genpd". --- drivers/firmware/psci/psci.h | 1 + drivers/firmware/psci/psci_pm_domain.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h index 05af462cc96e..fbc9980dee69 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -15,6 +15,7 @@ int psci_dt_parse_state_node(struct device_node *np, u32 *state); int psci_dt_init_pm_domains(struct device_node *np); int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, struct device_node *cpu_node, u32 *psci_states); +int psci_dt_attach_cpu(int cpu); #else static inline int psci_dt_init_pm_domains(struct device_node *np) { return 0; } #endif diff --git a/drivers/firmware/psci/psci_pm_domain.c b/drivers/firmware/psci/psci_pm_domain.c index 6c9d6a644c7f..b0fa7da8a0ce 100644 --- a/drivers/firmware/psci/psci_pm_domain.c +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -367,4 +369,21 @@ int psci_dt_pm_domains_parse_states(struct cpuidle_driver *drv, return 0; } + +int psci_dt_attach_cpu(int cpu) +{ + struct device *dev = get_cpu_device(cpu); + int ret; + + ret = dev_pm_domain_attach(dev, true); + if (ret) + return ret; + + pm_runtime_irq_safe(dev); + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + return 0; +} #endif From patchwork Thu Nov 29 17:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5759917F0 for ; Thu, 29 Nov 2018 17:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45EC22920E for ; Thu, 29 Nov 2018 17:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A70C2F4DE; Thu, 29 Nov 2018 17:52:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF0ED2F4F4 for ; Thu, 29 Nov 2018 17:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GzPVcdt6JaqBaO3tfK1IUrySRyUBCJZxoViKA02wG6E=; b=OZQN5rX64AT4BXvAKv8i3gR5G6 wopES9/Flr02eSsKY0glhzsc2Q3ZpxHR0SMs3VbFDVX1IoFc9JmYL2Vj2A5+ammemQV2HN7JmH04j mBIGukUBlc7GTHnSXheuIw+VEgsYuE+5ojmvY/kxVSx5LpS5gNVoltTGJECyhFnoq0uvURr5WRezL dediwojKCLFW1pvMLnsfMtM0c1rImV/481n1dThz+veU6QevQfknJ6dky3XBt/Q21yMtlDJq2mCKW C1ay5twEPgexYMQHTnOAalvZd078tADLeznDu4Zkm4shxAJBhZsgtghgLL8ZaX43j1tXk20EHjfAq hjs6hcKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQUG-00070M-I0; Thu, 29 Nov 2018 17:52:28 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPv-0001XZ-FV for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:09 +0000 Received: by mail-lj1-x241.google.com with SMTP id v15-v6so2504757ljh.13 for ; Thu, 29 Nov 2018 09:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RFaG8cXFhArmCpS6rP1BJYuJ7tPHpHBulh3EEudBMoM=; b=YsyItLbVHbH3tNLzCiQMEYnmNZdjcvUx83pMpRN5YHP4Kjmhe6ZXEntFzFIP+AgDbr qJwxSlvke/NW59tkmG9joPEpjGPElE19RUBmi1WUnO9dFz/sBAqaNSjy1xznLW4+AKe/ 4lyBldpmHWjI+AbKgVIYPcICKOGDXesumiTy0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RFaG8cXFhArmCpS6rP1BJYuJ7tPHpHBulh3EEudBMoM=; b=knCGoCsK6kfnrJpUlQ0dJn/UhMmOLh41iKznNvU87gNcKRVwNToFOnwDKQCo1NF/kv Q3DkvnLlPKpyzl0Mg66gHob/+z/h89fZopj8kE4ZEm3MBzlQ42JR28kAvY/QZ0949ZUw K1aqL6AR0ukjegNQFiAR9SSWCqGAuuDkG03iaRXtYYAJ6GO4s9QuvjANEpWistCFWmPP PrHdrJiWRYK/dnUel3ux+adkXz7ZNvPsg9/RECHLct1tWUDizVRSjKDrRYlniqern2hG nOQwm2veA9zk2BGXeEH8zy6QQPOWE/X8plRjwLaO7P6mUZ/Z25oMNhu74SHGJTBhOnME ATSg== X-Gm-Message-State: AA+aEWZDdY+s4pti8nl+sCKtyNWIyp9B8LvyVWkrebnbrjuCIVirDViA XZyVxoPkhN6jIp2+lwPu5ql9mA== X-Google-Smtp-Source: AFSGD/WVodyz08Ry3gytrKNYSqfpWR2+qsmxRgCgsjxMAmnxCpSQnymL3the+lKJOkCI1ZjncfMR9g== X-Received: by 2002:a2e:e02:: with SMTP id 2-v6mr1536589ljo.10.1543513666911; Thu, 29 Nov 2018 09:47:46 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:46 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 22/27] drivers: firmware: psci: Attach the CPU's device to its PM domain Date: Thu, 29 Nov 2018 18:46:55 +0100 Message-Id: <20181129174700.16585-23-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094800_139474_1BC66532 X-CRM114-Status: GOOD ( 18.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to allow the CPU to be power managed through a potential PM domain and the corresponding topology, it needs to be attached to it. For that reason, check if the PM domain data structures have been initiated for PSCI and if so, let's try to attach the CPU device to its PM domain. However, before attaching the CPU to its PM domain, we need to check whether the PSCI firmware supports OS initiated mode or not. If that isn't the case, we rely solely on the cpuidle framework to deal with the idle state selection, which means we need to parse DT and convert the hierarchical described domain idle states into regular cpuidle states, hence let's do that. Signed-off-by: Ulf Hansson --- Changes in v10: - Attach CPU devices to their PM domains, regardless of OSI mode or PC mode. - For PC mode, convert domain idle states to generic cpuidle states to let the cpuidle driver manage them. --- drivers/firmware/psci/psci.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 5b481e91ccab..94cd0431b004 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -327,7 +327,7 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, u32 *psci_states; struct device_node *state_node; - psci_states = kcalloc(num_state_nodes, sizeof(*psci_states), + psci_states = kcalloc(CPUIDLE_STATE_MAX, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; @@ -351,6 +351,26 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } + /* + * If the hierarchical CPU topology is used, let's attach the CPU device + * to its corresponding PM domain. If OSI mode isn't supported, pick up + * the additional cpuidle states, from the domain idle states described + * in the hierarchical DT layout, as to enable the cpuidle driver to + * manage them. + */ + if (psci_dt_topology) { + if (!psci_has_osi_support()) { + ret = psci_dt_pm_domains_parse_states(drv, cpu_node, + psci_states); + if (ret) + goto free_mem; + } + + ret = psci_dt_attach_cpu(cpu); + if (ret) + goto free_mem; + } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; From patchwork Thu Nov 29 17:46:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2FA31057 for ; Thu, 29 Nov 2018 17:52:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0F0A2F4C4 for ; Thu, 29 Nov 2018 17:52:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A56142F4F6; Thu, 29 Nov 2018 17:52:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47CD42F4F4 for ; Thu, 29 Nov 2018 17:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GDIdWN7d2GCrNOGneqHLiTB8+jUUZnYr9f9ftWemy2Y=; b=rmnOTWtSYWF/N5nr6lLx41/oEh BnXSK3aM8kW0eQkNUKfS32QiOXGH+IV4+zyKq61EUBz6OpdzgeuSFz9IjzuVzqnnG2qzN8SvivDiB DBxfhmRM5xw+ZKIDP3Ud/8kn/xoJCtgf78uj+Y05NyLkAIY0xnJ0BbCKDWjRwItAW8nFJhoX/imbD R0j0djTRQ7T6MGSGEkBt0onV85KyyaqQTBZ6EDazWNnmAyO4EPku5ewkhKdQHcO6DhwYXp1gKIlN/ WFKP26EKfrqlMiwcP45wa52dMNDNS98dAl+vY1ZKbbe+Fyfnt6y2l7cSJlcbIAT9MWiHdn12217lj Z/dccO5g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQUU-0007FC-NE; Thu, 29 Nov 2018 17:52:42 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPx-0001Yp-1N for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:10 +0000 Received: by mail-lj1-x242.google.com with SMTP id t9-v6so2523372ljh.6 for ; Thu, 29 Nov 2018 09:47:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=00sBAXywF3WZULK8cp3GDi0TaSy7ngQJNGllHojB6lk=; b=dKE3qxiTNFTTGb5T+hiqrOqJFim4aiRChTUuNwS2xw3/dZuh9DAHSNXaDLW74AS3pg lqi8hr2A4WN5tItntkMx4nEIWt69NUtA+5ATJ2GbhiBDjsUni1YWaOPqKXDu+4lgVcZ6 8HF0CsduMwAzz1Xj7pFRsv+e/Vp0FqO7xL5UI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=00sBAXywF3WZULK8cp3GDi0TaSy7ngQJNGllHojB6lk=; b=ViDGsr6Z6t5N3z9y2MQFxS94+dikhFPJ4WLvq0oAcjTP10cgrg1cZewD89JNUi3aET qlf355BNCwi/hRT2fJ8G6J2cOkS0RCtqCrffS4XooVanpWzdjclsqcUk8CwSya7pBIA5 Vs7xc8ohceqp2dPMKq4aJiNpgF81IcewrfqbRQTu3eWHKIdJlhzTkHjA6/CawlLkfIVo ckElOl/OKJqleT1ub7xiJ6DUUUyoXQ1Lt0jba6wobuOnhoacKe5GkODv1JxCc/mWT7IR 9FMB632qbyQqtRuIDKL0z4UcbM8MND6fogMkVY07PYeZipE6fNcghSv6em9uuLBw3kHy yypQ== X-Gm-Message-State: AA+aEWYmyGYMyvGphEJ8Ic1FgP8itUdCdyM4gILDNcRbIuNZCqEqD40u xWmgCnLB7kE2lbW9VXHvyuGh7Q== X-Google-Smtp-Source: AFSGD/XFzpmZt9P+s57VsvnAF06eON+JaheyOilxYXLdRGfV6H6Nt3KWs6+j8OeMMOH0S0u5nu6hVw== X-Received: by 2002:a2e:3509:: with SMTP id z9-v6mr1668038ljz.54.1543513669095; Thu, 29 Nov 2018 09:47:49 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:48 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 23/27] drivers: firmware: psci: Manage runtime PM in the idle path for CPUs Date: Thu, 29 Nov 2018 18:46:56 +0100 Message-Id: <20181129174700.16585-24-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094801_370617_70CB0FA9 X-CRM114-Status: GOOD ( 19.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the hierarchical CPU topology layout is used in DT, let's allow the CPU to be power managed through its PM domain and via runtime PM. In other words, let's deploy runtime PM support to the PSCI driver during idle management of the CPU. Signed-off-by: Ulf Hansson --- Changes in v10: - New patch: Replaces the earlier patch "kernel/cpu_pm: Manage runtime PM in the idle path for CPUs". In the end it seemed like a better idea to start with something specific to PSCI, rather than (ab?)using the generic functions cpu_pm_enter|exit(). - Do runtime PM get/put for the deepest idle state for the CPU. --- drivers/firmware/psci/psci.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 94cd0431b004..b03bccce0a5d 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -319,6 +320,7 @@ int psci_dt_parse_state_node(struct device_node *np, u32 *state) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static DEFINE_PER_CPU_READ_MOSTLY(u32, psci_rpm_state_id); static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, int cpu) @@ -369,6 +371,9 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, ret = psci_dt_attach_cpu(cpu); if (ret) goto free_mem; + + /* Store index of deepest state to later for runtime PM. */ + per_cpu(psci_rpm_state_id, cpu) = drv->state_count - 1; } /* Idle states parsed correctly, initialize per-cpu pointer */ @@ -466,7 +471,9 @@ int psci_cpu_suspend_enter(unsigned long index) { int ret; u32 *state = __this_cpu_read(psci_power_state); - u32 composite_state = state[index - 1] | psci_get_domain_state(); + u32 composite_state, rpm_state_id; + bool runtime_pm = false; + struct device *dev = NULL; /* * idle state index 0 corresponds to wfi, should never be called @@ -475,11 +482,29 @@ int psci_cpu_suspend_enter(unsigned long index) if (WARN_ON_ONCE(!index)) return -EINVAL; + /* + * Do runtime PM if we are using the hierarchical CPU toplogy, but only + * when cpuidle have selected the deepest idle state for the CPU. + */ + if (psci_dt_topology) { + rpm_state_id = __this_cpu_read(psci_rpm_state_id); + runtime_pm = rpm_state_id == index; + if (runtime_pm) { + dev = get_cpu_device(smp_processor_id()); + pm_runtime_put_sync_suspend(dev); + } + } + + composite_state = state[index - 1] | psci_get_domain_state(); + if (!psci_power_state_loses_context(composite_state)) ret = psci_ops.cpu_suspend(composite_state, 0); else ret = cpu_suspend(index, psci_suspend_finisher); + if (runtime_pm) + pm_runtime_get_sync(dev); + /* Clear the domain state to start fresh when back from idle. */ psci_set_domain_state(0); From patchwork Thu Nov 29 17:46:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 717BA13BB for ; Thu, 29 Nov 2018 18:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 602F82F61A for ; Thu, 29 Nov 2018 18:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E6242F611; Thu, 29 Nov 2018 18:01:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 636692F611 for ; Thu, 29 Nov 2018 18:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=d2I/cXoFtaKWfrwbPa5LBApgU87xFURcnLvfL2A0q0I=; b=ALroGfJnOpENKeudabVJ7HOupM NMA6yLZzsEkKC+8x2eMOTuy8qO2RV2+9Xbveed0wW68e1mRwSIVr6UF8i7+ijAWdDBXV/HO+J3QZ4 D5eFQNs6gJDW/1ZiszA+rNzK19Yz7wTx1W5c+AIQL5mhb4sNBMIHAaUuc5y8+lhtXnulA8/WM7TZS 5ERaEq6BeaygzIgeMZZ3X9xCkgPQ7jY0X4eV9SlcImfl4AvbLVuh3Wle6alXUYakoH1O8dFuFvuBe qARumuLiGPbv36OZP0C82fhb7MqtkiMcxN1QNKy2lLmOofVF7i4KzwgVFnf843hPXYo7GKXxbQTD7 VT97xSOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQci-00068o-GU; Thu, 29 Nov 2018 18:01:12 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQcZ-0005tF-Cp for linux-arm-kernel@bombadil.infradead.org; Thu, 29 Nov 2018 18:01:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=MgMAZ/4tvqaJw8e1WJm4aCfDZ tuYrYKEanSROsOQMHT09hVOTCd90M+ryxRSpCVnxI8EQUDFmWs0meYOZtH/ZnnhJzhH0/FRM75paQ z3OaY4Gj7hX/nEO0iu0fkAdUs3UdvOJN2YhniqdsQVKlhbepe0OnBPgyXct+RVf4PzN1nB/ZkcZRE hyKKy3dwqyZdOrxN6Z9ihwcvD4xQZRL01t1MGr/cRKq0xhSB4EecGzg0bKZ2lMMAwYWfEtQpfin7z b4/Cqz8AphetwTXx2eiM7+tDyd0bKHzyaD8iYHZ9ciXOgOi+x0DAH8UCXuLBI6Ti/vprGNBy1DvUA aub050IiQ==; Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPz-0005A0-Kc for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:07 +0000 Received: by mail-lf1-x144.google.com with SMTP id a16so2111504lfg.3 for ; Thu, 29 Nov 2018 09:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=UPPBOHaniBcnAzLge02a1Ved7MDAgwg3PT63fbQBxmWP6r7IUNmB9wBF+cpdUregbU YNpOhRm0kjRcXF6xnbJ01Ca2Erys97CKhH7FfDfbIj5YdHlt1zhk9sD+G18xFUEPnTeG o/6qnFNHOkaoXtqDBngZxRNXPyWTOoR/EGa+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=pn8YFPB/4WXrCerxrqMZJYoYX6LFz5cPUCyEW3wQoqvoNWE/+GHhJimgUB0ssvi4Ci V3hMa+azt7Id/anoDgZ5H9KoQU+BV15ELlW66yDoO1LyrQuvlfN+uxgpS4FcovxGuNNn kbbVWylphf/KFTdyS3Iw39ZTvW6u+OMlGA5ZbVKz0O5vdCmuyXVd9UaaMKc8NnTnRaDZ /ZI1TJHS+NMUknCSENAzmNaugqzufzt7hynjebMAydp5vYY5EA7K67BLw+Gt6ly+HQXF dJUFK+QsNQdZcXzIrGhJ15/Z0HPHdvgh1vHq4S5fD9c3y5Jo/XnGtjfJll5EzT7UJLUt LxAA== X-Gm-Message-State: AA+aEWZSvWrs2esA3bieAC8SEjZY58tPA57yDnX/4ZGHgbXSnjrh94yM vU2OGqZNItRW1WHDsfeZFqrBEA== X-Google-Smtp-Source: AFSGD/Vv4orDwR+nTAJgZv7KcoNBHuFUfJ1RXoB3WL0hhWGM6CeGAm1v2qYblWtvCG+N9/GJet3jBw== X-Received: by 2002:a19:2d16:: with SMTP id k22mr1586183lfj.12.1543513671100; Thu, 29 Nov 2018 09:47:51 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:50 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 24/27] drivers: firmware: psci: Support CPU hotplug for the hierarchical model Date: Thu, 29 Nov 2018 18:46:57 +0100 Message-Id: <20181129174700.16585-25-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_174803_801587_5D7C8378 X-CRM114-Status: GOOD ( 21.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the hierarchical CPU topology is used and when a CPU has been put offline (hotplug), that same CPU prevents its PM domain and thus also potential master PM domains, from being powered off. This is because genpd observes the CPU's struct device to remain being active from a runtime PM point of view. To deal with this, let's decrease the runtime PM usage count by calling pm_runtime_put_sync_suspend() of the CPU's struct device when putting it offline. Consequentially, we must then increase the runtime PM usage for the CPU, while putting it online again. Signed-off-by: Ulf Hansson --- Changes in v10: - Make it work when the hierarchical CPU topology is used, which may be used both for OSI and PC mode. - Rework the code to prevent "BUG: sleeping function called from invalid context". --- drivers/firmware/psci/psci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index b03bccce0a5d..f62c4963eb62 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -199,9 +200,20 @@ static int psci_cpu_suspend(u32 state, unsigned long entry_point) static int psci_cpu_off(u32 state) { + struct device *dev; int err; u32 fn; + /* + * When the hierarchical CPU topology is used, decrease the runtime PM + * usage count for the current CPU, as to allow other parts in the + * topology to enter low power states. + */ + if (psci_dt_topology) { + dev = get_cpu_device(smp_processor_id()); + pm_runtime_put_sync_suspend(dev); + } + fn = psci_function_id[PSCI_FN_CPU_OFF]; err = invoke_psci_fn(fn, state, 0, 0); return psci_to_linux_errno(err); @@ -209,6 +221,7 @@ static int psci_cpu_off(u32 state) static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) { + struct device *dev; int err; u32 fn; @@ -216,6 +229,13 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) err = invoke_psci_fn(fn, cpuid, entry_point, 0); /* Clear the domain state to start fresh. */ psci_set_domain_state(0); + + /* Increase runtime PM usage count if the hierarchical CPU toplogy. */ + if (!err && psci_dt_topology) { + dev = get_cpu_device(cpuid); + pm_runtime_get_sync(dev); + } + return psci_to_linux_errno(err); } From patchwork Thu Nov 29 17:46:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B92BC17F0 for ; Thu, 29 Nov 2018 17:53:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4AC52B376 for ; Thu, 29 Nov 2018 17:53:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98F062B8E5; Thu, 29 Nov 2018 17:53:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A29862891F for ; Thu, 29 Nov 2018 17:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EfO2m1NXiMKYMdDlO93OPJTCDeiMVtEuSVTky3Mo2SI=; b=Yetd0lfNif+sRHgIV8nX6hpmyC /EsyVyX4YawsM0ZGwmpqR8CKzZBvgDt0j5E/IVTPOUZDWRPhoDUgY/Hh9o3Wo5ONGFkWblQGBa6iV n64A5Z5KFpIt/EgSLb/N+MrK54jQddirM6PQxIQ9XXGLNycy3DH6y+DF1d7pu0n6ddQlTedpCVcZE +b3HarkrZ4pyweJWrXvxN+pjkP/IbP0uS8Ya4UgAUph1XoTZEVq7Tgt4HyPxyRRqBnoBE0199cQxl 8yiCFFFp+ez19xkU5IT/jJ8nrMk1d0wmqi+RjqY8K5502vZu+wkrlGOYxP/kyGLgfaaprR4dewfle kV7K9HDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQVF-00082T-R3; Thu, 29 Nov 2018 17:53:29 +0000 Received: from mail-lf1-f66.google.com ([209.85.167.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQQ2-0001dx-8H for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:13 +0000 Received: by mail-lf1-f66.google.com with SMTP id p17so2119835lfh.4 for ; Thu, 29 Nov 2018 09:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=creKAO5CsDdP5/fdWi07H8cJaJAAKbloLoHhussbOK8=; b=Oq4RLwG9RC6q2KpDvl5rQwPShMgDUxq9Bcao8uuCY9Q4AUGv2qJ6j4CCs4QQpzURNm TPpTC3Cm6RmvLVIsxY6SlVz5CJCcQKq09+p++pgz9zsmI8exx5qUyut7Q3F4AYFnUW5Q CrFgG6cAu86X9HxVLNMns/Wgs98w0VXiRfNds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=creKAO5CsDdP5/fdWi07H8cJaJAAKbloLoHhussbOK8=; b=sSLQh6V+PkbYkrJaPpcSyrnpos2Aj5MYanyd49tR9cqqhYK5kyuJOoGhc+TN9yhynP t01vaMOvmU15s+mfPZE8qJB162ihr1dwvi1NgWM1o1xGSXB0VVOYI24cPNhKAKnucYYk tTO7qWCVdOj0hRadw3ZPJ8MTKY3SBJRDC4FM5AOZk+9aLPNhtY6lSaqCTKRbdKooNnoY 2febrKCIyndgaw+9cPzGdLL/MgDTROfAlpfsSee6YACNgPOHPwDTu7DXVjlo6BxODnNr cdbdQqvFG4JFQ81S2XEKp/fv+rzRVq72nHelZmbBvQGdUfuxdaXEqR9XfUwEMqsDzHrB U+Ow== X-Gm-Message-State: AA+aEWZ6hR7ibh6BAQx861h7AYRdhN5auYJT0q96dqQMQ4mwIhOPqb8R aGau7ruCBoPa/wM6wmw/7w1OfQ== X-Google-Smtp-Source: AFSGD/XXZec1/y3UQsrlSnc/06AM5EYbLIVlOfcxbfHPLR90+FhEc7xHuwtxbcuBhvmXGgdvSxh8tw== X-Received: by 2002:a19:6e0b:: with SMTP id j11mr1724953lfc.124.1543513673516; Thu, 29 Nov 2018 09:47:53 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:52 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 25/27] arm64: kernel: Respect the hierarchical CPU topology in DT for PSCI Date: Thu, 29 Nov 2018 18:46:58 +0100 Message-Id: <20181129174700.16585-26-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094806_291951_280C8B23 X-CRM114-Status: GOOD ( 14.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , Will Deacon , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , Catalin Marinas , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To let the PSCI driver parse for the hierarchical CPU topology in DT and thus potentially initiate the corresponding PM domain data structures, let's call psci_dt_topology_init() from the existing topology_init() subsys_initcall. Cc: Catalin Marinas Cc: Will Deacon Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - None. --- arch/arm64/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index f4fc1e0544b7..4d59a72f8b0b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -364,6 +364,9 @@ static int __init topology_init(void) { int i; + if (acpi_disabled) + psci_dt_topology_init(); + for_each_online_node(i) register_one_node(i); From patchwork Thu Nov 29 17:46:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0F3F17F0 for ; Thu, 29 Nov 2018 17:55:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D8322F536 for ; Thu, 29 Nov 2018 17:55:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 916CD2F538; Thu, 29 Nov 2018 17:55:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 32E082F536 for ; Thu, 29 Nov 2018 17:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r8iHh5DiBA4Biy1CoBJDeQicgLqMS0j8YqjDJF+JcEE=; b=NeZIWywr6j0yqSIgYWiYe3FAWz 4Yp1DZPLcED+3MjHlwZUzEIH/2rhJ9CWxN9uZJLBKYVWPizb4R2dtJ8quxNa5/Le3Nmz+2iUiGE7g YaPYZNxB0Mgb1wk8AHZczvzmo0Sn87Z2En2DOpWayeSohnVlaJIewyh1YyvzMJEqrYpkI9oJWXKKT WoqyFY7i9nZiIVLFI1bIIREvIFoA+KQrOYJ/b+wLjuVUDhyABZXt6greWq0rNx2YXf+iNK1gzKlPk PLctXXT4CN2dIHAL38W3a8nRtHS68NsntWoE/2iCY5jWvJC4Tp6wjTOlF33EvGuuNvoICMTXMBC8a WNaBaSew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQXL-00021F-83; Thu, 29 Nov 2018 17:55:39 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQPx-0001fK-1R for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:11 +0000 Received: by mail-lj1-x242.google.com with SMTP id k19-v6so2512534lji.11 for ; Thu, 29 Nov 2018 09:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qhm2IiUZApJ/TAq2ykdaaOR5m9yofOsDK7mxY+y8g9A=; b=f1AF3JDLkqgKfUHBCg9Mlk5vpshh2imO1hpXNe/KWlxh0ZKLVnssZTlbDOENbV7aeJ KqsGLAj5CWrkGjuCTQpzFxwYqwNbzolo4Dl4XL5+HnFiOQTJ4kXyTWJw7WFVYu5mgsT8 /LpslPfUFTqndoYSJljDH6vvWB8L4zHCOtmdI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qhm2IiUZApJ/TAq2ykdaaOR5m9yofOsDK7mxY+y8g9A=; b=SOR5TLI2M0/jtTHwyORvmQLJQ9FWW2/KnBIaZ28yiCVCTG/uOL+nbj+XEUCnYf3R25 YmW0W8X3jgdMJv0INnanUfb9227Hm43rLojpBo17D4hfrCPCphy7/ROFQm9PIYZ0y0kS duQV4yhQbkGWp5dvCwWghdEnjjSmj6ErEyfQ0HpGpRrjz+UqzeV5bP+hFFw+XsN3p2ke gZwBr7pMe5h9f4lkzNCZWxjPGIOYi8KzfHNFQUJyjDZKYLzV7po7EYad/vd+KKUMaDQs +/bHNj7de39LzOd8UYyVoLggGesxTs+7Ufkj4/yjFHYpF0pZPCjMaaBZYnI8lndyL5pl 0FLA== X-Gm-Message-State: AA+aEWY3h/6SE693VNLQHX1sUpFY1aXBAiQdnH8AK4b5+qbxrmTH5cu0 NM3IrP3k56Vw0gixPZPxDjluqQ== X-Google-Smtp-Source: AFSGD/VpdNjWwHYOSKVaOwFj+iKJH8+CQrAUJfEIVXU94bMoGWr9Vi7reDmC0tycSePMwDsONANRFw== X-Received: by 2002:a2e:5b1d:: with SMTP id p29-v6mr1717026ljb.176.1543513675268; Thu, 29 Nov 2018 09:47:55 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:54 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 26/27] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Thu, 29 Nov 2018 18:46:59 +0100 Message-Id: <20181129174700.16585-27-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094801_372364_F2688183 X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Brown , Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , Lina Iyer , linux-arm-msm@vger.kernel.org, Andy Gross , "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lina Iyer In the hierarchical layout, we are creating power domains around each CPU and describes the idle states for them inside the power domain provider node. Note that, the CPU's idle states still needs to be compatible with "arm,idle-state". Furthermore, represent the CPU cluster as a separate master power domain, powering the CPU's power domains. The cluster node, contains the idle states for the cluster and each idle state needs to be compatible with the "domain-idle-state". If the running platform is using a PSCI FW that supports the OS initiated CPU suspend mode, which likely should be the case unless the PSCI FW is very old, this change triggers the PSCI driver to enable it. Cc: Andy Gross Cc: David Brown Cc: Lina Iyer Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- Changes in v10: - Added power-domain-names property to the CPU nodes, as to avoid possible future churns, if ever multiple power-domains specifiers. --- arch/arm64/boot/dts/qcom/msm8916.dtsi | 57 +++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index d302d8d639a1..cfafce4bfdf0 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -110,10 +110,11 @@ reg = <0x0>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; CPU1: cpu@1 { @@ -122,10 +123,11 @@ reg = <0x1>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; CPU2: cpu@2 { @@ -134,10 +136,11 @@ reg = <0x2>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; CPU3: cpu@3 { @@ -146,10 +149,11 @@ reg = <0x3>; next-level-cache = <&L2_0>; enable-method = "psci"; - cpu-idle-states = <&CPU_SPC>; clocks = <&apcs 0>; operating-points-v2 = <&cpu_opp_table>; #cooling-cells = <2>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; L2_0: l2-cache { @@ -166,12 +170,57 @@ min-residency-us = <2000>; local-timer-stop; }; + + CLUSTER_RET: cluster-retention { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000010>; + entry-latency-us = <500>; + exit-latency-us = <500>; + min-residency-us = <2000>; + }; + + CLUSTER_PWRDN: cluster-gdhs { + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000030>; + entry-latency-us = <2000>; + exit-latency-us = <2000>; + min-residency-us = <6000>; + }; }; }; psci { compatible = "arm,psci-1.0"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD>; + domain-idle-states = <&CPU_SPC>; + }; + + CLUSTER_PD: cluster-pd { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_RET>, <&CLUSTER_PWRDN>; + }; }; pmu { From patchwork Thu Nov 29 17:47:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10705183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 695E813AD for ; Thu, 29 Nov 2018 17:55:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 593B72C864 for ; Thu, 29 Nov 2018 17:55:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DCAE2F536; Thu, 29 Nov 2018 17:55:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D60D72C864 for ; Thu, 29 Nov 2018 17:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/rEpBdxa9TSqX8ygrgA8sKQI9P68We0IUB8NtbwSfE0=; b=slrvRVnvxmo6QXISLY4jrk0SVI qeUBckrWKkZTFy4xbEIL/VxYp5Et5n84s4UgaytXgVjFGwlWL4uMTeo7U+OKBzOFP3hjwa6o0wfr5 McxULt5CssIE3Nb1N4y2x3Iu06xJdJBON5OR+yHxGMZcSiznVMC5TWKIq8n4vculiQQ0m1frj793B DkN8/6OC2Lns+Q3/7Tn4Hjd6F431AVnF59sTv5oZWZwQ+U9XGMcu6THxiCYjNqKMMAeNDNXG4D1RD rcJRp4fXQ3I2yOfIwXprnCLZy0YzMfSqRohLVFwJQ1Biy6yZqHit8/GEYZZd6byXfBssSKfq0ou/I k5Wle6Lg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQXR-00027n-VV; Thu, 29 Nov 2018 17:55:46 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSQQ4-0001hC-Tz for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:48:14 +0000 Received: by mail-lf1-x144.google.com with SMTP id e26so2125962lfc.2 for ; Thu, 29 Nov 2018 09:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=edUuds9oK7rq3a7y1o1twsgnSy+L5oYmA4xb9WHJ9+k=; b=A6wx/B1lx1+bygG6vNTP5U1cnmX9jGEyu1b3aHBxjvlAIzHP/jh/FWsauGN28VCUzQ ljorwL5unf+YDLuCY0t6Ivi4w5Lj71gYb0YXCgZ4jRGr+Jt6dYLG2khG3OERWdIZ5xkY Ac65FBUbc5jI8f4Eyk6HdNONOTEhIVUNeWVhQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=edUuds9oK7rq3a7y1o1twsgnSy+L5oYmA4xb9WHJ9+k=; b=qdXTsEUuVzfho92+/2usxOuh0zpuaoZ0Njy0I9A7ZZcOtjUipUYq4mYi8Dui756/b4 RLJNfhrSRJmw3RidhsfPspQ4Pqs3fgLYky2RCwKQsi5qUfTCnueQY1T1spVroS/q4ubQ BwMU502w9LuXmxBtDeky2qw0jjCmv6bEfvY+yf14c2uf30onp8kCDrvAtV0euE7ej9Sz UDJxkTEEN0bwZAtyv1l3eQbM5CuOnZmviwxFJHCCUmc8TGdETYX8498bbCEv/6asa2dK prrzUN2yGAD05ZIqdE4Lgqr2eouR8mJTw02ttIRd1qXtsHxbE5rrB/02kg58TlVV/ZlT tZrQ== X-Gm-Message-State: AA+aEWYh1UzHZSH2uwYH8yajGAnwgmbt1Mh36P32vkSnfvqBbBTH85sj RpjOUuuhaHWNTFEmdby+xRvTTw== X-Google-Smtp-Source: AFSGD/XVzFGUZimGhzy88XMVy4uhorvpa7/8oAxi7Md22GA4kR2vIjSPoAiN4QAPlVeK/uqUb9G+/Q== X-Received: by 2002:a19:59c2:: with SMTP id n185mr1558629lfb.118.1543513677002; Thu, 29 Nov 2018 09:47:57 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:56 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v10 27/27] arm64: dts: hikey: Convert to the hierarchical CPU topology layout Date: Thu, 29 Nov 2018 18:47:00 +0100 Message-Id: <20181129174700.16585-28-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_094809_095897_25E494D4 X-CRM114-Status: GOOD ( 15.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Tony Lindgren , linux-arm-msm@vger.kernel.org, "Raju P . L . S . S . S . N" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To enable the OS to manage last-man standing activities for a CPU, while an idle state for a group of CPUs is selected, let's convert the Hikey platform into using the hierarchical CPU topology layout. Signed-off-by: Ulf Hansson --- Changes in v10: - New patch. --- arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 87 ++++++++++++++++++++--- 1 file changed, 76 insertions(+), 11 deletions(-) diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi index 97d5bf2c6ec5..fa5b385cfbc4 100644 --- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi @@ -20,6 +20,64 @@ psci { compatible = "arm,psci-0.2"; method = "smc"; + + CPU_PD0: cpu-pd0 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD1: cpu-pd1 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD2: cpu-pd2 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD3: cpu-pd3 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD0>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD4: cpu-pd4 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD5: cpu-pd5 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD6: cpu-pd6 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CPU_PD7: cpu-pd7 { + #power-domain-cells = <0>; + power-domains = <&CLUSTER_PD1>; + domain-idle-states = <&CPU_SLEEP>; + }; + + CLUSTER_PD0: cluster-pd0 { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_SLEEP>; + }; + + CLUSTER_PD1: cluster-pd1 { + #power-domain-cells = <0>; + domain-idle-states = <&CLUSTER_SLEEP>; + }; }; cpus { @@ -70,9 +128,8 @@ }; CLUSTER_SLEEP: cluster-sleep { - compatible = "arm,idle-state"; - local-timer-stop; - arm,psci-suspend-param = <0x1010000>; + compatible = "domain-idle-state"; + arm,psci-suspend-param = <0x1000000>; entry-latency-us = <1000>; exit-latency-us = <700>; min-residency-us = <2700>; @@ -88,9 +145,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; }; cpu1: cpu@1 { @@ -101,9 +159,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; }; cpu2: cpu@2 { @@ -114,9 +173,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; }; cpu3: cpu@3 { @@ -127,9 +187,10 @@ next-level-cache = <&CLUSTER0_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; }; cpu4: cpu@100 { @@ -140,9 +201,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD4>; + power-domain-names = "psci"; }; cpu5: cpu@101 { @@ -153,9 +215,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD5>; + power-domain-names = "psci"; }; cpu6: cpu@102 { @@ -166,9 +229,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD6>; + power-domain-names = "psci"; }; cpu7: cpu@103 { @@ -179,9 +243,10 @@ next-level-cache = <&CLUSTER1_L2>; clocks = <&stub_clock 0>; operating-points-v2 = <&cpu_opp_table>; - cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP>; #cooling-cells = <2>; /* min followed by max */ dynamic-power-coefficient = <311>; + power-domains = <&CPU_PD7>; + power-domain-names = "psci"; }; CLUSTER0_L2: l2-cache0 {