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: 161261 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6561526jan; Wed, 27 Mar 2019 07:35:57 -0700 (PDT) X-Received: by 2002:a2e:8693:: with SMTP id l19mr9051335lji.47.1553697357129; Wed, 27 Mar 2019 07:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553697357; cv=none; d=google.com; s=arc-20160816; b=a8iVPEM2QZZwAqHUZrKr8YOrTrzhTWMnyaWt8Ix0KWfXog133Vw1zFmw2zigWhuLM4 dQKFJSywxSnsV7DbwqkTz2XZftkToTfAtovfHLpqPi+j/EP3EYEd49bkBFhj5JozgiIH wuCy+KVgMEZIOIp15+TSMHs16ayCKnWPOCBkJyPwmw17NasgR9ybKGy/hD2M38a7AtCz oVFQAIg75kh/B+bKZZcUwhqF3aOi7zO1emj8xPYsR0ftN/pGxbRq4JuRHnFKIziINv8w RsyjwHx9LH2PKZE051xaC+8P29RPvGSToZLXYoTWLOoWzJOYIBpuZdOlHakwWfax1Y+d qq8g== 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=xqDhXSTUJNklRs7Nsz2EsWlg0IJVd5TtQANghzoIj6Y=; b=ECu8dz4P1py7Du7IVxLUQdHiZO3XbAinNPNPz5Ef2rl2RhZh33qXyl54kW0qOsxl40 xOtSZark6aLUIPat/fFpY55S8E4/HwYsxE1FHZGKfWir2wCTjW+yurL7kLjsrtJAOaf+ gwaFalXTpUbKeq9tiwhqYEHK1HCpBIWWLDeoul76+RvQ1tmZhByv86Q9z3w9I5kkqiE6 Avyg3DxBCbG3R5iuZYJIyYIXz3OFwzXNqPrAazz79iIchg2JFv3O5Ntvt33Fiq21P6vk zumQvH/YtgbnT1HaVZsjUI+6bNY1tjlyrZDxrY7MD3VLnB6y3BUKamh2e0hF0xVBF8Cb 0w1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vUdTcIfa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 k5sor6198657lfm.7.2019.03.27.07.35.56 for (Google Transport Security); Wed, 27 Mar 2019 07:35:57 -0700 (PDT) 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=vUdTcIfa; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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=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=gF6xseyHDlwnNVWOFDlo/KJkGBLyyttIuo3oh4dIGGQCML5xT7eW4oEN94Pa02o1S0 inTsdYugGmaE71U+cttFOwrGi7+AHJuT67r8ovg4ihmDFgqy89gsiOjfgy02fLPUZ5uF 0Xjj2zpJh6Gu9xmAn1h/89qe3sBXvy09WWbHFI4KjBHlbVKZstF29lYfZpmadm4uJD+4 0uHCYdGPHWcZV3SKj3h34XTG/EzMlj1FIMLmMsHj5puneAZbqbAS5JZnrAlkCdCUox8B CVvN78CNeHfIIiHP/FNhlF54o+O030Jg3ZXwcgZX+gC+bLn3PwSCkaIMQ8P4/9MghkxY 2ecA== X-Gm-Message-State: APjAAAVoUPI55Exj6DcRKrPFmfoxAGnPEYePdGIuImEVp189OFzxIxou SvGn+1+wCwJkjkzg7W0hNXKszeSJ 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) Return-Path: 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> 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(-) -- 2.17.1 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;