From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lina Iyer Subject: Re: [PATCH 1/8] PM / Domains: Make genpd state allocation dynamic Date: Thu, 6 Oct 2016 09:40:52 -0600 Message-ID: <20161006154052.GB28930@linaro.org> References: <1475699519-109623-1-git-send-email-lina.iyer@linaro.org> <1475699519-109623-2-git-send-email-lina.iyer@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Return-path: Received: from mail-pa0-f46.google.com ([209.85.220.46]:34538 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754408AbcJFPkz (ORCPT ); Thu, 6 Oct 2016 11:40:55 -0400 Received: by mail-pa0-f46.google.com with SMTP id rz1so10533787pab.1 for ; Thu, 06 Oct 2016 08:40:55 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Ulf Hansson Cc: Kevin Hilman , "Rafael J. Wysocki" , "linux-pm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Andy Gross , Stephen Boyd , "linux-arm-msm@vger.kernel.org" , Brendan Jackman , Lorenzo Pieralisi , Sudeep Holla , Juri Lelli , Axel Haslam On Thu, Oct 06 2016 at 02:37 -0600, Ulf Hansson wrote: >On 5 October 2016 at 22:31, Lina Iyer wrote: >> 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 <...> >> -#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 */ >> >> -- >> 2.7.4 >> > >In general I like the improvement, but.. > >This change implies that ->states may very well be NULL. This isn't >validated by genpd's internal logic when power off/on the domain >(genpd_power_on|off(), __default_power_down_ok()). You need to fix >this, somehow. > Good point. >Perhaps the easiest solutions is, when pm_genpd_init() finds that >->state is NULL, that we allocate a struct genpd_power_state with >array size of 1 and assign it to ->states. Although, doing this also >means you need to track that genpd was responsible for the the >allocation, so it must also free the data from within genpd_remove(). > >Unless you have other ideas!? > I can think of some hacks, but they are uglier than the problem we are trying to solve. We could drop this patch. Real world situations would not have more than 8 states and if there is one, we can think about it then. Thanks, Lina