From patchwork Wed Feb 27 19:58:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159289 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4833404jad; Wed, 27 Feb 2019 11:58:43 -0800 (PST) X-Received: by 2002:a19:8094:: with SMTP id b142mr1875130lfd.117.1551297523140; Wed, 27 Feb 2019 11:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551297523; cv=none; d=google.com; s=arc-20160816; b=rpRJft/KTn34QT49/fXVNJSJXtn1aNLxwrR1fOO/vCfa8ZTDPYYl4gXpHeMH1cYMEu JsENnzcBz0EYjmvgoXrkC/BELjTfqLAkwueycjlJxG6D3Toi4abmPhCgWSWCBBMivAhs fsFG8URC3VwlYlAjhd/QzuwOP7RglHgio3T/r1s++S8pvQV7OX3Ibclq5acd5veZlnKO Gk7jjnsAlLwjxW3C11dK7OdrW+tY8AKQJSdngrDxYQ2aablsCO439n9BGu4Pzm1C0Rog zmPMIb31orQePhXz//ZYpJqCOcmVyhThOg237WnxqpX2AnTakgjEFnxJMbn1svcQDs7p JSgw== 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=XKFXfVA/MFOFOm3N3DxhXtUoRuHmZYEZxmpq4iLOsS0=; b=tIlexEhijS0eDMdrflhHE1yIxS6bXRfHFTiLoxGSKq/2FNG1ozzmlkpkqwM8ae7eET 0gsYbBj09G0jlM+k6JnJo1cFzzyq/My4Pr7ovxZhHQXzUSGuCNaS8a1oHcoCjViEQDpQ rAtCVVorazEN5CrxwX8dZHoOD+/Qr+MlGXYRCF4wiP0/cYw4VMbP9hjn+A2DB8QP68Ci iFeXMbAHB4wTOL7G7OjgoFwl0D9o8vy9ZoCl9MAf45+WSyvUJ0swUPVBpOEz5rcrac4P +4WJXgnAI6LXa/tt1bCBg7lUrjqEA3EPsWmv01RxWDek+m/+Xt/5Bv5FD7rB7Um3gOB3 8GQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCNOViW0; 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 d3sor10169901ljj.39.2019.02.27.11.58.42 for (Google Transport Security); Wed, 27 Feb 2019 11:58:43 -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=BCNOViW0; 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=XKFXfVA/MFOFOm3N3DxhXtUoRuHmZYEZxmpq4iLOsS0=; b=BCNOViW05Viv/rVAqgh4Vsn2bB/S6rmx007nW5Zwfg3vOsf2oiUNr2cy+h1kftVC1O bu8OYpbnjns/sJO3ZVm2y2mMVvfyKc5T8ToLluuy4Ym+LbQsz5Bw8NYC596JvipOH2k9 4hUg069/roFn9YCZWfP6Ya/L0OOyZxOhQvrivrUoEomsZXKx4S3j/C7bhV/lcIWBHY/9 ZS+1Z69pFXGch6UfZOAc3Y2359plZH2U7Sx37NqdNH25je5jjhYblLPfuyWaY58vBevx uUqpLXxkYkaERvVNnnVdnmP1OxIeXVmuPuDi5S71RyTevI9kwdjMnD2n17nhk0uMunLa Fqtw== 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=XKFXfVA/MFOFOm3N3DxhXtUoRuHmZYEZxmpq4iLOsS0=; b=W0yawMxSki6xCPY9navIl7FWRaOTFHPBlZLt7wdMTbQBRRVkTGaVu7/iZiA1QF2GLG cJtcfBXcNR4uMiPU090JjgkKZte2Ev/zO+tZ0PqdVwqEgFOcpJVzA7Y24DI3gZQDA0EY wMpIKAAVMTd3tfWpj5Ge6FP5ujLK0s1FW7QpEVTF2W5b8LxfCl7+4YPf6pCwc168lGJE DuuMbvWQyL75ltdGTpDAeNx9iFxXT4dWbHKJgXpuVl7WAoDlPcY4iUJJODals9PfpK2M OWUSoMRNlpEPW7WiuFgjdfi4z/RpM1hK+ak3U/M1ez8vZv8xffZkWfWxk+LzqGVcs2km Gehw== X-Gm-Message-State: AHQUAuY94Uahmncp7Hkg5RoVt/Zca3VJRA5mDPLfRJ0ghnpjgzO2HJJ2 T5dULgfU+o9NH1oDi5R+UG8BvM/C X-Google-Smtp-Source: APXvYqwoEEWsyKRDgF2ZqvMiwFnQqs7Nd2PwXFGAP3pHpMx7U5f+SRreNguy4ZpIWPZAhCu2g6hqmg== X-Received: by 2002:a2e:9916:: with SMTP id v22mr2435944lji.68.1551297522613; Wed, 27 Feb 2019 11:58:42 -0800 (PST) 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 z128sm723802lfa.60.2019.02.27.11.58.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 11:58:41 -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 v12 1/4] PM / Domains: Add a generic data pointer to the genpd_power_state struct Date: Wed, 27 Feb 2019 20:58:33 +0100 Message-Id: <20190227195836.24739-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190227195836.24739-1-ulf.hansson@linaro.org> References: <20190227195836.24739-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 v12: - None. --- drivers/base/power/domain.c | 12 ++++++++++-- include/linux/pm_domain.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) -- 2.17.1 Acked-by: Daniel Lezcano 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;