From patchwork Mon Jun 12 15:55:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 103645 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp260250qgd; Mon, 12 Jun 2017 08:57:36 -0700 (PDT) X-Received: by 10.99.127.73 with SMTP id p9mr59071669pgn.169.1497283056660; Mon, 12 Jun 2017 08:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497283056; cv=none; d=google.com; s=arc-20160816; b=csFyoffbydl+38cOj3hnMNrV3g7s7LKNCVlB/n3BDSImtmdrBUlZCR6HQWd4Z/BCyE T8MlmL8lrPu0IsvEH+fLuCX9/k/RSBjeNbI7DRKz79QUSCYI7u/h00aC6mxssHpgiKhg 7zZDXMHXJ0nXS9p6ZMe8XHZxiSACDVkbCCju6o51mefFRj+/BaRDRTSC21bseBa7SYa+ YQrHcQWPZgdZhUppGjQrTjbn0ZjcIF2RMhfEW0D+G+fjrNFAr7hGDcLjzpMcqkyPjW/T ipQySptESEC88aUyG+MlwGg0GGNv5DRexotn6bWaGKfAGmXUr0wd+NRb2Abds2Q5H31t Y/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=FYtyRDTgFKMz4tbFcH1cEAomeE2isqJ67tqDqam/FCE=; b=03D4JzQR4DON3I+cyRHJsuDIb/Ogc6qWdd7iAyDzIa0Ceg3CPaef5fstEtZyyXJXPO pLTQ2ZOc8IwbpbYfEBNGb3L7XGiN7zpqI3W8DWFZ+1ULh/aqawGzZeoW211ycJsv8hxa 8R3UbNFRogN7E3dYzRLNNjwTjjVwXRdFKG3LUQvPh/5yycCBncjsh9/n3uFxBhGzFzWy 3yUyWVL/zpPPMY2aJlPsdTowgG/3ff0izLBXnqVOFlskoylckPgeLCthdUU1bmjYAqSP oLXhXtPs3eHeODosxrTup/CXjzeeJAqrW6AXB4iVxUOaeit5JELuLhSeLPTH+BmfBkID W5Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si7263583plk.458.2017.06.12.08.57.36; Mon, 12 Jun 2017 08:57:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753157AbdFLP5N (ORCPT + 25 others); Mon, 12 Jun 2017 11:57:13 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:36078 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbdFLP5K (ORCPT ); Mon, 12 Jun 2017 11:57:10 -0400 Received: by mail-wr0-f182.google.com with SMTP id v111so102465297wrc.3 for ; Mon, 12 Jun 2017 08:57:10 -0700 (PDT) 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=FYtyRDTgFKMz4tbFcH1cEAomeE2isqJ67tqDqam/FCE=; b=L+gF9gAma3PRVziluRE2GNcVTKJvZA2jEFz1a7bv9lXcBcZPzD9R6Y76QVGCNLZEmP 6XeNlu8vq8LhRa7JojdwX2i4bGaj2S1pKNqEKkv5mJXQlhC2oEm5Uot8anJxLbF5zZDe T8MpGo0Ks0tQxOQT6HQQRrZ92POifuwAckpq8= 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=FYtyRDTgFKMz4tbFcH1cEAomeE2isqJ67tqDqam/FCE=; b=IhjR7aFVsuPPfkRuNSmiSkBLcAyiwN5xo3LaDOHcZBcAM3gtpIOk3EX+d6cRbqNsHt geel4FEp/o7FRnbcuZPrG6SiuFFpWv5JAFstgIKdrFqI2B7/YQfU96QMxrDV3EamYaM8 ByYqai2ylzceCnz3hp00kEbGNodKERrokZARssqTZ4sbtKvsVmiB+YH8Q77zaiVmR6yT DR311XaqYDELjSwrq28kdJhB6D34Q5yd6VsEheC80n+bdzVbMTmCXOVEiLKrYM7XQ2ZV pTsmIzowFBN6DFkZQsekmRe5lKsQChoTyJkm22N8c/qYyfnPr0/9527/8SOK8rwz2nPB 4ByQ== X-Gm-Message-State: AODbwcA8oJIaOwltGqTQodX9BNp2E48fZX2O783Qh1+bo2m8T26Ws5uQ zHG4pAQBNsfb2Ze8Y4vMXA== X-Received: by 10.223.129.183 with SMTP id 52mr7473962wra.71.1497283029065; Mon, 12 Jun 2017 08:57:09 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:289a:9b8c:a41f:e1d5]) by smtp.gmail.com with ESMTPSA id q77sm153978wmb.4.2017.06.12.08.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 08:57:08 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Christophe Jaillet , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] cpuidle: dt: Add missing 'of_node_put()' Date: Mon, 12 Jun 2017 17:55:09 +0200 Message-Id: <1497282910-19085-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170612155441.GE2261@mai> References: <20170612155441.GE2261@mai> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Jaillet 'of_node_put()' should be called on pointer returned by 'of_parse_phandle()' when done. In this function this is done in all path except this 'continue', so add it. Fixes: 97735da074fd ("drivers: cpuidle: Add status property to ARM idle states") Signed-off-by: Christophe JAILLET Signed-off-by: Daniel Lezcano --- drivers/cpuidle/dt_idle_states.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 Acked-by: Lorenzo Pieralisi diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index ffca4fc..ae8eb03 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -180,8 +180,10 @@ int dt_init_idle_driver(struct cpuidle_driver *drv, if (!state_node) break; - if (!of_device_is_available(state_node)) + if (!of_device_is_available(state_node)) { + of_node_put(state_node); continue; + } if (!idle_state_valid(state_node, i, cpumask)) { pr_warn("%s idle state not valid, bailing out\n", From patchwork Mon Jun 12 15:55:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 103646 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp260259qgd; Mon, 12 Jun 2017 08:57:38 -0700 (PDT) X-Received: by 10.84.215.148 with SMTP id l20mr32404764pli.79.1497283058319; Mon, 12 Jun 2017 08:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497283058; cv=none; d=google.com; s=arc-20160816; b=mfQCFKywXaDtl3F2kaQdhRXAZUwYp4PcKYs+BFqpes6esiJQtqo56tG0UPUcrpVmc0 iBEyXrKtkwDgo6SecNWFI/kJdFWxEXgPxQYFG4PMdTqQHXex4OV7h6vJu2aU95Z9KgbN 5HJoFgAOIeqmT//iT2C146ydOZBfPk9TU6AKvNYaaHBaGgPN8CIkbIjz1YaGdLQXLMGr thKkPfPlCAGIDdMCPToPksixyhi/lPsxPt2yUPLTBkp5cKFVmVfCqimLuiwdjxaj0MUE y+rYmF7zR4lCWNVFXSc4wzO4aSYnpbnSKPXiimLBEkJGq/zEFbBJT93Dxz/jqJWpp1mB 4prA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=BoaKjWcNrqu3XmTN2AVNCsL46SKPiITwLjAw3HkdOYs=; b=LQQgeT5QsEh5fZoCJ6nfQjSyFBoV/UlnjHaRAP2TyM7jJQB3mEPMqrcdhbUUfbD0+k c2HMeOFxX/mDkXpteAQGVy5F+ppYOIqla01uzuDRETaE5NIs5FqagvwApaUVMAHxklQH oLQ21d3V+4bZK7HiPJp+kYqcwkBFDuASD3H4Gz1O2rEJPCWbgaiEhhBz3Ft0xXdB6G+8 wkSD8dZFdXyRdHZc4oILvRV1LMOOWvwBt3MAkKZXOEeuOgZGSKDOR4yWHLxAXIA9gO8C BWX5uhE+ksJLzS0YTxbii64XKdTQlkVktBFcBp+h3ZafwkC6m1XhnPi1yxwWQHxUlx7v Fq1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si7263583plk.458.2017.06.12.08.57.38; Mon, 12 Jun 2017 08:57:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753717AbdFLP5S (ORCPT + 25 others); Mon, 12 Jun 2017 11:57:18 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:35181 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753329AbdFLP5P (ORCPT ); Mon, 12 Jun 2017 11:57:15 -0400 Received: by mail-wr0-f172.google.com with SMTP id q97so102810421wrb.2 for ; Mon, 12 Jun 2017 08:57:14 -0700 (PDT) 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=BoaKjWcNrqu3XmTN2AVNCsL46SKPiITwLjAw3HkdOYs=; b=QiYjc1Yn8buy4C7G/aG6Zd+vk3Y06Y8e4NIvBxCR/3Z5LnS2TrusSBf3lIygZR7dfR 8upLn22MX1s6XQaHx7IT00z/444m6MxTjRggbKMK+1BwdJDCWdxahoUhE0StneH3qbOH hHtkXPty84+4ZWzk8lesDWJ+m3jIq8avMdOoY= 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=BoaKjWcNrqu3XmTN2AVNCsL46SKPiITwLjAw3HkdOYs=; b=GCc5ob63Kzt1r8RJK3lozZbFev0EAoqnJyKFPRWraZRPDzcI84V6idppZU18EFhMV9 lPRvn1GkDIjV46fvKvDPkr5x6CHMX26P8yv5S8uC8MIYfsly/onshYqVuMLWsDqYNLLO ifv0rIjsH0vAgW51+u8A8bluuOmXW+pVdVsl4G33u50xINfSRlDgpiawy3DxxkHHljri dYxSRKt/Hpq0z4h6TCLJbjHQK6JL4MCvMw9x98hKgExmKiAVKq939AmYXVhyI2NSllTp 74DM1I/zS1z50tLIE+5zhXVwFn3tI2BJkb/fCMJfaniMH33gaUIAYprfPaPFOq5S3P1x 6QKw== X-Gm-Message-State: AODbwcA0I4zRFgmylS0a1voT+WiLcfhQ6oc1wWj6eCdaH7zf/aV497rL 3TAdz3fG2xVe6W2t X-Received: by 10.28.52.139 with SMTP id b133mr8515564wma.119.1497283033971; Mon, 12 Jun 2017 08:57:13 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:289a:9b8c:a41f:e1d5]) by smtp.gmail.com with ESMTPSA id q77sm153978wmb.4.2017.06.12.08.57.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 08:57:13 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Sudeep Holla , Lorenzo Pieralisi , Leo Yan , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] ARM: cpuidle: Support asymmetric idle definition Date: Mon, 12 Jun 2017 17:55:10 +0200 Message-Id: <1497282910-19085-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497282910-19085-1-git-send-email-daniel.lezcano@linaro.org> References: <20170612155441.GE2261@mai> <1497282910-19085-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some hardware have clusters with different idle states. The current code does not support this and fails as it expects all the idle states to be identical. Because of this, the Mediatek mtk8173 had to create the same idle state for a big.Little system and now the Hisilicon 960 is facing the same situation. Solve this by simply assuming the multiple driver will be needed for all the platforms using the ARM generic cpuidle driver which makes sense because of the different topologies we can support with a single kernel for ARM32 or ARM64. Every CPU has its own driver, so every single CPU can specify in the DT the idle states. This simple approach allows to support the future dynamIQ system, current SMP and HMP. Tested on: - 96boards: Hikey 620 - 96boards: Hikey 960 - 96boards: dragonboard410c - Mediatek 8173 Cc: Sudeep Holla Cc: Lorenzo Pieralisi Tested-by: Leo Yan Signed-off-by: Daniel Lezcano --- drivers/cpuidle/Kconfig.arm | 1 + drivers/cpuidle/cpuidle-arm.c | 62 ++++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 24 deletions(-) -- 2.7.4 Acked-by: Sudeep Holla diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm index 21340e0..f521448 100644 --- a/drivers/cpuidle/Kconfig.arm +++ b/drivers/cpuidle/Kconfig.arm @@ -4,6 +4,7 @@ config ARM_CPUIDLE bool "Generic ARM/ARM64 CPU idle Driver" select DT_IDLE_STATES + select CPU_IDLE_MULTIPLE_DRIVERS help Select this to enable generic cpuidle driver for ARM. It provides a generic idle driver whose idle states are configured diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index f440d38..7080c38 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -44,7 +45,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx); } -static struct cpuidle_driver arm_idle_driver = { +static struct cpuidle_driver arm_idle_driver __initdata = { .name = "arm_idle", .owner = THIS_MODULE, /* @@ -80,30 +81,42 @@ static const struct of_device_id arm_idle_state_match[] __initconst = { static int __init arm_idle_init(void) { int cpu, ret; - struct cpuidle_driver *drv = &arm_idle_driver; + struct cpuidle_driver *drv; struct cpuidle_device *dev; - /* - * Initialize idle states data, starting at index 1. - * This driver is DT only, if no DT idle states are detected (ret == 0) - * let the driver initialization fail accordingly since there is no - * reason to initialize the idle driver if only wfi is supported. - */ - ret = dt_init_idle_driver(drv, arm_idle_state_match, 1); - if (ret <= 0) - return ret ? : -ENODEV; - - ret = cpuidle_register_driver(drv); - if (ret) { - pr_err("Failed to register cpuidle driver\n"); - return ret; - } - - /* - * Call arch CPU operations in order to initialize - * idle states suspend back-end specific data - */ for_each_possible_cpu(cpu) { + + drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL); + if (!drv) { + ret = -ENOMEM; + goto out_fail; + } + + drv->cpumask = (struct cpumask *)cpumask_of(cpu); + + /* + * Initialize idle states data, starting at index 1. This + * driver is DT only, if no DT idle states are detected (ret + * == 0) let the driver initialization fail accordingly since + * there is no reason to initialize the idle driver if only + * wfi is supported. + */ + ret = dt_init_idle_driver(drv, arm_idle_state_match, 1); + if (ret <= 0) { + ret = ret ? : -ENODEV; + goto out_fail; + } + + ret = cpuidle_register_driver(drv); + if (ret) { + pr_err("Failed to register cpuidle driver\n"); + goto out_fail; + } + + /* + * Call arch CPU operations in order to initialize + * idle states suspend back-end specific data + */ ret = arm_cpuidle_init(cpu); /* @@ -141,10 +154,11 @@ static int __init arm_idle_init(void) dev = per_cpu(cpuidle_devices, cpu); cpuidle_unregister_device(dev); kfree(dev); + drv = cpuidle_get_driver(); + cpuidle_unregister_driver(drv); + kfree(drv); } - cpuidle_unregister_driver(drv); - return ret; } device_initcall(arm_idle_init);