From patchwork Wed Oct 5 20:31:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9363385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8FEC36077E for ; Wed, 5 Oct 2016 20:34:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 820DE28CDC for ; Wed, 5 Oct 2016 20:34:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7647B28CE0; Wed, 5 Oct 2016 20:34:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2789128CDC for ; Wed, 5 Oct 2016 20:34:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1brsrt-0007Uy-9t; Wed, 05 Oct 2016 20:32:45 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1brsrb-0007Np-Ie for linux-arm-kernel@lists.infradead.org; Wed, 05 Oct 2016 20:32:29 +0000 Received: by mail-pa0-x22f.google.com with SMTP id ik13so36266063pac.2 for ; Wed, 05 Oct 2016 13:32:07 -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=T7H/+8HXw3iuCz+PGzgYPwvc9tG1Xbr7CILsGc/QJ/s=; b=ItlcOMIVKCYrza2tQNu7njRHwwFVQ4mWfiT2N7IVuwCXL44DnxG8GPZ1DeDKLFjykZ dhHs0a1eNbm9duDqB03zE7uA7frgBJkSyKg6eqak6cqlqK06HJL5Ql5eu6MTwv1Pprb/ Ir5lyzBngJFKbmnqOPT6qzrh/5Z9NLVMCr0xw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T7H/+8HXw3iuCz+PGzgYPwvc9tG1Xbr7CILsGc/QJ/s=; b=Zq9YyCzdSpjr+ooHYFPr2+/WuRWZkLiR3q29rb/jpWrH4f8xN3mW+os2bFBhhTlzAo cY3NmyAr0tat9SYLjydhRuTwmSOMAfXK24I7jU2AmRBvxIiL4UPFQHtJXj7af+8xVTVz oYYoYfXt7yrGnQXJl9DzchyRESwkRFLlGeerP3h3pLZeXURNmFwQ/DzCymD2z1ixAi9c LzIM20/l0tijcsBA2zLVR3GU3SuquUMHBr1s5qNB8GuZ4WYNBzpBDyUARz+FKpXUwrbt dgegwSxVrY8axee7MmHg6jEY1Y/w1cao1+sHI1ezFiYQLJOEmSKtlMgTjGOfeeQ6MRtm peFw== X-Gm-Message-State: AA6/9RnU7fXrdX5YKc9ua5O9WeFk+nrRPn/HNWaE9netjyetAprkMUq4yyC/hyz6uu+xhXd6 X-Received: by 10.66.161.33 with SMTP id xp1mr10135810pab.21.1475699526740; Wed, 05 Oct 2016 13:32:06 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id s80sm42999467pfd.10.2016.10.05.13.32.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Oct 2016 13:32:05 -0700 (PDT) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/8] PM / Domains: Make genpd state allocation dynamic Date: Wed, 5 Oct 2016 14:31:52 -0600 Message-Id: <1475699519-109623-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475699519-109623-1-git-send-email-lina.iyer@linaro.org> References: <1475699519-109623-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161005_133227_729092_4E02CEA8 X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Juri.Lelli@arm.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, Axel Haslam , brendan.jackman@arm.com, sudeep.holla@arm.com, andy.gross@linaro.org, Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Allow PM Domain states to be defined dynamically by the drivers. This removes the limitation on the maximum number of states possible for a domain. Cc: Axel Haslam Suggested-by: Ulf Hansson Signed-off-by: Lina Iyer --- arch/arm/mach-imx/gpc.c | 17 ++++++++++------- drivers/base/power/domain.c | 10 ---------- include/linux/pm_domain.h | 4 +--- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-imx/gpc.c b/arch/arm/mach-imx/gpc.c index 0df062d..b92dad5 100644 --- a/arch/arm/mach-imx/gpc.c +++ b/arch/arm/mach-imx/gpc.c @@ -380,13 +380,6 @@ static struct pu_domain imx6q_pu_domain = { .name = "PU", .power_off = imx6q_pm_pu_power_off, .power_on = imx6q_pm_pu_power_on, - .states = { - [0] = { - .power_off_latency_ns = 25000, - .power_on_latency_ns = 2000000, - }, - }, - .state_count = 1, }, }; @@ -430,6 +423,16 @@ static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg) if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) return 0; + imx6q_pu_domain.base.states = devm_kzalloc(dev, + sizeof(*imx6q_pu_domain.base.states), + GFP_KERNEL); + if (!imx6q_pu_domain.base.states) + return -ENOMEM; + + imx6q_pu_domain.base.states[0].power_off_latency_ns = 25000; + imx6q_pu_domain.base.states[0].power_on_latency_ns = 2000000; + mx6q_pu_domain.base.state_count = 1, + pm_genpd_init(&imx6q_pu_domain.base, NULL, false); return of_genpd_add_provider_onecell(dev->of_node, &imx_gpc_onecell_data); diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e023066..740afa9 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1325,16 +1325,6 @@ int pm_genpd_init(struct generic_pm_domain *genpd, genpd->dev_ops.start = pm_clk_resume; } - if (genpd->state_idx >= GENPD_MAX_NUM_STATES) { - pr_warn("Initial state index out of bounds.\n"); - genpd->state_idx = GENPD_MAX_NUM_STATES - 1; - } - - if (genpd->state_count > GENPD_MAX_NUM_STATES) { - pr_warn("Limiting states to %d\n", GENPD_MAX_NUM_STATES); - genpd->state_count = GENPD_MAX_NUM_STATES; - } - /* Use only one "off" state if there were no states declared */ if (genpd->state_count == 0) genpd->state_count = 1; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index a09fe5c..bd1ffb9 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -19,8 +19,6 @@ /* 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_MAX_NUM_STATES 8 /* Number of possible low power states */ - enum gpd_status { GPD_STATE_ACTIVE = 0, /* PM domain is active */ GPD_STATE_POWER_OFF, /* PM domain is off */ @@ -70,7 +68,7 @@ struct generic_pm_domain { void (*detach_dev)(struct generic_pm_domain *domain, struct device *dev); unsigned int flags; /* Bit field of configs for genpd */ - struct genpd_power_state states[GENPD_MAX_NUM_STATES]; + struct genpd_power_state *states; unsigned int state_count; /* number of states */ unsigned int state_idx; /* state that genpd will go to when off */