From patchwork Sun Mar 14 11:13:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 400087 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2613053jai; Sun, 14 Mar 2021 04:14:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYamAQT4O/fHRnwCObw3NWtGPEpArx6TkyQPnf5UeFWx8D3L7nEl3zbRiHlkVMwSnzj29i X-Received: by 2002:a05:6402:1517:: with SMTP id f23mr24848138edw.272.1615720488066; Sun, 14 Mar 2021 04:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615720488; cv=none; d=google.com; s=arc-20160816; b=ytV1Rn8gV9WPCArQ7EaUqWCDSLoS8/H8pIGoSluk/lgpC8Y6LmvccKhWIQlxT4ST8b cOya45f0IGnwXePkC0xh/UOJsE4BZiz5el+vtJclSTaX1JP8snulEGJBwTXnrlo0AtIR htFU+F2r5GYuRMwOhNhiXpG2ZSg1RGdYBw9O/tj2PnnsH0fJE8ocx6vnmPQcSh5d5Kwq fp6WVBe9LPTeMS+/GXWGIWpKDG/8Mp9H64kwui8v4W08+z7vDSERsOMY3OkL2rgwCHQa 0WklzhQ8mPEduGmFoeYgYr5VhcVYE7YgjEPRIVDpGg99Q/8NEPxxHYVzBdlO+60dtne6 gP6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=s7fCt8jAahXLsklhkFc/v9K2fCeNdzwdfE44cqbig58=; b=LEusWzIGEwx7KxMdP0OmYSNWttgaRCX7efqwHwANEZjI7oEK81H28e9HEGrcndMsX6 6wN7XV80LjpCLhz2zijr12lQLj6tu8AxeOd4pkeiLMT/LG3Xs9RTmlaYJ9OZo5ESqClc i/ynXyOZ63apvDvy+WCU9NYb8Iw43A+JcVgxmqzqGLiAG/o2iRJg3L75uZ/jUE27FliV Va0muNrbEOHhrBJvglkFMTufG2nWhpipcADsDTMBReDJHVUbnUhsBIemJf6MG0raWIW+ Ea1xBbWxFFNJHeK2tFW/mQgC8smrUkauFkn1BOplt7nBZSV094iStkFmypnG/WprkJb6 A3cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K7VrwnkR; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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. [23.128.96.18]) by mx.google.com with ESMTP id z22si8231744edc.427.2021.03.14.04.14.47; Sun, 14 Mar 2021 04:14:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K7VrwnkR; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S235216AbhCNLOP (ORCPT + 7 others); Sun, 14 Mar 2021 07:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235212AbhCNLN6 (ORCPT ); Sun, 14 Mar 2021 07:13:58 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2717C061762 for ; Sun, 14 Mar 2021 04:13:57 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo17727239wmq.4 for ; Sun, 14 Mar 2021 04:13:57 -0700 (PDT) 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=s7fCt8jAahXLsklhkFc/v9K2fCeNdzwdfE44cqbig58=; b=K7VrwnkRfLrUeSeIcYIRCBIcLacD2X4jICNHmsyBy1+d293KQskwN7hpsHzRLNYl9r zGPFSFcHdWBnRijlEVADWVuQg24UdnKyVQf9s4dtEeqVguRQAVv/pShMJI2HEt44r5Fq 9TmhtrXGa9LGf7cUSpmWrWRNamoOLWva3vyg+PGLYNOKoiUQuD8P5R1cYAvEBbougiDj Xc5oVCJSzscgmTQE+zQZxkPE7vBhPtb+Nq7tCbs7l50qlFjbaSZmVdjnZm5v9FVhESeH h4DosGPfdepRQp5f+hdUBXedAx5gHbs1ejZ4ccqCPWBGrDp1G1OaKmlDfQxH1doHCOz8 uSpw== 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=s7fCt8jAahXLsklhkFc/v9K2fCeNdzwdfE44cqbig58=; b=XEwxOS2u15Tyx1Q45Jf6CNiDWesghBpqmde+9kNQeK1mSCFiXhN8rVBmkAUW7EopIB BrWN9tv4SF8KosvMl+JUXRR3CO61VlyYED9ihKpJsdUNx2vx1vMB2aSDXFWoCGHhQghB t85YsH5YqXifk1ZUBViPVrGZoIc8ilNThVNpOdHPwejPUGPGGaXbrHXBa8/z1lCO9mEW 4yCQ4S8+T8YojbEchAnO6ShsrZ8sgfMtDFqFUZaPAjYrlwsWeZ2wMRGlZfgABi5kjkgY wTm+EBjMgkpu4yKtWyvrgIT54BTFa7sB53oqHJ9PVM12KPsZ3FSSjp+vfYKVSMWOpnEg b7VA== X-Gm-Message-State: AOAM532eS8eRuPyl8O46pwboj6lpht75oce+DanMEwfDOFghGYWHfoTK IlfuxW/nGS1Uso2G9fy0+8FO3g== X-Received: by 2002:a1c:66c4:: with SMTP id a187mr21369695wmc.164.1615720435569; Sun, 14 Mar 2021 04:13:55 -0700 (PDT) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id i8sm16828330wry.90.2021.03.14.04.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 04:13:55 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rui.zhang@intel.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Viresh Kumar , Amit Daniel Kachhap , Javi Merino , Amit Kucheria Subject: [PATCH v3 2/5] thermal/drivers/cpufreq_cooling: Use device name instead of auto-numbering Date: Sun, 14 Mar 2021 12:13:30 +0100 Message-Id: <20210314111333.16551-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210314111333.16551-1-daniel.lezcano@linaro.org> References: <20210314111333.16551-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the naming of a cooling device is just a cooling technique followed by a number. When there are multiple cooling devices using the same technique, it is impossible to clearly identify the related device as this one is just a number. For instance: thermal-cpufreq-0 thermal-cpufreq-1 etc ... The 'thermal' prefix is redundant with the subsystem namespace. This patch removes the 'thermal' prefix and changes the number by the device name. So the naming above becomes: cpufreq-cpu0 cpufreq-cpu4 etc ... Signed-off-by: Daniel Lezcano Acked-by: Viresh Kumar Reviewed-by: Lukasz Luba --- V2: - Use kasprintf() instead of fixed array length on the stack - Fixed typo in the log - Removed idr.h inclusion --- drivers/thermal/cpufreq_cooling.c | 34 +++++++++++-------------------- 1 file changed, 12 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index 10af3341e5ea..3f5f1dce1320 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -13,10 +13,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -50,8 +50,6 @@ struct time_in_idle { /** * struct cpufreq_cooling_device - data for cooling device with cpufreq - * @id: unique integer value corresponding to each cpufreq_cooling_device - * registered. * @last_load: load measured by the latest call to cpufreq_get_requested_power() * @cpufreq_state: integer value representing the current state of cpufreq * cooling devices. @@ -69,7 +67,6 @@ struct time_in_idle { * cpufreq_cooling_device. */ struct cpufreq_cooling_device { - int id; u32 last_load; unsigned int cpufreq_state; unsigned int max_level; @@ -82,7 +79,6 @@ struct cpufreq_cooling_device { struct freq_qos_request qos_req; }; -static DEFINE_IDA(cpufreq_ida); static DEFINE_MUTEX(cooling_list_lock); static LIST_HEAD(cpufreq_cdev_list); @@ -528,11 +524,11 @@ __cpufreq_cooling_register(struct device_node *np, { struct thermal_cooling_device *cdev; struct cpufreq_cooling_device *cpufreq_cdev; - char dev_name[THERMAL_NAME_LENGTH]; unsigned int i; struct device *dev; int ret; struct thermal_cooling_device_ops *cooling_ops; + char *name; dev = get_cpu_device(policy->cpu); if (unlikely(!dev)) { @@ -567,16 +563,6 @@ __cpufreq_cooling_register(struct device_node *np, /* max_level is an index, not a counter */ cpufreq_cdev->max_level = i - 1; - ret = ida_simple_get(&cpufreq_ida, 0, 0, GFP_KERNEL); - if (ret < 0) { - cdev = ERR_PTR(ret); - goto free_idle_time; - } - cpufreq_cdev->id = ret; - - snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", - cpufreq_cdev->id); - cooling_ops = &cpufreq_cooling_ops; #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR @@ -591,7 +577,7 @@ __cpufreq_cooling_register(struct device_node *np, pr_err("%s: unsorted frequency tables are not supported\n", __func__); cdev = ERR_PTR(-EINVAL); - goto remove_ida; + goto free_idle_time; } ret = freq_qos_add_request(&policy->constraints, @@ -601,11 +587,18 @@ __cpufreq_cooling_register(struct device_node *np, pr_err("%s: Failed to add freq constraint (%d)\n", __func__, ret); cdev = ERR_PTR(ret); - goto remove_ida; + goto free_idle_time; } - cdev = thermal_of_cooling_device_register(np, dev_name, cpufreq_cdev, + cdev = ERR_PTR(-ENOMEM); + name = kasprintf(GFP_KERNEL, "cpufreq-%s", dev_name(dev)); + if (!name) + goto remove_qos_req; + + cdev = thermal_of_cooling_device_register(np, name, cpufreq_cdev, cooling_ops); + kfree(name); + if (IS_ERR(cdev)) goto remove_qos_req; @@ -617,8 +610,6 @@ __cpufreq_cooling_register(struct device_node *np, remove_qos_req: freq_qos_remove_request(&cpufreq_cdev->qos_req); -remove_ida: - ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id); free_idle_time: free_idle_time(cpufreq_cdev); free_cdev: @@ -712,7 +703,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) thermal_cooling_device_unregister(cdev); freq_qos_remove_request(&cpufreq_cdev->qos_req); - ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id); free_idle_time(cpufreq_cdev); kfree(cpufreq_cdev); }