From patchwork Wed Dec 12 10:57:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153572 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1679519ljp; Wed, 12 Dec 2018 02:58:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/UdoeBnzvAccBx/Yx2b9qCfcHnsLfeMnVue12+DVG+031N7Ubhezuaa9sfBhAIBffG+q8XH X-Received: by 2002:a63:5b48:: with SMTP id l8mr15090200pgm.80.1544612282981; Wed, 12 Dec 2018 02:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544612282; cv=none; d=google.com; s=arc-20160816; b=NOx5FXzLvhrIzYMCjYUvSasgfgQ0wVtB0++R/M1xYa2jCXGvqzp6CUQ24QOgV0qs2a pd6b9EIEGZ7hgrLI5fKLP+cknz0t1RUfvHwFtcD7I8doIz7fgBJ2O3AnScaguHyh6f39 LDIfqsMr8J3IcRSWAhJ5EP3a7jXw/BoEz80HBC+HES4ny40P+XwsvFf5COqlYVb8WJxi eD8Og1RZzaW2onH6JniniIEpXlYM+uya850SZ6iCS/kQ6i3eMOeSQoJeS+YdCFzpFfDb Jm6F3MxHagH/lC/qbAQy6NDYT0/i6LEbXM+pSl3KWh6dQ9PRc2CRrtpcmg734e9C0DvC EPBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=bk54xQeB4RRTFpyHhnPJn/1Y7xRxpuULs4X8cSJgtucMac+a4RFzDXFEloXGaMRwhd vQpjlpOvywm99tHymVQgsbKsJ/2rZpAxdJRacl36EoTUZyNVa3Z+aaIDPjLpidP7S/xD 5RDkBqcnkfF+MVZT9BZNosF/b8B1xyLTW5yoxlnSGhoEulHIAG7SzDru7ZFpRAR24M+A ricpZDJtebxJ+WbDsxNQbR7en2BT1cfHgYXVf/KgbXGUNl6qacdcOw+JLD/9F5w4JWfy tndMSGadvwYThavzBW5LiIfhD+0y3IPnDESz6/J4JO9MYykGsTiSt0cyjgbKkjmTr6qJ px7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O1nD1RQ6; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si16383713pfq.19.2018.12.12.02.58.01; Wed, 12 Dec 2018 02:58:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O1nD1RQ6; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727303AbeLLK6A (ORCPT + 11 others); Wed, 12 Dec 2018 05:58:00 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:47054 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbeLLK6A (ORCPT ); Wed, 12 Dec 2018 05:58:00 -0500 Received: by mail-pg1-f196.google.com with SMTP id w7so8152623pgp.13 for ; Wed, 12 Dec 2018 02:57:59 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=O1nD1RQ6wqsp1qr0IUDtT04iphzs5fMjIeu+3J1eDmQ0bbiv046og7u0wiaNLj4PVV F/44HnYNiv15OL6axGl+G8oh53E6UGcjiaVEqECFj5KInABoyEOdKdIqkn+KZJhqB3AV c93FNJsp8t8MgD0qxSqZGinupFU2akEU4b8t8= 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:mime-version:content-transfer-encoding; bh=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=a7RgawyQq6/1heG+FJGJ7yAHJ1YS3YBJJcO5y4BQQsOuMkTnMeHjTR0E1wNfKgHm/o EIGI5ViUOOA0Or1+udTlAc62JS3+jIe+UJdPInxtXNRHYeOiqFtaGEM8q7F47727fvh8 N+9v4pLHwHkd5kGbdubFQa3ZNoRMdlR/kWJVANDTrZ7tT9PuecCjIlDiHhhiQoq5E+RG KonUJXxACCDkFoYp1tX7eJhv+vlj5xxgvWFyu9VNEOfZGKQw4oOMl6xir2ZqtX82roSN Zm7i8zTt5bpilvqHqs8WkFPQHbKTOhJ2JzyEB7zTuYLSeAdF69NsBUBAJGzM43E6VfGM aydg== X-Gm-Message-State: AA+aEWY5Hm/PlI0bLcDuPa+/JXEdBr3q5ymq7ep/FNX6AgnS3WMmNgV9 i1MGa9D6/GX6GHynF/v7Xk0L+w== X-Received: by 2002:a62:cd44:: with SMTP id o65mr19677416pfg.222.1544612279473; Wed, 12 Dec 2018 02:57:59 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id y6sm32795503pfd.104.2018.12.12.02.57.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 02:57:58 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Len Brown , Pavel Machek Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 4/6] PM / Domains: Save OPP table pointer in genpd Date: Wed, 12 Dec 2018 16:27:27 +0530 Message-Id: <6fd6a8a689cd86eaae5a64be958870795e88cdb1.1544611890.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org dev_pm_genpd_set_performance_state() will be required to call dev_pm_opp_xlate_performance_state() going forward to translate from performance state of a sub-domain to performance state of its master. And dev_pm_opp_xlate_performance_state() needs pointers to the OPP tables of both genpd and its master. Lets fetch and save them while the OPP tables are added. Fetching the OPP tables should never fail as we just added the OPP tables and so add a WARN_ON() for such a bug instead of full error paths. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 23 +++++++++++++++++++++-- include/linux/pm_domain.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4a4e39d12354..1e98c637e069 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1896,12 +1896,21 @@ int of_genpd_add_provider_simple(struct device_node *np, ret); goto unlock; } + + /* + * Save table for faster processing while setting performance + * state. + */ + genpd->opp_table = dev_pm_opp_get_opp_table(&genpd->dev); + WARN_ON(!genpd->opp_table); } ret = genpd_add_provider(np, genpd_xlate_simple, genpd); if (ret) { - if (genpd->set_performance_state) + if (genpd->set_performance_state) { + dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); + } goto unlock; } @@ -1954,6 +1963,13 @@ int of_genpd_add_provider_onecell(struct device_node *np, i, ret); goto error; } + + /* + * Save table for faster processing while setting + * performance state. + */ + genpd->opp_table = dev_pm_opp_get_opp_table_indexed(&genpd->dev, i); + WARN_ON(!genpd->opp_table); } genpd->provider = &np->fwnode; @@ -1978,8 +1994,10 @@ int of_genpd_add_provider_onecell(struct device_node *np, genpd->provider = NULL; genpd->has_provider = false; - if (genpd->set_performance_state) + if (genpd->set_performance_state) { + dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); + } } mutex_unlock(&gpd_list_lock); @@ -2013,6 +2031,7 @@ void of_genpd_del_provider(struct device_node *np) if (!gpd->set_performance_state) continue; + dev_pm_opp_put_opp_table(gpd->opp_table); dev_pm_opp_of_remove_table(&gpd->dev); } } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 642036952553..9ad101362aef 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -73,6 +73,7 @@ struct genpd_power_state { struct genpd_lock_ops; struct dev_pm_opp; +struct opp_table; struct generic_pm_domain { struct device dev; @@ -94,6 +95,7 @@ struct generic_pm_domain { unsigned int performance_state; /* Aggregated max performance state */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); + struct opp_table *opp_table; /* OPP table of the genpd */ unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd,