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);