From patchwork Tue Mar 3 20:35:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11418767 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3626217E0 for ; Tue, 3 Mar 2020 20:36:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 147D2208C3 for ; Tue, 3 Mar 2020 20:36:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NKaL+1yL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M6nT4o+P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 147D2208C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=fpE9AgqrlZBpBiMsbvmj1JX2z8kVPd77/eaiv9S1aOQ=; b=NKaL+1yLgr19/o WAGT7DlcIcyYAVFFZ5fgm8PE+/YQnpgkDVSqWxFpcfzYzoBU3BaE/IEWQfRcs3fFIqWP6oggG13xA HjjbtToOG3hZpiJyUfYNbrRsURBR+1H4DETIixCjqpy7WP/iy+z+XbJjAytyclFQppal3dEenWC5s oiYVmmmIU5ZFjNAvBfwCvcaOiOIWANWFVoZKsA4nYKPZjbFjwkVvP8Vndz4RGpQwYQ1nREF2sFLVP /KY32enfxrHo1nKLxeR5JywXc+XGcQFPd/6Hsb5xEfKdVLuwrye09WU0daK3JFSOsKot7hcEjgO2A QUDchhpOVDGhCQaKknnw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EHJ-0004vz-2u; Tue, 03 Mar 2020 20:36:33 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EH6-0004lA-Lb for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2020 20:36:22 +0000 Received: by mail-lj1-x244.google.com with SMTP id q19so4126807ljp.9 for ; Tue, 03 Mar 2020 12:36: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 :mime-version:content-transfer-encoding; bh=3+0UYj3qVJZMwBRFalwhwumi1SLOyZkXHX2X4PQigTk=; b=M6nT4o+PaOt0lluB6TctZ125cHNRlgBI/C3zswdbS6bE4Vor6LpM3xul+GzDk3LYMc qw+N/dL5nSOCxpgekkdUlti+upKi21MCbPGU/bH9dA31iwdJrjuUmx50lvX4KtVd47p/ lGSRoDHKlev29S/7Vs+Z/wjbkDTdKZJ3qP6cAKGHBQ4J3m5MJ3pL5+jtoffHYIz8rb/D LyJGPV8uyzka1C/i7OsLZ1YfXnjmIl1B6XuEbzK8VLlbznNOGVRIOhySviyL9ZP5yMhT CFX4hcgpE/r3MtTYFG9uc6R3sKXfs0gMaoa5+35Hr17dAW1rceC8NKY5fQ9zkfbSVx2u Md3w== 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:mime-version:content-transfer-encoding; bh=3+0UYj3qVJZMwBRFalwhwumi1SLOyZkXHX2X4PQigTk=; b=DiGaPNBZHegd0Svn/P6vsUwbKHBSvlUdyA5crCOnQoKA4FGVhBWQdIGca0WPX1GztA UcAXidDnxZ8A8TOky8qhiVw5lep5ptbzXBA8candZuptpKxHHmB7CDuNOR7LRla5B+c/ LA3cTlr26IeOeqanDNGK533Cyw9ITSm00/VHq7HDyJX4/C71eY6ZKXYxEM8Gy/XO6OES hsmRb1kRHi0GSQNT7ZGthZB4HTtn3fUK0HRQE3rfMdyipnKNaNI0x2b/fAXFJ39WE3DZ qOsXgbeOckynHNCPaJzJhBkWFd8jmHaq4J1ETsJHEjb7l+fwFPxmrro/2/IN859C3Q8i w/Dg== X-Gm-Message-State: ANhLgQ2oJgPRyeyr8IjWfp0lcZWFkzITwzX60emDW/8LR4Ho8Iss7KTl oIZBJvwQHI+S9Fk3XT0QksZ6sg== X-Google-Smtp-Source: ADFU+vtxH5Gk3A2TqaasCf1CsCDxKPfx3AYiuDLFIZjyb++K4u0hf79plZcWKxwzcA4xfdBGagw2Yg== X-Received: by 2002:a2e:b442:: with SMTP id o2mr3427232ljm.261.1583267779037; Tue, 03 Mar 2020 12:36: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 t195sm1339532lff.0.2020.03.03.12.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 12:36:18 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 1/4] PM / Domains: Allow no domain-idle-states DT property in genpd when parsing Date: Tue, 3 Mar 2020 21:35:56 +0100 Message-Id: <20200303203559.23995-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303203559.23995-1-ulf.hansson@linaro.org> References: <20200303203559.23995-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200303_123620_702136_9150BFA8 X-CRM114-Status: GOOD ( 14.08 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:244 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Benjamin Gaignard , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Commit 2c361684803e ("PM / Domains: Don't treat zero found compatible idle states as an error"), moved of_genpd_parse_idle_states() towards allowing none compatible idle state to be found for the device node, rather than returning an error code. However, it didn't consider that the "domain-idle-states" DT property may be missing as it's optional, which makes of_count_phandle_with_args() to return -ENOENT. Let's fix this to make the behaviour consistent. Reported-by: Benjamin Gaignard Fixes: 2c361684803e ("PM / Domains: Don't treat zero found compatible idle states as an error") Cc: Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 959d6d5eb000..0a01df608849 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2653,7 +2653,7 @@ static int genpd_iterate_idle_states(struct device_node *dn, ret = of_count_phandle_with_args(dn, "domain-idle-states", NULL); if (ret <= 0) - return ret; + return ret == -ENOENT ? 0 : ret; /* Loop over the phandles until all the requested entry is found */ of_for_each_phandle(&it, ret, dn, "domain-idle-states", NULL, 0) { From patchwork Tue Mar 3 20:35:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11418769 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA91B924 for ; Tue, 3 Mar 2020 20:36:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B516920CC7 for ; Tue, 3 Mar 2020 20:36:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DRvF7jjW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="z4JKkqN1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B516920CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=8ZWXe379gw6NXHjN9lvBaDXO0aVXEyFns/9pw3WwjJg=; b=DRvF7jjWnU88fw OkslMLGtwZgxLuenbmPsopa+DcENtMd9sIcrnprF9HapkZz5tL+ka1KH1lg+EFDw9sHu8Gq4gETGI vBBA3Zzceg32FrVWPVGqIvUm7GqOU5pxnlzhdbWlUu7sgN3HllIadmYnZHIX2SXkVGOAS5TFdR+o1 Mogd/mVgWz938lz5hjG+PZRfLu1uhCmMDgRU6CCUnIoh+VO5OZCU2mmRgWrhgszokeienikHK9WBA qouagkd+PcbSoRH0Er+CkZisqB2XxA+JVNDRwApRUY3gasPezObvxbGjejKhrmQmn8zbMMMInJD1m IxAq0Y68MQSnw2y16rHw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EHY-0005Ck-N9; Tue, 03 Mar 2020 20:36:48 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EH8-0004la-DG for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2020 20:36:23 +0000 Received: by mail-lf1-x144.google.com with SMTP id y17so3929036lfe.8 for ; Tue, 03 Mar 2020 12:36: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 :mime-version:content-transfer-encoding; bh=NROpLkqIKQsmOxVfnI3TCB5D/se19mcdjX7Jsvn77Ws=; b=z4JKkqN1r6xRG/KIVxn8rmsB5O65VLA31nuxkGSm+tnCsAynoEP9joIT0dW5u+frjr JOlrQLtXbkN8siv27mSjBLOMMLUXSCLVlzDVAhvV8sGDQp/BHBd92V79Sh+/wZ5MRY8+ PoSDLHf23NLIt7YzoSkdsbz/WPP1+DRFdvsaU4/KD2Af/0+Pb54gQUARhQmJpGvYIK9n n+eBd8csqq57uOxodmQ5EKSE/Kh3WENqdrUou1a8C2F8Pqd0Zs4b3YORqcuRhHKXVNa0 vaq3aMWT/6JGXo92PgRuKP+rMc9mhcJBgnaMT2OZ+b3mZywsnprdDXo3sqAXZj5zM++Y 9Xrg== 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:mime-version:content-transfer-encoding; bh=NROpLkqIKQsmOxVfnI3TCB5D/se19mcdjX7Jsvn77Ws=; b=SfvA4BY8fLhSI0G2O/QCdr2zjZtoEh6Kb4HBeKZQ9jzRb1lPcak3J6ompid6SgXBfc ALYP5dZBq34PCEMFbAvO9Ge2LsWybi/DhXajkUnnoJg7tjT7YSL759p/ba5WGlpvM97w ZgNhkAkbkHHjGhJzFTXdqCFh6gYTbLgUDWZAg6XFaSJSwyGM7QiGWqUE2HzQpVMxJaF4 b540YNwSYBVEu0knnTwh7uYjy7vuzgy3vO3MOyKVL8LiuMhOVMcaOWePjPaS9Q4/Cdfs EKCfzUm0nP0x1ZS4OvJYdLWUmkLydbP6kFImqFSt3YMqoUlh7G5hNMDxXpJch53KwwK5 ly5w== X-Gm-Message-State: ANhLgQ0gWPetB7NmkwRj1QfljyIkNAGUFW4aAVu3qqgUJLS5EL+gBSsX 7kTPCRScWwptpHzHsZ24KPYd3w== X-Google-Smtp-Source: ADFU+vvzLeYQbIe0vTeTmA7QTfjZa5SPu8+43nq3kqPmgzCEuIsW2a14EHXf+icCB4h+M6eJ1zgXPg== X-Received: by 2002:ac2:5a05:: with SMTP id q5mr3792740lfn.143.1583267780603; Tue, 03 Mar 2020 12:36:20 -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 t195sm1339532lff.0.2020.03.03.12.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 12:36:19 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 2/4] cpuidle: psci: Fixup support for domain idle states being zero Date: Tue, 3 Mar 2020 21:35:57 +0100 Message-Id: <20200303203559.23995-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303203559.23995-1-ulf.hansson@linaro.org> References: <20200303203559.23995-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200303_123622_443111_51CC8244 X-CRM114-Status: GOOD ( 11.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:144 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Benjamin Gaignard , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The current code intends to allow a PSCI PM domain to have none domain idle states defined in DT. However, a few minor things needs to be fixed to make this correctly supported, so let's do that. Reported-by: Benjamin Gaignard Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index 423f03bbeb74..c34b12c4069a 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -49,6 +49,9 @@ static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states, int i, ret; u32 psci_state, *psci_state_buf; + if (!states) + return 0; + for (i = 0; i < state_count; i++) { ret = psci_dt_parse_state_node(to_of_node(states[i].fwnode), &psci_state); @@ -96,6 +99,9 @@ static void psci_pd_free_states(struct genpd_power_state *states, { int i; + if (!states) + return; + for (i = 0; i < state_count; i++) kfree(states[i].data); kfree(states); From patchwork Tue Mar 3 20:35:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11418771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19CDC1395 for ; Tue, 3 Mar 2020 20:37:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6D2A20848 for ; Tue, 3 Mar 2020 20:37:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k2s+h/n1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xL/TeD7x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6D2A20848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=aagsSjD26aMv8JDR5q15TTUBci0uhCyKbrHOJejT8JY=; b=k2s+h/n1dvTO6z ZH5syziRc2Q5Fmz2jpESEeHA2oxdrgR+GgL4REQVpwkEbfCKVc4P5WTJ9dUKyy08m4o6tThDVWsGI efYCQN2BaaiXVFWQU1bP72qhoGkMOLYaq/eww1aXWzYPtesXsAX+XtIss7D540tATeIMdG8sT3gUZ xkbUUfBtLLEMRcMmgw2kXlevA+DVH8AAy6rygBHDR3JHssfxK8IFy+DXgDLRx7vwbRvK5egxR8h7B CShAm2rwnbYlfRltqqoJcpWA3zJmHJ8K9bdGLwI9rJjJ14rbMNWJO7cQNvODETg/gfHuSLieQiVWs soPey8yNIMdgye6lIBBA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EHj-0005OJ-QU; Tue, 03 Mar 2020 20:36:59 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EH9-0004m7-VO for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2020 20:36:25 +0000 Received: by mail-lj1-x242.google.com with SMTP id u26so5040751ljd.8 for ; Tue, 03 Mar 2020 12:36:23 -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 :mime-version:content-transfer-encoding; bh=p6OxZjqO84dNl99kuVPctKqSI5SbottYVoqCuAlbKlY=; b=xL/TeD7xGicYVnZjuz5GIxiYOxPH4BTrkcynvaLMauv1NyLuQtHbfACxUi7y3w5VfQ qBbXxi4obb7qT3QVorg9XjxXG+W3XJDgFKvEyveWOQocNLnkXALY3aR32yqG94pKZUcl jvMUa1LO/S2GhGsGYyNUD7RNYW0GsGmvPnh8kgxFn3DJtqGTbL/8DIO7DmaU6bUOjp1F fTQqat4KxMdVagRi9hGOUlLG1rfyN7y91LriVd0D7hbvBNI8ld0LNRkEVNm4gCaDCH4a zqhfX0P+cUgzYVj/+MXpoRIcT9EC9DS1X9VkqHvJsWqk/Rh/DkmZ5Twp6fCLT3AIL8jA iJKQ== 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:mime-version:content-transfer-encoding; bh=p6OxZjqO84dNl99kuVPctKqSI5SbottYVoqCuAlbKlY=; b=RsL3LwjaAk1PS5+JAaq5UOo784q6J3quWeYwQKtHrJZ4QNF/2hpeJEHIoEnC/CnfUj zvBWpr31ukLhjYFXVr5HoADQ7dao/j2o0I4IzsH1Mw6ntZP7K3EVn/xDtj+Ksdvx1UqZ 5QnP6EPtv1Rxu59V+mD/tN2NpPlfmCh6p052izsgsCKXSDGki2IanUUZ4s2Fw9s/en5D eScecEvjrLNMBqWtxW/nC6S9fu3BMnBpRo75uM3iS5MlhSMZqQrt358gFluaVuCdVdmk 6jy3CuzyTPgTCCWtY+twX7ltOdIjDOl+JprqmkHlcXTJXkBEo3HYYLnNMayvzdeWj5hm h6jg== X-Gm-Message-State: ANhLgQ3mqS0ICME0h10yXR7dIuDYnyroiO1JrzEfuj12qjmBA3KmOzUo F0vGTPIZZFXc3Fu8L+as2dVWAg== X-Google-Smtp-Source: ADFU+vu6WzpHn5qg+aeDQWydbv05vDibX4pkN4lVrelM0STP1h+Lc44f+lGs0T4jy2FAanBW1AKICA== X-Received: by 2002:a2e:3a13:: with SMTP id h19mr1138741lja.16.1583267782135; Tue, 03 Mar 2020 12:36: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 t195sm1339532lff.0.2020.03.03.12.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 12:36:21 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 3/4] cpuidle: psci: Split psci_dt_cpu_init_idle() Date: Tue, 3 Mar 2020 21:35:58 +0100 Message-Id: <20200303203559.23995-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303203559.23995-1-ulf.hansson@linaro.org> References: <20200303203559.23995-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200303_123624_013236_B89EA00C X-CRM114-Status: GOOD ( 18.14 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:242 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Benjamin Gaignard , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org To make the code a bit more readable, but also to prepare some code to be re-used, let's move the OSI specific initialization out of the psci_dt_cpu_init_idle() and into a separate function. Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") Signed-off-by: Ulf Hansson Reviewed-by: Sudeep Holla --- Changes in v2: - Adopted suggestions from Stephen to use IS_ERR_OR_NULL and PTR_ERR_OR_ZERO, which further clarified the code. --- drivers/cpuidle/cpuidle-psci.c | 46 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index edd7a54ef0d3..bae9140a65a5 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -160,6 +160,29 @@ int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } +static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, + struct psci_cpuidle_data *data, + unsigned int state_count, int cpu) +{ + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (!psci_has_osi_support()) + return 0; + + data->dev = psci_dt_attach_cpu(cpu); + if (IS_ERR_OR_NULL(data->dev)) + return PTR_ERR_OR_ZERO(data->dev); + + /* + * Using the deepest state for the CPU to trigger a potential selection + * of a shared state for the domain, assumes the domain states are all + * deeper states. + */ + drv->states[state_count - 1].enter = psci_enter_domain_idle_state; + psci_cpuidle_use_cpuhp = true; + + return 0; +} + static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, unsigned int state_count, int cpu) @@ -193,25 +216,10 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } - /* Currently limit the hierarchical topology to be used in OSI mode. */ - if (psci_has_osi_support()) { - data->dev = psci_dt_attach_cpu(cpu); - if (IS_ERR(data->dev)) { - ret = PTR_ERR(data->dev); - goto free_mem; - } - - /* - * Using the deepest state for the CPU to trigger a potential - * selection of a shared state for the domain, assumes the - * domain states are all deeper states. - */ - if (data->dev) { - drv->states[state_count - 1].enter = - psci_enter_domain_idle_state; - psci_cpuidle_use_cpuhp = true; - } - } + /* Initialize optional data, used for the hierarchical topology. */ + ret = psci_dt_cpu_init_topology(drv, data, state_count, cpu); + if (ret < 0) + goto free_mem; /* Idle states parsed correctly, store them in the per-cpu struct. */ data->psci_states = psci_states; From patchwork Tue Mar 3 20:35:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11418773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4784A924 for ; Tue, 3 Mar 2020 20:37:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2581A20848 for ; Tue, 3 Mar 2020 20:37:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NRBSdCt8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Fq/sp9HG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2581A20848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=a40wlbqrn4SOYigbK/5eCGBobHIfPL/F6CXpv32Yf3U=; b=NRBSdCt8YkQMh4 wCEV2lLsEWIuPOfiYcGuSYUjRKpSDXhLPJP4oDa7GAb9uSqP3dwMkeI6Pv1TmAkVuoGAuK+1l3ACP vMWJ1vJKmnK0cC9YG5sW3MT6+AqdwvsA5/JXA12a2VBpg6w+6dtgyPYvOyAB3TLOQIR4aNsF1f7AA K100FyNNDev196NoKpqyDsIK4sKv1TVfwW6bPhTzmsjXvwVmyJ4mHauS81Tvz85Pe4430sMIHM0Gk a7nUovsneaCijItuW01NJspXpIPlyEx/OuorHApwUxtHBCqf5Qb27GKVmv6unG+FEEhKWZuDV/Lg8 7icbRhiwuZwdX6/6z+dQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EI5-0005i5-Fl; Tue, 03 Mar 2020 20:37:21 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9EHB-0004mi-18 for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2020 20:36:26 +0000 Received: by mail-lj1-x244.google.com with SMTP id q19so4127000ljp.9 for ; Tue, 03 Mar 2020 12:36: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 :mime-version:content-transfer-encoding; bh=7PinDvT3vaZ+q6CFmJPa7CF8xALNvmK8t7KJc3O4ca4=; b=Fq/sp9HG47oR3mlEYYx860yS6y7Je9qVstoba2QSh8hz5l2dwmaB6g1W8Zk+yDHKzo 1qmVSw2rUW2hmBPDL+w2zNpuAAZ8uwSywAn3K6o3SPEznX1iHxralqz2M+rB5FnYlN7/ +OIDlP1SWny1pE5E8KQrWDkImEI/q7miYGDO0zz2JYVBbjJkoruHX5FRHM8RdYu5jFY7 nsX1gCXhQewE0swh1cr5Sk+B4srQFVwSeBgahNvVvvVxuda36+DCxOVHHc0cCgdwVr8c 0C3XZJEUdNwCWDAbp1hj6NVeL4kjQ62RTtg0zmYRmxAOucjwocHHMxEkQOT0Th0CTJgy XkHA== 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:mime-version:content-transfer-encoding; bh=7PinDvT3vaZ+q6CFmJPa7CF8xALNvmK8t7KJc3O4ca4=; b=g12PnQH1r81URmFSHpgc9xd/8nWYT8ntKFS8KXZ9vMuy6GUObj5/CljCczts5wP2dR s+F6XLMT8OY6VbSWYs+8KbOw0SYQk09BAJvNCEB+B1kgc+Lwe8AkJl8F2SjLIEeunHRj Svbd4Bmj1NkW0WrZsHdLZohRWnBGzf6S4odYJkgfs0vIwFOsLwJMIl9Chb1t1eCQbuup b0us8Nvz1gDa79v3mV62zJr7rGDRuePa1FAlDg1Mf37cpAu7izUihSo8iQNpl2JwXDtz ngv62FEWK10GLZSXndqE89fgQO5XekShGvsOqeGRGg2PeNVYlvZLFY4op7I084hiwVA2 ClRA== X-Gm-Message-State: ANhLgQ0CyzBR6syx0Q6Us/CK6Cbml2jk0LhASdT1OmqI8/TNKkD9D+rO eJC5PxjCBUGjlQuXwzVJYQ1taA== X-Google-Smtp-Source: ADFU+vt6uuUl+iUGLAMABwb54VVP9bXXM8EH32uRgtLikEC1RAhEd/mfOswBvrjjq1aT9X1OAg20ig== X-Received: by 2002:a2e:9e4c:: with SMTP id g12mr3324423ljk.15.1583267783555; Tue, 03 Mar 2020 12:36:23 -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 t195sm1339532lff.0.2020.03.03.12.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 12:36:23 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v2 4/4] cpuidle: psci: Allow WFI to be the only state for the hierarchical topology Date: Tue, 3 Mar 2020 21:35:59 +0100 Message-Id: <20200303203559.23995-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303203559.23995-1-ulf.hansson@linaro.org> References: <20200303203559.23995-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200303_123625_108537_90C8FAF0 X-CRM114-Status: GOOD ( 22.59 ) X-Spam-Score: 0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:244 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.4 FILL_THIS_FORM_SHORT Fill in a short form with personal information X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Benjamin Gaignard , Stephen Boyd , Daniel Lezcano , "Rafael J . Wysocki" , Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org It's possible that only the WFI state is supported for the CPU, while also a shared idle state exists for a group of CPUs. When the hierarchical topology is used, the shared idle state may not be compatible with arm,idle-state, rather with "domain-idle-state", which makes dt_init_idle_driver() to return zero. This leads to that the cpuidle-psci driver bails out during initialization, avoiding to register a cpuidle driver and instead relies on the default architectural back-end (called via cpu_do_idle()). In other words, the shared idle state becomes unused. Let's fix this behaviour, by allowing the dt_init_idle_driver() to return 0 and then continue with the initialization. If it turns out that the hierarchical topology is used and we have some additional states to manage, then continue with the cpuidle driver registration, otherwise bail out as before. Reported-by: Benjamin Gaignard Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") Signed-off-by: Ulf Hansson --- Changes in v2: - Convert the error code returned from psci_cpu_suspend_enter() into an expected error code by cpuidle core. --- drivers/cpuidle/cpuidle-psci.c | 48 +++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index bae9140a65a5..ae0fabec2742 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -56,16 +56,19 @@ static int psci_enter_domain_idle_state(struct cpuidle_device *dev, u32 *states = data->psci_states; struct device *pd_dev = data->dev; u32 state; - int ret; + int ret = 0; /* Do runtime PM to manage a hierarchical CPU toplogy. */ pm_runtime_put_sync_suspend(pd_dev); state = psci_get_domain_state(); - if (!state) + if (!state && states) state = states[idx]; - ret = psci_enter_state(idx, state); + if (state) + ret = psci_cpu_suspend_enter(state) ? -1 : idx; + else + cpu_do_idle(); pm_runtime_get_sync(pd_dev); @@ -180,7 +183,7 @@ static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, drv->states[state_count - 1].enter = psci_enter_domain_idle_state; psci_cpuidle_use_cpuhp = true; - return 0; + return 1; } static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, @@ -192,6 +195,13 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *state_node; struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); + /* + * Special case when WFI is the only state, as we may still need to + * initialize data, if the hierarchical topology is used. + */ + if (!state_count) + return psci_dt_cpu_init_topology(drv, data, 1, cpu); + state_count++; /* Add WFI state too */ psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) @@ -223,7 +233,7 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, /* Idle states parsed correctly, store them in the per-cpu struct. */ data->psci_states = psci_states; - return 0; + return state_count; free_mem: kfree(psci_states); @@ -282,33 +292,35 @@ static int __init psci_idle_init_cpu(int cpu) return -ENOMEM; drv->cpumask = (struct cpumask *)cpumask_of(cpu); + drv->state_count = 1; /* - * Initialize idle states data, starting at index 1, since - * by default idle state 0 is the quiescent state reached - * by the cpu by executing the wfi instruction. - * - * If no DT idle states are detected (ret == 0) let the driver - * initialization fail accordingly since there is no reason to - * initialize the idle driver if only wfi is supported, the - * default archictectural back-end already executes wfi - * on idle entry. + * Initialize idle states data, starting at index 1, since by default + * idle state 0 is the quiescent state reached by the cpu by executing + * the wfi instruction. If no DT idle states are detected (ret == 0), + * we may still use the hierarchical topology. */ ret = dt_init_idle_driver(drv, psci_idle_state_match, 1); - if (ret <= 0) { - ret = ret ? : -ENODEV; + if (ret < 0) goto out_kfree_drv; - } /* * Initialize PSCI idle states. */ ret = psci_cpu_init_idle(drv, cpu, ret); - if (ret) { + if (ret < 0) { pr_err("CPU %d failed to PSCI idle\n", cpu); goto out_kfree_drv; } + /* If there are no idle states to manage, but the wfi state and we also + * don't use the hierarchical topology, let the driver initialization + * fail. Instead, let's rely on the default architectural back-end to + * execute wfi on idle entry. + */ + if (!ret) + goto out_kfree_drv; + ret = cpuidle_register(drv, NULL); if (ret) goto out_kfree_drv;