From patchwork Thu Nov 29 17:46:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 152426 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2671927ljp; Thu, 29 Nov 2018 09:47:10 -0800 (PST) X-Received: by 2002:a19:978c:: with SMTP id z134mr1736533lfd.109.1543513630498; Thu, 29 Nov 2018 09:47:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513630; cv=none; d=google.com; s=arc-20160816; b=fl/kvj7+GYjdp0S0n6JS5Hx0YyZXMYBppg2j3TwmXfQ5OJfXJkbG872nPExPiK9jY1 YqM6Mquvm8ooyqK5aCQuAt8PCE+j2CnavZiKROHZoMCsnOIbNbkv3wBFZmKj++vlRz7G z+o6KKQww+9TszX4C6xkWF6tAFIIkaR27qDN8BHGRvIT3dWPvM/qd8/p/yp5udhXC6ri Ln6VTm0JOiRAub0zKe6+gPtdyV9KwW6yjHcWjrzMpXJpuQayc9jE3OCnrolq//oziYpn IhTMwS5zIjlcx79DYxp08rVjnn5z1F4oz0CjLuWK1zOzJUwKYhSlMphoYUk0kINn9bjJ EZGw== 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=2OFzyl7DYqM+TKMo2yE9Sged+x4IOY1BMaINc0irzbk=; b=QVej93zO4TsUaOpKAUz1CsBywMKpF5D+eZUljCCeIunwtmps4OF7ArXGwQGauWRh4v MlAvVQSAv2idBXqrBaksaMbcgOHP6uzzEklSTPDSkno4F6TKFbAm6b1DWNTYvOqXH9Dv 65A6ba1qC0Y/RJEg1hvCzHwnHblSWb122u4zECJKrqHTO12vyN+5ezqV+dXmhtDb090K N9VKeeAGNhMJ4zKxggQ/wJ+PGssktBIua+9sdtKqO7niv/7alXCOrzE0YNJR0Wqtva4r rsgaRPCygC6LJs8lyZIdUvM6qAzlVrnagISahbqI0FxG+HxJGF9ol2V7tAXp/q/YesOS zHlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WF/uDC6c"; 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 c7sor731481lfk.50.2018.11.29.09.47.10 for (Google Transport Security); Thu, 29 Nov 2018 09:47:10 -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="WF/uDC6c"; 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=2OFzyl7DYqM+TKMo2yE9Sged+x4IOY1BMaINc0irzbk=; b=WF/uDC6cto89UDdfBnGrf81NlzZ26+j7fWxzr3FcUZ6bWkeWgWVSaZuoeSFwtlCJcl ngNYcGXO/yOYk1SP4DlEzNaHgCCudJxCxzVB9V/lGel5iAWprOmMJl3y0UydtSlM96+S vrGMzuCnis/xZHu8BwGfiah6JjJ2lyvNiNMLE= 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=2OFzyl7DYqM+TKMo2yE9Sged+x4IOY1BMaINc0irzbk=; b=nCQd2ucFNSQqM1dYLMSairHLtTzpK4m42qbqBY13OEs4ZRW63GTbb3Ziml7/XbVwSN Y6KMrwiiP23g94TkuppWda6BtzwktU7/1ymZzw8GBMa5JVOPMB5IIXmhY5Cws6hfdndZ t2Q1j6pXVB7k4WnuxDDTxGGl79ZyRfzESG1db1NLzMxKI1GUcfGDvFMI4Tjvc58foykl jFEU3dYoqP5ecSueZdFNA/19l0ZIhO9NQeRTgr0HON9AQU0yJk16Giw2cs3IWxrOxAiT XjZLJE1CDR+WTcvewKZWBWj9avIYgJX8E8eijMqSO2aJApSSPC9lQxlaSdWK+d8oqbGG 7gKw== X-Gm-Message-State: AA+aEWZesYI6Z+kUi6/131wG2yzdZFXnQ+wThy5mYB9Xhb6jYWrP+ERI 6mG+4hbnY2qhN2/StKZY+bseTgqf X-Google-Smtp-Source: AFSGD/WcONLGmNXYECO9oNRUxrjzh2zAGhw9wIqkXq80q8IdpwQYFhZTN3X/sVmIELfDUDxcx4LF2Q== X-Received: by 2002:a19:2c92:: with SMTP id s140mr1622412lfs.42.1543513630200; Thu, 29 Nov 2018 09:47:10 -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 j76-v6sm393983ljb.12.2018.11.29.09.47.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:09 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "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 v10 01/27] PM / Domains: Add generic data pointer to genpd_power_state struct Date: Thu, 29 Nov 2018 18:46:34 +0100 Message-Id: <20181129174700.16585-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-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. In order to introduce the pointer, we also need to adopt how genpd frees the allocated data for the default genpd_power_state struct, that it may allocate at pm_genpd_init(). More precisely, let's use an internal genpd flag to understand when the states needs to be freed by genpd. When freeing the states data in genpd_remove(), let's also clear the corresponding genpd->states pointer and reset the genpd->state_count. In this way, a genpd backend driver becomes aware of when there is state specific data for it to free. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- Changes in v10: - Update the patch allow backend drivers to free the states specific data during genpd removal. Due to this added complexity, I decided to keep the patch separate, rather than fold it into the patch that makes use of the new void pointer, which was suggested by Rafael. - Claim authorship of the patch as lots of changes has been done since the original pick up from Lina Iyer. --- drivers/base/power/domain.c | 8 ++++++-- include/linux/pm_domain.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7f38a92b444a..e27b91d36a2a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1620,7 +1620,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_state = true; return 0; } @@ -1736,7 +1736,11 @@ 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_state) { + kfree(genpd->states); + genpd->states = NULL; + genpd->state_count = 0; + } 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 3b5d7280e52e..f9e09bd4152c 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,7 +111,7 @@ struct generic_pm_domain { struct genpd_power_state *states; 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 */ + bool free_state; /* Free the state that was allocated for default */ ktime_t on_time; ktime_t accounting_time; const struct genpd_lock_ops *lock_ops;