From patchwork Mon Feb 11 08:41:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 157978 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2346339jaa; Mon, 11 Feb 2019 00:41:54 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia4k91zbhmGux5ZIL9TbqFa+V9IOXQPGxozDmP0vzxtiggW0DpWkA5Xp26RNcz31mYDFqu4 X-Received: by 2002:a65:6105:: with SMTP id z5mr28284031pgu.26.1549874514090; Mon, 11 Feb 2019 00:41:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549874514; cv=none; d=google.com; s=arc-20160816; b=Sg59sKFYJ1TkDw245Y04Mlac2dT0DdEbV/+wLRAOkZhNcAt7Lcuq2REVS1OSnaSW+x QXBjwix5LXL0Ir3MEyuSVfKYfNo8zlI5I4bD6ZSvEEqYYpGdjz/isvKGakUzPiKyKllQ LIjfdWxeo/0vpnGzrgayCtM2qhjvazuX10291rnbbZrWGF0Jiw165Cugc+aCF5Z3lQDi 6JRVkcx/sHNB7rrcdb80q/nQ4emC5gokPSp7kQEFQ/xlZE680AnEGLu9XM6dYS7D50nd 4pgG8R7jn5z2bZ/1Ws8OLyCznp6jDPweadnT9xv5xpE41rBSh5qla0/n13m4tqk411gA XUXA== 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=f2xUPJ0VeEmUdzCbdA+JjT7JZvX3sMGSKBadMB0TcQ4=; b=EGzqPo/PZbUYSPy3fpnLKYoSSa/52jvuFvT5k76pAvAGq4LL97g/eSk3Mk++qqrbQo EGpnYmSPRoAfXGDjtXNh5Zzb/xEOjhLtGqrFj3yaEYc+edPzTmvI7DJvAjNMsVUYvQnO chhlmWzNQFAQANxfXKCnjYtlDWSAEYeqJbnBWsT+bFJt5ScZxI5XOUGb/bZ3gS9WFQtE cHXBoRKDYwQ/M0ZgA55VepJJ9vaH4zqvVbtXN90JE9Imhk2dRBD5TUznwpuVlx7gVCxj B4nU/EmZgh9Y08avRyLlLz1l78GdjGWsvjT7TC2/49pC7W9m9VF6bF7C/9yUmDOYQJqD 4X3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OqhiGIbX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y4si7583024pgv.520.2019.02.11.00.41.53; Mon, 11 Feb 2019 00:41:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=OqhiGIbX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727150AbfBKIlw (ORCPT + 31 others); Mon, 11 Feb 2019 03:41:52 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46300 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727092AbfBKIlu (ORCPT ); Mon, 11 Feb 2019 03:41:50 -0500 Received: by mail-pf1-f194.google.com with SMTP id g6so1017535pfh.13 for ; Mon, 11 Feb 2019 00:41:50 -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=f2xUPJ0VeEmUdzCbdA+JjT7JZvX3sMGSKBadMB0TcQ4=; b=OqhiGIbXtzXUVI1C8avuY43tRwF3EkVCzY5e8qsW3p7NCUzasvuP1LktlvReVFTRpx aeulSPvVltElImwNXVUGO8kmYv4UnEXPD3x2Dt8APpdYQOWIUnjyAno2yl5Hue7o1+8C ygWbSPu+oVq015orwnRXaeuSdiMitSarbmy+Awgd4qzMnzA6cy7HYbkNNgeRqk2LpItS 0Tq1ZOg8XxGP3F442j/fiuua/Ygsq/3Q1tpj+qbqKPnxMT902PWqJZR5imWcrdsnOJEn ucVNHl3qajdtkuzSx2jBJ/zqrjvHYRPN0SosL5SWB24Vm6/GdB6QvxIRcBOUZSpxMEWX O+0A== 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=f2xUPJ0VeEmUdzCbdA+JjT7JZvX3sMGSKBadMB0TcQ4=; b=DMF1XcgeZnPZzTB89lfXx4+QYqfp8fjkCBA61OY8hx6ZBV6J7bO7TOnfReBwn2pAUt zPxBsSIjUCYUDRdinr66IbA0qx3Ty5Wr0G9y2/CsQpH7WxflzuU6beux88VvARPO6n4w YgrIxLfZ9j6Z0vzAqRBXxHYNA/jjbnxupohsx+SjEhLkWseuwrNcAuleM1UM7tcYBHcU Uk1vMFgpiE9VZyVWIpA2113ZN2/M9YAbjQJl/KJeMULSzJbg596G1fJQkZQoaoBTccVv k09oDSC/9634hUFhZw1Sh0hQlCq5rOSABXgrt1EBZLaPHCIENutfIGgWayHAPtXADtTO lERA== X-Gm-Message-State: AHQUAuZMqFr2sW1JeIeWtEZTIfjVURKrOqino5pFbsSG0LBDV/oP2ejl jayZdhDedbc5yVhTDpkqaS7fpQ== X-Received: by 2002:a65:5c4b:: with SMTP id v11mr17775297pgr.333.1549874509763; Mon, 11 Feb 2019 00:41:49 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id n10sm14833460pfj.14.2019.02.11.00.41.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 00:41:49 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Sudeep Holla , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] cpufreq: Allow light-weight tear down on CPU offline operation Date: Mon, 11 Feb 2019 14:11:35 +0530 Message-Id: <03ac36a174f6c28be0b3af9d2db8631d56695f1d.1549874368.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce00 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpufreq core doesn't remove the cpufreq policy anymore on CPU offline operation, rather that happens when the CPU device gets unregistered from the kernel. This allows faster recovery when the CPU comes back online. This is also very useful during system wide suspend/resume where we offline all non-boot CPUs during suspend and then bring them back on resume. This commit takes the same idea a step ahead to allow drivers to do light weight tear-down during CPU offline operation. A new callback is introduced, light_weight_exit(), which gets called when all the CPUs of a policy are removed/offlined and the existing exit() callback gets called when the policy gets freed. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 16 +++++++++++----- include/linux/cpufreq.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) -- 2.20.1.321.g9e740568ce00 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 96a69c67a545..215a8bfc78bb 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1421,11 +1421,12 @@ static int cpufreq_offline(unsigned int cpu) cpufreq_exit_governor(policy); /* - * Perform the ->exit() even during light-weight tear-down, - * since this is a core component, and is essential for the - * subsequent light-weight ->init() to succeed. + * Perform the ->light_weight_exit() during light-weight tear-down, as + * that allows fast recovery when the CPU comes back. */ - if (cpufreq_driver->exit) { + if (cpufreq_driver->light_weight_exit) { + cpufreq_driver->light_weight_exit(policy); + } else if (cpufreq_driver->exit) { cpufreq_driver->exit(policy); policy->freq_table = NULL; } @@ -1454,8 +1455,13 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) cpumask_clear_cpu(cpu, policy->real_cpus); remove_cpu_dev_symlink(policy, dev); - if (cpumask_empty(policy->real_cpus)) + if (cpumask_empty(policy->real_cpus)) { + /* We did light-weight exit earlier, do full tear down now */ + if (cpufreq_driver->light_weight_exit) + cpufreq_driver->exit(policy); + cpufreq_policy_free(policy); + } } /** diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9db074ecbbd7..36ce31516041 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -325,6 +325,7 @@ struct cpufreq_driver { /* optional */ int (*bios_limit)(int cpu, unsigned int *limit); + int (*light_weight_exit)(struct cpufreq_policy *policy); int (*exit)(struct cpufreq_policy *policy); void (*stop_cpu)(struct cpufreq_policy *policy); int (*suspend)(struct cpufreq_policy *policy); From patchwork Mon Feb 11 08:41:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 157979 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2346390jaa; Mon, 11 Feb 2019 00:41:59 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia/XkQUodoie+9kQ2HJDt6aOTGrhSv1pU2beIx5ey8AsqvRV0DSCJZH+HIQo57fnKr14d7m X-Received: by 2002:a63:4342:: with SMTP id q63mr32852427pga.63.1549874519033; Mon, 11 Feb 2019 00:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549874519; cv=none; d=google.com; s=arc-20160816; b=ukshAZz9F5iTak8i9WFtadZj+pfo0FYPTWbc6/wZsoNTBL+RiBrZpIxq1+5j3WhLuH 2JwfPizPppmiVnzbJItdyNrz3+v7TxxWHuHB0EthutylD287+2F2MlUhzJSJZSvwL+wD dbZaxH3xLUCzi7703u5AIvyWcmr2U44Fb7VcbsLQIZRv0gX9f0b2r5mbNkLUaLhIF0Dh iwCG9XV1bCtw2U1BOZj7id7ClJXzYXSXMqqND51rwrhFbIsrZm0pZeBfHysj/utHxsE/ UEaP4F2CiHa0BniChFG1udvksUT+arEwWjFPV47XNpwjpXz330+pT+d7MUmraZDwncyk HzLw== 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=y3+EyDegbUZpN+/R1MgR55TgRo8j8NBTJTSndSQPWD0=; b=1LQVKzw6pFu5vJISFpj0FKRl7o/ewq/sM66MkL0rDlVoDYkPJyGbBH/WdOz9toPyb+ gPTHvnNb8iC3G7Gpx2veidWzQ49ZGfRZvCfrk4dXSB4x46AluZg6sjYTjap5KGcL18c3 XuhHmDPPS87XA53Y5f5bMEb+e8Khi7f6Skb+JNU+jORIaR24yNFWCjIgXS8gZtKrBnB8 3veoUPHkxYqGI99eU5VMv8McyAdrDmJnYJ3DrfjuWFbCOjLgcsILEENqha2YfZq9PXF+ OSl0HyT18Asl5NqlJC4+8ooA60/Pc/ztVaAveQzGUct3xMf3D4HMYSPH88KcMtMbkU+N 6R+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nQPLUdQ8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 o12si8722220pgv.252.2019.02.11.00.41.58; Mon, 11 Feb 2019 00:41:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=nQPLUdQ8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727194AbfBKIl5 (ORCPT + 31 others); Mon, 11 Feb 2019 03:41:57 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39418 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727153AbfBKIlx (ORCPT ); Mon, 11 Feb 2019 03:41:53 -0500 Received: by mail-pl1-f194.google.com with SMTP id 101so4985780pld.6 for ; Mon, 11 Feb 2019 00:41:52 -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=y3+EyDegbUZpN+/R1MgR55TgRo8j8NBTJTSndSQPWD0=; b=nQPLUdQ88SR8I618ybEF8PhcK/8OnkEyxsMH/TdZxs7qW3iSyHn7lUcaTr8GQ07QWH iP8FXv5dSYeLNQ0lCSXM/MvC73lxeaWP0nVpsNe3lQNpbsuhWzrSMT7pBof4smocsBTv 0EFbGSxTAYh11BQc9kFDi2RgQXbMy4FK2V1k7PvPEiFEh9PV9h55in5F+Ec/wZdcarzQ Dui1JyeqHyKrv6xU5PtT/ztO0z6rR6lLmaqtwCuVhLjcuih/x62+TvrlRHYvUQX9umqp nIdG9qsZC5arJT66/GjlQcog2UhnNUaFYYKg3f6EU+PnezQFBUdn23SvQVqRdUHOxYt0 fcSw== 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=y3+EyDegbUZpN+/R1MgR55TgRo8j8NBTJTSndSQPWD0=; b=Fen8zVYvkETPPPFfGrfcAxsuL/PpIpFHUMFlAtU8UtZ+bI4SScbvrX6xknsktRbKqD kfD6mk8AVk3qfGdXigfCw/cSjr1fOw+GbafbPxim4ggajOxAlPceU1lSr1XshleBWPP/ Ofh21ExRV9Qq0/gNBSQypPHNA0f40zJUPzqlvaTRfupRthBRoR5ztRK4mEl7hE5SoPPH x5rcpNPR60BsERHTNh3sznDdTgHAOAnvagP1dczx7XhIF35mtuNSHoZvGHG8WcUq3hN3 1yh4BKE4U4NQXvRZ1wXZmtDzJcttv3USzbzCMJGz6GWh9UVmJ0zSQH1u2fE8q6TXD/4x LneQ== X-Gm-Message-State: AHQUAuZVkvNH6r0pjxL+fukkA1buIDe+a8/eOwrCWCfSo2hRDiOYtaX2 30InHYQgp3AdJGh7Q6vsbNA1xw== X-Received: by 2002:a17:902:a411:: with SMTP id p17mr36083302plq.292.1549874512588; Mon, 11 Feb 2019 00:41:52 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id m68sm3134173pfj.89.2019.02.11.00.41.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 00:41:51 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Sudeep Holla , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] cpufreq: dt: Implement light_weight_exit() callback Date: Mon, 11 Feb 2019 14:11:36 +0530 Message-Id: <742f4f42ae944a3ad13216f96fb0d03d394c395e.1549874368.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce00 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the light-weight tear down helper to reduce the amount of work to do on CPU offline/online operation. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq-dt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.20.1.321.g9e740568ce00 diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 7ba392911cd0..69309a8121f0 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -160,6 +160,15 @@ static int cpufreq_init(struct cpufreq_policy *policy) const char *name; int ret; + /* + * We did light-weight shutdown earlier, nothing else to initialize here + * apart from policy->cpus. + */ + if (policy->driver_data) { + cpumask_copy(policy->cpus, policy->related_cpus); + return 0; + } + cpu_dev = get_cpu_device(policy->cpu); if (!cpu_dev) { pr_err("failed to get cpu%d device\n", policy->cpu); @@ -295,6 +304,15 @@ static int cpufreq_init(struct cpufreq_policy *policy) return ret; } +static int cpufreq_light_weight_exit(struct cpufreq_policy *policy) +{ + /* + * Preserve policy->driver_data and don't free resources on light-weight + * tear down. + */ + return 0; +} + static int cpufreq_exit(struct cpufreq_policy *policy) { struct private_data *priv = policy->driver_data; @@ -319,6 +337,7 @@ static struct cpufreq_driver dt_cpufreq_driver = { .get = cpufreq_generic_get, .init = cpufreq_init, .exit = cpufreq_exit, + .light_weight_exit = cpufreq_light_weight_exit, .name = "cpufreq-dt", .attr = cpufreq_dt_attr, .suspend = cpufreq_generic_suspend,