From patchwork Sun Mar 14 11:13:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 400088 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2613070jai; Sun, 14 Mar 2021 04:14:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXA0U9K+D3yzE2NVhwgptrd33Fopo8hTrpWyx+J2nd5x1inXqu4TfFxrPcbN5MjF36qLdU X-Received: by 2002:aa7:df14:: with SMTP id c20mr24279524edy.197.1615720489274; Sun, 14 Mar 2021 04:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615720489; cv=none; d=google.com; s=arc-20160816; b=eT2jewuEUZkGhfjLmLyol3QZEOJgL0l83rScYshTNe2cv4tsleTQL9LUzZ/AX24bfb N+0KTSngnKbbuUKnTr70umQXfWF0LcumFvANyqlFLseTBb2YCWA5DqIz9BXiNPnRjxW8 wOoCOcNGsPX2N3z8xinTpaBur3BQeVDiQkbHJw1LRRQPdhZi3AYj8ZkMxK5cyXN5PWRQ ngc+gMIcaXMkFVLSJj5R2rxIYATL2+I3MjlMXdMgC42cpD8/yX+5loV8J+NNwEdc5nEN yW0551N7Fy0l/7tXJMBk3deLQd4b0StQyqHaU/lb5Pu9BycdJ52/s1zZgqXbFKfgn1ZN iviA== 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=DuYOMewCZUtcJ4+tVTYyeku7t/eSId6NRi7iq7c/+IU=; b=yOeSIe1gu8tX8VwxkOqOKJV6anPzAjxvIgacGhpJEHEsOX5vAgKnS5txkVc0RTPz3g qVJw1WziZox/7sjulE2xrst1ctgMxtGf4TfP2O80cNXQdEb0lNJ7iYi1tqO76gCy+JbN TB3KNaD+pBBmNLbIreWKCjUocSZGj0U/sLUdkMpb0ltssTuwdFvQAsT4tPcvUznZcfi8 KhmnlFNQTR/0Ja8LAE1cQyBlxg60UFKwc62FA1kFliXeAwoGO+epeHJSdyyAnlfFouos 5x/vrXBKPmabNT3YXi9+6V+CEBWG5WslEaMo4zlblNv6sIgOAboct4g2XCBRcH9x9tNl 7hVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X9Stiduf; 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.49; Sun, 14 Mar 2021 04:14:49 -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=X9Stiduf; 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 S235293AbhCNLOQ (ORCPT + 7 others); Sun, 14 Mar 2021 07:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235224AbhCNLOA (ORCPT ); Sun, 14 Mar 2021 07:14:00 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C288CC061762 for ; Sun, 14 Mar 2021 04:13:59 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo17727278wmq.4 for ; Sun, 14 Mar 2021 04:13:59 -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=DuYOMewCZUtcJ4+tVTYyeku7t/eSId6NRi7iq7c/+IU=; b=X9StidufVkJ+3sDek2S0nGNm62UHGOd9Vt7j3iEksR5/6KMbqZyNiY7mxArpsZxp6R Wk8o5FNiXf8SK3lqCjWn7woo1N/zjL9z6ZZ6RZGmCY4nKK7C9HfrQ4l21m2D8pe2WFGc dMFYeAsnQs2M16lfrih7gD708+5PIvMEEz88v/MyggdO3tHmiCYNlVuc6f5Y7hOn3myE hR++jfeKoyQpP8rF0sHfrJFbREu13qSQsAq9pfsnZcxH34Q68RS7YfI2y2BSgeCBJH2p vzC1MlmVWbSnPU/9y7/9WbQx11Xh9KnWdcrBvnD4RIvpI0ARhIXkbbx5htFEvUspB6mW oY8A== 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=DuYOMewCZUtcJ4+tVTYyeku7t/eSId6NRi7iq7c/+IU=; b=mrspjnOKOJ43eJ93U1gk5Pjnnl8nCoDyZhB8o4xFxgZjvB6rpIW0gSpuw+KiBhwa0d F21Nx8tGovmf6eltIa4QYUgXCNfPBncIVyrLbYJ010YvR2Bs+O32I4+wDUlaSUDDSSHQ W3ZIlS1rJaCescTYUEa0GgwuHybLrMuXv5U95fALnQf/nRk3VS4pmcNpPr+hHXWYryxr hvvTWcuHan8gyLzJU4+SqDvdtUw4M7MEx2tnAiltl/1QvOJml1V6D/npGdiKw+uFdDiZ v3mvsM64JEDTQIBsVnZ9LuVvuwnmh0wM22v5ot7dc3spL1EXFsYnQ2pP5hcJOlb3Dsp5 p8tA== X-Gm-Message-State: AOAM530DQ6g9TCrNARSKJobSmKvN83pLMrKllB8BqnJZAnlU040cIRX5 YwafalRCUw5jB+6tf+SG3HWhZg== X-Received: by 2002:a05:600c:2254:: with SMTP id a20mr22407030wmm.115.1615720438410; Sun, 14 Mar 2021 04:13:58 -0700 (PDT) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id i8sm16828330wry.90.2021.03.14.04.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 04:13:58 -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, Amit Daniel Kachhap , Viresh Kumar , Javi Merino , Amit Kucheria Subject: [PATCH v3 4/5] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering Date: Sun, 14 Mar 2021 12:13:32 +0100 Message-Id: <20210314111333.16551-4-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-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 Reviewed-by: Lukasz Luba --- V2: - Removed idr.h header - Used kasprintf instead of fixed buffer length on the stack - Fixed typo in the log --- drivers/thermal/cpuidle_cooling.c | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c index 7ecab4b16b29..f32976163bad 100644 --- a/drivers/thermal/cpuidle_cooling.c +++ b/drivers/thermal/cpuidle_cooling.c @@ -9,9 +9,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -26,8 +26,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 +172,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; + int ret; idle_cdev = kzalloc(sizeof(*idle_cdev), GFP_KERNEL); if (!idle_cdev) { @@ -185,16 +184,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,24 +198,30 @@ 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)); - cdev = thermal_of_cooling_device_register(np, dev_name, idle_cdev, + name = kasprintf(GFP_KERNEL, "idle-%s", dev_name(dev)); + if (!name) { + ret = -ENOMEM; + goto out_unregister; + } + + cdev = thermal_of_cooling_device_register(np, name, idle_cdev, &cpuidle_cooling_ops); + kfree(name); + if (IS_ERR(cdev)) { ret = PTR_ERR(cdev); goto out_unregister; } 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: