From patchwork Thu Feb 27 12:45:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183946 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4469028ile; Thu, 27 Feb 2020 04:46:16 -0800 (PST) X-Received: by 2002:a2e:7d0e:: with SMTP id y14mr2886346ljc.158.1582807576742; Thu, 27 Feb 2020 04:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582807576; cv=none; d=google.com; s=arc-20160816; b=LDq3ZPGEcBxXHHQq6NpaaLgtVtFIhQsrjahdwE8FVe30O5Egqk347/mhlyzrxm0JtS dQm0tjhxo3KdGh4zG90q4jMsqn9qN0QlpYzTVjHUXx1bdazcSY1T+wou5OJLYGel59YK RXlo4yXGCoXZJ7ychUJmNh/5fVD2oq9BUCQCI/tLggXmjDKnsyf0aBcOR5sG70o2UW7Y YoWR+a1m2LLZ243SGVPvs18IZFd7UJJ9ntRRL9Qu83i693ChptiR+FHnbZ8bYXxoQZ0Z j87jhEeHIPt8PMO17lS9SPwyuDfXYwDaO0IopXm+h5hUAdb8sDiK7iLJG2lzng1ixX16 RNIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=3+0UYj3qVJZMwBRFalwhwumi1SLOyZkXHX2X4PQigTk=; b=IM2eUHz+ljP+MuLiGIKsVKMKEWIai4LmrD5HzUrZu52QRaJg0ys3be477q4b1RxFMk Athlsl03G7DFaam68hvqGyZGprBU38LTWTG238NRYxW+BWb4kBa5umrakFjnBdVSMEVk VzZzZHxpk0ZsfMStB+ChVTQmk2KYC7ge8Mt6NaADim9hJx/XmjVdfbmwqo98zcz1+fyg MBjPzomWYSZ9tCZ2RRZJkImC5Az8BgV1H5X2oaG4TtEx68bC6H62jZE2/9veeX0+7fqX dM5BMWjeD7+EVOyboMo9MUUmJmy6ffZzXfDmu9puaK58osh+qLhkUyXH0xr4eAth07JI Rlpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mXb6at++; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d28sor12417lfn.55.2020.02.27.04.46.15 for (Google Transport Security); Thu, 27 Feb 2020 04:46:15 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mXb6at++; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=mXb6at++ivddD2NTVyokGX6Bv9FhnYBxuwJBu37CLMiC7ZKw+agfQ8IcqYkg5R62dV UbBJskVFA9v0xAAj88zbm115M1Ky/Shbongm6s1uqNzblmPlJpA2AlhbNzAonTqF6KVT 3f/G2VBMbDM89Gh1lBSYuFEgrllGeNDN08WuURX9P9tevKQmiXieDsY0P2yJqyq3PT9i oVHssqDaQ1V4wZZAid9+NJ84Jnb46rLodKD+SSpZ/3FX0TCDUBxHuSYZBntM+ZH66VrM J7J/NKuN7xia8AKCAQQtvg87aTIL4OKo8vWc6bJ6Ce5c9W/CjOlDCG+LC+WNFAbe2hcJ eX7g== 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=hV+h/uFnrRSZNGGZkCRxNzNNHYr9QOYYp1rOIWxQoHi/fvl9O0b108BGJ//z56Ln/i EXrtsq5Wep/FlpcrC17V0/NUmWFYPong9JHXhMMoX885fFH19DkUdxAQqQPNjx59N4wC RUpoAGvEp2z1pfn2GbDmvTtSADSJREXK5a0+zesmULGIqe8du9PC1jEdpBjXQ+kBBv/q EHXHpqaomKRygnnJwVvpcdaM1b5bxlCY8tFCyHguoMONVV8jt5kwPD00nZZ1iqnGnraQ k5vE0fyncbpxqwOhtCLBtboHzjk5/kDagJkhmdosfV5Zfw46E0VrVXCsYdjLbGbopIoc FxiA== X-Gm-Message-State: ANhLgQ3e2QWNXIKntjebS+mMZsXZ6cMu1jIk28ZEDUxWwhTzfeQDmRAX WH1HFS2dNUcGFaBDGrfMuCGMmIcc X-Google-Smtp-Source: ADFU+vsHQVosAGa6s8cq304/BYeC23/PJ+nzRpBSOGRg4zjwsWrSheAAC7nA+O5n//KNTf0/gfXSPw== X-Received: by 2002:ac2:5299:: with SMTP id q25mr2092593lfm.213.1582807575348; Thu, 27 Feb 2020 04:46:15 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l16sm2669334lfh.74.2020.02.27.04.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 04:46:12 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH 1/4] PM / Domains: Allow no domain-idle-states DT property in genpd when parsing Date: Thu, 27 Feb 2020 13:45:48 +0100 Message-Id: <20200227124551.31860-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227124551.31860-1-ulf.hansson@linaro.org> References: <20200227124551.31860-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 --- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 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 Thu Feb 27 12:45:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183947 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4469069ile; Thu, 27 Feb 2020 04:46:20 -0800 (PST) X-Received: by 2002:a19:c1cd:: with SMTP id r196mr2116284lff.22.1582807580660; Thu, 27 Feb 2020 04:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582807580; cv=none; d=google.com; s=arc-20160816; b=Zrf5R2ANbWG4eHlkZHSboIwx/lfuWx5l3eUr5FDgOS1owkL3W08ivJ8vKjLIeuaq/+ 3n+BqZ5+1In5E5PpmUzU8gJRvz5q2l/O2ZLi8GbgaFrfrpDn+RoW/1EJfqsYz+H94Lz2 w+ZBWz42l94cKGnp3hOmLgttGM7RFuKnYlRdRf/IfPzDctg/2YNKtAYMhBuoyto+ec8P Ux9vVp7q9oIwvZpQfJ80EjvcxxUvyw4NpRSH65T5XLhZu96bzVRu3yC/4xq714pAQ5N6 vvo6KmRE2zH+rKj89EiGSwhb0plsAOxjd7oB8wt9S2oZdacNsFo7dbfjTctiMWoKMtZU vb7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=NROpLkqIKQsmOxVfnI3TCB5D/se19mcdjX7Jsvn77Ws=; b=o9TWd5ueZItAaXrUD5CMf1mP/m6lwebrmOpd+zVUTNc2alZON6SJ5sYncksdr+f0Kn FSv7x+4jpnIThiihtJm40OhixjoX3KgK/JR2zi/Iaqxzsxi/Dhd1RbuxKltrXhQOIE1p HvOwfRdp9rMRdifvEb8oJyY3N6n96IJkprF/nvNoa+HMoiohWEzmGnILJu2CQu6qlP6u tfQvfbq4lzM5RV8O2W2Xotz1DzJcnkGZ3865X3rkpMhAeeBuPl+OZUt5l5A0yzzMCEY+ bPUv5YobULH/p21nShL+yqfVR7FBdKPmJMYFAbghvBYnVrp1nxa+SginZRiLVOKOJxAM Tvqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zJlxUbiY; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o28sor761009lfg.2.2020.02.27.04.46.19 for (Google Transport Security); Thu, 27 Feb 2020 04:46:19 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zJlxUbiY; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=zJlxUbiYhFoF+ODVDIvKjAu386tBZM5zdC9FOjCrrAN13EelHbSprIimZNdA9DUoAV HkDCSE3OSDzA5dNryQ2b9btHIUkJRTlRng1zEMwkc+XwCHscftdZISwd1pqrl+BwtHqv GlD8ZaB9R1oX1MDCPKIlITtO4YG6dJh7RZZAOXumSZkEOwCp3JhVK/bpllsEEQrzn8k2 o/gU2N6cqqB7dbSwPiqnkijOTNTasogux6I/C8ZWBKKFy9gM8lmYh4TTcTBQQJ/CxsrM XWv6ndjECgFxLLJ/1x/6NU6gCzaV5JEcxLS17mV1i0dmQtSDVdQQ9/QeAcybUpkrhOLN /DaA== 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=OaUvePD360LHylkYniO6BTsnSwmYUy6ChE97siy941f2Ui8Aky9nmiXrPT7o+76eF+ L0OiP90mIqaIqnB+bI+ujAoVsys3ISdi4x/coG4vFTsltAz+PykLF6ahasQTcv/bfWD2 /GiriccNe7mFzW3Mt4nyzi9btYi609t4P+jVSNELOJXEmA9svbhGdk+laDeFA2RfrBs7 UaiQYcLEhLC0HHOQPESwHHArP8nthPa5/w0aYRaWmvc+C+hPKPxyC3V5jTDTbvBWaGsl WQxSe++r/gMgkPVB3jT3/0aTJuqFgIwMIKzZrGDFddHCDlgtoBQK+t+7Z3QhiujMM2g8 Vz4w== X-Gm-Message-State: ANhLgQ16qtigcQanZljM9E7aOn/1eufSHX3MlukZY3zOStS3F7mio5hf Pyk94exbath14LoSOMe1H3kY6+0N X-Google-Smtp-Source: ADFU+vu8QOXDccJ4lKeIOMwWimtNYjnsyBTcgqPyMEimE4UADfTmMgToy/05O3pHPo7qI+ThXa9XeA== X-Received: by 2002:ac2:4a66:: with SMTP id q6mr2085068lfp.16.1582807579162; Thu, 27 Feb 2020 04:46:19 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l16sm2669334lfh.74.2020.02.27.04.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 04:46:17 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] cpuidle: psci: Fixup support for domain idle states being zero Date: Thu, 27 Feb 2020 13:45:49 +0100 Message-Id: <20200227124551.31860-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227124551.31860-1-ulf.hansson@linaro.org> References: <20200227124551.31860-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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(+) -- 2.20.1 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 Thu Feb 27 12:45:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183948 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4469120ile; Thu, 27 Feb 2020 04:46:24 -0800 (PST) X-Received: by 2002:a2e:22c5:: with SMTP id i188mr2845563lji.34.1582807583999; Thu, 27 Feb 2020 04:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582807583; cv=none; d=google.com; s=arc-20160816; b=sKGmk/s/ktTmla4zyUC9uO7SNr8uoWgA7gdIsSdmpffYCu8Wb+57tgEseRESd4yXkm g5MOAPaQRTNTqaSdMPRJIgEuNqzS5R9wJOUO0NEMC8+lH5UlSSZ03DasdpFqE4qOw6/T 3cVJfkExrQ7Kj0jg52Bg+VwlRRj7smmw8EGyKchEVmUFc2tHImrKdcEkJfrdFbx8D2L0 Ah+RDnll29UtayEeaQj6VujfD7zHYD2icwGt4Ob5nDEMY+Lt9ZOv8Z1469uNFtn0ae+8 g8Hovh7DWOR4MzgK4WgIhTceAB7A/Iw0iEfh1xXhkP0N5qfiG1SoefDuedm6Q6sdTz+H 1LKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ZPYRIg41YwW5y7gzBIFCCQYc7BuElmJfratXvS9/RTU=; b=w/tbOw1sNjYTKsPbDQFVayqX96q17rsYKd41KDXkKo3xSqi8ktJ2C8JR6bs9R34Fh1 s7+W0n4fqIsYtPlnj/nwF0LsXO0lYKZPNTcWD8d/Xh9OsgH6SItj1mr2Wd0aseiMpQSj 9hIvtUJXCodwEjtSBxFXXDkuL3Q1nEnS5CHHYthxuFJp3OB66a3WSviTq9FTu2MzJgMy QJdxSpAa3XUBX7K9NcYqBjsbkeyg8Et+carEJ6aOfy+5L+OmmjPuziFeBEWxNXFqEQ/4 jYsYEzhE89lywH7OnBRN69n4ZC13XguIw2MGFexvmmBWTQEC1h93imunO+RI6LUKQaYW ZJEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GRMBtDnu; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y206sor748743lfc.7.2020.02.27.04.46.22 for (Google Transport Security); Thu, 27 Feb 2020 04:46:22 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GRMBtDnu; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=ZPYRIg41YwW5y7gzBIFCCQYc7BuElmJfratXvS9/RTU=; b=GRMBtDnuFIHhKQLNR5bYnf0YeAvzu8Lkr45VhsfqrQDfegayFVkGEDHxmkTQbBM127 d0GGkdb82XKNRJ+F0B/Y7uK2QtkhbkfZmBzDRNEW6o1VKKoUgSaYFLuKaD6kIzusy/rg VlObzJ6OLnbrt7IhkbLN+nAxe8wDM2LT2gZCSH+4Pib6NlW6ItxKWAWYb2xtBk5FDUQT KJMjc+wYUwfzW8jO13sOV78g6kTWdJn2sAcNBULDQIhQ5JwOsvghkPFsog4VDoMa2+3T 6TmnBYL2K1XcXcMwVwiBUOdbZUS2b4DvOfXDcQ1w17MtSe8UwPRJgNyllErCUf8gBaZw iXKg== 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=ZPYRIg41YwW5y7gzBIFCCQYc7BuElmJfratXvS9/RTU=; b=Scc/Sp6llQNddXxz0NOyqILII0DdRzbs27Av6Jpkk8ZUE4PN8xqRJMSpJVd7XwBl5K WUBuONkLdJnjnscU1g9TRU9yISiKzcQJg48FANglPgS53OV/rQYH+kL/Mw79pt8HYLbv 2nTwK25HUSlb3CYXcPC+kAs4b98BA6cip8W0ormhY8wSiIfQg1BNF+K+0tZ3x/mleeqQ T170hXtcaULLkfhXWrnOMWmgXZ5a/vPrQ12VkyurHUjwHAheAPjhr4F3fL6jdJi2Enbj tDbS+4ZAJGANuQcwvohRZdN1SrPkKauIdtvPpdbvsMtJcWCRP4XqKyq7dWwAIO9Kr1hz OCmg== X-Gm-Message-State: ANhLgQ0O+TVoPz9hGTkcbE+94/w9Y5fVdf51KWXnidXtjGiH2imSj368 zs31VcyntxlQsTQp+aIU8dmfjTua X-Google-Smtp-Source: ADFU+vvy3xadzFJgMR579KvBJp97cg/u1LNr5iTXRd789EXBWJ1RL/VY1A+sJYMUch7iOHDB2kfK+w== X-Received: by 2002:a19:6445:: with SMTP id b5mr2044742lfj.187.1582807582480; Thu, 27 Feb 2020 04:46:22 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l16sm2669334lfh.74.2020.02.27.04.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 04:46:20 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] cpuidle: psci: Split psci_dt_cpu_init_idle() Date: Thu, 27 Feb 2020 13:45:50 +0100 Message-Id: <20200227124551.31860-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227124551.31860-1-ulf.hansson@linaro.org> References: <20200227124551.31860-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 --- drivers/cpuidle/cpuidle-psci.c | 49 +++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index edd7a54ef0d3..7b459f987c50 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -160,6 +160,32 @@ 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(data->dev)) + return PTR_ERR(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. + */ + if (data->dev) { + 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 +219,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 Thu Feb 27 12:45:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183949 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4469190ile; Thu, 27 Feb 2020 04:46:27 -0800 (PST) X-Received: by 2002:ac2:5a05:: with SMTP id q5mr2052906lfn.143.1582807586930; Thu, 27 Feb 2020 04:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582807586; cv=none; d=google.com; s=arc-20160816; b=tn0zIwLVRzk36y3ME1qRuZLw4aSpmki71o2/VFeIfMvxMPynV5fDEbJYjEBUJqamSr NMNdREf3lrAbEyyCzQtz7dPM52/9v2exo3UJJxTYmRrJJvO0PbTrhnu65LZRSOQqQEqI 7SaJqntRiovFWwZ3ObUGQ3QpYXHWt9t409zlpSsomxPzeVY6FisrnxvQcCDsx/hiJS1V U3NGRHwrUB9khxEjCg22FTq8JFXxQtHSEI0wMJjo3q+ykFiCwC5Xuk4O1pBHsR1wafz/ Zxds3OwIXLi2gKR8lKiGYkW7XJHtjp6hJCOxOy0PJMn5d3lZM1sjxksBDzdUfnNpSN8D 3ADA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=QTt6UBxA6W5SX+1ICKiklMI9uA6M1ZbDrJNq6V8cSwg=; b=RzmjGDIHmakZJNcIG2BKSPdlSMpR18kWEKYEXT/pujddsA2adVYVcKCkQakNHZ6vGF ze0c2jMPUS0U7zAR4fw9JaX89JefOk1nWCPIHhPsWtFAZ4Qi/wAjfzDm/wNjQZoaKzv8 xed8hrHiiThtZPDlQqzzy2wFML6ThfTIKqY38/WHMXGCsq264cMKl5YN2A8/r25XayJQ p7bSL+1vvo37gN6UCmndmoDK+8+BUAqkwVYHFoDruxKfPtHAFuVAMYrMLHqMDolhVEaC wtAyKw5oGWOZidXc35IRtYbQ3dBaOFkai4SjEMJxMl2oK2HmO2xpv4A+1WyynKZdGVf7 kaBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xFBxcPAE; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m10sor1950279ljp.0.2020.02.27.04.46.26 for (Google Transport Security); Thu, 27 Feb 2020 04:46:26 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xFBxcPAE; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=QTt6UBxA6W5SX+1ICKiklMI9uA6M1ZbDrJNq6V8cSwg=; b=xFBxcPAEgZhFSYaozHLmDlFYl2fFzeMwv0JES7iXa4HWNnguu8lRelP1AwlGXLi4Qy PXZ2IGeC7mCYSD4xntHc/sAo8J5Xel+aewoQbyw+hhIROWcalIsqchcyI/nUDI7+Ezjn gRfLnTl1Dnu9W+EwekxM1i0OuJAZi1egMepLusHNJCyyyYFrfOM6GaB87hkHSQ2rX5k3 wZs1KJyTfwGRQadAaYQh24FuXwXLM4Xy/JcfzQbiH+NNGi6AVVG2pqzCOzf75aKeuNSz H7aSSCv2FmrbgwHqn/ZfbZIxSpHqAmmzzMwLxN5arR4pyQyUL8ZB24l1u39rCDrlIDGz UqZA== 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=QTt6UBxA6W5SX+1ICKiklMI9uA6M1ZbDrJNq6V8cSwg=; b=Jg4Q8kXmmtcVKW6ow4OrwztwD+zR7j5FRLzg5p5PKdKmWoWYl5tvANkm+35ZeQgPas EsDrvsJZsogKnkqjv57IeGa90WAjJKl2P7CyoMoTL42ZAzT04viuxZAydBucUurSS5Yd yB9KsWvaPNurdfRklAi9Ihc2ZeonlSccQE0L39I4LifqqEMYW/I7g2sM35UFtBuDYK1+ aLUe3wvJAkx/FeWrUZAZOStAH+qUmyNPbG2gUieN6DqyUf50yZL8mZkvieBPPwYE8FJ7 diu97w9gECq+CfR08LzgEa8JhAkifB9v6tgb1xiGZNFl0HGl21xuGV1CKmOL4B7VRbGG pWwg== X-Gm-Message-State: ANhLgQ3r7kFithaioM9lKPvi9lSF31GDkuWPPvLsbtviMCdd8LG5N29T 4V384FC9WDzxevGK4xEfc75iQxdL X-Google-Smtp-Source: ADFU+vtahVhqQemAkBHrVNd22ZkStLpI5Lit/jghKpl6hbLD66xlZ/d/3Okl8cC8HxMB8genhlJvdg== X-Received: by 2002:a2e:81c7:: with SMTP id s7mr2781657ljg.3.1582807586339; Thu, 27 Feb 2020 04:46:26 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l16sm2669334lfh.74.2020.02.27.04.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 04:46:24 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] cpuidle: psci: Allow WFI to be the only state for the hierarchical topology Date: Thu, 27 Feb 2020 13:45:51 +0100 Message-Id: <20200227124551.31860-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227124551.31860-1-ulf.hansson@linaro.org> References: <20200227124551.31860-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 we did before. 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.c | 47 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) -- 2.20.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 7b459f987c50..7699b2dab622 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); + else + cpu_do_idle(); pm_runtime_get_sync(pd_dev); @@ -181,6 +184,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 1; } return 0; @@ -195,6 +199,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) @@ -226,7 +237,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); @@ -285,33 +296,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;