From patchwork Wed Oct 3 14:38: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: 148056 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557422lji; Wed, 3 Oct 2018 07:38:41 -0700 (PDT) X-Received: by 2002:a2e:6e08:: with SMTP id j8-v6mr1465886ljc.61.1538577521388; Wed, 03 Oct 2018 07:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577521; cv=none; d=google.com; s=arc-20160816; b=QCfh2qFPpD8MuEmqhumNnydVbBep4IzokStk+plS6+fCAa4T5ixdvmm/H4RsITqhf+ P/DfyKJNioo4ha7kUuJ8A6LE8rhWOSQLilN2RSHuWHPpjwBkwarvU91gUTI3UDSIJ1kg rNxz+kOL64VPP/IyBu75oB6BV+e6ki6mmc5GFFudTX5Efkm/UYaDpWwD1TWjwWI0Hx+V cEGGJIUKGy1oYbJQ5paLtOh3Z1ga1421fhEtSV3aKvuqD+hE4LEAznovUs7++1TpgH14 +Mh3RHFSxMPzpbm8GD9P3TgYbQFxsTfC9vNYChIUSqpoxltp6c4tbcSF8EUm/kj4tAQP XJwg== 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; bh=lOD5x9dibVDZPPRf+HmlB0VLhQ+dq9aywfJobMmjAbY=; b=xM6G0v4RVLha0DUM2/pbGbCDHa0afSvmas+G81dQYi2cdiT9N3R/wetVIyDFEZJwqc EQM+oadMo4hRq8VJOO1Q8oWsJDUs0SotUOraybMnekoaLU5IGqkgzylzqVhz1itkIpnR U7sWzODe9P+98MBp+oROmaBhjJtLJFgLsiG/3DnC4EWPOSL0RdUMkdRi9iGqTYpnBJBc +mnM74Yp9FpsOdkm4KdZ+ByMwKfCDlY1gElq3W7rf97R9WC3FyvgpuxVZHEetURKv29/ 4uYcnjOoVWcXQDakQo3cSc7CR39oRlwdq1un3QsyrajlZRQqA1DKjUMjgFMXZFIuCffG vUhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RZ8hvbTQ; 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 u191-v6sor974074lja.32.2018.10.03.07.38.41 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=RZ8hvbTQ; 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=lOD5x9dibVDZPPRf+HmlB0VLhQ+dq9aywfJobMmjAbY=; b=RZ8hvbTQATzJjRDFdCkxhcX5piHn5HTxpCsnq5o90Cm5QmrwYKBxaToPvaD0O1X3Bb AcxEUfcmqXX2h9Us8+QrYsjyl3HWR7FVjhoK1muBM3ivgY+vAssmfX6feNbbmzYuJOG2 xdkoBcB1TkhnFERmGxxp9ix/XP2N2t/i/6H5g= 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=lOD5x9dibVDZPPRf+HmlB0VLhQ+dq9aywfJobMmjAbY=; b=oO1Rz+7sloOPZfyrz+4RuzGkHjsioHv5OYGyJ6zJcYzj9xXdk6ryX/T/avoXlMe5HB +8HaKM70LLYt5K+LUXjKHQFTDjGc55lgXptjp/LKab4JgLoQ2hwWa/DLvmkcEZeM5wpC Q4H6sBuAoXiUm1TfQMKFm3alwrp4dTdyuF6vq1tEDvLEdDuGXyU9i8TH/huSJnDPrqdm I7RoPwkmGDcuL9pW9Ufigwq/tTY5BAo78ya17BUVxzw6MuiddQAWbl0K4/Vbi67Xg7Si P51DSyY0mBLyk9ClZQHe4cEpPv6Xm/DFf06FP9LzwC6TkDZoao8TA1JWw/TsLiRVUwBF GyKQ== X-Gm-Message-State: ABuFfojf6xyPokji5xSGoDtRmSI17z5//0pc948JY/yHPFfylTfQFtLM ekueM/qkU9oab7MtYI22JIJS1+py X-Google-Smtp-Source: ACcGV61DbPnzSLG0nVWYgX1I5i3G12v3UxOKQEvibV7kGdEUWyHVXws7WQhu9Pzav2u7XCqgP7qPgA== X-Received: by 2002:a2e:8346:: with SMTP id l6-v6mr1385660ljh.72.1538577521080; Wed, 03 Oct 2018 07:38: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 18-v6sm380867ljo.74.2018.10.03.07.38.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:40 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 01/11] PM / Domains: Don't treat zero found compatible idle states as an error Date: Wed, 3 Oct 2018 16:38:14 +0200 Message-Id: <20181003143824.13059-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 4b5714199490..e1bbddb02871 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2478,8 +2478,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) @@ -2488,8 +2488,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 Oct 3 14:38: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: 148057 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557468lji; Wed, 3 Oct 2018 07:38:43 -0700 (PDT) X-Received: by 2002:a2e:b04b:: with SMTP id d11-v6mr1342013ljl.93.1538577523175; Wed, 03 Oct 2018 07:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577523; cv=none; d=google.com; s=arc-20160816; b=rXuZ7impl82VUglV+FvjKARF1eckDaS2dMrOJgB+PyTybK7ho6A7xr/JAVLzVadZAE Lzgawe0oIhORQHtb2Y9dVKrmxWdtH+TUoX9kR1ri0UCJirOVJG+gHhb3SKlJkQdJmb6R 0ZvD/1idj3z0DY+Hwkz+QYG+2vykRafBhKRcm5h/bI+yg9BcTBniwctACIKMZ7e1HA/m xIsfFNbqbOAXAAuDKScAAYeE5ioIlFkakoK0u9+VUtHXCmh8Vh7rNoU67GaMHjGghXRg s1HCN0sRiUHAe/ccteFm55M3Hl8ORaRLnoOCY9BlMdm9WVQU9Rl7MdzO6DudE3Anr75f i4Qg== 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; bh=kJSeKBUogM0CddiVrJB+tVbUEkpCSyoWfL42ruK06nI=; b=QGpR3AQFelJOzBtQ5B90pZmH5eoHmZGVmijKDahhVHK052j4/MCTVESyBDCnrmmX/T MV+dPihpvtj7CyglOSBEvvlKotblBapX0+CIdBDjlTffOJ6v2ylHrYeknD5oFYv4/OS4 yNkcgsFCBO1NTTDULogbvfsZDf9Q7/tkXhuEbmZ/0+IiTjJ1TcjHKbznda7xjOmKhrtw OBIr3lFo/swpFHBfmEJS2Fjwyq3bwMLHG6gkIe4Tq4F3JaeLK+pT9BxKD5QUMrR2W/No j+90pfK+UCndUzHJRQ11mngWIU7vIANtKmNyqVFGDotzuFese4R6rrCrQp/NAfUp3aQF 9o4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DwRFYkao; 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 j24-v6sor964766ljb.14.2018.10.03.07.38.43 for (Google Transport Security); Wed, 03 Oct 2018 07:38:43 -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=DwRFYkao; 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=kJSeKBUogM0CddiVrJB+tVbUEkpCSyoWfL42ruK06nI=; b=DwRFYkaoZ6lC+9pxBSR4zeinWa7QO2knEkf2vgyEZ51boEFWR8kOhlNQrxpBY0F/Bv 9rFf56a4v0+He2NkyQVaeO2FF/UBKU51JdN7abJuUVv0q1eopsLZsVq4lBHVf+zDLYUt azaa9ZQZe93Cgh/u0+FgfbwSmdE4bBOgwxbvo= 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=kJSeKBUogM0CddiVrJB+tVbUEkpCSyoWfL42ruK06nI=; b=OONz0l6f2+b63TctRYChJVgMIikq3x7pO1AwyUXHMmJqd0eVp+VUdZZr/B9JzMPDQG acBF5eRwrfgyPW05nPsjaNtDs+D7LTY3k0HzrkBUrjuVLUsKUSFnDq9QHoH8bkXaXwtT A9ErqgImih/QOMqTauGycqe0IYO2wLmXqlBheVMcYClRwfzcsEXDR4W2qrYDUgulArx2 kauT+iZZHgQ/hG5j0CKjf5ELcMypDPoKgzVY4kiU2l+udYaoHxngY+zEMcfoWk+Og6sW afge1wv74bT6OAeebr/tHlQ3yj0mPBJyE3RJ3rexAo0kcRk9SnHX6OdjoCq1mB5AFZZp TjcQ== X-Gm-Message-State: ABuFfoh5kJ0zcwY7ol73oQ+ZYEpSaQ1cPVQiClSCqONBkper7BEu2sDW 6yc4NWxKlZYZSKxYJPxYu8fFH7KZ X-Google-Smtp-Source: ACcGV6370bjHoVakbi2zeNv/IgWVUeb5Wz40qgaKOiXCLbCfIn0ouaVWSqOVrCfjNlpSIpy+kZ3erg== X-Received: by 2002:a2e:9993:: with SMTP id w19-v6mr1327092lji.165.1538577522876; Wed, 03 Oct 2018 07:38: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 18-v6sm380867ljo.74.2018.10.03.07.38.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:42 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 02/11] PM / Domains: Deal with multiple states but no governor in genpd Date: Wed, 3 Oct 2018 16:38:15 +0200 Message-Id: <20181003143824.13059-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 e1bbddb02871..7f38a92b444a 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 Oct 3 14:38: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: 148058 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557499lji; Wed, 3 Oct 2018 07:38:44 -0700 (PDT) X-Received: by 2002:a2e:8589:: with SMTP id b9-v6mr1422464lji.122.1538577524852; Wed, 03 Oct 2018 07:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577524; cv=none; d=google.com; s=arc-20160816; b=F8aO15j//IagIgPIxx36ZgLKnZ+UR5JPviijwJ1n49zNa6dsZMOAo5qmqf+sytgOBa iUTZt2oy+IolPYRVYf5tLkbuNyIWC8/99wdLuJl0u3/2d2aovZGav1eiMv+350ZPpM8T QMdLP7LjZFKcqRJ6gxwemRsAWX/fPQ0xyhh1Cxys/yAl4J8W0NUk42rWrnr2FgcWu9GZ 6H9odrrm72dsDxs/NfyyipX5KUxfjdeFsfLY26tTFvYS5T/JBVCnOqFAAcprUl2HBYa4 DD5cMBYjSjmOHVyORNIDlAWfy2F2efsX1q2fQ3NEzYo1USIrWYMTceETjxuaNnl9YO62 R8+Q== 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; bh=Az8HN+a97vIgrScBCEqR/rzOTiI9JWpLJgNiF/xNs1Y=; b=sUN1MUbnTUA19L/SF4bMfrOyOzuLp4slZLXCtw2o06TOGicCwjf8ZV87wsIsTs4+G3 t+4wrfoNnOw4FWVr3GH4afhf1NxiOEX8aPOfzZ3xOiB9jyXYvwzqoLZFt1t+stA8jiGZ 3MfkMNRYn3JKM1o+N5xEYemwq4UjDxpEOHbqeKw1+RnmWRUMdxO0OilA+Q6gxWBS2BKe 0Wu+CdPDxjc1KKMZ5Eh9z/ag1U/Kmz7Phf+q7NCDcBn9cYVJZSbH4nmPtJlCZU0cPKFL /D1x5vsAOSQf+a7z72VwASH24mBiZ7oXzqCQXxoFdN2vrirNuI0f6TLJ+5qnfXZuKlzn eEjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fwrq5zIZ; 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 h65-v6sor959551lji.34.2018.10.03.07.38.44 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=Fwrq5zIZ; 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=Az8HN+a97vIgrScBCEqR/rzOTiI9JWpLJgNiF/xNs1Y=; b=Fwrq5zIZgGrEsBsxyR54t24qFEqHXkC4DSb+7TXhUtrfB3IWXrdMfuwFYzFi7XS+ud Ha8AaviFQc7guk7xMwsdCNQll3VLrH5kZKgOsnkQHvs6/B/eWYplidelM/qkMrzO2BV9 KWzKRwxQgixw+ofsPAuPI3+F3/iZy0QnSjLRA= 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=Az8HN+a97vIgrScBCEqR/rzOTiI9JWpLJgNiF/xNs1Y=; b=OjMa1lG8CDWcIF+ZxGC54WJA9LsxTuYCSTW+5xnw0Ml2IQVgRa8W0OV6cfnkfiU1t/ cNZt9slOzJS+1+Q9TQSkL0ldnfHtflCX10LX0QXlVz1zvYWQ2LW8xI2gvLABr0m6fnvS GHs9F53zyBU32AsOiXelI6c5sSCFqH8UDZj/uoIk/tWF2QiRzYoXd/XS3p77ttNWQ1My owqt0WoGAK4Ej4v77LMufANCu2SXWm8eFh/LNK6VafR7WFS3OAv+LeiKWkoVXF+o4GaJ JF4lrqTvpzrrLQHgeujV6AkTI5dDczZDXzyk54utWwj6XE4IzjoYPYM1ofwO+mNB8QfW WCAg== X-Gm-Message-State: ABuFfogNyDc+AQb4/p+fHLHJBp1vi2aOwZJ4qROSE813s1Fc+xqAV2Ny R/h+BzniindR9yHw1MLAs0PThARh X-Google-Smtp-Source: ACcGV63ZCUlRFuzoFUlWb1bs+KEJI66Yb1IoBIe4epyTsr714kZsnJnvwgbB3Aut6FDAYv3Eilj24g== X-Received: by 2002:a2e:2d0a:: with SMTP id t10-v6mr1494652ljt.8.1538577524605; Wed, 03 Oct 2018 07:38: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 18-v6sm380867ljo.74.2018.10.03.07.38.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:44 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 03/11] PM / Domains: Document flags for genpd Date: Wed, 3 Oct 2018 16:38:16 +0200 Message-Id: <20181003143824.13059-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-1-ulf.hansson@linaro.org> The current documented description of the GENPD_FLAG_* flags, are too simplified, so let's extend them. Signed-off-by: Ulf Hansson --- include/linux/pm_domain.h | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 776c546d581a..3b5d7280e52e 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -17,11 +17,36 @@ #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 */ +/* + * Flags to control the behaviour of a genpd. + * + * These flags may be set in the struct generic_pm_domain's flags field by a + * genpd backend driver. The flags must be set before it calls pm_genpd_init(), + * which initializes a genpd. + * + * GENPD_FLAG_PM_CLK: Instructs genpd to use the PM clk framework, + * while powering on/off attached devices. + * + * GENPD_FLAG_IRQ_SAFE: This informs genpd that its backend callbacks, + * ->power_on|off(), doesn't sleep. Hence, these + * can be invoked from within atomic context, which + * enables genpd to power on/off the PM domain, + * even when pm_runtime_is_irq_safe() returns true, + * for any of its attached devices. Note that, a + * genpd having this flag set, requires its + * masterdomains to also have it set. + * + * GENPD_FLAG_ALWAYS_ON: Instructs genpd to always keep the PM domain + * powered on. + * + * GENPD_FLAG_ACTIVE_WAKEUP: Instructs genpd to keep the PM domain powered + * on, in case any of its attached devices is used + * in the wakeup path to serve system wakeups. + */ +#define GENPD_FLAG_PM_CLK (1U << 0) +#define GENPD_FLAG_IRQ_SAFE (1U << 1) +#define GENPD_FLAG_ALWAYS_ON (1U << 2) +#define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) enum gpd_status { GPD_STATE_ACTIVE = 0, /* PM domain is active */ From patchwork Wed Oct 3 14:38: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: 148059 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557540lji; Wed, 3 Oct 2018 07:38:46 -0700 (PDT) X-Received: by 2002:a19:9b12:: with SMTP id d18-v6mr1279566lfe.132.1538577526785; Wed, 03 Oct 2018 07:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577526; cv=none; d=google.com; s=arc-20160816; b=zrdd9sbQlQDhxyOyEACQsS4QI3Y9U6M9tfh7+shFxHu6BT5pXFt2K2gW0KD1jNN1W3 ENScmqIVliZReHmhfzC9fJR609ZBDGBqxnchs8RIe7NS+HP7Y6lLWCaNwgJAmKX9EaS5 tps8dAszi/mu8Vnvc0NU4JAZe71kNR60ttDyKW4uMnjbgH7JBVgLj/A5qhOYCEslKuYV MvyfVE1PYHCNWm6iZ97heuUi+SpIZD78jWBPEy2iY2vdpsDZXdcFV1qlWp2maNaWBfUo dpMEFKZKto2AlHh/RK9ecn27svmCAaWC+xN6Rf7ya1VMxyLjRJNyoUq1aaJhRbjus+Gi D3bQ== 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; bh=s31a5XHCk1LHbjCX4EljRqRwb2bVRICfynyfVhTJkR0=; b=brfPdF+0lQoCF5N/PYg45dT24eH9yJaCekeM6Q2cWN0I7pt2QQU2FQZOZUjxMnnVLl k9xM3HaGtGOu9k/YFpvfmQzB72VfdVZRms4Mzauv3nytxDDjL8OPtkCKczhqYkruOc24 xZAXXQ/9M3RZdT3ALbKt9o55dOOrbvQ38Ajvr2TWMHPAjC99Rzz4zmyWUICAAvdKQsHN k9qbJ4B9uWlSraWxZkHYF+bXg1XayGgZvIcOnUSOxCw/CgZYbuekZCTT0j9eOv57WNhn YtHCtR8+op071DdgFw4EzEOYDUvbBkbrHhKf5z0eh96RUmj2mUnK+WOjNT97EY0xtvuV wFkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cJpZuUlt; 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 g20-v6sor630433lfj.66.2018.10.03.07.38.46 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=cJpZuUlt; 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=cJpZuUltyX6boYTW8n4eqSmCtDpkBhfsHeqYJhTyPZ6bb6+Rvz0bCRdZgp3y+Sb2Hb idkNPCM6mStTSZ3vEPyZL81N7AKdv835h4VsriHXyryb0vHe3etv9zGCi3JNVe1XcuDb iKugtj2VvyCC1IJtpJj+OsFeoUpbrUy9sSCpg= 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=JNoqH3Wt7mnPqbQU3tjSFwCz6i2n6eN/xbhPmL2p9hAyUITowKMoYGkep8kILIPCR0 Z8Jj16tHCtdy08XrzsRiX9G8w1QTgtuZr5hTS78fa9ZhF/XAjDI13lcAbhU0Hhho84ZM gfJzhrZm+s3q+xl+4GFQisarcQhBQt3+J+vkwujJzOiMb10z8EhiUpuvMrPZAMGh4i0s Ull98ssbA/Pj+TklSjALwIwFeAVgzhQWEBfdvbsEq/zexhBYTUwa0lyT9isinoqqP7cv 0Gq+bBuqGGSIj1VfiRtijE8gdbfbBSjKViCjx6NB4fs8w+EqkaijAur3F5Mf+fYKUAd7 wrBg== X-Gm-Message-State: ABuFfojzwfKG5+Il8qxon2HBIBVqkxRs506LR3uygJswKQ/bF74FBTU9 KLRkj88/4D4LQySgThAQKFmb7/+m X-Google-Smtp-Source: ACcGV63w+k8Ky9ZPT8u3CThlZWEmR6v2MMxYmqJi3yPsnkwQAG4RywU2Gz8ZjEHETXI75Fzvgn697Q== X-Received: by 2002:a19:8f57:: with SMTP id r84-v6mr1172229lfd.131.1538577526472; Wed, 03 Oct 2018 07:38:46 -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 18-v6sm380867ljo.74.2018.10.03.07.38.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:45 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer Subject: [PATCH v9 04/11] dt: psci: Update DT bindings to support hierarchical PSCI states Date: Wed, 3 Oct 2018 16:38:17 +0200 Message-Id: <20181003143824.13059-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 Oct 3 14:38: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: 148060 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557585lji; Wed, 3 Oct 2018 07:38:48 -0700 (PDT) X-Received: by 2002:a19:1188:: with SMTP id 8-v6mr1300066lfr.32.1538577528685; Wed, 03 Oct 2018 07:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577528; cv=none; d=google.com; s=arc-20160816; b=j4CmIEb0PFnt8VX9zaERKneqSmPMPv0qWLuPvpqwfoItTiYjJZ4na1sqwkDYg+koGd B3XA35SOUl+3DTLwT4PzZHjGBingZ9MDou60V9wd6RlsvVTG4n+8YQg5mU0ycBlb3atp VXt+/Y+diWbMnPwYyBvpzl2UAnTHZA60b0mMioijS9HZDz+TWkWnZ2saawaeJeQ247em QY/pdDWTUAkNCT8meiPyirLNcZsV/WKN4Nzu1OkLig9Pyo26CXK5M2b9d9HZKCjkLG6Z OImHJPMYf/LpOzFa++rZTmrRWUAaIfcL804EtsXAFERAcKZNIze7+fBd7p9jO7j48mgV wezg== 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; bh=cS7yfKOveXJgyBYsXQ8YQO6oBGRBpzCQCXH8+3mFFEo=; b=N0GPdHoFbpqF6FbNVtuXqcZ8/OCfWwAynezirEwVb1gOWwd8Gsk0kcxWt5W3/zof1o ZRjNlrkHIG5jGHTC0u+Aua2AUKkeQg+1h/r7XogDbfPG+Z7jrJGWhrQf2pSJuZWFMd82 cWVSMcN9fCf73NLm0fHPMo8Z7OUNB9rXl6IUHbwzdLm2AJFQV0z+IVvvNbt6D4szyYN1 Qsg4AxpV77hQ0QuzH65RzxcX+gtePZXMnXPQidrNjaaX0iD2iAlnOYB1OwdM9l28b+a1 ncIrPBo4PT22KIljWJqODHsF/gSly/oA6tuU5DVuGp+4xlnrY1/J8NnWL0+JEBtMiZbV 2eNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fx8drnSO; 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 33-v6sor961131ljb.42.2018.10.03.07.38.48 for (Google Transport Security); Wed, 03 Oct 2018 07:38:48 -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=fx8drnSO; 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=cS7yfKOveXJgyBYsXQ8YQO6oBGRBpzCQCXH8+3mFFEo=; b=fx8drnSOtxA3anI913lckFGxRqtRu9w78vmnWNXJmbewRUm68yE+tLRZwARZiLhlbp 8s2PeeUM6AktExnm3R52LXidDskn4om25dn5FRc/BgLRDtDTAc6QkltsvqzkgyCSrEaP JRgkyom0mn8LCuWB9BTRe59/wnvMkVSCX+CA4= 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=cS7yfKOveXJgyBYsXQ8YQO6oBGRBpzCQCXH8+3mFFEo=; b=XqKsKQrFOdvYfbcZlQ8XWo4Pp0vCaNKony+4JkJZPL+xvhjDBQx4VKatxciXhbiiMo u1xQhDsyDzvYyXgwhbwZVplo3IeK4PJb4r2twbY2UlSfCYH/oIfy9iy1D/9fBSKrOeLR jpHKjgVfFPNndZP+VcVDfft1e2dHJD61EW+J3xkwWuVlMkXPJMH7353DCsAOTgFdFRbJ qI7f+hAOZViI+iNnwTjyUJPXqzG0wjX1hqw/tg7J310TOxCPXJjUQoZ9Z/2hvrf+D5hM 5xKIItlc5WOXFsBjvduMQVhi/YGHfUz/GAH1JLGhcgraLH337zq0iOZ//RwKoc03gZEr joNg== X-Gm-Message-State: ABuFfohOzPm0BOE2gW+LtYQX+gLbsjR1H5uirwxSkCWz0Yko6b/MnB/h 6Xn+xofqRTRRCfeoSUIqS3fBh8n8T2BgXQ== X-Google-Smtp-Source: ACcGV60jlY8/LrhTbGcUaUP2h57fyQo8XWU2VREO/R04Mmves3FRLEypNxsuTv3kNJxTH2FkfaaWHg== X-Received: by 2002:a2e:6a19:: with SMTP id f25-v6mr1412659ljc.50.1538577528355; Wed, 03 Oct 2018 07:38:48 -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 18-v6sm380867ljo.74.2018.10.03.07.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:47 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , 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 v9 05/11] of: base: Add of_get_cpu_state_node() to get idle states for a CPU node Date: Wed, 3 Oct 2018 16:38:18 +0200 Message-Id: <20181003143824.13059-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 74eaedd5b860..bf1d5fa34899 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -424,6 +424,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 99b0ebf49632..42dae048674c 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -353,6 +353,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) @@ -754,6 +756,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 Oct 3 14:38: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: 148061 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557616lji; Wed, 3 Oct 2018 07:38:50 -0700 (PDT) X-Received: by 2002:a2e:50e:: with SMTP id 14-v6mr1400250ljf.152.1538577530312; Wed, 03 Oct 2018 07:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577530; cv=none; d=google.com; s=arc-20160816; b=RRxv4aWCQIF7huyHUFyKLilSOccJPOFIm33pVKROgxMnCUHtQiWiPF0PYFN9Aor+yh e0xKkl4f/Pdf89tE7+BXs2nVU09QJB8mDSCd1O+Geso3VIOeNkCYISm4A0RYF1MA6npi AkKYBDix6uzDe8oqW1o8Rfq1cQrQLUXyN344qX4ciGqootWMdPYcVaZmj5iuTz6jMcIn PFqUYt789TVuJvDwwCgun0AIvkS5v2zHFWSFlHFT3TWzCLQJhKzPz6IwIowSmdkol+Ab jZzQTzSzNhRG/DGCzW0EyrS1Y9awk8385TFJnlRLtt+2UOjX3H7MjeY9643vsjIZwLh5 T5CQ== 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; bh=NdOVQOgn6QPfKNtGaQ+NXVIYYOcD0EuuWacQGnuhPH8=; b=AivuxaeHKXPC9xdIl/AHztMZgtL9bVrrDA32XbjvfgjNgw7tuDQcmvy1baKSj0t1yS gKPIclfNBOHT6QlBTLx2deVE6ySlQWa47ViGKJg59mH4FU3jh60Y4d+Oba7B3OH2eZIU o207TgLhY/ltV2AYF89C9IDoWGdkmK1opk9p7gXPLBMfAAMHUAd0eyz+o8dPFjeA6jUb /Iej7IMxyprOunMfp+qKwrUSEAPoIep+7zz1YU0Ril/15/y+D11JdjqzOjZOnUB46mhv HWRqakK+eCgFY6IRjjHhqew3qOzFgNbv/Xo9zNAAYaXVZzcdbB83tgdQ7CDHR+NtqDhq avWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WRWo6nk0; 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 z7-v6sor973140ljk.22.2018.10.03.07.38.50 for (Google Transport Security); Wed, 03 Oct 2018 07:38:50 -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=WRWo6nk0; 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=WRWo6nk0nJa1hY05q+tQgr8xYnf2RAMUdfJAU1VKIlIychduM+cr+0DxYEisUldbgH +/Rt0QJ+NphPgxHDcGKI/myX65HaEuMqK3zWKyh4M0a9UZFtPkE7T53oOXkcZ4QqMCk6 1+HW35LznBwGCIspaeGz+RXntF71adUgghmqI= 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=joNbUxdIE7sPXmTjILqsWQIJLqQNY3pYFVJQaDM24PrQ8031R9UCV+qNBsKtUFIa69 BQPUthpOAdnbfXyW03Jv4+iq7xMRAe5r9KCapoROLcbQX6vGBX1KBcHf23lui9pa9+oE BiX5nYyF9V2Y4W31mK4scd9uSKpi9a87bf/y0OsR5X7/gbx7uTp5KOonNHmOj7tFS8Nv Hybx5HHzXyxRGLzjMn7TRtAmRnNZzOsbo2P8LAsIS5owWczRiDkEjwwkcLIeUhl8QNjJ C65cluNnBYTWdQcW2TqGoa6mzODmCJBohJifc43NjYuyiilV3oBAdfuswc15wGyogomE lrtA== X-Gm-Message-State: ABuFfogfOnhrlEMUG9QhlcDQrJeN9P994334s0sUXL5muSpZm9JUPhOW M6g+TT8xotxNoKaVIdzGT7VRzR6m X-Google-Smtp-Source: ACcGV63AVZN1e1UHiciRJACevTU85s4dyI3oLi6l675UID00+PW7/sACBRYiDcjYfxt4IYXNSs8MVQ== X-Received: by 2002:a2e:591d:: with SMTP id n29-v6mr1383472ljb.70.1538577530142; Wed, 03 Oct 2018 07:38:50 -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 18-v6sm380867ljo.74.2018.10.03.07.38.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:49 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer Subject: [PATCH v9 06/11] cpuidle: dt: Support hierarchical CPU idle states Date: Wed, 3 Oct 2018 16:38:19 +0200 Message-Id: <20181003143824.13059-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 Oct 3 14:38: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: 148062 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557654lji; Wed, 3 Oct 2018 07:38:52 -0700 (PDT) X-Received: by 2002:a2e:908:: with SMTP id 8-v6mr1328242ljj.1.1538577532271; Wed, 03 Oct 2018 07:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577532; cv=none; d=google.com; s=arc-20160816; b=K2THMQrHKKdJugs+1150NoMghn/ppyb85gONzL+HZRts0kid4d3Vie1zxjA0wW6oMe DoJekEu7oyXAjFJPnjzJ1kTk55m4htgm93dcNVL7RbSVdXnMkcdCMAqbKkN7SJF4gAz/ WYvzase294qk3XO9bvX2i319WR+9pjNqyK0xCSB2L7GqJsYicIP+TzuR4Xjt/2efpyVk eM1l09bZTPIQzPK7RAhAwUPqGg1QrZbP/ZnH1gj4J4PLuAO6hajTX8zvrcOvp9al8G83 XUiBfO33G0luEXbQ0N4sNDe/CRT17tWRwFm/Ci0MUlOex2ZgXxU7TRijmvk6oDECjffL F/Qg== 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; bh=24N1Dc3/4aVSfatj0cCLPTM9sDMCdxo5zYgoCR5YTHc=; b=mYvaF56JqUPNv+BgTsfUnnm1DcfAevbMyy9HAwk18ttvI4wO6+7q2VNoghcHtu3f/X Bhq6OudaM/eCqTCR8KXEO2EyWD7ReeorCfFaUhM3/XiRBooW+MLMxSacfoF+6GYqQC4+ oRKTmZJsexotKAtAMWlEOociuM1PKW8i3B0iQgTUGg8jz3tAQ+dwNgNSzvaTvxVp8VUl dU1CGqeq1PjHjsi9nECPi6swmSK5iu82RC7ZvOjzYv+JoxdSuUUMGqdzlddjcbIdTKw3 iZadPQWLuKWjsCOMqHO1B+KEMC35XP3sQ3/m3duR+0av5a7908ljYqn0bItBFRE5Pok4 N+pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XjLORK1O; 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 84-v6sor966529ljc.24.2018.10.03.07.38.52 for (Google Transport Security); Wed, 03 Oct 2018 07:38:52 -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=XjLORK1O; 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=XjLORK1OYwzVBRY8kPy7QP/UtnW4VxCS18LStrS5+NaSElLf53WYhSsAeOpJRZ878b VqSg3YrZ+3izUx8IHKra0aZC8NThLEYOzlsrPV1UKUz850Cj11Hr//MXWdQh2hoGNqL3 G9+bkTyfOZHm7ZpL8euDuDaqLQg9V8vs/pk+A= 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=O1m7rbx20KeJkfiPcybxTwwe/e/z+2eGxIJQpzvM0MzUwIbX/a9tMMnz7Kme/04fke o2wPME9wnxcci8jgUUESQ9gUhGPVjc5kcIQyG1OSRwHARaMMoMqPGucOCexGlTfAa/dk oXMWNEfZpxorZY6Ck1vhMy7pUfT2Ww7Ma+3vWBZw4moiOniy3uyq+lVZKZEUUscKlGWO dK2rN6ixz+aDUuUO8rLu5sczTJ+VvAwe3GKKg967feYPHQCa6PjRhyt83j/fHiCqPRij mu+SfmFHy6lflp+60GiAn4k4jSIA7df50rMJfPKXJIAQs4wv77My64EjY7Ej2N/9ubdi rVKA== X-Gm-Message-State: ABuFfoj3pldKu/Z0E77y0E3REW7PpgjBc4+GNt7HHqVF0kx+fiiu75o4 BWjhULpx1P2Lp1hrZc3IsXx6KB0f X-Google-Smtp-Source: ACcGV60MQ4bvS0UIONM4xmbNp7c8w3D3iNVTmeIbx24qsydvm8zeVD1SDHaFgQtHq/VCA7CWpui8zQ== X-Received: by 2002:a2e:90d8:: with SMTP id o24-v6mr1361712ljg.97.1538577532011; Wed, 03 Oct 2018 07:38:52 -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 18-v6sm380867ljo.74.2018.10.03.07.38.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:51 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 07/11] drivers: firmware: psci: Move psci to separate directory Date: Wed, 3 Oct 2018 16:38:20 +0200 Message-Id: <20181003143824.13059-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 Oct 3 14:38: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: 148063 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557687lji; Wed, 3 Oct 2018 07:38:53 -0700 (PDT) X-Received: by 2002:a19:6b0a:: with SMTP id d10-v6mr1223678lfa.49.1538577533713; Wed, 03 Oct 2018 07:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577533; cv=none; d=google.com; s=arc-20160816; b=XiPHiUKKdEahnxjimGRBWgvXiScJGzxvsdnjeL/qy3EM/HFIrFwOnp9C7Qgrj5B8bJ eOcHU2KgVg/Or4boaFEyNTBOeRagqeKPAVrA2Di+z4hLtgP4hRoiC6Bf27lUxzEezCAg 57xYx9q6P/SWLeCrAh7/WDc8nG/OT7xsZZIiSAGrUlzCUyWvrgP4hpiJpoLCWwqnK0QI ZNz55DWsseYApsOzEBYpjSMgrUkxXpATW6KZ3GS+iGWegTtfYes98BpEE/wGbSlygN4t 7UzYT/k/OWDuW7y2nx1HyAUokoj+Upvq7syTMqt3/jrqPKBvNryNQ83TzWDMLYvpQGk4 BeOQ== 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; bh=xjIfDLEOSbswJu1KU5trsLmIXoVIJYa2zHdFwxdeDkw=; b=LBQice+jHknh1SsVniZVLJah85oFG7hLensKqRzNHWQdp1WN0l1i9xnUmjWoUpHh7I YJdbIEaZ27FJe4BaEroRE5F7/tjU6ElbdhzeMfFnx2Jkpw3ZMkyxUrlpijf0ycwHeuNF eBEBCckNWVdPUhy+6DV9me+EHeP70yr91LEhDkQlCRrgYdKbyWHhNgorXDgbJYvSiPxU 3Yovshd07xF+iQCLxKtgC8akZkMlbDRk7DJqXsVwoenUEz9jJXLBZm6ew/+v7UZ4QzOB 9Au93DeqC9SisvRU6+j4LcDTupeE+o2gSRC3n5/9zTaBhphH9t13vO3uFcHjO2KYk2F8 uISQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U3C1wZIb; 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-v6sor972139lji.33.2018.10.03.07.38.53 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=U3C1wZIb; 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=xjIfDLEOSbswJu1KU5trsLmIXoVIJYa2zHdFwxdeDkw=; b=U3C1wZIbccVX95gm6USfQzQ0KIFAGQLNCGJxAHczc0sW6zurvyAsLwcGQZKmye94yN TdWwdXGnFiIhk1GqGfBo5C5OXqJxbyB6FLYPahHeGXQqpmvMfHYQmFd/aPsdOJCaEB4I rxHYsizpoJLG7SeQHX+4NEJ9kXI/taVpgxH1c= 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=xjIfDLEOSbswJu1KU5trsLmIXoVIJYa2zHdFwxdeDkw=; b=Ly3Lx7YPd5PSWBN1DJKQVxLy4NPmmXGlKKnd8kgiL0U77cthlfEQt4NmqbCbNWty9Z rrgbChFH11b9YjS5b+XxVFD6EdlBT6HZIliiktaTR/v9BwfQsV5w6VwwhBpn4Wo7yyQL x18H7yD6eJcgMsWgMvSprGcJ2NdZRk9vQZnGSaCPWe2Dra4VIRMQz4om5bDWGvin8R4M P6L3CY2GkpwYb/LoNcl69bTSkjSPltoQoGLWRxBukAIV+R/KurVyfWG+wcU1Jsv44Bio fPV8RTbSOZvKcYZsxfq1wkonQWbjwD0aVlbzWUrKZ+PoRzyOu5D8O0xjdufY8uGQgLxU D08g== X-Gm-Message-State: ABuFfohcoErchzV7Htg5926jWziu8u1OBY5ReM0DDLPv48XbOMjO4hRb kjGvoTFk2jRLFEt+ir1BIjW4DqW+ X-Google-Smtp-Source: ACcGV61z6YccPbjrV9ap4UqG6C7FdyslfItrbDmr+r8uVsqkpaonCiN5ShavWM01TG7ypXVgx40HvA== X-Received: by 2002:a2e:9c59:: with SMTP id t25-v6mr1431593ljj.107.1538577533544; Wed, 03 Oct 2018 07:38: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 18-v6sm380867ljo.74.2018.10.03.07.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:52 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 08/11] MAINTAINERS: Update files for PSCI Date: Wed, 3 Oct 2018 16:38:21 +0200 Message-Id: <20181003143824.13059-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 b22e7fdfd2ea..710b906037ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11624,7 +11624,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 Oct 3 14:38: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: 148064 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557729lji; Wed, 3 Oct 2018 07:38:55 -0700 (PDT) X-Received: by 2002:a19:1603:: with SMTP id m3-v6mr1243539lfi.82.1538577535418; Wed, 03 Oct 2018 07:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577535; cv=none; d=google.com; s=arc-20160816; b=GNk7G0u4DsWExtn8pU4VZjj0EH7CLpOoopmGHDV4qKOrteH8EY1/5DNn9vT8WAi4dk zuLVcg+L1XY4+nUtIU6ewtn29G9pCrihwEmT17vYMlXlfsqOR+nkYbvtGNv6pfTcgOno L5m1j7RIfjbGVcBOmB5gqsnBZATZfKDCL4G9bhPd7kvBsfEhdrvYPmL95yewEljzZJfd Mxob8H7J5YmNnFGPu6kzovrOLVpL4HLM6FP8Iupwk+5GpfRmB5fL07QV4c4ZxK+CqEBe jqKcKRv5kRmo0Iwua5orPnVmMBzEJJP90utowT9jJWH7jK9//zN9NdanxJvqWsbG5fNm GZOg== 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; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=ilJjP97X0gS/Im0JHmI+JrwslO8hmMGD+Og0mc9ptaYEH3uVGkLPH4xugvGkbKBPDR CVkbfuyyTgHK/mqtlNsarQukOaVmHuY/CLuLIs47nJ9JHAqmXrwvq4SSkq5G67P54iwP eleNZTK3XnQrBY3FBpfQaiSM3ZYhgCIaOG2lzyoRJ7QFwiUeMtt8i7GdFRruhMvT/2bm eqRwCGmo4lJt6PWMFsgd/bzFvIuM5yumNvMvDEqTgGkWdSjgmXaSuce2oidanEYflQTg IwSYLWFVJtGybdgkL7+blCcXMK9uNQAGsCVOl6uAVkdSGpBzNAv1UAOqUNNP8p017u9q 37Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=desWZW6k; 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 a12-v6sor981889ljj.10.2018.10.03.07.38.55 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=desWZW6k; 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=desWZW6kZm9MoHxRhIgV19z7b6BH/QRJ2OPUabhMbRjAACBRrfdos4w49U1tyBVfGU btwLt77IkDaYsTQprkKZB1Jo6BKOJEBmqoiMiLWXNOB/lsM+gjDCj7a4GLIbRSb9OZ7Z h4CEgzpdwfkr4cOrcZUV5LUdctmd0wy/Ld3kM= 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=tQkUrIjxNN/5EmFuFc1GPDUM7oKUnYJ68l8z7NUCc4s7EemBXos3NKurF8zxRflW9f 9jpxHwnGoso/jzZ+U1d2PZqAZYASbEL80bkIa4A1fQ8se6+B0EbZJMgeqDRBqAzjIBvj cA6t7rvyS1hL0Nrsd8mCzMPbg43ZxyqZJ+VGzN8gWJN4Ls6uPnpoNwSl+7f5cY4dOQok H9EzgO2k8BFkGxfEGiOm9FYmKCMT85WWR0pDuQ7p61AI6bP5diE1+wAjve3isaoKZeSs ZiUchrbfNprE+eY9nM+5IXZhkvIk569iJ55Mdq0KTps9QSZjfFGog/C8IhGxn1JdEKUq NEjA== X-Gm-Message-State: ABuFfoiCN6IKgGnmSan86ZTLVSnu7Z4DmZkGAmb7hQeGBVKTYqX2zBEu SWyRdLRqn9Gmkt2W3XIHMtJ2tTnI X-Google-Smtp-Source: ACcGV62eYUZ0f1Bynmiavxa68k4auoEEG8yZecIQWETDoD832ixenFDZHZdEHJxZcAlphUS5fEAo0Q== X-Received: by 2002:a2e:7f14:: with SMTP id a20-v6mr1338534ljd.148.1538577535185; Wed, 03 Oct 2018 07:38:55 -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 18-v6sm380867ljo.74.2018.10.03.07.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:54 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 09/11] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 3 Oct 2018 16:38:22 +0200 Message-Id: <20181003143824.13059-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 Oct 3 14:38: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: 148065 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557756lji; Wed, 3 Oct 2018 07:38:56 -0700 (PDT) X-Received: by 2002:a2e:1b9c:: with SMTP id c28-v6mr1345243ljf.73.1538577536855; Wed, 03 Oct 2018 07:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577536; cv=none; d=google.com; s=arc-20160816; b=Ni1mUTPH9Zse78uCG2IZlhOcGdOl6hZr5AWrD47W/IHpLNU9ximMy+zZiC4yfh7XLK SOOBkB1BsPR77tu72p+84pADn7sNIo/DvA+iW7JAHfkK0clU4t7VaT3Nu7Y2uUoB5okg 7NIuodU+pVk9lQbTXw4835MOa2K4jN25lcnxlRvukLAl+nxjj92PzGLtjBuMP9jQnY/d 4oz5oe8k4MkjTyQcFobm/BVFQ5FHg/UeRmPDtFb1RvJCONAqn60NHgMwmNqwwyPKpmW5 2MklhyZkphFKLsTSn3XTEn4K8pSl6WMzcWSRH/XP7jq2g82D5jYLas5EZfK10njDusdV Ym8Q== 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; bh=3WUKn2dvevp+IRdH7T6aKSOygQUa+Gx75wLOTzgVKrQ=; b=ZF6idFiQgD1UoC4hto2lYf+SonMnmYG/vG1gAvYJk5ieeenZljBu9GKNJ/GjFuejTn z8VBSEJ4JX2p+Y2DlGa6djth32hn4BwYUyg/YbSJB0ztheVnuCz1F+nbb/PiV9T9oj5y ppfSnOwsZ0vGKTyJn19FFYqMgcKJAXQJ8sY4WyTrvqkKrdo12/Ect+Y9xh+/DX+7LdOj IljZG6yIfkrAQY+FrqSz56G19FviLb5wERLvjhTUQqjR8TiMqxC7ZMssKANJr2MW9Rm5 ZueV7ub8tgJQVyMgIag0dVvI+J7b+6m4OzcXKNZNUb/DiUzF5B6lFLShmYGM4cmhyIl1 PJPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HckMrUez; 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 10-v6sor978646ljv.30.2018.10.03.07.38.56 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=HckMrUez; 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=HckMrUezE7fEmusY25qeIMXC09B5MKn2lggvEGrfhbXvyprgkkZsbk7mSbfl9OS+39 PyEOZG79GlLGsAnHWfz2AlLsFCJdLxauI2i2sQj9/26x5rW7kQtlBpWOut+Ow7BI/pST hDY8lQaAmmvARDGOc0V/ih3wyyznRhC1IGRM4= 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=Jm7IMFMrG5PxB8zsJTUwH2VxJdaZuiI+p3D0v+vqACelfs5w1h546L68Hrrz7CVtaU ouBaKSe/jlnj2P3dNhjIj4N31FZNbrcUAcfykjEToRTFlSjteTcfEr7ZqU3xMxLsQ/0M vSy+fKRGo+UEeFaFSg7j0V+SW4zuMkCtZN5S8ZpCeh9nv8Bg0HwNL6/RQZVYx8nQlbJi U7/uYN4GXG181Rmaa83Hsd97TR/mI4tIDrmnnGAk10cIig02LiSRPENLywDQBVMavorY LCQRyTnoX7Q2/kSiy9FKFD/weuz1cYFVMXJgb8CNVcUDe0wB4EqZrIPf1/72zKPhD42I y1vw== X-Gm-Message-State: ABuFfojSFbAIsTCIEMjJEJQYG7r5NMWXWBLpUvNtBVzNyFr5W9QaVFWR 2O0KtnCkeyitfgEuHGr9pOvcZfOz X-Google-Smtp-Source: ACcGV62S/kE0nzS+/14hY0+pwMhcgKntySwtELjwoN11ELXKVw3eYUQRrI9eg/ZW2gbrfOGyyqP2qw== X-Received: by 2002:a2e:86ca:: with SMTP id n10-v6mr1531860ljj.90.1538577536631; Wed, 03 Oct 2018 07:38: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 18-v6sm380867ljo.74.2018.10.03.07.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:56 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer Subject: [PATCH v9 10/11] drivers: firmware: psci: Support hierarchical CPU idle states Date: Wed, 3 Oct 2018 16:38:23 +0200 Message-Id: <20181003143824.13059-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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 Oct 3 14:38: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: 148066 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557790lji; Wed, 3 Oct 2018 07:38:58 -0700 (PDT) X-Received: by 2002:a2e:921a:: with SMTP id k26-v6mr1352930ljg.163.1538577538423; Wed, 03 Oct 2018 07:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577538; cv=none; d=google.com; s=arc-20160816; b=UHzqMTZeZpeE310RNdQqepSMfgmLSkXv0fbRy1AkqMw1t+wsl5+PrB32mX/mdJ6zSE mCHXQAhDWjwB5oKa7sVf0M0z8jnDbSlGeTpV0mi0Gwv5NyIa0G7nSMTo+xKo90HuugnN EwADs4ZTsXwn1aacdB42qy5ddPrdQbOAEo3v7QAqvlusMAT8L0+3mk2YRUk1a32tr8ID eJurNZJfl+I6n/dvhn8rUCh5JEZr7qBtD+TaaUbAn6LXhJ3EgklNSKUJnKgnhVnFHGzg ETFArYr0lHXj9WzpC4zEN7pa6bvBNxpDcosxZrD9Op9CIPMNCfrQPfcxwA83JOtfPh3D bmIA== 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; bh=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=GKlPTGWvlNpDeEL/RGDSTui8/bvfas/GbXXhsjIOMqOEO765g6L5aWRcB9bcdSTLbU +a0NUehRpg47Y7yfhvAiKQPuqGvdHZvPJMg7OInp2lsZCli4ZuUM8Pva5EgVM3+c0Woj EaJbpK+wNVE3d3w56RP9ne60y6ltVRnZQVrpzX/DfmTpT62wBZJNkCRFYR2lleLhLnVo ubJLX2gT837vPdaMyZgEkFg7daYHrghVimOvJ/LfTSKBMQ7cp2YoUyAFox9gjaQ92W/U 4XnP8zqXsaR/5cdp/e/LUlk4Zfd83USbYe15HhzJgCE0502mFbX+NFDjJC4zGM87sUyX P1Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H0bYXmMh; 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 p5-v6sor626020lfh.24.2018.10.03.07.38.58 for (Google Transport Security); Wed, 03 Oct 2018 07:38: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=H0bYXmMh; 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=H0bYXmMhr8euPxdBpNA9AnsaYn53qUB0wHQFSrgL4hE63SPaGSrM+bC/pMemM+dLTN py83DMk+1hfKAd+qyzkiu7hbKNlnKXbxAjm3A6CitXadRIugK3gAq3twnJdizU/V0oKe 4Zecg7CXLZJ8Q7RDZXZR3GMnGDF/iygCBUGfo= 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=tXyDth7/uJIJcKN7miPa1rZ2rorJIoZ7API2QJEHmLXLI6kY6/A96jMVMq9JEwmJNK e0NiqPUVuUkl/QghfKEdSLXKIzT5iFOmwoidTZ6vem+ZSAl4Y7leuoH3Q/p7319RFmUJ RgwkDwdeCQaBUoOYn+waRMjgj86E5Wp/lytYOO5K3slrbnEbOGL2/eXDvxaxcKMDOUgk z5iWlrkgGYrStIY520cyffdSEc3eZCysmfyP4dF7WcpHeSmLQDZLbGj7fSYrCtBzmgKw RVFjw1qjPHerjy3/HDGavQWR2xPFb3PFazHQuiZhte3iBNahh0vfqay6ELzYbTG0y6+R UxHg== X-Gm-Message-State: ABuFfoi5tso3codFjxwWmR5gArATvPve59NViNLd0glHNChBMA3QIIBZ qcyCu+4dH08hgF9n+NDLFmOj2isU X-Google-Smtp-Source: ACcGV61f5JUyC6umbYRFx0mdAKGPXSoeFi5/0BwWrS2NmAnUsu6nhSdb24pQow20ow245IggCVsDLw== X-Received: by 2002:a19:ca09:: with SMTP id a9-v6mr1159446lfg.149.1538577538176; Wed, 03 Oct 2018 07:38: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 18-v6sm380867ljo.74.2018.10.03.07.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:57 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 11/11] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 3 Oct 2018 16:38:24 +0200 Message-Id: <20181003143824.13059-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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