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: 9363353 X-Patchwork-Delegate: agross@codeaurora.org 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 977686077E for ; Wed, 5 Oct 2016 20:32:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A51F28CDC for ; Wed, 5 Oct 2016 20:32:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F45628CE0; Wed, 5 Oct 2016 20:32:10 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E37F28CDC for ; Wed, 5 Oct 2016 20:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755021AbcJEUcI (ORCPT ); Wed, 5 Oct 2016 16:32:08 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33532 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755028AbcJEUcH (ORCPT ); Wed, 5 Oct 2016 16:32:07 -0400 Received: by mail-pa0-f46.google.com with SMTP id cd13so85840168pac.0 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=EsxIoYLEiurZ8zVqt/73SbENfJMiIlXJhuNa2mg+jD4dM2W1NrcG9l2HtQWyzTyc0a 4gRZKjeBgbByTm5g6d7XIu7Z2TLrsPMOYAQtWl75nRZGPwh+OoLb0Cm0L1wR2giKlwVy D8ZeRphUa3UYT8qThB7XU8t+++MStiNpWWk27AKxUHSaIq81STF4yt35P/4UNY4eaZ+h jgw95EZYvAHhssB4phHANX7w4283L+KHFrFr2gsIsiZOaMJcCqsJCJ7M0VEG06xEQX+R lR8o5C970fBEntzSPYHM5qXZIvPNwRVoVPQrgxDebRPa2r3GWySBIXsqP8MEYhGQyj4S dBgw== X-Gm-Message-State: AA6/9RnWidFxdLQu+J1EGkIO3REViQRWWrzv6xcv+YQItG0aBA31Z5hnbpSX1BHUbPhM4SFw 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 Cc: andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, brendan.jackman@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Juri.Lelli@arm.com, Lina Iyer , Axel Haslam 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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 */