Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3406129imu; Mon, 14 Jan 2019 02:23:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN5iIy1oR4XqaZYMinT7r1x7SB2DdYuGnM+5vPR7zyVnRNPmDDpiIVbPxLdrwnXlFM+YMGuH X-Received: by 2002:a62:5444:: with SMTP id i65mr25400891pfb.193.1547461413136; Mon, 14 Jan 2019 02:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547461413; cv=none; d=google.com; s=arc-20160816; b=X4nXeXfxZN2b0D3En1cUqPnHsfE6xnHWpSyExhi6P1e7iO2Ig36Y0kpAWaBjTJrhLE jTkchQPsfs0qrnMkOKpMc6XBG9sUXelVAWk6uWkza35t0QKVhxIICZRiLAa44faLlUAg qYAcYjD+A5TyYUCIw3+ratIgGUzD5Jm2odWIaQCxrhFOgYkWFgLYEKWjZNwpDX/XAWRD zRkyHy9pzeXN0D3XeqAQaNYJj3SwP01RnnMo8k8QKbIt5feis1NO71giXTbQ8/lrVP/R ILDoO2r7bBJstozFU5aOELylRvNBJxb+FSmVT2QOabilvlWUgW6V3AoUcjTthG4HWyXt tbxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=BQcigTwmLx6wtNJkbza+fNndqo6R5swIJwwOJw4wxh8=; b=Vha6Myy7gSdxKiZTZZHNr1sURp93cMvCZmyP5YiJE9YrHxCWbB6mhg+a12ZlDoE8Jd XuRXK1hHkUGibW0u/U51GhYwR+1viRcGOSnjEqHOwhcxmiiwkuqvbwQ7cqICvVJWsEN3 k2mNGvhpwU3qboPmNW5e53bQ08AYjMfrNp/63cQADJx+BPxJDBy+mTQXT5x52Y+qoODV RO/jDG+mPc/QhoOXrpyeGPaOaE1hOr7b5zGU+p56BcoF7DnrPMjTeqDfJzBJZw54Gwgu 5J0CJ2DxQg05sRvFwgrzTGfg95KUf6tWdf3b1btTEYUDPvOFacGuvRYqkazccGFsoAx5 XBgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KAd62fxQ; 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 p26si16502pli.225.2019.01.14.02.23.17; Mon, 14 Jan 2019 02:23:33 -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=KAd62fxQ; 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 S1726798AbfANKVr (ORCPT + 99 others); Mon, 14 Jan 2019 05:21:47 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43680 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfANKVp (ORCPT ); Mon, 14 Jan 2019 05:21:45 -0500 Received: by mail-wr1-f66.google.com with SMTP id r10so22138460wrs.10 for ; Mon, 14 Jan 2019 02:21:44 -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 :in-reply-to:references; bh=BQcigTwmLx6wtNJkbza+fNndqo6R5swIJwwOJw4wxh8=; b=KAd62fxQUgm/bVgOmDp0tmRdPoWBzID9XmJsxzsC2JFZ9SX6MqJWIDvc4/SeJBQCpW SbqHlojaHVqFxQtORtMCHZM1W70Tw0wKJYdJ8vUud0iVkiHw+86Qtkip9OWXRfy+hFjG /ZuzduBHyvGE512CYtsrGQX3jvjPawx7+9L8U= 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:in-reply-to:references; bh=BQcigTwmLx6wtNJkbza+fNndqo6R5swIJwwOJw4wxh8=; b=X7WTKwBRM/eN2LojnT1mA59pV1lXCNWAQanTT3Uz6eLRloUBAjorhhsVe5Wy9F3rLi Fljf4Cmatwwgn3dQVlKQEyYts+LWU5da4pMCp0TP+Fht+Nzwvaz6y0T0TbBZCzFTxgHJ kaeahApzZSgFbd62gb1H/4E6nb03GE/FD6PGk0ck6os6CGXagyix4VikZ1j4Zksw4zjw iaJUUmx25vOcwXQc/ypSjbIwmOhXw+kmSdc9uGmrA1mbvmOM43fiGI56IByDz74o5Enn hInP89x5vzedAQnXHKq3LFbOsOjev63XEy+Dt4mDN0dAqtwkjzpOOpOfRBiVgA4dfDOc PjRw== X-Gm-Message-State: AJcUukfhnAMVFsZZSoctrWIe25UCZ5y7E2ZFRIA87aQjaigx1W3CZNyk DBM4el/Uyb2MRbQ1q6kfeYOTaRj52yU= X-Received: by 2002:adf:97d1:: with SMTP id t17mr23797843wrb.283.1547461303153; Mon, 14 Jan 2019 02:21:43 -0800 (PST) Received: from localhost ([49.248.81.155]) by smtp.gmail.com with ESMTPSA id f130sm26226842wme.41.2019.01.14.02.21.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 02:21:42 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, viresh.kumar@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, tdas@codeaurora.org, swboyd@chromium.org, dianders@chromium.org, mka@chromium.org, "Rafael J. Wysocki" , linux-pm@vger.kernel.org (open list:CPU FREQUENCY DRIVERS) Subject: [PATCH v2 4/9] cpufreq: Add a flag to auto-register a cooling device Date: Mon, 14 Jan 2019 15:51:06 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All cpufreq drivers do similar things to register as a cooling device. Provide a cpufreq driver flag so drivers can just ask the cpufreq core to register the cooling device on their behalf. This allows us to get rid of duplicated code in the drivers. Suggested-by: Stephen Boyd Suggested-by: Viresh Kumar Signed-off-by: Amit Kucheria --- drivers/cpufreq/cpufreq.c | 13 +++++++++++++ include/linux/cpufreq.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 6f23ebb395f1..7faebfc61e60 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -30,6 +30,7 @@ #include #include #include +#include static LIST_HEAD(cpufreq_policy_list); @@ -1318,6 +1319,12 @@ static int cpufreq_online(unsigned int cpu) if (cpufreq_driver->ready) cpufreq_driver->ready(policy); + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { + struct thermal_cooling_device **cdev = &policy->cooldev; + + *cdev = of_cpufreq_cooling_register(policy); + } + pr_debug("initialization complete\n"); return 0; @@ -1411,6 +1418,12 @@ static int cpufreq_offline(unsigned int cpu) if (has_target()) cpufreq_exit_governor(policy); + if (cpufreq_driver->flags & CPUFREQ_AUTO_REGISTER_COOLING_DEV) { + struct thermal_cooling_device **cdev = &policy->cooldev; + + cpufreq_cooling_unregister(*cdev); + } + /* * Perform the ->exit() even during light-weight tear-down, * since this is a core component, and is essential for the diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9fbc1d996967..0c51d5ce7350 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -388,6 +388,12 @@ struct cpufreq_driver { */ #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING (1 << 6) +/* + * Set by drivers that want the core to automatically register the cpufreq + * driver as a thermal cooling device + */ +#define CPUFREQ_AUTO_REGISTER_COOLING_DEV (1 << 7) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); -- 2.17.1