From patchwork Wed Mar 27 14:35:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10873573 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6848C1390 for ; Wed, 27 Mar 2019 14:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 573B728698 for ; Wed, 27 Mar 2019 14:36:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B34228A01; Wed, 27 Mar 2019 14:36:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 E221928A17 for ; Wed, 27 Mar 2019 14:36:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbfC0OgA (ORCPT ); Wed, 27 Mar 2019 10:36:00 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40973 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbfC0Of6 (ORCPT ); Wed, 27 Mar 2019 10:35:58 -0400 Received: by mail-lf1-f68.google.com with SMTP id 10so11536446lfr.8 for ; Wed, 27 Mar 2019 07:35:57 -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=xqDhXSTUJNklRs7Nsz2EsWlg0IJVd5TtQANghzoIj6Y=; b=vUdTcIfazo4TkG+buldam+PhyFFNuDthLSslrkpqwoNrYsu9WlNlKvCd+BtFpo5FYh 89eb2KqV9okg5JSqhPhLjyra4l3GTxsGzD17RUxkhr+oB4xNyS+EKB9yX1/Vib1G4qjV kelNtpBQgdCNT31xGRERRrVn/akwMUFsyT193BRZqUMiOFFEBy4T1lHJLhgAB10PDnkf 8q0oG8j60vwlTk0DPt+SCObhXi0ferjtdFQkmBy6EIcmEG0VgMXI+JS9ls6pnKl3PgnR 0pOR0NYNy9SkPTqPIUaMH3BCAe9q6a8sH3awjerhjj642XPPRHMLwUhHddsNk8uq8KKn jkww== 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=xqDhXSTUJNklRs7Nsz2EsWlg0IJVd5TtQANghzoIj6Y=; b=IRvzIsUGllcJVxqCHL7vRKVuDjKU5wEmoYPHrelDPV51UlD0LiJjZIUcYCaiX4kEYY YoJjPSMGVxD5+ZDKUFwQNOGqeRgF0zL6rJ24cgHRPORNwQu06kVQH6WJXhab+pmQGYa8 GeX2cfEHcE/ReMSRcfodbzFHi1MpHkdPc6NR/dTq2i0M6Q2419xZDf5CdvPI5CAo4ojw 2CCZwegsgqVXc9cc2ZwY04OtjGafbI5eNKOEyYXMHqsLoVL78A6K9fJQGE4+KM+x6YYy 41oOV9xtft+iXKpVYHdiSgDKK5I4OBT6MFutL4BP1K7GNfkp7OIz+2twarLxLLlRO3FZ XY4Q== X-Gm-Message-State: APjAAAWN/j4sOLfogVOzCJEZRTstLHVcU/S59aVQVBP37XHTRwqkybfb r48LCdXh+Bq8rhzHPZh3KwLbMg== X-Google-Smtp-Source: APXvYqzEgmGdFWFkPc93PX7NAm6POm61bIL9xLa3T0OreH/UQDLKrqrYmy0xCbUzxhqvX5C9ZJv03g== X-Received: by 2002:a19:d144:: with SMTP id i65mr17047487lfg.52.1553697356770; Wed, 27 Mar 2019 07:35:56 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id q2sm4548789lfj.58.2019.03.27.07.35.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 07:35:55 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Frederic Weisbecker , Thomas Gleixner , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , 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 v13 1/4] PM / Domains: Add a generic data pointer to the genpd_power_state struct Date: Wed, 27 Mar 2019 15:35:45 +0100 Message-Id: <20190327143548.25305-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190327143548.25305-1-ulf.hansson@linaro.org> References: <20190327143548.25305-1-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let's add a data pointer to the genpd_power_state struct, to allow a genpd backend driver to store per state specific data. To introduce the pointer, we need to change the way genpd deals with freeing of the corresponding allocated data. More precisely, let's clarify the responsibility of whom that shall free the data, by adding a ->free_states() callback to the struct generic_pm_domain. The one allocating the data shall assign the callback, to allow genpd to invoke it from genpd_remove(). Cc: Lina Iyer Co-developed-by: Lina Iyer Acked-by: Daniel Lezcano Signed-off-by: Ulf Hansson --- Changes in v13: - None (re-based). --- drivers/base/power/domain.c | 12 ++++++++++-- include/linux/pm_domain.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 96a6dc9d305c..ff6f992f7a1d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1686,6 +1686,12 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, } EXPORT_SYMBOL_GPL(pm_genpd_remove_subdomain); +static void genpd_free_default_power_state(struct genpd_power_state *states, + unsigned int state_count) +{ + kfree(states); +} + static int genpd_set_default_power_state(struct generic_pm_domain *genpd) { struct genpd_power_state *state; @@ -1696,7 +1702,7 @@ static int genpd_set_default_power_state(struct generic_pm_domain *genpd) genpd->states = state; genpd->state_count = 1; - genpd->free = state; + genpd->free_states = genpd_free_default_power_state; return 0; } @@ -1812,7 +1818,9 @@ static int genpd_remove(struct generic_pm_domain *genpd) list_del(&genpd->gpd_list_node); genpd_unlock(genpd); cancel_work_sync(&genpd->power_off_work); - kfree(genpd->free); + if (genpd->free_states) + genpd->free_states(genpd->states, genpd->state_count); + pr_debug("%s: removed %s\n", __func__, genpd->name); return 0; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 1ed5874bcee0..8e1399231753 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -69,6 +69,7 @@ struct genpd_power_state { s64 residency_ns; struct fwnode_handle *fwnode; ktime_t idle_time; + void *data; }; struct genpd_lock_ops; @@ -110,9 +111,10 @@ struct generic_pm_domain { struct device *dev); unsigned int flags; /* Bit field of configs for genpd */ struct genpd_power_state *states; + void (*free_states)(struct genpd_power_state *states, + unsigned int state_count); unsigned int state_count; /* number of states */ unsigned int state_idx; /* state that genpd will go to when off */ - void *free; /* Free the state that was allocated for default */ ktime_t on_time; ktime_t accounting_time; const struct genpd_lock_ops *lock_ops;