From patchwork Wed Mar 10 11:45:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 396697 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp304098jai; Wed, 10 Mar 2021 03:47:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzs12YQHGQmmpSFIXqk1g9C1Q+43/ylxCd9L26gecC6OrbDhsxJ251YVw7gCofzPbSMdQYT X-Received: by 2002:a17:906:4c56:: with SMTP id d22mr3308729ejw.426.1615376835496; Wed, 10 Mar 2021 03:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615376835; cv=none; d=google.com; s=arc-20160816; b=hfgQ9CgSlf5HnzS4RI60yVh/T5ZLdQt4l7ITuBuochXZv/gWitw92pzYzJhmms0WsK Vhq4QZhk/pj9WFDLSjuRkQ+fseNDOCR6e6C+bPXBGoxnK87lfeMospVjitKWkseGRd4g R93kYNWSkkbsQTpaObs1Ry9U3/MK6uA60QelIZ2aUU2DiKmB29Y92iJBej8VC4W+c9t6 Shr0XWpiE6jKRegEXsuTdP4s/rgzzmi6SxGYdav0Cm8jZ/tIkG6At/PQBOjl5cMXXXhu ryQb9aoYIOvPYZW+/Na/+0e77f60L0uaIVOG+q8mrEu7eDRu7xwf9Z6HoW13UHs5N+3C oZTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=lski913ktSP8z+F8LEUqQKTYxY9cEhVj/daGsVMQLcc=; b=B/mJiFRVTsoMOtBox/VKkeeViKopnceiGc4i0iW/RzNj5GUx3b7vNyTeCIfLe8g36w M2vTVxzwQOZ6PkkluMFCg8zY3ihRpSE6hPeisMXSTKwq0ZK7mrQZRM2rHnOlM2NjHC3e DotMKAp3ldIAyFgQwGvJPikK2YV4wWy42YeK8AFa2F12QbVOLm8K8MKFfC8gh+mAGNNI zXCFhDNNKSD8XFbfLTL7m0QsgEN/yk057UbcsTgndOhpTJz4mU+sXvvNdT0rWKVp6/tr ARByMKAWYusddDpmztDB43GgG4eu2lorjBqYeCqFfubWthi/StVjEfHK5CX0yNnll0aI iRYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DJn2FKek; 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 o13si11755863ejr.741.2021.03.10.03.47.15; Wed, 10 Mar 2021 03:47:15 -0800 (PST) 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=DJn2FKek; 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 S230122AbhCJLqm (ORCPT + 7 others); Wed, 10 Mar 2021 06:46:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbhCJLqX (ORCPT ); Wed, 10 Mar 2021 06:46:23 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEFFEC061760 for ; Wed, 10 Mar 2021 03:46:22 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id u187so6896611wmg.4 for ; Wed, 10 Mar 2021 03:46:22 -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; bh=lski913ktSP8z+F8LEUqQKTYxY9cEhVj/daGsVMQLcc=; b=DJn2FKek4IRBjH/67DixsRaeG489z6IfxHRlZ/37cV7Aw5ODxrQZhVye3Of2PiWRZG WN2bSPgs/hKnC6/xBvb44kJgJLN7/5sQpwC+6ZdQLCp8rAMdhbJnK41DoXdXDDZ3K1AS 8cA2OYNV9Iz/SW7EjMPjYF/wwnmcoqBDgHgiK8RnIxfy+4Qc9Mc6FZw90u2R5Q0FtHKC ju3odNJCgk/3W2fxN6dciBDOJFkxiVczUwEqfmfL7uH8lcp1y94hHDoGGuttHUYZYRtE y5bi+XFbk0sFK5RRmKhS7tZd8GyVjsuxxKgBz0900EP+AQLF+zfmTYfW5P9qO0BvyFM9 iB3Q== 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; bh=lski913ktSP8z+F8LEUqQKTYxY9cEhVj/daGsVMQLcc=; b=i/IDM45A9KCTMRUO2MsD9XjFqVTr8RucbeXPDnD4JIk2o7thlNnlndZG+AhSs6tEP9 KxyZDWP3rIkvsBw0osu3ncR3Rulm+xvwtN92HV72MLcloA6aVeXTJazujFH9NBYO/Gsj WqsEDlS76unNJIOXb74vjtzKR1dT0WJCbIYcfu///OuaBceNrRzWI1jYyrC2BXHgfi/k n/PJFDOZlWbNrzs03PYwNMch+ouCjwsbxKLl4FYJLk/jz+WtSvP2GeED5z9IgeeaFu/P cXbFAeEHP1+BBmZHi3CjV9U4/xYjY1oE6r3qIGcBYG/saMvfEc5vEwRufXqXIiU06oWI GVKQ== X-Gm-Message-State: AOAM533Q3juGBhi7AJ3ZSWt8oFPdMPoIO2x5gkkwEKalxcg4CoC6rgag S0+wh/YyYbDjmfBpYeiGNSzQwA== X-Received: by 2002:a05:600c:290b:: with SMTP id i11mr2995379wmd.129.1615376781251; Wed, 10 Mar 2021 03:46:21 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id h10sm30368165wrp.22.2021.03.10.03.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 03:46:20 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rui.zhang@intel.com Cc: amitk@kernel.org, linux-pm@vger.kernel.org, Amit Daniel Kachhap , Viresh Kumar , Javi Merino , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/3] thermal/drivers/cpufreq_cooling: Use device name instead of auto-numbering Date: Wed, 10 Mar 2021 12:45:58 +0100 Message-Id: <20210310114600.27178-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 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 --- drivers/thermal/cpufreq_cooling.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) -- 2.17.1 Acked-by: Viresh Kumar Reviewed-by: Lukasz Luba diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index 10af3341e5ea..cf0332bbdcd3 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -50,8 +51,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 +68,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 +80,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 +525,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[THERMAL_NAME_LENGTH]; dev = get_cpu_device(policy->cpu); if (unlikely(!dev)) { @@ -567,16 +564,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 +578,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,10 +588,12 @@ __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, + snprintf(name, sizeof(name), "cpufreq-%s", dev_name(dev)); + + cdev = thermal_of_cooling_device_register(np, name, cpufreq_cdev, cooling_ops); if (IS_ERR(cdev)) goto remove_qos_req; @@ -617,8 +606,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 +699,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); } From patchwork Wed Mar 10 11:45:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 396696 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp304094jai; Wed, 10 Mar 2021 03:47:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlk5MkSzWqOsNpwWGJRjMLnMPiRBh8Pkb1zZiJSSnmzZ494Ve40OmnzB6GGPmupzFtjyIW X-Received: by 2002:a50:bb47:: with SMTP id y65mr2794014ede.305.1615376835104; Wed, 10 Mar 2021 03:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615376835; cv=none; d=google.com; s=arc-20160816; b=hk3Ly2Fj7228C1CXxF/mXBK9mjaZU3N97Vfr8lgaSDyCZxsym/tojHTRAT+kWn+bJf ZvBYSPYJyOQz5kdfFMnIkIb4hwX6uMuwcw/NyjLx8dF9oeURlIJh/FHnNSETxdeajAL4 VH0DZQkVnIIAIdlhUqVBwzSkOI8N0Xo1KBJSUMzTBTT/bbr5Nd5Z9l7DE8H0Tpv7vRAM cfDzlFE4FTmw1YfyGKFW4evF4YVIL13LZQpycF65ngx2IsKtxGhqHppex0xutNixfUsM ocHoYPRH98lIks9eQJ1cB55KVhD9JbrDyoCqO46I2IhHIaO4ki4xDlMXwI2KZ0K/jzc9 ch1Q== 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=/GwBIjz9iOP0pxeHT+2leILb24Wf53Rkht4zzhD+XbE=; b=jWtIhgutWDJwrq+OkuQsZdj6jYGKKy10jDKdwlHpl/lGzObyn474EWFiNV56Fskdju mtbDNUmTlhLAwevuHI+T06hmyDMCyA3dIZ3VGuSXZG9dEyjUvQtgOP1Syn4hfE/BHbix gPXJXzlprYQ0GK50nMY9ZrAdoTNUJRX2yzwA3DXWB+qrxypb7mbjdXKWOrCKUnhDcvfW xf59hUVhlAZHB96aXNtdIJn7392s8xCHmUfClobQeXDBh4mu1F30BfgQBd2EyFyoJM1N 3vSI7eI6SJjFInZnMtU7GhKfepSI0FtsFscZpI8by9+GRnO2YRtuyTr1p0VAeCpyt4to EIPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MAzzHWKc; 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 o13si11755863ejr.741.2021.03.10.03.47.14; Wed, 10 Mar 2021 03:47:15 -0800 (PST) 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=MAzzHWKc; 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 S229948AbhCJLqm (ORCPT + 7 others); Wed, 10 Mar 2021 06:46:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbhCJLqY (ORCPT ); Wed, 10 Mar 2021 06:46:24 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC9A2C06174A for ; Wed, 10 Mar 2021 03:46:23 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id i9so6918090wml.0 for ; Wed, 10 Mar 2021 03:46:23 -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; bh=/GwBIjz9iOP0pxeHT+2leILb24Wf53Rkht4zzhD+XbE=; b=MAzzHWKc3AcB9TA+bPnp96grLDeT6sUGggo4ltJGXiBM+hXmVJt5CTsJT9qjvZE/Pi nmNN85mJMa87JZWdxPwX3sZ8qgr9Rxmar6J3R0MNet2PVKRQAfLThadVCc27z4FeYMzk D1RtQ0lL2ALlrSbvWyEwz7sSxXM4xzZdINDN2IoaOgorIyUt/Ra0J0l410565mej6R8q /f48EaIA/1jUgnzsSpcOwJ1pXtncBUkmqBMiZhcG478z/ufGkNc8XQKKdYHDO8F7A0Vg MS2VFLaUKsHjV2Do1BJBEpja9m0IGUWUpxriaG7BwcQqnYwKlfa94KVQAHOpKPsCSpha xBPA== 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=/GwBIjz9iOP0pxeHT+2leILb24Wf53Rkht4zzhD+XbE=; b=WstWNT22iLny3tnle6/tYRtULojxboP3i9KjZ0wA/7HGKzKkH7xRQpPjiy55kP/Pea Y+TW6ZIkxdd6fU2A7qopFo7z2coM/IHFom/NzSNwNZ525UxrAJG/6ChNTJ5DhWMVv3WW EaAHlQVB4D8dR2djiBO+F1j6OgKF/B5Px4oJD0KbjufEXe95jVXAffNr7uL8bQ45pHQe UvVMUYpFcuhODkfnsQkWG5zo7/MdmMFN0Z6CkygK010d5/mnpHgs+xMy9nqx4zlDkecf aI3ZtyraUTZV2+lCJzBlfayzTSuAHLoc9iTHyAAYKPD3BLb8Zp0Tyx+HwYwtzEfh73fI 8l0w== X-Gm-Message-State: AOAM532kMx424WCQ8fyCPGQIzIsI2bRqR5p0vNpnvmxasHnmxGlmKrgP uQt7jUxhGGEEsUEmCgpu2Hl50A== X-Received: by 2002:a1c:66c4:: with SMTP id a187mr2933680wmc.164.1615376782515; Wed, 10 Mar 2021 03:46:22 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id h10sm30368165wrp.22.2021.03.10.03.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 03:46:22 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rui.zhang@intel.com Cc: amitk@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering Date: Wed, 10 Mar 2021 12:45:59 +0100 Message-Id: <20210310114600.27178-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310114600.27178-1-daniel.lezcano@linaro.org> References: <20210310114600.27178-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-devfreq-0 thermal-devfreq-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: devfreq-5000000.gpu devfreq-1d84000.ufshc etc ... Signed-off-by: Daniel Lezcano --- drivers/thermal/devfreq_cooling.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index fed3121ff2a1..62abcffeb422 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -25,11 +25,8 @@ #define HZ_PER_KHZ 1000 #define SCALE_ERROR_MITIGATION 100 -static DEFINE_IDA(devfreq_ida); - /** * struct devfreq_cooling_device - Devfreq cooling device - * @id: unique integer value corresponding to each * devfreq_cooling_device registered. * @cdev: Pointer to associated thermal cooling device. * @devfreq: Pointer to associated devfreq device. @@ -51,7 +48,6 @@ static DEFINE_IDA(devfreq_ida); * @em_pd: Energy Model for the associated Devfreq device */ struct devfreq_cooling_device { - int id; struct thermal_cooling_device *cdev; struct devfreq *devfreq; unsigned long cooling_state; @@ -363,7 +359,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, struct thermal_cooling_device *cdev; struct device *dev = df->dev.parent; struct devfreq_cooling_device *dfc; - char dev_name[THERMAL_NAME_LENGTH]; + char name[THERMAL_NAME_LENGTH]; int err, num_opps; dfc = kzalloc(sizeof(*dfc), GFP_KERNEL); @@ -407,30 +403,22 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, if (err < 0) goto free_table; - err = ida_simple_get(&devfreq_ida, 0, 0, GFP_KERNEL); - if (err < 0) - goto remove_qos_req; - - dfc->id = err; - - snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id); + snprintf(name, sizeof(name), "devfreq-%s", dev_name(dev)); - cdev = thermal_of_cooling_device_register(np, dev_name, dfc, + cdev = thermal_of_cooling_device_register(np, name, dfc, &devfreq_cooling_ops); if (IS_ERR(cdev)) { err = PTR_ERR(cdev); dev_err(dev, "Failed to register devfreq cooling device (%d)\n", err); - goto release_ida; + goto remove_qos_req; } dfc->cdev = cdev; return cdev; -release_ida: - ida_simple_remove(&devfreq_ida, dfc->id); remove_qos_req: dev_pm_qos_remove_request(&dfc->req_max_freq); free_table: @@ -527,7 +515,6 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev) dev = dfc->devfreq->dev.parent; thermal_cooling_device_unregister(dfc->cdev); - ida_simple_remove(&devfreq_ida, dfc->id); dev_pm_qos_remove_request(&dfc->req_max_freq); em_dev_unregister_perf_domain(dev); From patchwork Wed Mar 10 11:46:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 396695 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp304087jai; Wed, 10 Mar 2021 03:47:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLYrhbjTidgNn3grByx+RKbwvtgfYsyQ6nsMESIyYezw8v8CsJJQhQJ0JSOQjJZT2yI6F+ X-Received: by 2002:a17:906:f0c8:: with SMTP id dk8mr3244550ejb.300.1615376834745; Wed, 10 Mar 2021 03:47:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615376834; cv=none; d=google.com; s=arc-20160816; b=e1qn5oYQ6sZtOanjU2Qo/fz/1YFvc8eTQulxapsY6vVn/ug9yTUdo+pf1JhLvi9pNq ezp2nanOMyzFeJiPYClNzfv7xRep7SIN8FHIZ+PMqBGgn9kiDFOzVlv4yedqsO1d4X+i n+LNkrJ+FqW9YWTg0NG50eJPjEEUtTPgKEwxyT65U63pmvmFvttD43VJyw/rl5RHqNtl RrH40Gqb08KYjOqkI/Ajh7SRifsP9D5f2WqRtmrjvkCRmQ5EduF27zeGr5iWZwCt6GJl Erp6yZj9LRjz8Tb5g9mmacb4zojLM1ricN9AfJgblzko+OG9+SPCQ/zOg84WAKbwSLSb L0YA== 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=LvlruMaCLBIyF4bqWN8JBBR1UbyF6IvONx4LBcx3yHE=; b=ehvsCbwca1ACO23rlzV+zI943xQ3p+91uszv6tuaaIVdSTnxBKPeSOckZpg5Cj7E2E JLbpgJLyvJYXtksdEAT+N/Q9Yjt0GQhsJH60hv9EPK5xl00mOaznprk18ctTwWE32r5x Hejlf7LcVsbM95iymIR+aIH5dYFwO8JBpbUWDCeTucmwR4pFgDT29xoYBFjf++R+FlcA HSa3oKldelTM2rLqDPL76cuwN9aoRUh4PYOOV+/LxWjf2oVliBwsRlqWWy0qm/cf2dTY OTQTgxYIb5bpR+HrzR2Uou/VvMM2smTJyNpNabGK3X9M6rJa08SxzwPKepem1VvmTwxw k76A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pNawfMqa; 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 o13si11755863ejr.741.2021.03.10.03.47.14; Wed, 10 Mar 2021 03:47:14 -0800 (PST) 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=pNawfMqa; 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 S231397AbhCJLqn (ORCPT + 7 others); Wed, 10 Mar 2021 06:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbhCJLqZ (ORCPT ); Wed, 10 Mar 2021 06:46:25 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40DCAC06174A for ; Wed, 10 Mar 2021 03:46:25 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id j2so22951611wrx.9 for ; Wed, 10 Mar 2021 03:46:25 -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; bh=LvlruMaCLBIyF4bqWN8JBBR1UbyF6IvONx4LBcx3yHE=; b=pNawfMqaAG/zuHUmVubbWIU6RERPhmUscbJ7tzU6EaRl3Pm3U4PK2ZY/XwvPdAckBb 8dywq6SltsGp7ya34cWvnM1wG9Th5sLJWMDrXia1Z8tgAo+iT7w3KDLwkWVu9e46JQUP i7VKQWAn3pOw/lTdUqNCwwcDUBM0fTbMSt2rDYwwahGBE8nIbh/dwiR7qLox8frshMnQ TpMVNc+79/Qy5Bjh/k71lvk/dMv9+s2GU20gDKueU+ru8VyKZmPbg9zTOIRoenJ4HO0f dXcqPfRU4RRmq7z1HUv3WYGYltjc5f1f6zFV8j5P5lEERSslB/ZtV8e+Qd1JnoXcNOTS hj/w== 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=LvlruMaCLBIyF4bqWN8JBBR1UbyF6IvONx4LBcx3yHE=; b=sn1E5PwTEEyLwjmY8twNmg3rQej0WB1pXNlCa2muWQki5+msTKW0VdAKHFLL+fg0dk /iz+k4BxQGTIf+Mv63LfHWVoYcq1JyDGdBTcki3mmbPE3wSfyczkhIxs24Cp5vWq9A29 5JdeoHJN85S0KZ27IYX+BO1r0YlgB4aTnI+jucDDx3lrsRco0OMvkjxIO1yG6YcMp7pk 4AkMYxYN9h0BBl6D5VIUheFPi1QT/uUDQwMWlsX47z4CKx3S1ioKSkcJn7jVNNjHqBRF zj/sFAGpfTjug9248UP2Ta+jap8Q7ZX7tZPWyCu3RAWqKh4i4YcVfRvBoWJQoy61ucKy Zh4w== X-Gm-Message-State: AOAM532aSBhkR7O+8t2g6HmP8x3oLZcx+BZyywOQ9rFuhSNUYT2L680/ IAk/xrqKhNixBwg7FHN+uEBuhA== X-Received: by 2002:a05:6000:c7:: with SMTP id q7mr3148842wrx.356.1615376783902; Wed, 10 Mar 2021 03:46:23 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id h10sm30368165wrp.22.2021.03.10.03.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 03:46:23 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rui.zhang@intel.com Cc: amitk@kernel.org, linux-pm@vger.kernel.org, Amit Daniel Kachhap , Viresh Kumar , Javi Merino , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering Date: Wed, 10 Mar 2021 12:46:00 +0100 Message-Id: <20210310114600.27178-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210310114600.27178-1-daniel.lezcano@linaro.org> References: <20210310114600.27178-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-idle-0 thermal-idle-1 thermal-idle-2 thermal-idle-3 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: idle-cpu0 idle-cpu1 idle-cpu2 idle-cpu3 etc ... Signed-off-by: Daniel Lezcano --- drivers/thermal/cpuidle_cooling.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) -- 2.17.1 Reviewed-by: Lukasz Luba diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c index 7ecab4b16b29..8bc0a9b46358 100644 --- a/drivers/thermal/cpuidle_cooling.c +++ b/drivers/thermal/cpuidle_cooling.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -26,8 +27,6 @@ struct cpuidle_cooling_device { unsigned long state; }; -static DEFINE_IDA(cpuidle_ida); - /** * cpuidle_cooling_runtime - Running time computation * @idle_duration_us: CPU idle time to inject in microseconds @@ -174,10 +173,11 @@ static int __cpuidle_cooling_register(struct device_node *np, struct idle_inject_device *ii_dev; struct cpuidle_cooling_device *idle_cdev; struct thermal_cooling_device *cdev; + struct device *dev; unsigned int idle_duration_us = TICK_USEC; unsigned int latency_us = UINT_MAX; - char dev_name[THERMAL_NAME_LENGTH]; - int id, ret; + char name[THERMAL_NAME_LENGTH]; + int ret; idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL); if (!idle_cdev) { @@ -185,16 +185,10 @@ static int __cpuidle_cooling_register(struct device_node *np, goto out; } - id = ida_simple_get(&cpuidle_ida, 0, 0, GFP_KERNEL); - if (id < 0) { - ret = id; - goto out_kfree; - } - ii_dev = idle_inject_register(drv->cpumask); if (!ii_dev) { ret = -EINVAL; - goto out_id; + goto out_kfree; } of_property_read_u32(np, "duration-us", &idle_duration_us); @@ -205,9 +199,11 @@ static int __cpuidle_cooling_register(struct device_node *np, idle_cdev->ii_dev = ii_dev; - snprintf(dev_name, sizeof(dev_name), "thermal-idle-%d", id); + dev = get_cpu_device(cpumask_first(drv->cpumask)); + + snprintf(name, sizeof(name), "idle-%s", dev_name(dev)); - cdev = thermal_of_cooling_device_register(np, dev_name, idle_cdev, + cdev = thermal_of_cooling_device_register(np, name, idle_cdev, &cpuidle_cooling_ops); if (IS_ERR(cdev)) { ret = PTR_ERR(cdev); @@ -215,14 +211,12 @@ static int __cpuidle_cooling_register(struct device_node *np, } pr_debug("%s: Idle injection set with idle duration=%u, latency=%u\n", - dev_name, idle_duration_us, latency_us); + name, idle_duration_us, latency_us); return 0; out_unregister: idle_inject_unregister(ii_dev); -out_id: - ida_simple_remove(&cpuidle_ida, id); out_kfree: kfree(idle_cdev); out: