From patchwork Tue Feb 26 14:54:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159215 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3303917jad; Tue, 26 Feb 2019 06:54:33 -0800 (PST) X-Received: by 2002:a19:294d:: with SMTP id p74mr9344516lfp.101.1551192873374; Tue, 26 Feb 2019 06:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551192873; cv=none; d=google.com; s=arc-20160816; b=Z+uYg65r/Ad+KweI8v/qbn3hQSqDG2S4PTNAVM0mtA7DO0TL8YZWROBRuiMu+u1Vjw SCGTRuQs7f1joat/53AucySOG9EF0C1vsdBTzODND98KBdUn9KQWTTmVSDSYI6HtdZaP evKb5QcN21RwCdjd5dDuLhsg3U76UztOZWXwgqNXGTNB3dL5Fedi93W7e0j7Wrs4ipx0 qr2f0b2NW29tSc+IoGnGLh14g0DpE4TrIai9knA7KezPPnPFjk+5Z7AKesbqonzLG0tL gvbR9iWoSrBA1/9Nw1tUQcTmPauElhqdHmxZGOJzDonXGoxRE87/nmDD65jzfUYXIU5m GhPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4olRHrO4OGLzrA6TD5Q8IXYA3EOf33sfuFLg1Ze1+T8=; b=nvNFE3Xji3ERJCNp+Z6zjyY0/w8M9+a7PB0jupYMjUiD2FdntLb8otvqgO+yi4WZVJ nnISjtA7WWXu18Ft6ZpTK8463y49mSjtlW0N/WhV8232a0Q0X6WMpq7YmwJVfBZDyGCZ u4aoBRWZa29dCrm+gAL3Xq6akKtgEVL9kTIQCjdWk0vC0AtAmHwmf1LwYKhtNjSMIs4f IFfmdESimwZq307DYTW+vY6dqMAiHcBQ/lVSrGVXmePWK+uN/m6iBY/0Dk6LPtnFzIQT xSF4BpwI8qzl/4coRKLjzsqZlLuGOjC4VcNX7+t8U2f6sq4bPTAstMVx8QDTZJCropiN 5DuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UpiV1C7X; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i26sor7051300ljj.17.2019.02.26.06.54.33 for (Google Transport Security); Tue, 26 Feb 2019 06:54:33 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UpiV1C7X; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org 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=4olRHrO4OGLzrA6TD5Q8IXYA3EOf33sfuFLg1Ze1+T8=; b=UpiV1C7XUoRlE7eOlCQ7dZ0FXppFbUeWVKE+mS8DyVTrfoC9wQDiLrkZaRPQsDkffg 7LmpX1qQeqw7pZ4AGLlqSYJuLMPQL08U8CWEQRAzNONsI4X0V9xyDVzPq8sh0WB4flM1 esuF0lZLmPD4DVxaFMIq1+6Wc29pnSH+8Dkuhnz8A0Be9Wg7PKAiatg7BMtzX4BoINze +uZ4OPlROTt/bcxixY1D8S0MKU4u5tchRwXrsbPR5KkeD5uTBeH7HE6rueq/yA4Bnf6o 4giH0pEncr3VbdMzT1AqQ2na2sJZ2g7M9VVfBr+gsFBFrcJbgHblsvCVf/AUAccBFciE Kkjg== 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=4olRHrO4OGLzrA6TD5Q8IXYA3EOf33sfuFLg1Ze1+T8=; b=lU5azA7LHh2T2rjzZmAdYGqo4x9TqDRb9e0B7qy7GXZZ/kDpALZz9UdQW3LLRmrrvW SHPJIC1ZZuWEx3gCusAzzWe0V9apoDSUxJPBESDDEIGUr3z57k2sqcRNU1eyXkNptV66 WMJEVtXe2p6eRlLCaHQ77L8Zq5Yzasce+NLRddjjX9nNXLnhJhiWDpXOtr/8nLewxGUB dqCQvBD8uJ5qR8n/U32rst13DenigiorDYUJvuqskgJFJBZ73ZYF/kUTq5LoDZODrRO1 C0UgeloF2z7JBm5rwbgMjg6HtnL8NXLKRJgLzkaU/gkXWMIwe7ya13Tmmzuz2ELj69Tv 5Xkg== X-Gm-Message-State: AHQUAuangwlmls3c78ZQstym0+PGdwteZySwwoFVyTTMxouICk2Cnr9c QgP9h8llGQRNL/Pxi70Al1PjLbH7 X-Google-Smtp-Source: AHgI3IYhRgfMci2gWG7XJv/qsPRrrRxzcro7TN2Y9E2w5Y3G0gGzKJM7bcSXjPp5ZRxr+TyG33XsbQ== X-Received: by 2002:a2e:9916:: with SMTP id v22mr13192461lji.68.1551192872994; Tue, 26 Feb 2019 06:54:32 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t11sm2206554ljj.92.2019.02.26.06.54.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 06:54:32 -0800 (PST) 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 v11 1/8] PM / Domains: Add a generic data pointer to the genpd_power_state struct Date: Tue, 26 Feb 2019 15:54:08 +0100 Message-Id: <20190226145415.19411-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190226145415.19411-1-ulf.hansson@linaro.org> References: <20190226145415.19411-1-ulf.hansson@linaro.org> 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 Signed-off-by: Ulf Hansson --- Changes in v11: - Add a callback for freeing allocated power states. --- drivers/base/power/domain.c | 12 ++++++++++-- include/linux/pm_domain.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 2c334c01fc43..03885c003c6a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1685,6 +1685,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; @@ -1695,7 +1701,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; } @@ -1811,7 +1817,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;