From patchwork Tue Sep 29 13:12:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 54225 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 30B3B22B1E for ; Tue, 29 Sep 2015 13:13:02 +0000 (UTC) Received: by labnm6 with SMTP id nm6sf3908258lab.1 for ; Tue, 29 Sep 2015 06:13:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=s1PArni6PDYri0VWcoOoWdaZ/vuZDKasvCli4uVZJDQ=; b=ORP4BB3eRsi9H2vKuhCCC7zSPBPg8rnhDYTQnqkN9tdbmYFTv1ZkS4ypU4JyU7DMnj /2L+8/JI/lqjXrsngQs6TV3WlmGS+3ttZiKkgJDi2O+RyQaK7As0Rd5mYpJXNkf6ECJg DVajv/H6fYybVQDB17P3Yfm5ReQLPYO93J3GLQcTlYvZaMIQIct4FAmTziIe8cYNFWOC ytxU51PUR/4L/S8rS4akZUOFz6lHShcz6uS00I5W6UuJZL8uIPhAGZrs1czEBWcssuBe qKa0yuPCpgca94+n2TD7CTegdSyy/Y5dB/YOkq8HorqFKA5QGE9sT09EtF5ykB515z7V 4qVw== X-Gm-Message-State: ALoCoQkki4oloy80vDPs/haWOOqh+R470YABDIJbAxJcw9wrqZTVtW8GLacnpVSpBOjC3B9nqgy+ X-Received: by 10.112.145.3 with SMTP id sq3mr4323424lbb.7.1443532380659; Tue, 29 Sep 2015 06:13:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.208.78 with SMTP id h75ls388889lfg.83.gmail; Tue, 29 Sep 2015 06:13:00 -0700 (PDT) X-Received: by 10.112.32.72 with SMTP id g8mr7057959lbi.22.1443532380530; Tue, 29 Sep 2015 06:13:00 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id pq6si10814903lbb.61.2015.09.29.06.13.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 06:13:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laclj5 with SMTP id lj5so7828246lac.3 for ; Tue, 29 Sep 2015 06:13:00 -0700 (PDT) X-Received: by 10.112.199.70 with SMTP id ji6mr7335073lbc.73.1443532380363; Tue, 29 Sep 2015 06:13:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2135582lbq; Tue, 29 Sep 2015 06:12:59 -0700 (PDT) X-Received: by 10.112.25.4 with SMTP id y4mr7306561lbf.113.1443532379782; Tue, 29 Sep 2015 06:12:59 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id ew1si10808320lbc.98.2015.09.29.06.12.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 06:12:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by laer8 with SMTP id r8so7860718lae.2 for ; Tue, 29 Sep 2015 06:12:59 -0700 (PDT) X-Received: by 10.152.7.101 with SMTP id i5mr1279651laa.58.1443532379475; Tue, 29 Sep 2015 06:12:59 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by smtp.gmail.com with ESMTPSA id q137sm2798254lfd.36.2015.09.29.06.12.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2015 06:12:58 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Geert Uytterhoeven , Lina Iyer , Krzysztof Kozlowski Subject: [PATCH] PM / Domains: Remove in_progress counter from struct generic_pm_domain Date: Tue, 29 Sep 2015 15:12:37 +0200 Message-Id: <1443532357-3157-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Commit ba2bbfbf6307 ("PM / Domains: Remove intermediate states..") changed the power off sequence (pm_genpd_poweroff()), which from locking point of view means the genpd mutex is held throughout the sequence. The above change means the in_progress counter can't be updated while pm_genpd_poweroff() is executing, which allows us to remove the counter. Instead we inform pm_genpd_poweroff() via a bool parameter, to indicate whether we call it from the scheduled work or from the ->runtime_suspend() callback, since that all that matters. Signed-off-by: Ulf Hansson Reviewed-by: Lina Iyer --- drivers/base/power/domain.c | 12 +++++------- include/linux/pm_domain.h | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index cf4950d..c785f2e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -315,11 +315,12 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb, /** * pm_genpd_poweroff - Remove power from a given PM domain. * @genpd: PM domain to power down. + * @is_async: PM domain is powered down from a scheduled work * * If all of the @genpd's devices have been suspended and all of its subdomains * have been powered down, remove power from @genpd. */ -static int pm_genpd_poweroff(struct generic_pm_domain *genpd) +static int pm_genpd_poweroff(struct generic_pm_domain *genpd, bool is_async) { struct pm_domain_data *pdd; struct gpd_link *link; @@ -351,7 +352,7 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd) not_suspended++; } - if (not_suspended > genpd->in_progress) + if (not_suspended > 1 || (not_suspended == 1 && is_async)) return -EBUSY; if (genpd->gov && genpd->gov->power_down_ok) { @@ -399,7 +400,7 @@ static void genpd_power_off_work_fn(struct work_struct *work) genpd = container_of(work, struct generic_pm_domain, power_off_work); mutex_lock(&genpd->lock); - pm_genpd_poweroff(genpd); + pm_genpd_poweroff(genpd, true); mutex_unlock(&genpd->lock); } @@ -445,9 +446,7 @@ static int pm_genpd_runtime_suspend(struct device *dev) return 0; mutex_lock(&genpd->lock); - genpd->in_progress++; - pm_genpd_poweroff(genpd); - genpd->in_progress--; + pm_genpd_poweroff(genpd, false); mutex_unlock(&genpd->lock); return 0; @@ -1462,7 +1461,6 @@ void pm_genpd_init(struct generic_pm_domain *genpd, mutex_init(&genpd->lock); genpd->gov = gov; INIT_WORK(&genpd->power_off_work, genpd_power_off_work_fn); - genpd->in_progress = 0; atomic_set(&genpd->sd_count, 0); genpd->status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE; genpd->device_count = 0; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 384b1d1..0eaa730 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -47,7 +47,6 @@ struct generic_pm_domain { struct dev_power_governor *gov; struct work_struct power_off_work; const char *name; - unsigned int in_progress; /* Number of devices being suspended now */ atomic_t sd_count; /* Number of subdomains with power "on" */ enum gpd_status status; /* Current state of the domain */ unsigned int device_count; /* Number of devices */