From patchwork Wed Jun 20 17:22:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139377 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050597lji; Wed, 20 Jun 2018 10:22:51 -0700 (PDT) X-Received: by 2002:a2e:21c7:: with SMTP id h68-v6mr14478191lji.108.1529515371376; Wed, 20 Jun 2018 10:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515371; cv=none; d=google.com; s=arc-20160816; b=TsbQOiE8DGdFDj/tteBdUe7WBs1G9MVTIVWolwGPn8uOvUhmypcYXYHiY7Tu3blVL2 U99Kg8PO5+pi939PccB6+/odFRIaVasfPO0QK3taKT0Pvpfj+ImDhqCVoBYCO+Rmo7w9 kh18WY3ODgYWBmuKN+rIetJPCIfm8AJU+VI7yiPnhgufwS758oXRfSQ3x9ZBlM2UGlgs /Odrzm6tBKh8Cjywdo0jL1jItt2aqDriA57mWQVhtOfflynjmSSPwFc+nJyDk+IBNDrD k8sQcPqbaQyMK98HEHUzcPH411tjcBGLgANCYNj8wtCMIRwCLnsPP1a4zFhFHBlvsSaW bE/g== 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:arc-authentication-results; bh=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=WhnOSbbnY0bzTmcnohYcvZ6veC9nYvW1V1ctSC1xEM30W4/Diay1nyjGRVl1IJWT5j UzlYTFBcJAvYak7bUdCk8a+dFZSKXHuulA79d2faDT2IP2RCwex61YlXKEMvh46UFevW CQGSfIippwkp4rJ9IC6yYCtusW74r0rPMpTDaXh2yFfHjC5jlVtonhCXt+6kzhPzMG4O 0YbnHxXb5LZGfjP1BybnUtH7bD637HfQzdP3JEJfvbSbsSvgzLsFSIplmJ5iPINIgbEy JgOKH0GohmaUB5BwwqQNIkSmw1r72A50DMyOHqIt9QUB+fWvAH1mUBVYS7PArREKiMgo nAmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKWyS3hT; 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 i4-v6sor687559lji.77.2018.06.20.10.22.51 for (Google Transport Security); Wed, 20 Jun 2018 10:22:51 -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=UKWyS3hT; 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=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=UKWyS3hTToKxrXbPMXXRta1HjAcVNo2/elOmaTz2VWM9HaXeuoPJUWIzqmC4xJmUT6 F8wFz06W1B92R+249KsTGoHBm3XzhB7povwc3EAj6QJn91acb1MKY89vzo4r02bw64rY umdxH5INr3n8kHjJT5+oq7XPYhk7Du3FT4qek= 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=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=N5qmM/x1JBQ2RDgxlRu2GNvlRBd+UdH9JTGrGZO/Oi21x+OOjH649KDeecjAqJelVG n1HptJNIIyxOfifCFlnjn7zqx5UqcB1EERGh9fJdlJW2F2PIXrtseVtADMwA31vEUgyk hpYmrAfcfYNzQvUkEJIR0an2s4dkAjlwWWLxhCD4hm1oLz8UnI++HIp81wsPgoPspSoM V7MQs9DTRXRQK3W5+fp+gI6pOSAdbxqhhLndYLcUsG9G8PcR+MLvTa9NCQ/z5Ga5O0c6 4r6/wz1ikxr/tI4iHX0Z9xCHj1QmCA9/f9a+G/cfwKWN8XDC+NNm3nkob1w8BKvK9P1K lhGA== X-Gm-Message-State: APt69E19VrGKlqinNPkuobmc99mMKXVG1tCQ6QoO6gshArqx6SMhTGwG S6fEcQS/Y3JhgCoWRGvYGKVHcokN X-Google-Smtp-Source: ADUXVKKpZbnKqi0oKUPGq7T1+MiBtHrteMTDgrbFxl9QBtjQc36fvDAlSgdwGwy5+rWMXBOZHXzUUQ== X-Received: by 2002:a2e:594d:: with SMTP id n74-v6mr15420669ljb.128.1529515371181; Wed, 20 Jun 2018 10:22:51 -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 b2-v6sm514441lji.85.2018.06.20.10.22.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:50 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 09/26] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Wed, 20 Jun 2018 19:22:09 +0200 Message-Id: <20180620172226.15012-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> To allow CPUs being power managed by PM domains, let's deploy support for runtime PM for the CPU's corresponding struct device. More precisely, at the point when the CPU is about to enter an idle state, decrease the runtime PM usage count for its corresponding struct device, via calling pm_runtime_put_sync_suspend(). Then, at the point when the CPU resumes from idle, let's increase the runtime PM usage count, via calling pm_runtime_get_sync(). Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- kernel/cpu_pm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 67b02e138a47..492d4a83dca0 100644 --- a/kernel/cpu_pm.c +++ b/kernel/cpu_pm.c @@ -16,9 +16,11 @@ */ #include +#include #include #include #include +#include #include #include @@ -91,6 +93,7 @@ int cpu_pm_enter(void) { int nr_calls; int ret = 0; + struct device *dev = get_cpu_device(smp_processor_id()); ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); if (ret) @@ -100,6 +103,9 @@ int cpu_pm_enter(void) */ cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL); + if (!ret && dev && dev->pm_domain) + pm_runtime_put_sync_suspend(dev); + return ret; } EXPORT_SYMBOL_GPL(cpu_pm_enter); @@ -118,6 +124,11 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter); */ int cpu_pm_exit(void) { + struct device *dev = get_cpu_device(smp_processor_id()); + + if (dev && dev->pm_domain) + pm_runtime_get_sync(dev); + return cpu_pm_notify(CPU_PM_EXIT, -1, NULL); } EXPORT_SYMBOL_GPL(cpu_pm_exit);