From patchwork Wed Jun 20 17:22:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139369 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050332lji; Wed, 20 Jun 2018 10:22:37 -0700 (PDT) X-Received: by 2002:a19:9b49:: with SMTP id d70-v6mr6872886lfe.137.1529515357368; Wed, 20 Jun 2018 10:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515357; cv=none; d=google.com; s=arc-20160816; b=P9V7fgv+dG5y9XkgosvH5XKYHRR6pYZRhlu4iae7MkwxhMzh2C2LNeG95P8zULa4b7 EhN7UNFgmr05USkLYVH8hC508r70/TphPMXE9RT62zCvxf5lGBtql94pPfddQ4sdegHt RpLKkWiurQ/0/zCVw0eRv2I4UGJCEkvBiPTVZ88chkjUPRInCVGkFwTJlbxtxsaOepea N/oWQxbp8TBGkH9V23oO9Zc+Vo2V5ca+17xWSmcnRl7gA3rNCByspcXasw3fVzQTvQXs I63Lmw48jw9JI3yfIP4K/iQb9GKlsZdqavRk5FuSGODkpZOrddlc5/hZSACmvcygr8iu phOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=t+XLgWjK4qGNfGNB/J4glH0F0kJTpHUPhquo+uVr+2M8Gur2PiFmfYVI4CNPyDoHpA +Ey3gCso/Nizu9Fr6dHdvTunCC1jE40bBrcVpxaIfd9EgSZk0fJz8uoeiI9iphQl7hs7 Qxg+Q3GXWRFnM2JZPKsr5UlyQELnODgURj8SG6EZy7E3bnHW6gXYUmGl22X94Az+MXHl cTmgEu4DLSQqYXSUU3ojoz/2gdwcwNvoSu3VVVxZUqVq7GBB4Y1jvVaNFfVTPDu3PQpp s5BibtB/oWlvDjSbUMCWMHJqxw8JE5dzjAQlbaGafeR20dY68NxI0A+IXgyR1vQESYmC uliw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EF2bvCWY; 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 j22-v6sor733400ljh.37.2018.06.20.10.22.37 for (Google Transport Security); Wed, 20 Jun 2018 10:22:37 -0700 (PDT) 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=EF2bvCWY; 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; bh=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=EF2bvCWY87O7+fzTccjACc8uQ+tS6c1h47qU0WCLNE9BXDGDpA92Y+fa8fUNP0zlAn e1WjcPxKWKGFzqbDnJ1+i7Td/Zun5dmHEFYKseWWNCltTJu/QpSgKmKyjEwsnVloN5Ed URm3HgPUxaZXrnYKuvDuBJW2EHSlMzaWcJp+0= 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=Ta+r1yNZdCXimBKhBsWVqn0620vMogcKiWR1qFWwX9o=; b=opSsIn96I0PbrY9K74ShA+KteLuXELdMP83Maitfgcbk+dd12e/7LsVo60s72IWpSm Se4xzm1+GzMTohOZcV006YPDL+qYiRy4B/LTgVnA2RehU+hSwo0Cj2eWdztf20DcyVkz 24vB3w63OWQtkpedBlP9Q1WVBH897V6GYCDQFwrQHNiIFf+HDgfql4LHpfdcNpLG9Fv6 Cb2sNsClLAdhS1ISRBqcOvgm72qqhDzyE/qDqUNfvALs/MHW057m8WHwiCQceJ9qO9DE avz1AlI+mwagaU6ihxR/p2BX+zwx7O6NtvAEpiFJpGH7y6KFP81hDuyyZuypeL1klkYh TA5w== X-Gm-Message-State: APt69E36cS0GUUIg3bmpir7zFPNJnkV1JoraDJK/GXd/TnXpHHymMHS5 JYUeor9VBw1whxrZL1XAJZV9QUUG X-Google-Smtp-Source: ADUXVKJyxlvSIFg+/7EwbEUN34YH+vPDjyjo+9LB6G2f5ADATsPe/le1yelWM3DGCZZIG5bc1+t24g== X-Received: by 2002:a2e:750d:: with SMTP id q13-v6mr14482924ljc.56.1529515357131; Wed, 20 Jun 2018 10:22:37 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:36 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 01/26] PM / Domains: Don't treat zero found compatible idle states as an error Date: Wed, 20 Jun 2018 19:22:01 +0200 Message-Id: <20180620172226.15012-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Instead of returning -EINVAL from of_genpd_parse_idle_states() in case none compatible states was found, let's return 0 to indicate success. Assign also the out-parameter *states to NULL and *n to 0, to indicate to the caller that zero states have been found/allocated. This enables the caller of of_genpd_parse_idle_states() to easier act on the returned error code. Cc: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Lina Iyer --- drivers/base/power/domain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4925af5c4cf0..62969c3d5d04 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2452,8 +2452,8 @@ static int genpd_iterate_idle_states(struct device_node *dn, * * Returns the device states parsed from the OF node. The memory for the states * is allocated by this function and is the responsibility of the caller to - * free the memory after use. If no domain idle states is found it returns - * -EINVAL and in case of errors, a negative error code. + * free the memory after use. If any or zero compatible domain idle states is + * found it returns 0 and in case of errors, a negative error code is returned. */ int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n) @@ -2462,8 +2462,14 @@ int of_genpd_parse_idle_states(struct device_node *dn, int ret; ret = genpd_iterate_idle_states(dn, NULL); - if (ret <= 0) - return ret < 0 ? ret : -EINVAL; + if (ret < 0) + return ret; + + if (!ret) { + *states = NULL; + *n = 0; + return 0; + } st = kcalloc(ret, sizeof(*st), GFP_KERNEL); if (!st) From patchwork Wed Jun 20 17:22:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139370 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050379lji; Wed, 20 Jun 2018 10:22:39 -0700 (PDT) X-Received: by 2002:a2e:2d11:: with SMTP id t17-v6mr3025120ljt.145.1529515359676; Wed, 20 Jun 2018 10:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515359; cv=none; d=google.com; s=arc-20160816; b=kEwnSce2cmW1c5tkBvXtIrUrzeCWGg0J16W79KBbG529gaCeRm9Urg99Hb2mExsk7/ qVksZiH7Ho63CzU6LLo05DEqMxsuBvikURY4qp8W0zupd7tVOkoD4kK8uyEVwoFZ0ddr WfwUgsR62ECJ1b2TuyJernKCVd3Wc+g7LtRp7dISqR66zJyjIycOwPh3dle869CBomE0 Od0oWZM329qAWVGsWg6bI8mHGfmFabhB+NcybICL8Pizq8FfIrtma+eMA97RCAjSrCzA uRH7JZoCrSWEQpk1kudUfsvQ+Qabqa7LIyqKpu/aTuTLCr5wQxM6xz2Ewm+zqkywZEh7 BU3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=BZqpdm4C3crCBCfotBf9OcWNkhZg/AfpeooWj+mQ4ng=; b=0sS5BkDqQPVsvtwtRqSIy5NkyT1UYdGOtiofwIZoi0tSw8dBic8FjsKfLpvCuxsNrX 2t2wA+2fMwuXD/fh56OAiPhjk/tEx79W5d+YCp9M93q7KxGOecDsHYvMmWWKhNynOztl XzeCsMauT522pSgZX1ETBFKSCJNp+XZuweSXTNmoKAUweQbwZtr6S2mxbWbrBJUwKA8w GZr6WLuuqV9e9N0SJ11awt9O8p4MET4SxuB6UATxbGqhJDjSX1XGwE0H3twXIqWEZtd9 07bNbHvmeMXtAvgULQK0x7OOatXJYhyE+Z2qleEQurVdTr+1xA4fWM2u3VH+m5N277QW ZvXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HuZKqg5P; 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 c19-v6sor679894lfb.93.2018.06.20.10.22.39 for (Google Transport Security); Wed, 20 Jun 2018 10:22:39 -0700 (PDT) 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=HuZKqg5P; 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; bh=BZqpdm4C3crCBCfotBf9OcWNkhZg/AfpeooWj+mQ4ng=; b=HuZKqg5POieJbocrPk9ygoclVSJQuhhEuFrRfV+4xXpfR9GYqCiSTE7nQU8vuMEqZW 2DiX2fjdAa8dUMsMo+P9lNOfJ3Md1XR4lvfQZ7nNwEMUtR2o5XTyDvE0MaVgEzKdmEGU 9OB3SEj3oB8gI4wqYtPMvfL0CoiyoZnb2ShpM= 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=BZqpdm4C3crCBCfotBf9OcWNkhZg/AfpeooWj+mQ4ng=; b=HtPquqTpSqiqendHtYuHNUXIYHlUPMOSMYa3nRDQlL/y5W8mQQpfzu+vl38NnYTT+V 0x2HZBFzVytepooeocAvSDVQKZ6Zv/+Lbwq1LMaR0S7Eo2t196H9jodpWVeKgrYyzNSs jZAnkP0N6wEXXv7FP3TsO5ZxE1LuCHGkLADx89pqcN1uRZ8ju4S/Jw43+93KRvBU9xvG BfU+3kGgSvGxFWf6qvLlrEMRNNxnoOIofX5NbwKFnmWUJdIs1+TiOCrZBi228taNR+pL 2rfQ0uscxp9BlDoojToIooAGYUdPgdgr9hww0g5EjL8n01Ki8J1prwRtjJdJEY/cKIbY KAzg== X-Gm-Message-State: APt69E0lOa1111o7CMCdId4NKyo+0SaRtuWVsG2vN+1HxsGwyT6zB02R nf2xA7CrDb/zUmm3PxwsyRoUi1Du X-Google-Smtp-Source: ADUXVKK38wCwZLwB7I+7b8fn114FAubC4FEf9GTEb8eTjTSMDF6qQC6hOxWLaufsFg64ot3ikFni4w== X-Received: by 2002:a19:20c1:: with SMTP id g184-v6mr14014452lfg.96.1529515359346; Wed, 20 Jun 2018 10:22:39 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:38 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 02/26] PM / Domains: Deal with multiple states but no governor in genpd Date: Wed, 20 Jun 2018 19:22:02 +0200 Message-Id: <20180620172226.15012-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> A caller of pm_genpd_init() that provides some states for the genpd via the ->states pointer in the struct generic_pm_domain, should also provide a governor. This because it's the job of the governor to pick a state that satisfies the constraints. Therefore, let's print a warning to inform the user about such bogus configuration and avoid to bail out, by instead picking the shallowest state before genpd invokes the ->power_off() callback. Cc: Lina Iyer Signed-off-by: Ulf Hansson Reviewed-by: Lina Iyer --- drivers/base/power/domain.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 62969c3d5d04..21d298e1820b 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -467,6 +467,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, return -EAGAIN; } + /* Default to shallowest state. */ + if (!genpd->gov) + genpd->state_idx = 0; + if (genpd->power_off) { int ret; @@ -1687,6 +1691,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd, ret = genpd_set_default_power_state(genpd); if (ret) return ret; + } else if (!gov) { + pr_warn("%s : no governor for states\n", genpd->name); } device_initialize(&genpd->dev); From patchwork Wed Jun 20 17:22:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139371 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050410lji; Wed, 20 Jun 2018 10:22:41 -0700 (PDT) X-Received: by 2002:a2e:29cf:: with SMTP id p76-v6mr15789080ljp.12.1529515361226; Wed, 20 Jun 2018 10:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515361; cv=none; d=google.com; s=arc-20160816; b=msKIDfWXc1jlwGo8OQ37f1ivEPDjjgV5JPvJ4iXNM8MDhhKCoQsGkpropAlvftlQfk nRTJlDTBvnvFOtszU3pKVBapfKvOOeI4V9oR/N6spHw+YSLtAyWSRxfh6izGz+/av+9s BAIGBlTjmffP08P4dx7DklrUQvXfWpHEKvXEj2Jhjk8Edg0HDm3Jj2IeY2eWHm3xG72n cDnT6HA9fgMO73l3isGIsFvXukpyQBTCU89Zew2OfwhwOLFozQa5R5CmHr4uxK5MVdQ6 7Mvt6CQYc7w+HR5Iiwtu0qmPmgnmZBL0bTRMbk+o+G+Fd7Kh3S6w/szwM41vvNizgVtP tIng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=nn1c8Fl1Sgoee41Cdb6s6AY42Oe4mtKXW9dEF2Qclcg=; b=VKizCE6sgXXvaHX9EHHNU1tZwPpYeBWD8U5uXI1f5TD8gGTTlB2Ryl7U0infrlCXCW z1v7j0xGYCRmH/U0gowg39RzR/LcxAQqJGgfiqyDL80rnW5bNZnrQr3UmzttTYslbB55 AG56Pto7OGYedazagFwIebssGnbC99oTkkgrYOPQquJHMIyQX/OQdjrQim3zPyPeu3tP /BOYn72WUnRHDPM3UdwChRcwuI+vq5Zqtl9O1iYPYJTkIHPi41fn6HANgw/N2cGz7oET mhofdFdw8V1I37EmaOfcgF65oA2tVzUyytmm6DmY3x88nlanTMssl2GsdphUBjUvuReU fycw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fms5MZh+; 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 l68-v6sor480388lfe.32.2018.06.20.10.22.41 for (Google Transport Security); Wed, 20 Jun 2018 10:22:41 -0700 (PDT) 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=Fms5MZh+; 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; bh=nn1c8Fl1Sgoee41Cdb6s6AY42Oe4mtKXW9dEF2Qclcg=; b=Fms5MZh+Y2NcSUQLJvVveQhOzXD9FJ9G/WS/pMfGFfAUOcdghZncGQ4QUcrTfiDHjG s2YHhha23J5+08pidu3G24Vkg+/C4+xmFvoJKQbQU8oz864aHSKGBBacDTfWGElmm00o SbDwCWScWvHyM0uj4Iv4vQ5gQpncl6f+1U75I= 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=nn1c8Fl1Sgoee41Cdb6s6AY42Oe4mtKXW9dEF2Qclcg=; b=PsdWUe9k4eRV/J9IgTVHeWiv5nFC4siEz6TfQLduJgBS7cBIi/9c74injJbgWUQKpU fPIt3mDJUKjbeNRBh5IgnmoZZNTNDCoqe2PRboR6KAX329sNAl2RMXJiY+I5egdWzE3D tLjVuBcBVaFE3c0qxo6THYTzdc1i4cm3AQmroiRYlgdI9eBsKzTDL1u7JpOFcigNMraw xo/2G2xvomn17olUlDyATl5/wev9heMjq4sN5XyzW2UW+dImF8oK4RhuGoB+QaN3LHNO MIV9muvnpf9GocGXlLziDZjIOnn7m9H2b+BcJ8dCohuD027EySStNv5YF1+jh4nMOZNG j3Qg== X-Gm-Message-State: APt69E3RrCfXN8Mhbc6sR6DCAa1xl3rLHL9NZQ9vdWlig/5t1Rl1u/NX pycJn/EqKKGWfVs4l8NHdDnEI9Vk X-Google-Smtp-Source: ADUXVKIp+MmPDN24YhDdaNyV+1Ej2navlR1CYNT8tfon9FH0v9XjFYh6yVpaxHrvw4RI+dky1S41Gg== X-Received: by 2002:a19:5943:: with SMTP id n64-v6mr13137400lfb.107.1529515361033; Wed, 20 Jun 2018 10:22:41 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:40 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 03/26] PM / Domains: Add generic data pointer to genpd_power_state struct Date: Wed, 20 Jun 2018 19:22:03 +0200 Message-Id: <20180620172226.15012-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> From: Lina Iyer Let's add a data pointer to the genpd_power_state struct, to allow platforms to store per state specific data. Cc: Lina Iyer Signed-off-by: Lina Iyer Co-developed-by: Ulf Hansson Signed-off-by: Ulf Hansson --- include/linux/pm_domain.h | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 9206a4fef9ac..27fca748344a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -44,6 +44,7 @@ struct genpd_power_state { s64 residency_ns; struct fwnode_handle *fwnode; ktime_t idle_time; + void *data; }; struct genpd_lock_ops; From patchwork Wed Jun 20 17:22:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139372 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050445lji; Wed, 20 Jun 2018 10:22:43 -0700 (PDT) X-Received: by 2002:a19:2216:: with SMTP id i22-v6mr12532693lfi.136.1529515362972; Wed, 20 Jun 2018 10:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515362; cv=none; d=google.com; s=arc-20160816; b=Ntoj9RYxPuGvDDNFbC8tY/XHL5hRkFeqNkRlEDLegA/4wUmrmAIZfWZ4tR70xRlC1n qeGnp95HKAdHzzRVfHpILWSCpmxxBFS6p5TD9n9MuHerR690HJxdPbTG1qbIQhgV1B9j UV6jIzE7sz75bBUBSjCH0PvLTNIqZX4U6SGZIZNthHA1dQ7jnjV7a6zc3NKpZqauGCXB WubDvdae7Q8tdZNdPnwydAWLuxTFm9aYT+ohWMG3IrHd99D02AKvm7ZjHvCWm1cxWZMN 2QCJnxBiGaygFjg1C16MWYFj+tkJwnSAyam5iAPSPYnlg5FsxPe+c8srlPBA+hD5MCtX aXjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=q3sBFx4bDLVEE6Yvpy9kVMF3vWlpgdg6YBSbLYqXsME=; b=Ldwsd/zfHLEWxaL+Lid/Hm42hZvEFh88q7nyFOBgl3GmgOkEeCVV9b71KdkT03sLR2 yb4me8nqbGpG0NjF/RQQdG+YxtHZ+L/xom8125v5ttSuc9D7koJUEO1MHuygGiungqRE tUMQbSNcTHiSN3bIGI8Kj+H3ARUBlOEjik553kfb+iwhLFiWsPFCc5QzwF9SM+W5iBQi pL2I2Lafwe9HmOlVXekgkbXvvcqRaikK5ai5hIilx9V6JL8ZlmsZ9mTaZ09fI6DXFbpq 7V8MLmUygP1hJEgizwYA9S9wLIneD1LXBfV4PwmWKS2gFI3Sw1XbmcR2QhOv6yH2BWQv v00A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e/XMLeMl"; 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 v19-v6sor678980lfe.36.2018.06.20.10.22.42 for (Google Transport Security); Wed, 20 Jun 2018 10:22:42 -0700 (PDT) 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="e/XMLeMl"; 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; bh=q3sBFx4bDLVEE6Yvpy9kVMF3vWlpgdg6YBSbLYqXsME=; b=e/XMLeMlRx28jbEDB7QNTC7AZ+tIR885ZpI7S+nl9KRtbtMETY2CF2Pv+JFE1mweSe 1awjv5ZZJLYqTVddil3Hr7LCV3KHUgjjmPN5NSdSkzFsMaTzvaOXTGE/J9DXGl/0DfgP 4FBSc+VNLZq8otJedKQjH/MWqJZUvu5tbL0v8= 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=q3sBFx4bDLVEE6Yvpy9kVMF3vWlpgdg6YBSbLYqXsME=; b=XfWX8qJpRfYgh3jQ6dYPEUJGV3cp1K9QHu2Bibv2t1kVYoXGMgpG5ChAMXm9y2S+Ir f26muZBkFEdGjEjuqtldtuO4Y9f5v2CdSDo7TB2yK/+r9hqldxhPPZYWobFc3nyjdhcW bJMNwhUzdy1h2KewZ2nt4K0EtosSn8N/vV844AbBQXQv8z4CP6V2eWGQdPYRbwmnTHUm +TRP5RfVoDqj15rBbPHHaLlM3qvb8chNaEHrf9/L/xxi16JjZ76Y3R94CMRgVXh8hZbe wgmhCYCDzBTl6FOgfUBe9iZzfkJdHHuCCPLQ7MMkqJ5l64Q2jkRBofbS6dr/6GObZfFj +Hqw== X-Gm-Message-State: APt69E0NxweZEQt+f63k8ouvQe69q0LXi3PUXakeA6/IQz3xn4sjwC55 bZluq1zhV2CFe+edzPBxrbcq3xy5 X-Google-Smtp-Source: ADUXVKIp3AXtOaz03IpCwOZ9IQJrq2qZ7IYsLAa/KRT98qnsBHyHNXYzDx/1n/77pq4H37AKTRzMdA== X-Received: by 2002:a19:6550:: with SMTP id c16-v6mr14358137lfj.31.1529515362666; Wed, 20 Jun 2018 10:22:42 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:41 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 04/26] PM / Domains: Add support for CPU devices to genpd Date: Wed, 20 Jun 2018 19:22:04 +0200 Message-Id: <20180620172226.15012-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 genpd as to make it convenient to manage the specifics around CPUs. First, as 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 'cpus' to the struct generic_pm_domain. At the point when a device that belongs to a CPU, is attached/detached to its corresponding PM domain via genpd_add_device(), let's update the cpumask in genpd->cpus. Moreover, propagate the update of the cpumask to the master domains, which makes the genpd->cpus to contain a cpumask that hierarchically reflect all CPUs for a genpd, including CPUs attached to subdomains. Second, to unconditionally manage CPUs and the cpumask in genpd->cpus, is unnecessary for cases when only non-CPU devices are parts of a genpd. Let's avoid this by adding a new configuration bit, GENPD_FLAG_CPU_DOMAIN. Clients must set the bit before they call pm_genpd_init(), as to instruct genpd that it shall deal with CPUs and thus manage the cpumask in genpd->cpus. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 69 ++++++++++++++++++++++++++++++++++++- include/linux/pm_domain.h | 3 ++ 2 files changed, 71 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 21d298e1820b..6149ce0bfa7b 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,62 @@ 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) +{ + bool is_cpu = false; + int cpu; + + if (!genpd_is_cpu_domain(genpd)) + return; + + for_each_possible_cpu(cpu) { + if (get_cpu_device(cpu) == dev) { + is_cpu = true; + break; + } + } + + if (!is_cpu) + return; + + __genpd_update_cpumask(genpd, cpu, set, 0); +} + +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 +1456,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 +1519,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 +1747,16 @@ int pm_genpd_init(struct generic_pm_domain *genpd, if (genpd_is_always_on(genpd) && !genpd_status_on(genpd)) return -EINVAL; + if (!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) { + free_cpumask_var(genpd->cpus); return ret; + } } else if (!gov) { pr_warn("%s : no governor for states\n", genpd->name); } @@ -1736,6 +1802,7 @@ 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); + free_cpumask_var(genpd->cpus); kfree(genpd->free); pr_debug("%s: removed %s\n", __func__, genpd->name); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 27fca748344a..3f67ff0c1c69 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -16,12 +16,14 @@ #include #include #include +#include /* Defines used for the flags field in the struct generic_pm_domain */ #define GENPD_FLAG_PM_CLK (1U << 0) /* PM domain uses PM clk */ #define GENPD_FLAG_IRQ_SAFE (1U << 1) /* PM domain operates in atomic */ #define GENPD_FLAG_ALWAYS_ON (1U << 2) /* PM domain is always powered on */ #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) /* Keep devices active if wakeup */ +#define GENPD_FLAG_CPU_DOMAIN (1U << 4) /* PM domain manages CPUs */ enum gpd_status { GPD_STATE_ACTIVE = 0, /* PM domain is active */ @@ -68,6 +70,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 Wed Jun 20 17:22:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139373 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050481lji; Wed, 20 Jun 2018 10:22:44 -0700 (PDT) X-Received: by 2002:a2e:4dcc:: with SMTP id c73-v6mr14319561ljd.135.1529515364685; Wed, 20 Jun 2018 10:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515364; cv=none; d=google.com; s=arc-20160816; b=K92W4dNU4S7s4C2aL5CkWSJQOzw0++79xcTpOzz/YJT56g+jrSIba3rJTajJ4LvU9n 3nqhRPK67qxS18uOOn9o4LsTv5g4H7Z+N7IeFBRSfVYUhf1TX07lqsdMKi/LtL1QLdZ2 2i+wFQxcW7YN9SVM94vo/f/VUgjexgm/Dydk418OvGsFvrJjff49dTPAqKdwDxKg1+Pf YKzkkr0+fSM82knO6iIEyXL1YCrAvya4Yfl+1iejri5j3RAw4E9+eQRPKxoU47w5dDs1 KUL/+okkOO9xQ1qONyHxCCeUtfTqV2WeX+UlGikWiNMzyG3t1pTdcwsVpnsLB1MmtYTD ZSWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=40LOjQ+YPGx6FLKxOB2XtXKEBIZOB0eV+AE7c0B9P1E=; b=dWA+YCdyl41zhURaL6eJVsct4Mtt/B1Afpfs3sESnbKU0LFd4UFpflJxkSRyU9TaWG xFRFU0SZyOZ4ZF74znSHBQSNOy89GV8jl0/ohfITpxTyGQ13FgIvNHNGU5tEvzY6rM5H OX67jR5z/+l46vYuJoIlcU/E2RY/b1TX1EEjjZ9+XtxRVX9nGMc6Ulum1p4Ob1OEk9OX eu2JdsOp5QnrhxwIIOu4Ge+4hKW/BV1REJUZw9giEqHHzAust7N99xioePwrCyXthM8y dEgGZ+jjTihldrObh5XQaj/rdJiMJaxu3Q+wm55QzfT7n3H6g+/t5dQimqEkhpHvZJY3 U7RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aWFax21m; 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 z12-v6sor735653ljz.68.2018.06.20.10.22.44 for (Google Transport Security); Wed, 20 Jun 2018 10:22:44 -0700 (PDT) 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=aWFax21m; 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; bh=40LOjQ+YPGx6FLKxOB2XtXKEBIZOB0eV+AE7c0B9P1E=; b=aWFax21mb/OlcZ7istRxEXtPKUgExdCY0cZkrEYF2+Jr5f3yKt7cA4JqeDOe8p1AJY NNUJv+K8Al6QpPca5OFrRctUKi+y1W6JOcechSQQAEBT+F3kXon2QFO3P8WiL1gAl/Jp QxV1m/BbjaPYRQ1CJfXLnW72fnBPVUOcxglkk= 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=40LOjQ+YPGx6FLKxOB2XtXKEBIZOB0eV+AE7c0B9P1E=; b=OuVqguG9CH+B0OGJiMONlFzPMJVBmwfMAi9L2oGr2IOqPuL33sfyP9KXYpPt+o59I/ k51uB9AAiYp7nh6KsQfww3TJQ3cV1eWO6C6rLfgTyVtcyHpIUzxvpCdVnUAKKnRctEea gc1N3KEBfFrzufUmrulh7rtwahxATE1eUaEUQzbXOSgYiDYKPUhGGkA54DLRPfvpCM9t JOwBB1wZMJU1zBVLmxoDYZ+FlNEbUvADkmqxGAZxD8Kom1sVOaU1/ATFa0Rdy4ix9lLH y2hz29TqzbsGiQ9fkyORkKJ1o8nBBWQf/XF2kBtA8pnAhB3uDkzOWN6/zENI4rfncHi8 6Y1Q== X-Gm-Message-State: APt69E0jKJicUg76Pikr3+x7oPeha+C3xPeJ5fOsjGMAr0cYLT2/IsaV tMhNnyu9lVdf7UVP42bD6MjqvmOo X-Google-Smtp-Source: ADUXVKIIJjPRC5qpFFEOx8+I/8Zau9QXY7+lIPwkDkUPtNuVr2VDIS66YI54o1YXlQncriceQEnUqg== X-Received: by 2002:a2e:1d59:: with SMTP id d86-v6mr15375209ljd.104.1529515364476; Wed, 20 Jun 2018 10:22:44 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:43 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 05/26] PM / Domains: Add helper functions to attach/detach CPUs to/from genpd Date: Wed, 20 Jun 2018 19:22:05 +0200 Message-Id: <20180620172226.15012-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Introduce two new genpd helper functions, of_genpd_attach|detach_cpu(), which takes the CPU-number as an in-parameter. To attach a CPU to a genpd, of_genpd_attach_cpu() starts by fetching the struct device belonging to the CPU. Then it calls genpd_dev_pm_attach(), which via DT tries to hook up the CPU device to its corresponding PM domain. If it succeeds, of_genpd_attach_cpu() continues to prepare/enable runtime PM of the device. To detach a CPU from its PM domain, of_genpd_attach_cpu() reverse the operations made from of_genpd_attach_cpu(). However, first it checks that the CPU device has a valid PM domain pointer assigned, as to make sure it belongs to genpd. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 69 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 9 +++++ 2 files changed, 78 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 6149ce0bfa7b..299fa2febbec 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2445,6 +2445,75 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); +/* + * of_genpd_attach_cpu() - Attach a CPU to its PM domain + * @cpu: The CPU to be attached. + * + * Parses the OF node of the CPU's device, to find a PM domain specifier. If + * such is found, attaches the CPU's device to the retrieved pm_domain ops and + * enables runtime PM for it. This to allow the CPU to be power managed through + * its PM domain. + * + * Returns zero when successfully attached the CPU's device to its PM domain, + * else a negative error code. + */ +int of_genpd_attach_cpu(int cpu) +{ + struct device *dev = get_cpu_device(cpu); + int ret; + + if (!dev) { + pr_warn("genpd: no dev for cpu%d\n", cpu); + return -ENODEV; + } + + ret = genpd_dev_pm_attach(dev); + if (ret != 1) { + dev_warn(dev, "genpd: attach cpu failed %d\n", ret); + return ret < 0 ? ret : -ENODEV; + } + + pm_runtime_irq_safe(dev); + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + dev_info(dev, "genpd: attached cpu\n"); + return 0; +} +EXPORT_SYMBOL(of_genpd_attach_cpu); + +/** + * of_genpd_detach_cpu() - Detach a CPU from its PM domain + * @cpu: The CPU to be detached. + * + * Detach the CPU's device from its corresponding PM domain. If detaching is + * completed successfully, disable runtime PM and restore the runtime PM usage + * count for the CPU's device. + */ +void of_genpd_detach_cpu(int cpu) +{ + struct device *dev = get_cpu_device(cpu); + + if (!dev) { + pr_warn("genpd: no dev for cpu%d\n", cpu); + return; + } + + /* Check that the device is attached to a genpd. */ + if (!(dev->pm_domain && dev->pm_domain->detach == genpd_dev_pm_detach)) + return; + + genpd_dev_pm_detach(dev, true); + + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); + pm_runtime_reinit(dev); + + dev_info(dev, "genpd: detached cpu\n"); +} +EXPORT_SYMBOL(of_genpd_detach_cpu); + static const struct of_device_id idle_state_match[] = { { .compatible = "domain-idle-state", }, { } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 3f67ff0c1c69..2c09cf80b285 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -243,6 +243,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev, int genpd_dev_pm_attach(struct device *dev); struct device *genpd_dev_pm_attach_by_id(struct device *dev, unsigned int index); +int of_genpd_attach_cpu(int cpu); +void of_genpd_detach_cpu(int cpu); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ static inline int of_genpd_add_provider_simple(struct device_node *np, struct generic_pm_domain *genpd) @@ -294,6 +296,13 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, return NULL; } +static inline int of_genpd_attach_cpu(int cpu) +{ + return -ENODEV; +} + +static inline void of_genpd_detach_cpu(int cpu) {} + static inline struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) { From patchwork Wed Jun 20 17:22:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139374 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050511lji; Wed, 20 Jun 2018 10:22:46 -0700 (PDT) X-Received: by 2002:a2e:9516:: with SMTP id f22-v6mr14487515ljh.9.1529515366131; Wed, 20 Jun 2018 10:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515366; cv=none; d=google.com; s=arc-20160816; b=X78VNyettB7qhBXOi+SppxktW3+j1Zu82ueeoz6uq9YUrE9s8QSGfWiVOVoQ6t0rg7 k1LrPntKBJDaudpW6rxgVgRYoA7rB8RzIkBOya5BefnyOf+0j00KUCSBlBa+Skcmf9kW O6UuR77eaeeaWgRlsJpO6h+8Eq4Wi5sREGHcyoLp9/p9GRX/5SaeuJcjnns3MEsajYkM eC5nxZvQBOornQz5ECB96MIkSKOP/e+tqLaDOdnT+uw/Kc+bXup37KW0JRhN7nAU1W7/ /LeaCzFQFt8aC96cF4Z7Di16NIf1WKcODGq4OqSCG+liVWA8sWqA7vvBYG5HfbsI0v2a Zr4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=07ERcLm4/l9KBIvR0hJYkCSg/Ff9AAYnDyY4er6wGkiEu+Y6fnVcrFxpk61wgSE8GU UgvK5K5YHWLaP8EfcHuO5Q2MYlX95m9ywIs/3rJLb7AXjUS87dCoXr63lly5x0wQELDy O3Lao9CJUGY+N+oRvPzNQCBbVT5nrPHgvV2PL8YmwpgfcT13LZfgV4DFqoFDisCt97c8 rdHMGjqn6jm3czsaWt1Jd5ZsQOc0PlqQ6upu2/9N8BGspSWGZznCrOrjvlwL8BI10na1 uyyh+auRjtVaN9T9WRs7QYWkZsinhFDC2U34xcR1myexuBPh18GbD0uDTULAHJD+hYEr 9SfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dZi7K4N7; 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 x25-v6sor735650lji.41.2018.06.20.10.22.46 for (Google Transport Security); Wed, 20 Jun 2018 10:22:46 -0700 (PDT) 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=dZi7K4N7; 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; bh=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=dZi7K4N7GvETn6Hq9kRuFwIXXLI+F66+gwDmPH4DzgMvs0Pv1Eg4DTtOCmQQc5jjOg 1btH/zuEhKyYjPoJQPkRcfLRcwiISg6bRMbUA7wu0f3W4lf8UVMtybWTjIcedaEar8IH dFxJymLVGiVAWN2gIk6wVuXw5OqgwOlKgY6o4= 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=ZU7eQCdNUvVwVHNHQGUhwppj4DPi+mJPY3V/YyeaLt0=; b=ONHL24KhncCe/vnVD2YWkg/hEBvVfIRkyk7YGLiQNmmj6W07SiSV5GQn83ql8he8+4 y3q1bRKgZIvFHmGBtdC0FQU+bZHfTKzNi8ZC4Cm7xgd1jTbdFPsWKt9f2MdeVdJ0d0qj dFWk73PlVakKX9w50wc/HUTZFS3SCxV4AKQ9/27NsiY6N81ZnJAimH0B8f7/Xr3ty8dE MoFh3RnQaPk5+JDMYyV16hDtoft2hD4bEhdwwgCkF+2/+9LFUbvWXpIMpRs2zxhLdNeb g+45/4vcm2dBOL732ki90uhOmRssBGg9J0X1dh6LyAeiO798cf6GsZpXwjEA0m28VMlt 4r8w== X-Gm-Message-State: APt69E0aS4B6EJAL7gi7BpnSpfiojc1S4H3FRS5dc4kAT+1wLxsOyN9m S0fc43UQWzMBANY2x7kItvYzYJOd X-Google-Smtp-Source: ADUXVKLI5PAJJ9M0tBJGD4D4qY5SXbv264nb5hwS+QxygTGi2rPcN2hdXUkSOnAKqhPzvLQMt3Uo1Q== X-Received: by 2002:a2e:43db:: with SMTP id z88-v6mr14397880lje.24.1529515365948; Wed, 20 Jun 2018 10:22:45 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:45 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Ingo Molnar Subject: [PATCH v8 06/26] timer: Export next wakeup time of a CPU Date: Wed, 20 Jun 2018 19:22:06 +0200 Message-Id: <20180620172226.15012-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- include/linux/tick.h | 8 ++++++++ kernel/time/tick-sched.c | 10 ++++++++++ 2 files changed, 18 insertions(+) -- 2.17.1 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 da9455a6b42b..f380bb4f0744 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1089,6 +1089,16 @@ 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 + */ +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 Wed Jun 20 17:22:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139375 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050539lji; Wed, 20 Jun 2018 10:22:47 -0700 (PDT) X-Received: by 2002:a19:1c8d:: with SMTP id c135-v6mr1701527lfc.92.1529515367891; Wed, 20 Jun 2018 10:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515367; cv=none; d=google.com; s=arc-20160816; b=DyHpTCNDw6b6SNKvcXfPRq4k++HOXwhL7ntAvRd+ObBfLJO9OanCvXnQpxoaYeO5Tm UzN7OdQC+LEGPX3FroEeGd2ANlEw7s0hPn45kslWHU+VVR2hd5bJntxz2r0aN2S+GYzl wnTSjwoYtdn4FesR3I1UHCFRhaN1nxfneezpmpedfH7gbJAuNF8i+kODWpBUi1nmvqw4 W78zitP0psGDLA+B5+3bpieOLVroCm+UQsIfVD9O3rFjpBn8HAQ0WhTgWOB2Gez7ZoQ+ V1Ig4pbxtAPP5VR7681NUJKbMkI+ZzG6Jp1Wfm8AT2roFFhSJlmMHAicJjWTrv3TwVWS IHng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=LFPzDs1JucyTyUU9q3YaT4OD/JzXpPsipsDpCqXWAns=; b=wqisTyTPDN272Op322Wh0TU95oP5lYYmieAMgWhe1hJAIm6R64EdVu/hgqRqQDnpmr aq2tSdg5rJ2hB+kE5M8Qjhm20hPglL1AjIczFw23+ifn45Ae6zllOy6lqYtV61LlzePC 9yR6sBkwChUfDm0I1QTVTSrULC4h0mjYtZY2rDU3RP6XErn5jZs7vYC4VI2C9j2eJASR 7Gazu/kY/8xbAP0MbKlNpkfsxY+SsoJZGPTYxTQk3+gqdm/QdbWsPOVC67UCX+jikONz 6WzhigNoBKwhNoRSN4K56DyNima6FblkGOyuvFo1nHs+xVuPhmMOw1G99b1ecz7Tb6aW LIBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Pd+AU57/"; 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 a3-v6sor736167ljh.38.2018.06.20.10.22.47 for (Google Transport Security); Wed, 20 Jun 2018 10:22:47 -0700 (PDT) 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="Pd+AU57/"; 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; bh=LFPzDs1JucyTyUU9q3YaT4OD/JzXpPsipsDpCqXWAns=; b=Pd+AU57/ZbU9iVlM9eRTAuOn9GTqB6ot50bON6VCr0QtZEowyR6sePRKbj4JPhWgzu mTOhEKCczfF/p3cFIkRwIpRAdYi31j2ESbGBOYI7oXPX/eWp4DodDrcwp4lYr8MK2T8y mgxz3z+CuQXdsccOPAKsbsuwrNIXRQjLEj4F0= 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=LFPzDs1JucyTyUU9q3YaT4OD/JzXpPsipsDpCqXWAns=; b=BGljlrSlXgzZf2UuIFQT0NfFKdyaJ3TIjiwKfoRnRNsbAbSmLjp+X7Q7iJdkbwbVqV RwFT5zzdkvoTWckAhFEiK3eWKU6njNAbkDr7Kxb8H661j9/KODKH8bRy6BAwMYVM45sI aq0VCYcQUP59OHUQHnINKtRNmV00VI9VfpIcRTCmqIys8SZPW6gHEvjqLbZcPm1h/MDq vXnnRNfKSyzK0UawjtCA2+tuWx8MHKgvb9IINiTx9owqWQkd1EwchCZ1R6uZHfp26Sev 1mLXmOCdh0rjmVKa5LkVt5K39w9CzTmfNJkSvJg05v67/P+VKemxTpo7iBFzlms3kyeX AMlA== X-Gm-Message-State: APt69E1GW+ae3ZGGeTo3NxzGcF93tQ1PMBdfwAdegQ3+7TMn9Ktyi462 uNCNKM45VGLOMjBRIYWvLfynQkP1 X-Google-Smtp-Source: ADUXVKIXzbzMOEIVwbTkD347j4lM5kxIzlrYLKIeVYq/rh6c3durBgY/IosyfyDugqxJq+GurWA87w== X-Received: by 2002:a2e:c52:: with SMTP id o18-v6mr14820774ljd.72.1529515367664; Wed, 20 Jun 2018 10:22:47 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:46 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Ingo Molnar Subject: [PATCH v8 07/26] PM / Domains: Add genpd governor for CPUs Date: Wed, 20 Jun 2018 19:22:07 +0200 Message-Id: <20180620172226.15012-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- drivers/base/power/domain_governor.c | 58 ++++++++++++++++++++++++++++ include/linux/pm_domain.h | 2 + 2 files changed, 60 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 99896fbf18e4..1aad55719537 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) { @@ -245,6 +248,56 @@ 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; + + 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())); + + /* + * 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 deepest supported state. + */ + i = genpd->state_count - 1; + do { + if (!genpd->states[i].residency_ns) + break; + + /* Check idle_duration_ns >= 0 to compare signed/unsigned. */ + if (idle_duration_ns >= 0 && idle_duration_ns >= + (genpd->states[i].residency_ns + + genpd->states[i].power_off_latency_ns)) + break; + i--; + } while (i >= 0); + + if (i < 0) + return false; + + genpd->state_idx = i; + return true; +} + struct dev_power_governor simple_qos_governor = { .suspend_ok = default_suspend_ok, .power_down_ok = default_power_down_ok, @@ -257,3 +310,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 = NULL, + .power_down_ok = cpu_power_down_ok, +}; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 2c09cf80b285..97901c833108 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -160,6 +160,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) @@ -203,6 +204,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 Wed Jun 20 17:22:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139376 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050573lji; Wed, 20 Jun 2018 10:22:49 -0700 (PDT) X-Received: by 2002:a2e:18b:: with SMTP id f11-v6mr14719305lji.83.1529515369792; Wed, 20 Jun 2018 10:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515369; cv=none; d=google.com; s=arc-20160816; b=L8+s2QdeHIxEm9kjSBWNmZdg9rVZPCvT1DcMiki0PtmK2CrvtdrHKpCd1k9E1gXTdj cNzYrnedtt9jc0XI3pAuEQB8NYpt0B1+3r5FbZwqjXUXQY7ujKwTim9C2vCAfoETjNnk HvaQJRQfO3Oi7SWFOBZB9uTMNiPUGBmu9ln44J7dN1+fLzB0lNWytAm0Tldz4Wl6gaRj 4TGoiR9mSx5f9fs8J6P3uVcbFK/F//P47KqdNZRJXar0JMneRbvaROvrbvrf1zOlzV3X OQjKnJjIpY/bk2KC283SgCPtdcZkbG4lQuqgdf74jpgea0eGVWhxbm0AFt0ILXvqkcmF Lwig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=ZRhFVOBeSlXWUlWnU2mR5y2gmf5YR2vW22/QHKQ6EvstliLBbf371acew282wGQZAV NRkcteXidhdwBaDICizPY2dPLQU4Vw3YFgnF/lyMB7oJdpE4Ak+3UsbM9Nwn3iYWLI/2 MQcbgXvuhwHaUbipgvhTipSjY8TGigiVDYNF9s35sEQ31EslKCgyddzzL0h1lhU6SRoR jFSwvMAb3AIkJZ00I5b+tupzP3VUpmveiHjsuFj7qoNvimnnDpyOdL8tiNQbNTFt7vWB DSUjv3R5H3OnhCbRDNvJkUM5cbSyngXEw2tMBXecvIWiJ13M+kzxZ/ziTdw3Sy+gKudM cpyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9fuIxNS; 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 x28-v6sor730009ljb.114.2018.06.20.10.22.49 for (Google Transport Security); Wed, 20 Jun 2018 10:22:49 -0700 (PDT) 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=A9fuIxNS; 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; bh=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=A9fuIxNS3uBRahtGY3yF8BJX+KBopB0YlNuVvX9MTh+xt1z7j1iKkK9AELwlTF7KCl Rd/7Y/OeF6eDwgvDCt+aqtfnX8WxW1mYntnkQ3QBpQP5Z2bR6+dLVx+eNEIMg8natOdz MdlfGI3j2PSCpKmKUQiReapNtTpQ9lJlo6Q9g= 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=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=BNYzN/a30peLOnCqDoP2sQ8o5B6wrgI2+ni+uduf9w+0NIhUr/BvsUBjVSbvo9248w bwrstBnkbHDUZsw+WUjMWY9wHJg6Usn+AZtgD8mh8b7Wa7xxziOwYAap0B12BNusUd+Y 0seDzXMPTLoAXdZwyGB8w4SveVs94rgsC7a+rbG5DgmMDEoCGDyIDs+CfxxhjI8PXBMu HIVdKe/7bycHUhKwVjgulfNMtVbZ+0BKRr5WrI5UGyv17sAFFwAcK1dvKbTO7rok6b56 AklZ3ycVSXl4i/9IKXMJi5vlx/jepyy+sxy+IXBhKW7WdLW8eMFyTTIdE47qndROK+MI xH5Q== X-Gm-Message-State: APt69E3rN6RZT+BgVh3XmdaEup3JcksezCYrRLFivBFSqnIbEThV/ygq IdS1ytt/NF+PNYciPgXVdNrb1cfo X-Google-Smtp-Source: ADUXVKK84Q1LGQnNiTjybKUAInQtHrhH0fvzJOM/HZa6SCmBbdy9GJRiOUal7GTkipBNB47dsvQi5g== X-Received: by 2002:a2e:1092:: with SMTP id 18-v6mr15640303ljq.115.1529515369568; Wed, 20 Jun 2018 10:22:49 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:48 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 08/26] PM / Domains: Extend genpd CPU governor to cope with QoS constraints Date: Wed, 20 Jun 2018 19:22:08 +0200 Message-Id: <20180620172226.15012-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> CPU devices and other regular devices may share the same PM domain and may also be hierarchically related via subdomains. In either case, all devices including CPUs, may be attached to a PM domain managed by genpd, that has an idle state with an enter/exit latency. Let's take these latencies into account in the state selection process by genpd's governor for CPUs. This means the governor, pm_domain_cpu_gov, becomes extended to satisfy both a state's residency and a potential dev PM QoS constraint. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain_governor.c | 15 +++++++++++---- include/linux/pm_domain.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 1aad55719537..03d4e9454ce9 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -214,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 @@ -240,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; } @@ -255,6 +258,10 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) 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; @@ -276,9 +283,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) /* * 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 deepest supported state. + * Start at the state picked by the dev PM QoS constraint validation. */ - i = genpd->state_count - 1; + i = genpd->state_idx; do { if (!genpd->states[i].residency_ns) break; @@ -312,6 +319,6 @@ struct dev_power_governor pm_domain_always_on_gov = { }; struct dev_power_governor pm_domain_cpu_gov = { - .suspend_ok = NULL, + .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 97901c833108..dbc69721cad8 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -81,6 +81,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, From patchwork Wed Jun 20 17:22:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139377 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050597lji; Wed, 20 Jun 2018 10:22:51 -0700 (PDT) X-Received: by 2002:a2e:21c7:: with SMTP id h68-v6mr14478191lji.108.1529515371376; Wed, 20 Jun 2018 10:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515371; cv=none; d=google.com; s=arc-20160816; b=TsbQOiE8DGdFDj/tteBdUe7WBs1G9MVTIVWolwGPn8uOvUhmypcYXYHiY7Tu3blVL2 U99Kg8PO5+pi939PccB6+/odFRIaVasfPO0QK3taKT0Pvpfj+ImDhqCVoBYCO+Rmo7w9 kh18WY3ODgYWBmuKN+rIetJPCIfm8AJU+VI7yiPnhgufwS758oXRfSQ3x9ZBlM2UGlgs /Odrzm6tBKh8Cjywdo0jL1jItt2aqDriA57mWQVhtOfflynjmSSPwFc+nJyDk+IBNDrD k8sQcPqbaQyMK98HEHUzcPH411tjcBGLgANCYNj8wtCMIRwCLnsPP1a4zFhFHBlvsSaW bE/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=WhnOSbbnY0bzTmcnohYcvZ6veC9nYvW1V1ctSC1xEM30W4/Diay1nyjGRVl1IJWT5j UzlYTFBcJAvYak7bUdCk8a+dFZSKXHuulA79d2faDT2IP2RCwex61YlXKEMvh46UFevW CQGSfIippwkp4rJ9IC6yYCtusW74r0rPMpTDaXh2yFfHjC5jlVtonhCXt+6kzhPzMG4O 0YbnHxXb5LZGfjP1BybnUtH7bD637HfQzdP3JEJfvbSbsSvgzLsFSIplmJ5iPINIgbEy JgOKH0GohmaUB5BwwqQNIkSmw1r72A50DMyOHqIt9QUB+fWvAH1mUBVYS7PArREKiMgo nAmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKWyS3hT; 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 i4-v6sor687559lji.77.2018.06.20.10.22.51 for (Google Transport Security); Wed, 20 Jun 2018 10:22:51 -0700 (PDT) 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=UKWyS3hT; 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; bh=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=UKWyS3hTToKxrXbPMXXRta1HjAcVNo2/elOmaTz2VWM9HaXeuoPJUWIzqmC4xJmUT6 F8wFz06W1B92R+249KsTGoHBm3XzhB7povwc3EAj6QJn91acb1MKY89vzo4r02bw64rY umdxH5INr3n8kHjJT5+oq7XPYhk7Du3FT4qek= 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=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=N5qmM/x1JBQ2RDgxlRu2GNvlRBd+UdH9JTGrGZO/Oi21x+OOjH649KDeecjAqJelVG n1HptJNIIyxOfifCFlnjn7zqx5UqcB1EERGh9fJdlJW2F2PIXrtseVtADMwA31vEUgyk hpYmrAfcfYNzQvUkEJIR0an2s4dkAjlwWWLxhCD4hm1oLz8UnI++HIp81wsPgoPspSoM V7MQs9DTRXRQK3W5+fp+gI6pOSAdbxqhhLndYLcUsG9G8PcR+MLvTa9NCQ/z5Ga5O0c6 4r6/wz1ikxr/tI4iHX0Z9xCHj1QmCA9/f9a+G/cfwKWN8XDC+NNm3nkob1w8BKvK9P1K lhGA== X-Gm-Message-State: APt69E19VrGKlqinNPkuobmc99mMKXVG1tCQ6QoO6gshArqx6SMhTGwG S6fEcQS/Y3JhgCoWRGvYGKVHcokN X-Google-Smtp-Source: ADUXVKKpZbnKqi0oKUPGq7T1+MiBtHrteMTDgrbFxl9QBtjQc36fvDAlSgdwGwy5+rWMXBOZHXzUUQ== X-Received: by 2002:a2e:594d:: with SMTP id n74-v6mr15420669ljb.128.1529515371181; Wed, 20 Jun 2018 10:22:51 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:50 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 09/26] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Wed, 20 Jun 2018 19:22:09 +0200 Message-Id: <20180620172226.15012-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> To allow CPUs being power managed by PM domains, let's deploy support for runtime PM for the CPU's corresponding struct device. More precisely, at the point when the CPU is about to enter an idle state, decrease the runtime PM usage count for its corresponding struct device, via calling pm_runtime_put_sync_suspend(). Then, at the point when the CPU resumes from idle, let's increase the runtime PM usage count, via calling pm_runtime_get_sync(). Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- kernel/cpu_pm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 67b02e138a47..492d4a83dca0 100644 --- a/kernel/cpu_pm.c +++ b/kernel/cpu_pm.c @@ -16,9 +16,11 @@ */ #include +#include #include #include #include +#include #include #include @@ -91,6 +93,7 @@ int cpu_pm_enter(void) { int nr_calls; int ret = 0; + struct device *dev = get_cpu_device(smp_processor_id()); ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); if (ret) @@ -100,6 +103,9 @@ int cpu_pm_enter(void) */ cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL); + if (!ret && dev && dev->pm_domain) + pm_runtime_put_sync_suspend(dev); + return ret; } EXPORT_SYMBOL_GPL(cpu_pm_enter); @@ -118,6 +124,11 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter); */ int cpu_pm_exit(void) { + struct device *dev = get_cpu_device(smp_processor_id()); + + if (dev && dev->pm_domain) + pm_runtime_get_sync(dev); + return cpu_pm_notify(CPU_PM_EXIT, -1, NULL); } EXPORT_SYMBOL_GPL(cpu_pm_exit); From patchwork Wed Jun 20 17:22:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139378 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050628lji; Wed, 20 Jun 2018 10:22:53 -0700 (PDT) X-Received: by 2002:a2e:81a:: with SMTP id 26-v6mr15381861lji.46.1529515373395; Wed, 20 Jun 2018 10:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515373; cv=none; d=google.com; s=arc-20160816; b=h3akQUQ/6u/ykGnoTRVGnuZlaq2gHgRzYL1Uw1IO31boVTt8f0fi+xQywb1M8+o8Mt ddOgRD4Io0rIbSt1r2Wy1Q6FQ83ZFXxAfAHod0YtyP8ZzqxF+dxlF7YTM3zQGjYG5jH8 ibpcQ9IFPcjz9aakTNKS7Xj3NeP/JrmUkCUkFHgHsmaUkNS/U8zPXCY8LmjjmKDuXUPs aGBnkGbHGat9oCka/B7q5VeYP2ohG6NHJNu9rr7rG113jk/KQsiwyRgFiwGzrlv9Cc7Q 0E8dHL9G4rhe8XBOCQg3yxtFpbZqzWVaj4r+qmOfNCyfuboFmpGuFBqWYPQX7WWPm82J PqeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=s31a5XHCk1LHbjCX4EljRqRwb2bVRICfynyfVhTJkR0=; b=RZW9nYsGWidebl2vPB+ZPgPsjCfQ3S84bjLcyPRqwm7tfQLJETiitLJAgIzgedFkTE 6XJt2gx/wkrAmozrDoDcWev++qpQD4t0WCIZOEZTXrzx7F0xmHkAcb2rVn9soqs+j6Vk pqFLZTcDyTDaOjsDT6SGnOguQLOpHMBo+bn39I0NUc80SH1nXBawp71DNiVFaDZ6xwGt 4gzJziLBEC66JZM1zlB6RukW23+K8yrK1LLRCSr6j76dnDSFlnVABjYzWDjO6zNBur3W SBG16nxDB/XwVav07HVSUZvMP1jcOfVfSf7gZ1CMDppekauMaHZHCkPSbZ1if138Y0F+ f+vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iXrzpP2V; 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 y11-v6sor704242ljc.29.2018.06.20.10.22.53 for (Google Transport Security); Wed, 20 Jun 2018 10:22:53 -0700 (PDT) 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=iXrzpP2V; 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; bh=s31a5XHCk1LHbjCX4EljRqRwb2bVRICfynyfVhTJkR0=; b=iXrzpP2VIW1uEn7SDhpIWIrhT1BGKp3VQgqFi0ObjnSMqCpL0i+9njkgtjp25ss4EC Vr2fRR738kAgUu2guAiCra4VAoTy1ds84NwOpCTgnMm0AURdnyo+LEAVP803Uety06qT wjIikiNNl0q7q6Y7iCsDgqZd+215crOtzAx94= 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=s31a5XHCk1LHbjCX4EljRqRwb2bVRICfynyfVhTJkR0=; b=nr/HXhnqRdo/BFi2uGeUz5d0HxM3s/VByrGcA2re2wblycKKCRjYGPtq4e0mKDV0lB yiMWPEASerStKwdVw7ptekGsDcAxErpgr5hg0HyyfBwsLncixt1peQbI+3APPLh/+MHs 2+sY/kDkpXbo/3ylAK39JkjWxPbLscHuMgyZeZ2Lmk4V5texA9FdMHDksRgYNHqMDmKz 7D3seOjP3zMarKGg3NYuHwqy+0StnIEu3B+MEWOkZTXagh71V1pa9mGX9C3JaF6E1Fxp 7Ha2affhYGSgde00ltQlJUQqy2jiBYHnOCHFY6pKnW6p1rdDocXq7t6L+o2eJ5ZSpkCF uxhw== X-Gm-Message-State: APt69E2nlCXapF6ZZMmf8ZHKUVFfqB2cY1othjQczvAO6xYteqNXUDNB CAjLabDKM1hS3Uh0Fv1KD/17SUw9 X-Google-Smtp-Source: ADUXVKLEwIosHXuj6oU+qxd5HB2u0PN2D8EmIYEQDwCeLfDc7D46+QKsEdui2JXgn0HNmE72EDJWiA== X-Received: by 2002:a2e:18b:: with SMTP id f11-v6mr14719435lji.83.1529515373159; Wed, 20 Jun 2018 10:22:53 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:52 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 10/26] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Wed, 20 Jun 2018 19:22:10 +0200 Message-Id: <20180620172226.15012-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- .../devicetree/bindings/arm/psci.txt | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) -- 2.17.1 diff --git a/Documentation/devicetree/bindings/arm/psci.txt b/Documentation/devicetree/bindings/arm/psci.txt index a2c4f1d52492..17aa3d3a1c8e 100644 --- a/Documentation/devicetree/bindings/arm/psci.txt +++ b/Documentation/devicetree/bindings/arm/psci.txt @@ -105,7 +105,163 @@ 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". + +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. + +In PSCI firmware v1.0, the OS-Initiated mode is introduced. In order to use it, +the hierarchical representation must be used. + +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 = <0x000001>; + entry-latency-us = <10>; + exit-latency-us = <10>; + min-residency-us = <100>; + }; + + CLUSTER_RET: cluster-retention { + compatible = "arm,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 = "arm,idle-state"; + arm,psci-suspend-param = <0x1000030>; + 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>; + }; + + CPU1: cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a57", "arm,armv8"; + reg = <0x100>; + enable-method = "psci"; + power-domains = <&CPU_PD1>; + }; + + idle-states { + CPU_PWRDN: cpu-power-down { + compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x000001>; + 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 Wed Jun 20 17:22:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139379 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050656lji; Wed, 20 Jun 2018 10:22:55 -0700 (PDT) X-Received: by 2002:a2e:9e57:: with SMTP id g23-v6mr14201318ljk.14.1529515375112; Wed, 20 Jun 2018 10:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515375; cv=none; d=google.com; s=arc-20160816; b=vHIz9Ymxg6LVROigpH/hrIf5hAcFXRAWrPyCUTERHfCnZWv8gnRy0RYVFep/uxY+lf 0KS1Z8yOcIkJE5NsfbwZkp7ROh8uX3+0SWUeaJTI8dyNWNZgwvde0UEBmfE12G988Bz+ jYJSoSIIcxkQYkeKSh7Ew695HFgAVKeJziMLgSAJdB/SBtcNhBcyrme09xWhRIr0zeqD EU5OvpPhIh6ZJU4vnw5RU2f84jQfGfz4uywHYbd/HyNuO/4qal+LxUdNS16fLJtSffBY i8/TIZCJyGFUlVM5UbMghRhslA2OqK4PXm4a++1E8kWpBoGTOMkp3/pC0C9gDpeKHin+ f9vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=AMylSCkbzgDhVGAqXW5br7EGPsh0M0aMkU36t/fhU+E=; b=FgcV7OaLW4XVpnj2SwyNSpqEYYSM9MyscDfwJqh79oFxdWAoYa0ovXBsbPnKOKUBnh chu6gvclgjjo39EJbfWIVuPWzQ+fnBZJfh3RS2X8xz5a5n683E98equICRqrVj9rdhdS RoWwq46nG82EbrbnHecY85GWTIYjQ5X+3SKpT4Uw9iAc1KAaR7RNBFKF9WgBJP1DJF8D QsgV+9xtACydyONtjfABdH1uDu293nsCBm5ik83aTsiGYxs0JEbe864j3H+zKUer8sFz zebhyXZMV+8DEUermYn7FcgdmFJ6lKvm8WaAS7NxvYFV+PHFHD0jbfgCgBM4Fd6idDRX FYrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SKGWxFzG; 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 p21-v6sor698179ljh.91.2018.06.20.10.22.55 for (Google Transport Security); Wed, 20 Jun 2018 10:22:55 -0700 (PDT) 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=SKGWxFzG; 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; bh=AMylSCkbzgDhVGAqXW5br7EGPsh0M0aMkU36t/fhU+E=; b=SKGWxFzGSktnyD6kaX9ouo+P/jXcqpXVh7WmiipKR4mu8eL4DLn1dlzEuJ1UVq8Isf nHglT92pBOG4HoKUm0EsljQ8CMQHU/y/4uqGOUybUW/3pWPBLcIG8lCYhELSWFIusRTq VjDEfxFljyJQu7hsl5Egey8JJ52Ttelgdra2Y= 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=AMylSCkbzgDhVGAqXW5br7EGPsh0M0aMkU36t/fhU+E=; b=gN/9hKf6HVeQsSOwJ5piJYZittCU5ezQ4dagoocMyvSkmFp5NRcreJ/nX8M249n83N Po1hBCKkNWldVVGUmxNwFLlm7hCxyVTMm86BGUvOc2y8Gj60NuRJVC2pzR3K5Mu8ocWi ikppv8er0gHthsv9aLzEhznaUqHZEL5Y2JlMj6cqLb1uKUriGAIZVnTXl71kH48Qy9vw EJ2e+Jm+SoC0apk37uPcc4b0I/XyPp5G9xgZZZd6pOahAe83dqJx+2obZNRcd/3LEFB1 jeOkOvVB/WhLqLmbxgm3wkuP6koBDbZwmCpG8BtfgAJJeGlp9tHzWbhommLTaQje/uKe vt/g== X-Gm-Message-State: APt69E3kg2XxxQj2aXODetEoSY1f/KoUISUmyDaWc0P3b98+27GGKkOB oF+BpjT/tBZmfou6fl4tcbAglmyX X-Google-Smtp-Source: ADUXVKKw7oTkqAeuPRf8L9aMhza1orF6pS8GahQhO/Ol4QGWHx/duUSlOEM0HX43isb6GIHcjbqMPQ== X-Received: by 2002:a2e:870d:: with SMTP id m13-v6mr14276282lji.139.1529515374905; Wed, 20 Jun 2018 10:22:54 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:54 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 11/26] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Wed, 20 Jun 2018 19:22:11 +0200 Message-Id: <20180620172226.15012-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- drivers/of/base.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/of.h | 8 ++++++++ 2 files changed, 43 insertions(+) -- 2.17.1 diff --git a/drivers/of/base.c b/drivers/of/base.c index 848f549164cd..97350cce1b8e 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -399,6 +399,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 4d25e4f952d9..15072b10ef4d 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, const char *name, int *lenp); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); +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) @@ -733,6 +735,12 @@ static inline struct device_node *of_get_cpu_node(int cpu, 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 Wed Jun 20 17:22:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139380 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050692lji; Wed, 20 Jun 2018 10:22:56 -0700 (PDT) X-Received: by 2002:a19:c692:: with SMTP id w140-v6mr8574612lff.85.1529515376937; Wed, 20 Jun 2018 10:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515376; cv=none; d=google.com; s=arc-20160816; b=vFrqOH+c1Y1ZUxbzYTOwOIpfzNk4/GZ6J323awUgJdQx3QrgMKPutaSKo7xe2PgegJ 5WC9PwPZ9h4Ox8WUW0lrVIXoxicNjE4T0aLal0iZ6x+fPiMJ/pxEWT+j40FWN4PufqP7 wHQt5ZJhOJpMOC09+Z5fw9pgWCYtZXckh5igJUXGY+O9okcJaQgMTLjcGzPz3SdfQE35 cgejL1BPIy37wHgb57FT+FMuXnqkLyxOMLzAeMVCZ2oUxAdtpgBbw0KMFFr1dJ/kQGH+ q2Whwx8vxOvYWeNXap8BY7O78uD6ouf2NaM08lOdI0p0/RPoVVYC/kJm2Gm9Q4/86L45 wrxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=NdOVQOgn6QPfKNtGaQ+NXVIYYOcD0EuuWacQGnuhPH8=; b=ANxqwDENMXo5tDTiuihRpwCm7WK/CtsX/0RapwIiq3we5wsaxPCDGg3rr3eU2HhoJZ k44RJrQrZ7DezFkQ4WSZxzQ1bkldXM9EczAVGRs86L48tN+36SiIKXxURmEheUHp6hOq dhOQTkMhhIArUONYgPNG2wGEU2Ac+5Qdofhh4j661HEuGWDEROc8Gns/WKTXAYZda/fq VkchvN9+CswL2hQuF4wJwylReT3w6qWMplhvp/cCzlKuia2Vgj4qbclNz9hOmqLHwPke LgIlysdqOwVv3fDcP9z3gvCFzV/OZtRbegT/FuozONRt4mqAK64GiCXDHj2G07/yYRHF HZew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bxj+tfnA; 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 k18-v6sor736468ljj.66.2018.06.20.10.22.56 for (Google Transport Security); Wed, 20 Jun 2018 10:22:56 -0700 (PDT) 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=bxj+tfnA; 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; bh=NdOVQOgn6QPfKNtGaQ+NXVIYYOcD0EuuWacQGnuhPH8=; b=bxj+tfnAw37NyvY0WdDlwmR2qXNymUJepXFf+P3xWNtcQLIdfTA+QUNwlDOT2aL4rE GM7+CwE+5ixNl5W/l0aEM1mbXWeu+Vk9TD9OsYNRI+UuBLq/aSS1tuUsnhji8QuIIg9x fQxj0s8Q9sigqbWr3o/w0fUPJax0r2uKeKneM= 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=NdOVQOgn6QPfKNtGaQ+NXVIYYOcD0EuuWacQGnuhPH8=; b=FsggbIv1ihUsUoi61ZK02X4tnSOEelIIBrCpTXjwWywblbQmmwSM96z+0scEv5wbLo NtlQcwpEOx4nuopJMRw3oO/rmSS4fenGrs5lnMHvDRizBKfLXjXCEMH+gPau/A+Erikr 3dOzkNSTrPdzpHA55OioRNo8P7SXdeMpFVTonN7y1+UY2Fo/jtTvM0XSBlk9GQ5ox5Zh xvWBNEf4itwpqxFQ78pZmBxiMy2ECveCL05y4OjYR3xJAA9P6oYKyI0aHnepaTlORPxw xmjXnjhtNrrYtIRB7W4qgqJMO8KWfsH4eqhrg5UHacz7GFDewFBm7AZFupK5WNiBu1/R LkdQ== X-Gm-Message-State: APt69E22z2yS9LaM3Ws+sngIhslOvMyE8OnoiqlkOqzmdYuCWqM7D5Lf tpzG/rai13ecAeWgjcmwrFUNe2O8 X-Google-Smtp-Source: ADUXVKIfkA/aSkeTaO/Pmjg5O3hQYTz9idt4WA0jxR0DWKMwuZP8qg8sQLr7vhpNjIsL3Unx82VCbA== X-Received: by 2002:a2e:1710:: with SMTP id l16-v6mr15565951lje.74.1529515376747; Wed, 20 Jun 2018 10:22:56 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:56 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 12/26] cpuidle: dt: Support hierarchical CPU idle states Date: Wed, 20 Jun 2018 19:22:12 +0200 Message-Id: <20180620172226.15012-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- drivers/cpuidle/dt_idle_states.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.17.1 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 Wed Jun 20 17:22:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139381 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050735lji; Wed, 20 Jun 2018 10:22:58 -0700 (PDT) X-Received: by 2002:a2e:944e:: with SMTP id o14-v6mr144269ljh.118.1529515378778; Wed, 20 Jun 2018 10:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515378; cv=none; d=google.com; s=arc-20160816; b=USSYdrJ7yadME2GYa1Zzttwx3SivsF8BtitHdFS7NoOMA7XaBFdN91jj+pCjmXP69i NQizHj/pXxhTJrBZ48SJRQGAwngfmrh1Eh69FPIJ/p53TDw1wCON1v/ToqTAeAja/myT o4xMF+YFBgD79Hh5pgE2qG6RRHW3gc5GyickLD6OUPs9N8Apkbbw0CQ6lLl/x28nG5AQ rnRrpqjcmvsmbiXyIcZaZOR0RI8lTUxtFUhDIBDqXKnWjQyPMntDidf26QrzGSgP5A5p cDMrwHptl8Y2Oovvpk+RMa0xKIr0gflm9DB/38TLRDZzERIG8Zz6pHfBlKFidRuom57o mHLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=24N1Dc3/4aVSfatj0cCLPTM9sDMCdxo5zYgoCR5YTHc=; b=wP4nxTHniBjBnCbQQoIIkOYEUPZWZijnJ96cdlhRPM1sTt+fCcy9jcR4qWJ4ZTTXEf c3qMxayIIQDg9PMyShRemrhYBdSwXp2zduDmLnWnIXfCkx1qs6KBFdi11B26OkqnH1Kt zMSHWqMaNSqhsgryX66Trg/HrOkI+yrW4kdBs+2EQgocr2xGYmSfVJcTNdvCQ1XAXALG XuFaD3k6gZBj5HzyQKR4MJanEpsnCQojV9unYBJ+gLbPu++242+p5XmpL2u0z+f6mcQ/ 7ctdNDWx+e3fJK6mIXDmSNXpo0TjHBBNG9tPeUQXmfgHsd30MlOhD69XwzG6gH3r/EDn vDQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J+KVAB9a; 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 24-v6sor594800ljs.47.2018.06.20.10.22.58 for (Google Transport Security); Wed, 20 Jun 2018 10:22:58 -0700 (PDT) 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=J+KVAB9a; 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; bh=24N1Dc3/4aVSfatj0cCLPTM9sDMCdxo5zYgoCR5YTHc=; b=J+KVAB9aTvpKYALS4Wr+p8D1kMK7oRy9jJrRhoI+y086Fdf81Z8+HqPtV1GeeYQCev KBJmQpmVoALyf7MJJsszcCcX9bDGTcZhH8yNCkG5/lMXAHjHIwdCTEX+qxQfzfQVsAwh 71D19Qu7OO+blVZjgHCqMdR+Jvl2sdvOR79ks= 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=24N1Dc3/4aVSfatj0cCLPTM9sDMCdxo5zYgoCR5YTHc=; b=ROq7G+G2Rsjov0h+szo9qljXRCv+1i9jQvziZmgDxCqIqHJJwhnrAW5GbZa3mO9KJf 04i2dbN6FAmlLQnePcOgb9lyefGwp+wt9ctgY6DT8KUh0OkVyuj7UdWGvzYL9jUNf9J5 dURd+UUI9qteb8OiyRO1MmaOcpdLmhdZsuHM6j2SWPCIgkSX/YaEbWRnAaGG+GK9IZ+n KmA/0PecCv+EF1SpIsEEMBC5PxqNlyBs7f8OGdvIweTYP6PhTkknge6XQOs8b/q6BvLI kbClmwXbgXDGoJQJuXI5erjdfo8DuL/7bb1VyOwAKj9Ip3qBUfuyS9DI915KR7ulgPuL Fc8A== X-Gm-Message-State: APt69E29Y7dVAkte9I62P7UewgN1SwciOxMoKrJw13WsSP6GlkT7SJOW h5KXmv4V5FRMoWrNm9TLmJkhB9sr X-Google-Smtp-Source: ADUXVKKAfapQ3eKmMpfxG+iNZ+44iV9V05WmGSBlbaS5XBfzU+lIVLCKALmJEEWJDZq9Nrlj57M4OA== X-Received: by 2002:a2e:8350:: with SMTP id l16-v6mr14437649ljh.7.1529515378526; Wed, 20 Jun 2018 10:22:58 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:57 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 13/26] drivers: firmware: psci: Move psci to separate directory Date: Wed, 20 Jun 2018 19:22:13 +0200 Message-Id: <20180620172226.15012-14-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- 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%) -- 2.17.1 diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 6e83880046d7..923c42d5a2e6 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 @@ -286,6 +272,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 e18a041cfc53..ea284e551dc8 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 @@ -26,6 +24,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 Wed Jun 20 17:22:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139382 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050768lji; Wed, 20 Jun 2018 10:23:00 -0700 (PDT) X-Received: by 2002:a19:a68a:: with SMTP id p132-v6mr13073252lfe.89.1529515380950; Wed, 20 Jun 2018 10:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515380; cv=none; d=google.com; s=arc-20160816; b=YveP95HIV52uofA4pSsrYJqAOt6qFwEw4IJBmdekEs6dfNu6bRCAgf4r2yVlIr07PM yl2bTyGRuVq5hYXjGeftNKSRXW2HfV4lZeh3ANXx50c2HWmsZved91UwhTUEvXaMMfFX LaRuOzmU/ZM63exIqOkv/rszczhmte6Ifn+Ev1+6TdODhqeNvnTTvRDIk/imAAFOeHs/ fvN8ME4E5uTwas1ztoI7KfgLCQz4wcQSDaDItwVnKwCK1xJ9gve+KThRi0ql/P525LaQ Omu1+ShEJTHEs7mCEMM/xQ+9sQGXUkUDGwbg+UdrRKIbg6L17M4BaGqOl7HviPE62GdR wDhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=stG9JEg6XvAPhk1WXN8yw0kJgHmvBt8xw2+9hMCUZkw=; b=LDxmAebAOFUQsqmPBJTnJPO1BXaURU5Zn0lUJeU1RyXaJJE9wrjbo913nl8lNOkZ/k xq5JRVJDE6dAM4miiTMaMUykusbhSCREvAbFIzlrn4aPeUEFEFyM1+63OVylqaAxgfhx N+hXx6p2947cB7COfPqKdPQfgvXLllhPFehI9VArYRFuKgiUrVu0idLHyWrvsjxvLJt+ O9R5xacWQ0jL0GFecaxayy7wqEIVTQpoGDrZJpwA8uSUNIpTXqAK1mYj3HTWt+FOFTS1 9KBDe1Nx+jKDRzQJ7hZQGLTqQJY+jXA7HCAZYfj2mOTabmEvOyaAiuOAhngTkpbP19Sf 6gJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f2VcVFbD; 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 x25-v6sor735822lji.41.2018.06.20.10.23.00 for (Google Transport Security); Wed, 20 Jun 2018 10:23:00 -0700 (PDT) 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=f2VcVFbD; 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; bh=stG9JEg6XvAPhk1WXN8yw0kJgHmvBt8xw2+9hMCUZkw=; b=f2VcVFbDfq9GSnU9aRX+cuwWeC5t6Q+VTY8OIA7tl5quE3ybq3CkS2okHfLFvK4DaB r2rx3eh+WCoq4BDEeNQH1tUNm/BP63ik6rxXvPBVOpsDqktGFJeeRGRbrjCRjp+hyYvp /8RrYoYpqhwY/LXgfnXmcTiALQ3hGXNLO2Imo= 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=stG9JEg6XvAPhk1WXN8yw0kJgHmvBt8xw2+9hMCUZkw=; b=WojwTqpH8PZXTUm/eQsYqpW5w6y7orPZtoGUbO4266IO0L0k1Lb24hOFlyGVoW9V4j Ls+2YLm6CECpmpMmWtLxdyQ46P+EwDoU6HJuXGApc9dxKPF2Oc3uQutWs4Y8GL4dH8yW GNtOZyaechpNAKvILUSs6XlZztDH7KwPRi0SnkwERvJchH+trOWewKszUlF5D0fotTuP 6mqaQVmjqdZC006EZi+kQnXvedJ6GtJkiPSqn6iH6RScY3hdJRFrNu95CVha93Oqyd0/ lkk2EjIs9kT2kCPPyj6QViBWKBwBYnGcQ8ZxhGP/BVwEdJOyFUP76CZIYQv9wLmxVXhW n8JQ== X-Gm-Message-State: APt69E3ZQcbPIRMuQK1WRiwwjUQMfLzKqraQSMsTyl5dYSzyUvXT0vmq WThEZmtrAZYBdP68iycRMTycGYIS X-Google-Smtp-Source: ADUXVKLfyVEi5Cpmhgw449fGDSJ+NkJx7M9qWFFzfXqCwwyMscCj75rg7qW2MBn4WoGyz7l8b/kaLw== X-Received: by 2002:a2e:84d7:: with SMTP id q23-v6mr14273971ljh.126.1529515380784; Wed, 20 Jun 2018 10:23:00 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.22.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:59 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 14/26] MAINTAINERS: Update files for PSCI Date: Wed, 20 Jun 2018 19:22:14 +0200 Message-Id: <20180620172226.15012-15-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/MAINTAINERS b/MAINTAINERS index 9d5eeff51b5f..3f28c21d0ad0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11389,7 +11389,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 Wed Jun 20 17:22:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139383 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050798lji; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) X-Received: by 2002:a19:eb07:: with SMTP id j7-v6mr11659451lfh.141.1529515382823; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515382; cv=none; d=google.com; s=arc-20160816; b=04GiIuB2wBeHfpWkjTY084X1jaVviE6ouCmuF4ZZCN9HT5S36HGg3bLId/ObN6ZhHv jeHBjbEaVsU3Wg83CkLbPRWqs6jKpmvGftDX9BLsLwp7f7GtzlvitNX3CLzTgZuqoZwT 6LuzsM9W98Tk682yF89QaF4WcaHfsA+bEH8hDPrYnHCnUH5jCjhOhC3AwTNHAhoErETc NV1l5f97OeS0rPRi0DByU8R0lpvZV3z36eGwYo7dn8DOKXJMkhF+5wfko4yiR6KaCGbG 3q3ObMC56iB0r1FEIAbpO+Tk2Q3R8tfrSvu0goxDx3N32gWLT8LyYKynlKPxzCTlCuQN fQTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=mHhI7zOfluSH2ipPaP4UEIhExor3AaylN6Mul7H/gUb3WNwvFJMJkJkgbudAU5ILIs 1lFQGU4JekTRCo0kzmsY0WBND/SqDscR7OPBzvw43gHw85ZXAHtiPjPpaIuopL27j2Kt M835Rc870Whyf5cyyXa8XnlwxER+Rswo+qa8G93RYM2sNgc3HvUXd+vBdFm+JKHqCgDg eAg6h78zoKcwB/AAefNTSot+Ig9t+ldugwkwAsPH/7zgQnlIfRzHMZK/r84idsrq5l55 X8inNMW4XSi34pyTbpJ0zYIyHsZ/qB9dEojePPvqXFnaVnsWcArkxd5Rmv59WbjuG2vY jSsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtRIJm7X; 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 r22-v6sor743835ljh.86.2018.06.20.10.23.02 for (Google Transport Security); Wed, 20 Jun 2018 10:23:02 -0700 (PDT) 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=dtRIJm7X; 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; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=dtRIJm7XAWzuKjmeXnomgst7smQtEINE2MpLcO8A+M7VRbs5PKoD4FG61Lh2IkAMGu Tl6hNssPK8su+rIU+OItVIdBlHViX+vq23nrBPUju9JY1EuKaQV59i1i4uCo2uGXeVtm rfcKxJUrFLXrQedrqSEs/RaJza5ZkM8wxyA/4= 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=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=sExqsbxoxvPzDE9MztZQImiGSjvZ+E9iLQMa9QvMcHpAqXI1yUwYUvGXpgtE+I0BII F0V2js9A8+tAob0WkFgMmPi6pCIIPS3UjNWEzU0w3D4RlL9pD0v65lkqCwS+URb3b0nm pRDN/CTMvpsGx/gWE+PrRI7mHuhMvV2dAfwu7WmEzJKdIxbsy9T/48tP3EBZMGxDa57+ qFfFn+a6JP0+Y/U2FkS/7ovCyBx3wBfw/dCpMggMGedV7X8qlkt083tM2fzuQ3PoJC4l jphPr5SgN3yxdGUxEIDCqHiB/rP4BETEEJrwz94oGoFl3sh0dr3qyY46wzsDhQoF2MB/ t0/w== X-Gm-Message-State: APt69E0RePHBIRahEbbAQCwJu30qThuopTipHLcoSFAabqwrB/Knr8T+ +RzALW8fHu9XzhiQ8fUCAGV1HQHq X-Google-Smtp-Source: ADUXVKJiQlFWeGZEmlqwQkx047GLHSjmbFpCcwQ/EkZSuHGtcsYsECmjTNsT5vQg4C0qcFOJdXrHdA== X-Received: by 2002:a2e:4189:: with SMTP id d9-v6mr14339254ljf.36.1529515382622; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:01 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 15/26] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 20 Jun 2018 19:22:15 +0200 Message-Id: <20180620172226.15012-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Let's split 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 --- drivers/firmware/psci/psci.c | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index c80ec1d03274..9788bfc1cf8b 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -270,9 +270,26 @@ 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 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; @@ -291,29 +308,16 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) 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 Wed Jun 20 17:22:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139384 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050833lji; Wed, 20 Jun 2018 10:23:04 -0700 (PDT) X-Received: by 2002:a2e:5111:: with SMTP id f17-v6mr12877022ljb.16.1529515384714; Wed, 20 Jun 2018 10:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515384; cv=none; d=google.com; s=arc-20160816; b=k+G2rW45ix8xo7Vgohdod9zz/Z7cs8XCGgIxsZIFEax2JmqQQIWbD8v8Et2wXPzkDz c9pBFeGdoJZJJE2IvRuC2CBnXl85QxcO4jdY2Rrqcj3bwGmtfriHWOXA1oMwnhKRss8h i5z7Es9g0jIa51qzUJqml9KsYRAzi+lau09kSS5D+GF27VSJmDuVPNeGvFmIpfus3F6E CSHq8eRx0pjUS1D8UrrhqM+vZ4Y14wGS8QrkVh8vQrEAxgl5tNJ9akR/yOyn3TFA0lf/ 0FMTyqnKh1e+9E4KNE5xzsOEFAkMfOvGt/HqjxT3zWSUJ4oeqFJHZ+efwNTYBVZ1Puh7 oQIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3WUKn2dvevp+IRdH7T6aKSOygQUa+Gx75wLOTzgVKrQ=; b=EFgORTYrQpRMFValNIlGbK88T6zpqfmeOLNC5cZWXTfuB4axH89G6qPkfCJecXUOVo 8fR3Rr0PmCluosFGzXJyI7TtE/b8HO+Q/FAu/O0Ul4TKt/3f1qfh18qq6BzMkj/l6pfZ 0j0pOyAnf7E4t4XCnCVm/sT/kLyrEZaMa1mrIrnROZKvBoCM4EqzU/uI3rF3VzUWRZI8 bfxCe6pzUwQRopWGMwuPuC3kQ5PZT1sHj3KuXCfBIYv8IWKc7XaXYBTM3fIwrd6AENfp K02fPPBwxb++s4dXacbkZxSSJoX1WGWD+zv+mrv/iLNDhJHpKrcTSaVQGyIkFA1RGsHe +ssQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ccLWxAWK; 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 f68-v6sor730575lje.65.2018.06.20.10.23.04 for (Google Transport Security); Wed, 20 Jun 2018 10:23:04 -0700 (PDT) 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=ccLWxAWK; 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; bh=3WUKn2dvevp+IRdH7T6aKSOygQUa+Gx75wLOTzgVKrQ=; b=ccLWxAWKyM1XsPYFwBoyd1FnFJHtFSEKE0BrB3Mz5q7D5iS6hvFeiT/fgp33GKSrIz Gxj57mbMomjqk9vP9cNzlryga3fRrwsq5ynCb8/ACNT1wds3dTiZq6fS5nI0FwmGJaNN Dhc9dmqJto0CMZfqD2+biLfLs6O3t7oDPBPn8= 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=3WUKn2dvevp+IRdH7T6aKSOygQUa+Gx75wLOTzgVKrQ=; b=UrhIXKoPAlZp53MDckGn2+H4xZYYeMc33tzXIR7SEo25p4tjfy6iscL4wD2eOflqgA 5xEeY6bIArpBKs4b9FIcLch797DNqYh6ApCpLD4Mtv8GkATXM6MfBfLUL0ln2Bs2vsE/ CKtMBgdQksC3ml7FP4soW2diyUmDFjjcOBVjqo8Oi8HqbZjJm6uK0Sl9udn2AxdijcUj YJARFos1dbFfSP6gq4ICA66VZVzX/IBb+zGDV2xmfKGHzTIFZ+jOzhNHSY1RZcxNdq9v gWuFpBHNSQYMUF4+WV8UU3qifGhrWCw+qYUeEFJ14WQ2jsc+7D65O0cAfsFgyh2e0m0h /+1w== X-Gm-Message-State: APt69E31FfG6hpavPtLL9ZKHwO3xFts1FF6YvNmeCxEwTdf8gIFV/DqH JJnXh8HCk6mM2KY6rjxvTDcI1y0A X-Google-Smtp-Source: ADUXVKKz2Nd7fbMf9oDBOr3m4O64LNkWcMuCIRlWwRXw9QVs6dydR1O2ZmpjNZUXKxJwzp8CW+wBLw== X-Received: by 2002:a2e:2bcb:: with SMTP id r72-v6mr15489218ljr.133.1529515384517; Wed, 20 Jun 2018 10:23:04 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:03 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 16/26] drivers: firmware: psci: Support hierarchical CPU idle states Date: Wed, 20 Jun 2018 19:22:16 +0200 Message-Id: <20180620172226.15012-17-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- drivers/firmware/psci/psci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 9788bfc1cf8b..256b4edbb20a 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -294,8 +294,7 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) struct device_node *state_node; /* Count idle states */ - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - count))) { + while ((state_node = of_get_cpu_state_node(cpu_node, count))) { count++; of_node_put(state_node); } @@ -308,7 +307,7 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) return -ENOMEM; for (i = 0; i < count; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_get_cpu_state_node(cpu_node, i); ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node); From patchwork Wed Jun 20 17:22:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139385 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050854lji; Wed, 20 Jun 2018 10:23:06 -0700 (PDT) X-Received: by 2002:a19:23cb:: with SMTP id j194-v6mr12121192lfj.90.1529515386412; Wed, 20 Jun 2018 10:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515386; cv=none; d=google.com; s=arc-20160816; b=jaDkBh/1fuQ2tfFSBK+r3aJ5KwIbEn1po0T7J77Zjd3sdsfsQTmsYnR5eSPIWllWfg GJDMcXZ864njivBd54kTT1wK4Yqm5ZnfoBSUysdIUEefLzR9SP1K60oo3SUloKySuzRz F40sS2IsHAwdhbCbS0r1N5hqQ0CtskFI1SagihhOx7WNo/WtG9XhmMNzDOGwrSmi+xBh NRTCxqlMdjFuWbQOg7Zm8xda42lfSJcM59/0J43xTYswkXl0EEdysyuFZcyC3dhs4EmJ 31E4i/ixjRUeKDKJY8myDUH7vQAiez9IJ9VS4Cwg2RK0aqnglpS9Ysz4W5yKHuU70lD1 xjsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=EJe6I+cNF7nFtIcL17BDc/zrHRiyQ1P0iyKZtVUO00fNJvHa1h0crvTFhWASjlcBVx xWibMu/BemuvM8+RtIJ2YteHJzGC9gBQZgeqzchV0x0sXAqYZens1m5pXd39l11v6AVv /rTTSgbETVakaqTrjDtyci68qZogFWE3bVY7jQzMyMmOCZc9Kuo+u+GklVwVEKDK2OMV DRvxSUojjW35evy1z0jnlAFlEJRvMYobISVuoXc0A2fl/sCH/OEvPD9ccWiDUHuUBd47 c/iPTyqEDoB8f/4xn6xp3WXeU1G8k+el4UVOUWeuexXv/SnQf7Y/I9Xd4FEZXZCcfzcB kEUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FperrAB5; 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 z8-v6sor721092lji.30.2018.06.20.10.23.06 for (Google Transport Security); Wed, 20 Jun 2018 10:23:06 -0700 (PDT) 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=FperrAB5; 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; bh=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=FperrAB5E7YDSjYoP6q0jhEs2Ox1HY0CxDVeDxyDEatvk5EZ/4z2r8mMTpWW2c/L4s gkPJqTo9YiUfQY1rNcGhu8tbZfXXmVL7mgsOkFqSiSEH03eiQBsLjeQ4zNQ7OebEbRfa U+dUGEMYyssb5EltEDwG3oNn2SDVaeN8eJijM= 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=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=XV0Cg+rl1RlZ8KGJO1fVUe338qFKjx0w4qI0YlVLiISX6e99K/QmseP1bDk89u7FDL tfrrLhXOmD4yg8hAfguycTvZLg7C1khNtGYzCAdsEVky61KUOwnZ7QEkGCUSrWt54p5N DDvLfG1QUKgAu2GRQ+jsWCBiYndm8dQ6toTOEmuLnS9ttil01r1Sv1WfdOrMTDeUFw7T Xb0WsSy+twkdAxF/Ue6HFhnpAkHx13dqKmtJvvU+2BteCh68yyz3bBVVrMMfbZoFY6s1 3dZohR1dZg/xzk7/JCa58M9x9T0j5KmTfocqzu4QIGjUF7qjG0Ur+hvaIdAsVng3alMp 1AiQ== X-Gm-Message-State: APt69E1alT+BOZ95804MK7HW1AITT1sWSxt8htZHTOmfhAvGkvE5wpwN 16eYvpIKUfTxhMcosjPn/AK0rIwh X-Google-Smtp-Source: ADUXVKLqDwiJhzmBIyfbizy0XbX1XsRN+liNcsyiQfmTjx25S14cNOUZ4NdRtHhfg2gbblf3geySsg== X-Received: by 2002:a2e:9ac4:: with SMTP id p4-v6mr14792545ljj.60.1529515386233; Wed, 20 Jun 2018 10:23:06 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:05 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 17/26] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 20 Jun 2018 19:22:17 +0200 Message-Id: <20180620172226.15012-18-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- drivers/firmware/psci/psci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 256b4edbb20a..38881007584e 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -608,9 +608,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 @@ -618,11 +618,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(); } /* @@ -634,9 +630,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"); @@ -660,9 +655,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 = { @@ -677,6 +670,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); @@ -684,7 +678,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 Wed Jun 20 17:22:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139386 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050894lji; Wed, 20 Jun 2018 10:23:08 -0700 (PDT) X-Received: by 2002:a19:3b81:: with SMTP id d1-v6mr9650976lfl.111.1529515388276; Wed, 20 Jun 2018 10:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515388; cv=none; d=google.com; s=arc-20160816; b=ZMKbLDKdsieVdsz5bz1cqWSfb2g89v4HaRK5mmaUog/zz8PGPuMIz9BfMi5/FbsKJX YBT0vAGBlShWi1FJlOuuhbyLPwM2AKtZwJ9ywZYV0wRqsiQ4CHL7JI5Gs2MPOMlQtAS/ rdyQYSXr3zEjrti76+HIs06F1yHWlyeNuWdAAO2VozAcr/xBs682jZ0eKHTrnDVpBzEq gYAOSFcxIVXtUkY4lqvqGsJZbZWZPoLh/QDaqD1UtCqKyYhFc5JydlxBShBwBIFiZyPS 805aqvRwFjsIP1N0b8I39gI/sxjDBT+G/A/V7lPtD2btqB5OebvATQj5vISW0y5nV6Nu /pMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5c12PoaPayFjQRFBN/FJeDZsu2cQBeSb29KIyIwynIE=; b=rGn/Z7Wj16CdtiJBig71qaABYGG5f2S/JLlRCv+LWMBoKC3MksUOx5D/WOjMfX3Ib1 E10ayhX8SswzG2S9bRef+5Anhkjf4a0oDpje2h//Yq5Dps3teaguGM8eTDRcysVF+mTu 1876kefxjvjb6xww02wST+4lHdhf9SzIwmufPawODya+hJKNKFoYKXpxny8HRZVyv0Ko ZRo2QD5IOxf+S8a7Jf6WoNKiIuLKO8rY1xLg1pNOKaHVMPOJJC/vMBV3TVjkPXSyssCo +fsNyEhXSjSfgzVZ3EWkIfrVJ9Ydc9/grqcCXcOCDa6gWUMLPutTNVy4MnEMGNDPu+Bh aafw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fNMEG9yx; 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 x28-v6sor730200ljb.114.2018.06.20.10.23.08 for (Google Transport Security); Wed, 20 Jun 2018 10:23:08 -0700 (PDT) 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=fNMEG9yx; 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; bh=5c12PoaPayFjQRFBN/FJeDZsu2cQBeSb29KIyIwynIE=; b=fNMEG9yxB1x3uNbnRxEi56bcFRcCmaoR6Yq8DZbX198JH13Yvc6OshNhATfGUoTPNU rcWDutQB8eDtpnXaKF98ag5WBNOEsuCTzbjaoF4Rn+S+MT+4uK6tpg6VCjYphHSCl5qt I4mu1VwZAJ6u0lwrfKG5OGZ2hRzl+Ce0CWEVA= 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=5c12PoaPayFjQRFBN/FJeDZsu2cQBeSb29KIyIwynIE=; b=a2eR6LNxK/5InlqM3PtXiWjDakPtvXZiifSjTvuVrZdnpP4LVKygsuOrqCsDQif0tM fvfBTAvlUqDUUkewfP4+Y4EAz7JBmQVsdvncTe6YtzGbd6bfMm/8HYPDZrHyThfGlDss c5gTldtmGlj8A0W3DLGSh33fBJD43Yq+2oZxmC3LKiIG1od+UQK4X85z8qOtX3lEm8Dr EfPAKy2FVuWWPdNX1HKCSOP19dQRa23XijV8otxbAatOpCEJie61H3qtVPSZ8lkT3rC4 QPoX/laVR5pZwFtXkdnXMR+dl1JMHJnm9ooFptu+OuTog2XwhAa0K9wD5LYpceOeCill gKGg== X-Gm-Message-State: APt69E2BMsEhZPqSRHygjEu3l/wfRhiRZ23EnSuwEfGnJKQlExWyygIM 86DzasFwSsORlCa2hb9tCPWshJKv X-Google-Smtp-Source: ADUXVKLXnbEUhvdJrQNRK3z6KOMETfpBUAn8KW5mZVmF80413yeBds/6zQjy2v73Bo8Bct0QemdGUQ== X-Received: by 2002:a2e:3613:: with SMTP id d19-v6mr14809658lja.31.1529515388105; Wed, 20 Jun 2018 10:23:08 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:07 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 18/26] drivers: firmware: psci: Announce support for OS initiated suspend mode Date: Wed, 20 Jun 2018 19:22:18 +0200 Message-Id: <20180620172226.15012-19-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 --- drivers/firmware/psci/psci.c | 21 ++++++++++++++++++++- include/uapi/linux/psci.h | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 38881007584e..e8f4f8444ff1 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() ? @@ -658,10 +663,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 Wed Jun 20 17:22:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139387 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050943lji; Wed, 20 Jun 2018 10:23:10 -0700 (PDT) X-Received: by 2002:a2e:5818:: with SMTP id m24-v6mr15283543ljb.84.1529515390112; Wed, 20 Jun 2018 10:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515390; cv=none; d=google.com; s=arc-20160816; b=sBYsbpLYuqSryp3cD9kinfCHgjG/OUeWYnERkRrlDybH/sFXgGNwex/OuJrT6TuNMX Np1NWGXt4daY5iBN8tF0Penj9e5N8DX22lTV+FhTZWm9AlqpS+FlTsAvGICcpKlfMWqw YTZhwN1GaLO+KEa7NXEylYgi/x3ywfGWlhd5X2YrFg/jPhJ7C5Y3+3MOwt+dzP3wxYyI dMqkGaUe2ufuYLyXvKIYy0NOW4QWqLxIXHgCT6Kk9vYfGgcqem9R45CwWOVxGKDbgxvc 2ushYMO/Bius/q4AUWfNecKbz5IWRvg//9+FP9JuaMSLrJ+DpIub8fvvPUec34/8UtHz HEUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=db7OlwdaNb2AsHDFCdi0cJ7TPFMkpfrIP26q3CWUcRjVf0139lQHWYiJuN9vPRrOcU TR/qYAmtrcckdQd90SNDbmmze1Mj22FJtioynPmll6vZkMK3hEHzZGWkWXuxNTCOvjqA t1hT+E1luNtL3kYYsJkvYnAI9AdSd072wpKLiqfXSa4j9F/LkVD/my7ou1yxLBdZhO+1 3p4XBOTjTBUG9KKpYm0P+CdpB2bsE8zxS9Y4/sJb78QeCWCIgRpVO32xcXZ12+f3M6LQ cGkjTS/zfwbwPBPH3//EVjl9f2q+gy0VSiJzmufi+Xl/oZhbqJWB8sUeXJ2gJDzHfnvG Ea3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bReuTrLr; 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 n4-v6sor687696ljh.98.2018.06.20.10.23.10 for (Google Transport Security); Wed, 20 Jun 2018 10:23:10 -0700 (PDT) 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=bReuTrLr; 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; bh=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=bReuTrLrm8ygiBOgjl6MARfBuQGcn7wxebgSmffuWDknXNqjcktDDJC9JVeFhivxdT Bds9hIiSkFKakweH7n+2MtfsTaIh1XuQx5p1VN54QQ62CpGG7+XvUvZCEtXgZC/hAQeA ALy5UPbu5+NOfj5nA0dHa5W5XwE2Y1VXqAclY= 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=7/fxm1AKVizOXQknbpAI2N51c69eELd8rPbu3jzZtbE=; b=AmRrdONesOcy9jX7Q8c5oma90swiORelYIThsn1vY83jjSmHXBh98mtAsB4ERE2hfU eup4ugn/dMtMZ+Wm2h//Y5EDlGCOdwQ0qAZ0RO91nf6CTRFIjMzw8tlmo98ZnQY6KI7F v4cq6N9km88iyeTJXqqkvzAkNiYwjuKuhK1HU97Fef2c86wZouxnPc5nAKvNGbSlL64q 24SzbljC6tm6Lx4Ycy+ufm+yz3A3fBxPK78epQc7wNzoqCd2+ROcT0zA5Dg8w2HL64z4 drXfIQ9Win4jv5jJxb92xB+V8COHxGBQlumtDJUeu6GT4Q0ixsw/+nZbkg3/KGrzfw2m 6urw== X-Gm-Message-State: APt69E0GgJjuNl6i2RWIbj7jcbXBnE4T4qQdE7NyZ9ZgnOcm7TXhE2Re 7Ki56VUATlkX5KiOTVuppycgBqDq X-Google-Smtp-Source: ADUXVKIJo2YXgol7hsdEFgWgAY/YBNI7nk8q9PRx07agC9mkR5QY2YZjX/K7yb4J8x3kD2yJFJegrw== X-Received: by 2002:a2e:5c89:: with SMTP id q131-v6mr8812218ljb.77.1529515389928; Wed, 20 Jun 2018 10:23:09 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:09 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 19/26] drivers: firmware: psci: Prepare to use OS initiated suspend mode Date: Wed, 20 Jun 2018 19:22:19 +0200 Message-Id: <20180620172226.15012-20-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 needs to be created by ORing the bits for CPU's selected idle state with the bits for CPU's PM domain (CPU's cluster) 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 variable. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index e8f4f8444ff1..40b2b8945018 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); } @@ -408,15 +421,17 @@ int psci_cpu_init_idle(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 @@ -424,11 +439,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 Wed Jun 20 17:22:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139388 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050988lji; Wed, 20 Jun 2018 10:23:11 -0700 (PDT) X-Received: by 2002:a19:7707:: with SMTP id s7-v6mr7166666lfc.8.1529515391939; Wed, 20 Jun 2018 10:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515391; cv=none; d=google.com; s=arc-20160816; b=EcJ7EdjglpfRLEr1HLyMt0qdT/IaztTI7qLNwliMPzE301lfxJQAM/J+lU0EB1bioc fWjHOJ2Z/6ide04lV+HJKuVPEeLcVfRICvMl7lMjR1npyXP8iycxmlN303oiK7Q0QEOF wTugaHdsXGOXt/+7HoSOi0iT6VFsHvjSC7won0Vwvmiu4kuilE/P99nTh+n7+qFbYQDw f3//KZwPfGDDSy4aQXyQQYrE7kplN5buVMlSO+COJF5SKXEH/GN50YeSShGvaAxbme9u COhl35Ip1BHWxUGPc/6Ffsx1vX8GnxsXQYAU0qqaKD0eZ1SR3ZAnj6mwqL1ATyG7sAqp IehA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=cV7qOWslovasm3reIVu1jS3ltOLzaMhL00jKgYh6Nhw=; b=Ty6ZlEgsU0V5hCBl8VrXVZZfXj66WKNCYI83mu6bQu6seMq7cDKwCbzCHwRxS4irTR 3kUNxw3FBT7ANTMsbEH9inXCW3rSGGMXTfgzq3wIxVGjrbXx81Bb3VxmhvBCzlh4Gj8t +sTs2kd/wpDR4Q31FL2E7KZvei9Hm8eKa1mfxTwMUzu9OWtf6YFmsMPGY9jxSb9cJgwl nqRxWX9XY05jrLE7fMJgfUCErZf0+oXsuu1KsXZ2HY3Q6TXA+UvCSEwwKyA3+gqwiIVS CQVn18U1n6uy8ZUAK1uwEzZnY7gFfcrYJ2Od7fEvxYvcqUMe5Jpcy1lPEPyNRvJzjWpN arVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U8pYcg45; 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 w4-v6sor687660ljw.103.2018.06.20.10.23.11 for (Google Transport Security); Wed, 20 Jun 2018 10:23:11 -0700 (PDT) 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=U8pYcg45; 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; bh=cV7qOWslovasm3reIVu1jS3ltOLzaMhL00jKgYh6Nhw=; b=U8pYcg45t8FOmO1McVT3H9JZ/G4uT7s9zkL4ps+KG/97JI/6Ql0hgjW9pAV01OKjUi lyeaNcYRIuTt8+8veRE0Bzw6OJ9lpOrym7fbVoRr6D+0rpM6K+6snow/l8smcLBEdb5h uXLrPEAmJMZ8jeGhQipkGtVEEJwGc4BPpQO+I= 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=cV7qOWslovasm3reIVu1jS3ltOLzaMhL00jKgYh6Nhw=; b=klJFS4zp1bOx+A8XQLfiMp3fHqKv6WkiZJChD1Yii9f7lUJPEkJHFUBk6F/wqophAY MChQ20NPN6OCDuaATe4dxi77RuWjsOdyGEUE74MQto0o0qMLxbuP4cWIcuiqItNCIIiv XdQiXiJVsZCyhwFdCnj/zVLsL27bqMS2XTvFUnWrgcUbZ+PJuRBpcsa8cmEaOV6Bf1UR 9hjugZicYdNU6ZdpPbEpO2kmYQpMWhM9DPJVbb9zeRj83U3DuNNgLfKYiTaQMy+7kE+Z +intjoiSVsvmd/j8EeYxEYwt25bjQxp5qQdZEboTSNT/gyyF4nKPcyC9S/FCumZfdRKl 7QOA== X-Gm-Message-State: APt69E2jBi7LDz82Ge7/P4d1S1txwNYHlVmv3Z+r+p2IcFf4LOg+CvC0 LmFc/AH/Vk64VgQeKppLtLuuxnW3 X-Google-Smtp-Source: ADUXVKJJVNGM+2m2TzrlaYwXiNDTFLn50Pzw7JzQr2AX+vT+UeroiBIEV4hh+8y1pNT5a7XW22BNMQ== X-Received: by 2002:a2e:5d5d:: with SMTP id r90-v6mr14518777ljb.125.1529515391711; Wed, 20 Jun 2018 10:23:11 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:11 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 20/26] drivers: firmware: psci: Share a few internal PSCI functions Date: Wed, 20 Jun 2018 19:22:20 +0200 Message-Id: <20180620172226.15012-21-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Following changes needs to be able to call psci_get|set_domain_state() and psci_dt_parse_state_node(), but from a separate file. Let's make that possible by sharing them via a new internal PSCI header file. Cc: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 14 ++++++++------ drivers/firmware/psci/psci.h | 13 +++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 drivers/firmware/psci/psci.h -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 40b2b8945018..463f78cda3be 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,12 +92,12 @@ 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); } @@ -285,10 +287,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 +304,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 device_node *cpu_node, int cpu) { int i, ret = 0, count = 0; diff --git a/drivers/firmware/psci/psci.h b/drivers/firmware/psci/psci.h new file mode 100644 index 000000000000..dc7b596daa2b --- /dev/null +++ b/drivers/firmware/psci/psci.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PSCI_H +#define __PSCI_H + +struct device_node; + +u32 psci_get_domain_state(void); +void psci_set_domain_state(u32 state); + +int psci_dt_parse_state_node(struct device_node *np, u32 *state); + +#endif /* __PSCI_H */ From patchwork Wed Jun 20 17:22:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139389 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1051020lji; Wed, 20 Jun 2018 10:23:13 -0700 (PDT) X-Received: by 2002:a2e:1dd9:: with SMTP id w86-v6mr14447177lje.110.1529515393947; Wed, 20 Jun 2018 10:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515393; cv=none; d=google.com; s=arc-20160816; b=YWJnujeBsimQZdu4+1fTWIc6cxJbn5lPgugRZsry6+RYezG3mkB4DPPPI8CHSyitYM jPrLakIDm2v9uTw0QJXjWqFazovHet6bpTbfRg7exELZBC9f5uH1V9Tl20mIpHbTm3M9 egS16+NL5pXhyXD/JO4yhsWV7kjoZ9frcVjkyOcNxSZcwioEMGhy4yCzcdr3pk2JWpYt cqJx/0C/PuRrzVnhM0qdyIftBDxKEGYFSL5U7AL5iIFP+mGTmoltcZF14kHx9dMK8i3+ vu4Ts9rsd1Q0S9slBjSUMqmTC5fy6LG9xO6fFmzeCtZMWP52GCpaPJJNBJDkG0RHA5na JTfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dpRzWZ1lRV3PUFVF54+RtopoI+Qxx4PQOSnHva5FuG0=; b=xZ9OC0Khcsd0J1JBA0i14Sd7zZBUAbN9bo6cPumViPrz5H1q1lCPiY2M0rkJazQSgR 3CyhzwxZMX9Qz40DR8kSiwxMV8m2z8dNRvMR4kCwo7I3r7YCLli1o0rJg6iOMG+gG6I4 f6oFrvKQRoJf2D+Vk/xlhCz4QmXaosaepAgSJDxlWoZkW/W6mlDjc7tm54z4PrO5Q2su FmG1cAE/nbVQTQ3ynDjPW/ImFOAr1OaEGemPUcB/7y4sDR1oFVn6pjzCYOZFvSkqZxLL dH6tnouDJmKF+3AKmyX/EozDcKfP+EKi6cxaa4B4mp2QTrfLuqpKRpI8nnADQpwsNYYd ZO+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Eg0M4K1y; 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 z8-v6sor721138lji.30.2018.06.20.10.23.13 for (Google Transport Security); Wed, 20 Jun 2018 10:23:13 -0700 (PDT) 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=Eg0M4K1y; 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; bh=dpRzWZ1lRV3PUFVF54+RtopoI+Qxx4PQOSnHva5FuG0=; b=Eg0M4K1y1jPCN7GIdZAXDgAVpLPggcUYsLLm8zmicBLw9lxb5F2rFzBE/Il1E3g8NP 2plsB85rwB3kEaChU/AkeAoo4cKWGeyImYGUir3Nl/kOY9eC7esYJbCMcVJnQS+qccXh 0HOpUo0XXP0iPIig7ion/ai28kav03/03ZtiY= 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=dpRzWZ1lRV3PUFVF54+RtopoI+Qxx4PQOSnHva5FuG0=; b=aVeUInMOJmp7nF0zwBCmduPw8zbthRVT3yxWB8XNwasvthIgU7DFjAYZuJMxTXvxZ8 jTSA8P552216A5drvrgYx2ejltIM1K74jLwFGchmr0ca+eLdDrYvzA3okY2qj8IIkq7m 2mjV9zqjEjH9oHPQm3FpWJNEccKXa7QuQAcuOLwlaNrkuIDshEYSxBTUKlnBxVY6qcXn ULVEtKcW5JF/MFdNy2KftcnZ0NWLKluAqxagN9Bit/s3Y5NWBsY/69IaDqY1ecNn4gyy gIFkvF8N8dx0Aa1qpLkl1e2tAIJUKz1ZECy27H0lSjva30QGV1B1DelLUFIJxuAugKF6 ychQ== X-Gm-Message-State: APt69E3Peg7acOg6ATGoddtOXBftSjtMroSqljoTPHHVock0HokffgQs nHUK067mVwUODxIEjNfK9AAa3qeU X-Google-Smtp-Source: ADUXVKLVvZTFdpj3qKwzqzeDJnvXHNUoiFXlfoS4PQuZNDvYr6YFwfV+WCqsLUvtvRFLb00abw1Qng== X-Received: by 2002:a2e:428e:: with SMTP id h14-v6mr15515102ljf.136.1529515393686; Wed, 20 Jun 2018 10:23:13 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:13 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 21/26] drivers: firmware: psci: Add support for PM domains using genpd Date: Wed, 20 Jun 2018 19:22:21 +0200 Message-Id: <20180620172226.15012-22-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> When the hierarchical layout is used in DT, as to describe the PM topology for the CPUs, which are managed by PSCI, we want to be able to initialize and setup the corresponding PM domain data structures. Let's make this possible via adding a new file, psci_pm_domains.c and implement the needed interface towards the generic PM domain (aka genpd). Share a helper function, psci_dt_init_pm_domains(), which the regular PSCI firmware driver may call when it needs to initialize the PM topology using genpd. In principle, the implementation consists of allocating/initializing the genpd data structures, parsing the domain-idle states DT bindings via calling of_genpd_parse_idle_states() and to call pm_genpd_init() for the allocated genpds. Finally, one genpd OF provider is added per genpd. Via DT, this enables devices, including CPU devices, to be attached to the created genpds. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/Makefile | 2 +- drivers/firmware/psci/psci.h | 6 + drivers/firmware/psci/psci_pm_domain.c | 180 +++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/psci/psci_pm_domain.c -- 2.17.1 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.h b/drivers/firmware/psci/psci.h index dc7b596daa2b..a22684b24902 100644 --- a/drivers/firmware/psci/psci.h +++ b/drivers/firmware/psci/psci.h @@ -10,4 +10,10 @@ void psci_set_domain_state(u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF +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..f54819e7e487 --- /dev/null +++ b/drivers/firmware/psci/psci_pm_domain.c @@ -0,0 +1,180 @@ +// 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_PM_GENERIC_DOMAINS_OF +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 (!state->data) + return 0; + + 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_dt_parse_pd_states(struct genpd_power_state *states, + int state_count) +{ + int i, err; + u32 *psci_states; + + if (!state_count) + return 0; + + psci_states = kcalloc(state_count, sizeof(psci_states), GFP_KERNEL); + if (!psci_states) + return -ENOMEM; + + for (i = 0; i < state_count; i++) { + err = psci_dt_parse_state_node(to_of_node(states[i].fwnode), + &psci_states[i]); + if (err) { + kfree(psci_states); + return err; + } + } + + for (i = 0; i < state_count; i++) + states[i].data = &psci_states[i]; + + return 0; +} + +static int psci_dt_init_genpd(struct device_node *np, + struct genpd_power_state *states, + unsigned int state_count) +{ + struct generic_pm_domain *pd; + struct dev_power_governor *pd_gov; + int ret = -ENOMEM; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + return -ENOMEM; + + pd->name = kasprintf(GFP_KERNEL, "%pOF", np); + if (!pd->name) + goto free_pd; + + 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_name; + + ret = of_genpd_add_provider_simple(np, pd); + if (ret) + goto remove_pd; + + pr_info("init PM domain %s\n", pd->name); + return 0; + +remove_pd: + pm_genpd_remove(pd); +free_name: + kfree(pd->name); +free_pd: + kfree(pd); + pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); + return ret; +} + +static int psci_dt_set_genpd_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; + struct genpd_power_state *states; + int state_count; + int pd_count = 0; + int ret; + + /* Parse child nodes for "#power-domain-cells". */ + for_each_child_of_node(np, node) { + if (!of_find_property(node, "#power-domain-cells", NULL)) + continue; + + ret = of_genpd_parse_idle_states(node, &states, &state_count); + if (ret) + goto err_put; + + ret = psci_dt_parse_pd_states(states, state_count); + if (ret) + goto err_put; + + ret = psci_dt_init_genpd(node, states, state_count); + if (ret) + goto err_put; + + pd_count++; + } + + if (!pd_count) + return 0; + + ret = psci_dt_set_genpd_topology(np); + if (ret) + goto err_msg; + + return pd_count; + +err_put: + of_node_put(node); +err_msg: + pr_err("failed to create PM domains ret=%d\n", ret); + return ret; +} +#endif From patchwork Wed Jun 20 17:22:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139390 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1051048lji; Wed, 20 Jun 2018 10:23:15 -0700 (PDT) X-Received: by 2002:a2e:905a:: with SMTP id n26-v6mr14408078ljg.33.1529515395703; Wed, 20 Jun 2018 10:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515395; cv=none; d=google.com; s=arc-20160816; b=rnmxa+aJvDpdYvJrQmvPn+6Ne+/K5hftRAQVcHPvWQO+xB8E039NWjrsxBU1rer8lw ovG0Jw/mnGA/wCI5ZNgJftU6tP1ErBuelsFpO58zWyI6ja0VxEWHQvAVfeRkxFT0Pf7c L3EpfIscay3UcHfL9a0daNRzRP9mNIilDfmhluDFs9nL6akmBqUm/9BITcdd906bwghp t5M0Y2NsUhfVAOBX8Aaqs8kuZB80ZnJJx59wSx8aqftuc1D8u77xf5zgDNlGPbSaX4hB zTcaISmENWnjaGVU9PzNpqvUFKnguJ7rHr/NoPl4P3aznEZzgU5jUb9fVh0ln7nuSLaK h4bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=obVnlFJdxsGUIrbcYFsNPcmvDAVODyR1tm0m+FESLs4=; b=quqmizTkaOl5UsT/EnOs4frbwlmVike0gdkJfrw3OKTzvrrI5sS3BY6YWLh/njmIwN ggpD79Umb0XxKpri5PopMeLLIxwtYysQe9eqPr9Oe0C2OfwL/oLw5WKXLXGCPHmJ5R4U r9b/tBua71fJlaYO7n8jmU/eZSr4hxfsiD2c1/4mrlQ4t7GniZEdDlQ5WVwFUcfocL+/ zqdX/MSXoICg6hrfiy7hRndeL4GSvvevG7LPLXr7BR0E6TyHRqXrQ/a0UVCKQopuzwZx /8EaZf47z+kF5SCM7ipPnO5bFLulMsiaAAG6uIEed6Dcw0+7QnLT9J9vwl3MkltrcYBT 1jJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AnCYg2NX; 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 t9-v6sor739638ljh.51.2018.06.20.10.23.15 for (Google Transport Security); Wed, 20 Jun 2018 10:23:15 -0700 (PDT) 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=AnCYg2NX; 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; bh=obVnlFJdxsGUIrbcYFsNPcmvDAVODyR1tm0m+FESLs4=; b=AnCYg2NXxTXPOMS3NLdA54taBopJhCvN4sAF0xjh3TeRtV28/1UJ5iN37Mx8z8MtQ+ Sd03v3uXI+8MfdqapNB1+BCvfPIiOAB9CYEYGOdXpOlm9d0aJUQE6uKIxBvvT3TqWJPX y9oI25toX9WaZ3/Z2AaDFlQONWJ5W8lKApHQA= 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=obVnlFJdxsGUIrbcYFsNPcmvDAVODyR1tm0m+FESLs4=; b=hB6t+DFlRgh4y1J12fiuuXth5V7zoZ3CAGC88hVjaxxEYuCJBMN/PbKEAHhYny3Uz+ SvsPS4ahVMDoNADFaJWAHtp1f93U5Mt6D4R9s9FhrmLqICWvS6v7Rfdn2ksekkHxt8CO 9RU/Z+fVcQLyY5CSfdH3BnpNHWg0XjCSmHZeZ2Y6VRixjCcUo2umUxvdHvDtsuOJZur/ eVyC0kFUQqA6JW9MghYixIdjh/DtRaZBqRIjogK3h/GnCIpBml7rio/I5WlaCSTYL8tV MmZPsFCX9HBNtQjw4e8MUamaJwHrgrURaqzpEoPr9BtAiZwPNDkpM1m7Nta6ceFy8rO8 q7aw== X-Gm-Message-State: APt69E2xRp8YkVLCHI37+ZMvv/5S+oiuYtc2vetzvRWIFHMF79e4f4CQ 72Sr3Qek8YnR6sDRxylEqcGAJhIp X-Google-Smtp-Source: ADUXVKKP3XsV0AqKdjZqk5wC3TpY+18fzUVAsruGPiCBE3ius4Z6oJKYgOGVAhcSursIh5yCF97r/Q== X-Received: by 2002:a2e:750d:: with SMTP id q13-v6mr14484271ljc.56.1529515395487; Wed, 20 Jun 2018 10:23:15 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:14 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 22/26] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Wed, 20 Jun 2018 19:22:22 +0200 Message-Id: <20180620172226.15012-23-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> In case the hierarchical layout is used in DT, we want to initialize the corresponding PM domain topology for the CPUs, by using the generic PM domain (aka genpd) infrastructure. At first glance, it may seem feasible to hook into the existing psci_dt_init() function, although because it's called quite early in the boot sequence, allocating the dynamic data structure for a genpd doesn't work. Therefore, let's export a new init function for PSCI, psci_dt_topology_init(), which the ARM machine code should call from a suitable initcall. Succeeding to initialize the PM domain topology, which means at least one instance of a genpd becomes created, allows us to continue to enable the PSCI OS initiated mode for the platform. If everything turns out fine, let's print a message in log to inform the user about the changed mode. In case of any failures, we stick to the default PSCI Platform Coordinated mode. Moreover, in case the kernel started from a kexec call, let's make sure to explicitly default to this mode during boot, in case the previous kernel changed the mode. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 38 +++++++++++++++++++++++++++++++++++- include/linux/psci.h | 2 ++ 2 files changed, 39 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 463f78cda3be..80c286d83369 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -691,9 +691,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; } @@ -723,6 +728,37 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + if (!psci_has_osi_support()) + return 0; + + 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); + if (ret <= 0) + goto out; + + /* Enable OSI mode. */ + ret = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + if (ret) { + pr_info("failed to enable OSI mode: %d\n", ret); + goto out; + } + + pr_info("OSI mode enabled.\n"); +out: + 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 8b1b3b5935ab..298a044407f0 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -53,8 +53,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 Wed Jun 20 17:22:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139391 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1051084lji; Wed, 20 Jun 2018 10:23:17 -0700 (PDT) X-Received: by 2002:a2e:1414:: with SMTP id u20-v6mr15301097ljd.134.1529515397454; Wed, 20 Jun 2018 10:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515397; cv=none; d=google.com; s=arc-20160816; b=wgOARA1gWgBXJ+4qEIiW5TuhL9Kp8FBzbmJwaVmz3bQngjv/xyCu9/wgNQFqVQcP7V Cvgo3rAaTA9cCEZp41XgyKwCKfP/RPkKPaCdzXVPLTpflorRWsyJP+pCFRcD/HMLQChD zeKSrzjsjFlPrIJ2Iq1WvaltzLYbragNnOT6NN/5LwRmOKxim+WNUeO2fyZ8i1CJ50x8 QHy8nIpdeYzLOv4Q/P+ZtBl5Pd2cZIn7Ajmw3qbhCBjhF/jftB5GLLArUBunGdaNiyxN nh5LB1HzBSiGfijB6sFLhE3YZPC0M4YEyJkPVU1APAUsc2ZwBwAui8tUuduDisO8LeGm NPlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=iMx6h1L2HIsE81Qqf9KTc/HGuq09dzGoe43tExUeSqA=; b=ThBwodVPa1tsv42HlG2U4UXcFvc2sBCL/+b/Px4eCSa67t/8+b8RDjpxONtXWPnCuK vFzlDRPvNIpi48Oqr17SZy9/5Jj84gXqrqKpdn0W54Gj6Oj7DNQwrnBzqYSeuaCICy9F /NuLO+RlNkuA2JIKiH7k59sragTYxZK+j73qJffGp8DfIEus/uZuCd3MzlRXcqWWVdAX vN5uvQ3ZF81IMy6dRmHH4FkRXWus1CHFNGnUkcAXOi2LRqa9ARe5yHqcv5lsHb8QN2NI 7SgWUW3rTQxJ0TyciiRy0xo3qiBnLSmRkB27K2AZCSYgyQACUQvg+xfcqAC6Y5n0lTZg KdKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lr1SCMsT; 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 x28-v6sor730287ljb.114.2018.06.20.10.23.17 for (Google Transport Security); Wed, 20 Jun 2018 10:23:17 -0700 (PDT) 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=Lr1SCMsT; 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; bh=iMx6h1L2HIsE81Qqf9KTc/HGuq09dzGoe43tExUeSqA=; b=Lr1SCMsT8ul9gy3ZiZNlhP2+8AuWwFud0Q1JuVsoxiCkAjBT3/MVx41++wpXHYtrzt pIJuCC7YYAu1tt6OvJvaQR5TtdEdmaXw5ancZ1EQj+e15c59a9rvW635+5u8WDX4HYej oTmXppj0RJifVpThU5DPigCvFbvwigZjpnYxo= 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=iMx6h1L2HIsE81Qqf9KTc/HGuq09dzGoe43tExUeSqA=; b=Wky57t/1aF1OlS5Gr5wKZBytFDcZMv/DwpdKkXYqAPtJdF++EIK9jrqgRsFqi6/oMa 6h9rsABvKQIQxhzjtSnXqoEORo4iUr9sAjZefFlN5pKVjthYi68meFVzXWa/KtgLtJqd rLhHbiEcxBpfH+zOKRdxjcvkEvffdUKyJ9drDymxRnFCfGQtxkEFP6j2Gw4sAR9ROAA4 EJ4Vm/dhdz9ZjTHL8H7UP9+rTm00vkoZFFH2UBEFiPMhllIYfmENd1iPP0vEi2GGob/a x0fjEupaxZLJputO1HFRDjhXumkP2SJuw/Zs+0z8lrQQKya6xlEgZoiKdECE7LwV0Iuq 7lXQ== X-Gm-Message-State: APt69E3l+IwSJ+knLMYfJMCh1ELdDi9kSGxr8kbZigjR8Rk125YkGtd+ e941blG/FAY1ztJmu2+9UoY0QMFM X-Google-Smtp-Source: ADUXVKJN7qF1bO1BibAbpbCkbJJtFe10TW1BGESo34tVrvg1dCk+dsk7W0EoG6BuIGK2G2S49aEd3g== X-Received: by 2002:a2e:1d59:: with SMTP id d86-v6mr15376470ljd.104.1529515397265; Wed, 20 Jun 2018 10:23:17 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:16 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 23/26] drivers: firmware: psci: Try to attach CPU devices to their PM domains Date: Wed, 20 Jun 2018 19:22:23 +0200 Message-Id: <20180620172226.15012-24-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> In case the OS initiated CPU suspend mode have been enabled, the PM domain topology for CPUs have earlier been created by PSCI. Let's use this information in psci_dt_cpu_init_idle() as a condition for when it makes sense to try to attach the CPU to its corresponding PM domain, via calling of_genpd_attach_cpu(). If the CPU is attached successfully to its PM domain, idle management is now fully prepared to be controlled through runtime PM for the CPU. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 80c286d83369..700e0e995871 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -91,6 +92,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_osi_mode_enabled; u32 psci_get_domain_state(void) { @@ -339,6 +341,14 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; + + /* If running OSI mode, attach the CPU device to its PM domain. */ + if (psci_osi_mode_enabled) { + ret = of_genpd_attach_cpu(cpu); + if (ret) + goto free_mem; + } + return 0; free_mem: @@ -753,6 +763,7 @@ int __init psci_dt_topology_init(void) goto out; } + psci_osi_mode_enabled = true; pr_info("OSI mode enabled.\n"); out: of_node_put(np); From patchwork Wed Jun 20 17:22:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139392 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1051116lji; Wed, 20 Jun 2018 10:23:19 -0700 (PDT) X-Received: by 2002:a2e:92cb:: with SMTP id k11-v6mr2504956ljh.18.1529515399489; Wed, 20 Jun 2018 10:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515399; cv=none; d=google.com; s=arc-20160816; b=HgSCXjYVU4WcmtWXiot4UA6rijmfiUDbfJ+CIHiQsRTJBRzna6IEVAj9zauBG4PsBm gKzbddizH/xArWe9gao/PZuHFI4ZT9QvDHYgv1hdN0IEsD9d7DdHbAsEr/rKHaaa/Vtm lsphy/vYz60vau0/SZaTB0ue4PxdXNv94OFPy4cDaPh/T4ySImcQ7hxhJ9V4BKTsvvBj 4HwyEDm6gK6H/ooKeJK/JFtwzxi+DXXBzOlkErqH6Gh9VjiQk60ZHv9i6O2hsilJDQch DL3QMHXIcdd/VnHrxIaCpxfdb9h5KC1mS30lnzD45G2nl7Opa/FtUDf/vqgwx0Fv3Etf XiCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=w6707zj46IMqt6XCkQl3eda+NnYi5j11bRFglc+AHIo=; b=xBTUdRx/ROo6s8LxLnXr46Mp1DKtY0swJJ50rQDZAXhK6CfgVtAsNXNC7PKpAudJw6 YVFvQFOpQZoYRWLR4pcii3Dbw+iXSciF4uevaC0ONuvpITyWtPSLKrhMeRitksG/w70K 9WJfD8ViFzQ+d6QhGLyCAHXdPe4LB+nljmle0dP7eV6NEsTiHeJsm6luXGCl6dSp9/hP bdyS11a/XtqPJwjEMLAPaa/rP3vMsTkM0RVQPNBFBE77J8FdO1gERuIqnRlI/smV75iY qAufk7mtNBBbQKMRvN4cH6+2U9onZZC+L1FnuqsckNgZ6itwn7eClkMMgk3TnwjKH1ST nyjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MYqUP1PX; 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 l13-v6sor638200lfi.78.2018.06.20.10.23.19 for (Google Transport Security); Wed, 20 Jun 2018 10:23:19 -0700 (PDT) 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=MYqUP1PX; 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; bh=w6707zj46IMqt6XCkQl3eda+NnYi5j11bRFglc+AHIo=; b=MYqUP1PX6RNA8Jk/XK94dyVhwN3dNQK/vBGc7ZQbpt3uVK887zAsAYYjKClORu8hYZ YCval1UFbciw6q+Jf6WI/auuiDVzqnHaK29+Xwx4KQX80gN7FPLwOPneN3N5nWLlWJNn dnX/Cen42KgPaYzK2lzR+hKcvFi1RzNlQuXLs= 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=w6707zj46IMqt6XCkQl3eda+NnYi5j11bRFglc+AHIo=; b=rL7eyaAOQcKSVcSlWLifLlGy/sfDl23+igXSkeP4clDgEsu3ZnHDD18ssoycV9BflG 0QGjiZXOKX679qTukgjDVFJ4CODTxwVa/0PuyMz5Li1I5y8cDV/LUS5m3Rfvm0/OiEkM 4+WrxQzdYXpFKtgcPAtWzbNU7ktrP0grFjxjm3sjeXWF8lHZIBkT3DtZCytYgFGnOIp+ 7yXWgTteW+J/T65ITH1GXuCU2pUdTGSo5wvVodcgfGX449qE083OfvG8wpZ4mzJtirkk kPMO3GItzOzRpYsi/gPsJwduTZO6tq/eIKfO6Ue7Gh9cfMbuZyn6gDSoEQMIAe6gS4R9 hqOA== X-Gm-Message-State: APt69E0rfIkUIM4a1DASTumbbwzutCa72mxhObo5xzE+/fVSLYmz42xf 1C4lHR8D0Dz2d/NxXWpncrcUjCNc X-Google-Smtp-Source: ADUXVKKO7UQ2hkCEVdaK5Yf4srm6bzhJGEXUFWekAvaP3L9+qrqsnljNOBZe+oStCJOAS8uRawZ5tA== X-Received: by 2002:a19:428c:: with SMTP id p134-v6mr12790102lfa.4.1529515399164; Wed, 20 Jun 2018 10:23:19 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:18 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 24/26] drivers: firmware: psci: Deal with CPU hotplug when using OSI mode Date: Wed, 20 Jun 2018 19:22:24 +0200 Message-Id: <20180620172226.15012-25-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> To deal with CPU hotplug when OSI mode is used, the CPU device needs to be detached from its PM domain (genpd) when putting it offline, otherwise the CPU becomes considered as being in use from genpd and runtime PM point of view. Obviously, then we also need to re-attach the CPU device when bring the CPU back online, so let's do this. Cc: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 700e0e995871..e649673d71f0 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -190,6 +190,10 @@ static int psci_cpu_off(u32 state) int err; u32 fn; + /* If running OSI mode, detach the CPU device from its PM domain. */ + if (psci_osi_mode_enabled) + of_genpd_detach_cpu(smp_processor_id()); + fn = psci_function_id[PSCI_FN_CPU_OFF]; err = invoke_psci_fn(fn, state, 0, 0); return psci_to_linux_errno(err); @@ -204,6 +208,10 @@ 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); + + if (!err && psci_osi_mode_enabled) + of_genpd_attach_cpu(cpuid); + return psci_to_linux_errno(err); } From patchwork Wed Jun 20 17:22:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139393 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1051142lji; Wed, 20 Jun 2018 10:23:21 -0700 (PDT) X-Received: by 2002:a2e:635b:: with SMTP id x88-v6mr15648177ljb.103.1529515401203; Wed, 20 Jun 2018 10:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515401; cv=none; d=google.com; s=arc-20160816; b=krHBYXL9gdmntkl2s5mg1emh7KctNMghIYzqrN735jMA8dhYW/3BN6SIeez0bCev02 4OX+ni0CT5/LT+85tqUEb3WqZvK0p8GSaqb3VgGAAnajc2Adyxi5jaY80sWd14vpaH23 w3qtg9GTu733+YDrmNgDH7Vt9GFgrZkAR+CcocHZr3ctWZbhIn8eSFoM1+WuGd21+UlK ymT2w9DVl9dYOAzrkEcpbSbeWGOxHtbH7eQbBvaNaqA/vcMMxzcHa2esD3/fPic5E34l 4VMhwD42MILEt2ekqwPtad42xu0aDHnDR6ACRxV88rozKgJbG7ZhckZOnzUwPvA3+PUy GATg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=A0wHhSMjy2YWUBymI+ELB3cg7YhnejdDuSmcctGS5h0=; b=BplwKcQNQD5l1+h82Bdru0+dJgDcqbwePHh20m/6/hQCcAU6HUcOSbex+2wzSRZh0l UYBCUVo88GH/srM/bDxxIDqOakjju3asvECjHV9GXuiZnH4NPA8X4EnTHARa/hJ7dyU6 rIf0nbhrSPBT7bPoPLEM4Bg0tZP+LJVnkD8r+sDpvjDsPfP9AMR9z3XXeiyVeOvsjkAH gkUJuGdQklYMmYwe2uHWyiXpRPQauMBKYr/HyMOEuzPiSX9qG9Qv0OEquJkWqhHzT9g/ W/JaynIlG00+ML+g5wT/WQ118TB4eKcabW4xIS0RXlNJGNTxF7gDbZ8OqC5M/lyqA5yi rXbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cc4UVhff; 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 l3-v6sor655039lfc.52.2018.06.20.10.23.21 for (Google Transport Security); Wed, 20 Jun 2018 10:23:21 -0700 (PDT) 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=Cc4UVhff; 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; bh=A0wHhSMjy2YWUBymI+ELB3cg7YhnejdDuSmcctGS5h0=; b=Cc4UVhffJoYlqO+SbXv2kjA+4gpKKMPUH7+iUg1inol2Yd6GYumCkm6L9D0jffBF9g tId+4hG1pleNCzu5HlGkbCq6Z7yj6wdpXf2Fv4FuYgUNGv1mdzBpApn7ACORNAtB01sa h+4biO8cruT23jkl70yQj5Iby7nf+htjQvVeI= 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=A0wHhSMjy2YWUBymI+ELB3cg7YhnejdDuSmcctGS5h0=; b=sr/FR2AkJ5WMM0MzkUvHz69ZJCefw+AvjbUIyPzv9F7zAv4QFMkKzaKjrq7Xjs31m5 qBlGqqfvvss31QQKkLfTcMp0YTz307Qte9bfI0S7NMEpj8O+Xaj3GTypWvfY98p5lVwx Dweero9aXAKc1lmxTy/IBtxdszWyxzr5IIJI9mWLGjuadryiKoAdUMOV3kPNSj9Z3/bk qHqN1D5Gccsphxm10Ei+jjLFitRsZQQ7T4vPiTJf2fr0WcpFtp16a/dl52do//g2RpHm zm45o2anco9Kjf2eAi8yIUYD4r64/axVeR4B5fuqJIyL0pZSp+EkG72tTycDxxqLE63L BNoA== X-Gm-Message-State: APt69E1InsOtWUYNBMGDhAVYVCsPeARuVm/s0bejfdiHUzm/OgRw2zRs BJf16r/iHFgKv1RxNE/IViQChqMx X-Google-Smtp-Source: ADUXVKKGrJcQbuFacYuCzcPcajO2mFMxaQ9jmU/ZoosHYpnzyrE0TthM05Jg6JQq6VHUdQj72V3vRQ== X-Received: by 2002:a19:a78a:: with SMTP id q132-v6mr5269049lfe.126.1529515400950; Wed, 20 Jun 2018 10:23:20 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:20 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon Subject: [PATCH v8 25/26] arm64: kernel: Respect the hierarchical CPU topology in DT for PSCI Date: Wed, 20 Jun 2018 19:22:25 +0200 Message-Id: <20180620172226.15012-26-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> To let the PSCI driver to parse the CPU topology in DT, as to create CPU PM domains in case the hierarchical layout is used, 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 --- arch/arm64/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 30ad2f085d1f..574a5045f2f0 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -331,6 +331,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 Wed Jun 20 17:22:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139394 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1051176lji; Wed, 20 Jun 2018 10:23:22 -0700 (PDT) X-Received: by 2002:a2e:8455:: with SMTP id u21-v6mr14311859ljh.66.1529515402819; Wed, 20 Jun 2018 10:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515402; cv=none; d=google.com; s=arc-20160816; b=D4gpwehBCRtbOpBRN+V2xKWfpkQg1jLG7Xl45TnzeMLBwC3JRrBW+7iLKGf45sfxM5 zHK3VCo9qLPl8UxuY9T1gFDqFQL+B9xb+Lfe2QTbamTOHN7RKS6VYsDxht/QBZWWFENA 1MfU+1Jy+69QsoT7UxmcUbBc4C1MVpZAuT4/MVu9sG6oGWFaXfFUzammsJ+MMoPS+uUx t/13mVwpZ5e+RuEnObN9e2vmL8jLouCM6/EPxpNgLAxCkhTzak0fvVFY0wtjeGZHGVPo bGo3H09tseCLp03MsMLiYIrp0IeaCJBWm2xdOQcsJohbMN9LZlwbdj6PFvEFfs76KdjE XKdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=vciKAZrRv7ECOl2ptqOo+/cjgmJMMGADcdSrEduU6CM=; b=OgqoaKj+vOYmPA7Lu4piYCE5s43CFkhTxUxvi2cpeaaLjV35b3MOiSnMMPgQgKD7uH YaHUO3jE39D2FU59LMdobDKOgkJG0Eo8bX+GE1qSg6TSIOai/7+TFU8FtyO75MLO+WuT RUYg5qJfTpPotTyLdRQkxZU83i+q1A9/0IFHHqOBBsixMgDhFO+e+X8lVFkGcCLXCbkO uy0tv5MpTsWGDAYhbmYPQSGhjvjdHAL565Sh0PiHdeF0fvbBFrX+l0IHu2V7PyZNApD5 SAShBgK0cgFBnhjfKnzwg4NFegqvAGqtHfCTl2H+HlzTzPMTY+mYe6m/GMlSPrGd0RLZ urVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KkpC0Yn2; 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 a139-v6sor680702lfa.92.2018.06.20.10.23.22 for (Google Transport Security); Wed, 20 Jun 2018 10:23:22 -0700 (PDT) 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=KkpC0Yn2; 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; bh=vciKAZrRv7ECOl2ptqOo+/cjgmJMMGADcdSrEduU6CM=; b=KkpC0Yn2jPtKbAWQ0Aa+Ji7L3B367c355N3cQVkYlkTkk2twnsvqmvJIBt0lBz95/t XfvbnpxB1eMsui6wZaPKw7psnXfl3tiedOF1smCzsikembXej4uH3IllCXfihIZU95aJ auciZjtR8uD/oSbJlLihwNSXeJ9jjhsBOTa70= 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=vciKAZrRv7ECOl2ptqOo+/cjgmJMMGADcdSrEduU6CM=; b=AMDWTxkl7EPtF7A1XUWs5MoWW9UlBaP5f0jH2tQhVZfCvNafi0K1ntg+jg30MEr7xP wuQYxlQgfL6Cj+3NK5vyotgYY9oklAh9W9Hw+UREu2Q1TxGPm1XrtUM2zjrrMg9yc5qx lcf/YrnF4XRZeB2ctsdYag4TPan9QaaeqHCgTXHnUcuBVicV9dhzuWNUEk5MyaZEAGFd fK5jKVIS1ooX8Ae8VT4WnB4uphk43ZbAcG3coUK1Eq1mXdtHWQdtUNLQ9W+F77BhjnvJ Knnl5ECr1GQ1mbKLp4P/6F9mq9Q+Q9obhCUuI2mQLKY9Sqtt5jUKlRIuYYDwngaZDCm3 cI9g== X-Gm-Message-State: APt69E3+6I44SFLwguO1GdxSrSP4iKGdfel6FkcBpvcWQcK1Se1Kwa/m 78Lry+fjxwizfF6jgxstBi0sg/xK X-Google-Smtp-Source: ADUXVKLoRcYNVaAgk3ZjO+D0NDTmmrS1SX7JnugQWo+BRl11ewEOjLapCRe5ahKK5eg4vuZDor2X9w== X-Received: by 2002:a19:eb8c:: with SMTP id f12-v6mr7763384lfk.132.1529515402549; Wed, 20 Jun 2018 10:23:22 -0700 (PDT) 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 b2-v6sm514441lji.85.2018.06.20.10.23.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:21 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Gross , David Brown Subject: [PATCH v8 26/26] arm64: dts: Convert to the hierarchical CPU topology layout for MSM8916 Date: Wed, 20 Jun 2018 19:22:26 +0200 Message-Id: <20180620172226.15012-27-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> 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 makes 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 --- arch/arm64/boot/dts/qcom/msm8916.dtsi | 53 +++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi index 650f356f69ca..d67c51090d0c 100644 --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi @@ -113,10 +113,10 @@ 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>; }; CPU1: cpu@1 { @@ -125,10 +125,10 @@ 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>; }; CPU2: cpu@2 { @@ -137,10 +137,10 @@ 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>; }; CPU3: cpu@3 { @@ -149,10 +149,10 @@ 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>; }; L2_0: l2-cache { @@ -169,12 +169,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 {