From patchwork Mon Jan 14 10:21:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 155426 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3489408jaa; Mon, 14 Jan 2019 02:21:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN5yvSpE19wcLipKXSbNeZ7rWv37zQE9D8HVB25swDYZCSOmu2t5hVpWBo24EcUPxMwfTPt8 X-Received: by 2002:a62:6b8a:: with SMTP id g132mr24856106pfc.201.1547461309317; Mon, 14 Jan 2019 02:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547461309; cv=none; d=google.com; s=arc-20160816; b=mSWbShDf8dMQnm7y55qZ3lir0Nj3YjdyuGcgtvlT5coNcKWSAd1JE+0WMspYb/FKdq gYs5R1ljyhn0doSe6sdC0QOXD3miyYvpciBqoPM1m+UfDHKGRfP4Hi7Yn0UYhGespIa+ I0+DHP0JwSApJBpflc6IWGVSBYw1d2NeuFrA8FY0jfazdaI0hH8cv+XzQo5kE/LnmT7o XJQtPoQrLA/DRN41Ov0D1i4RgbKdDwACbbzq5N4wSAjRx61b58kejNR2HmzUeIcPD2yV hkUjT2Sx2DPH+U81mgsZPfG4d/xIyn/s4GXLiC8SSPmwm/y72s7VIR//Iz3TbAUr5IJ9 ItNg== 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 191si29906pgf.41.2019.01.14.02.21.49; Mon, 14 Jan 2019 02:21:49 -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 S1726802AbfANKVs (ORCPT + 31 others); Mon, 14 Jan 2019 05:21:48 -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(+) -- 2.17.1 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);