From patchwork Sun Mar 14 11:13:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 400085 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2613042jai; Sun, 14 Mar 2021 04:14:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw6GJPh5lHJ0CQ3hz1eKMuXxnPK3kHlJDKui98zM7hpxTK+1bofh1fl6OFOvR+dUvvf5v7 X-Received: by 2002:aa7:c78e:: with SMTP id n14mr24150618eds.31.1615720487055; Sun, 14 Mar 2021 04:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615720487; cv=none; d=google.com; s=arc-20160816; b=vMGjep8R3d8XcAGEJrV/AFukEQ1Fyuj3w8XufMh8BSrq9Gwbu60YdWovO+G/dskdY7 pA2AmTgtY6Io/UiRApQG2/vfN38umwi9cYrGzkruTler43R71sL6jm9OzG4slpmWPHHX zVXfOQynekv8Og3HCRh3bxveBvP6hhJFr5sNwL+B6h5zu6hzKVBu/yFtT9dFI991QLRA QDWK8mLMxszPKvxXLm+mh57LRIW1XBTBs8LQTaihwORXw5jUMzDAu7HVkcKxEzwJqlow TK4wMlS8P/QpXsrNigZckYZXSzPzEUsFOFh7tJH6mUtni+6PkAxxiuO1cShNXJ7ubdXg tlkw== 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=8xPAvMxHmY9pOZ0ZnygmV1N99XR+BZf8XBmni53ESgY=; b=ar/ZyiagJJGEgzofUTs0FTF7mjuqyWl5d/7cTvn76c40QVXOSJml9ngDlLEbAiwpHA OUwxq9l70RR2WSyj8S5K9fF1Wo959AdfUBVULGrDJmwCYAcMtsD5YPgkFjQlzQVwCeFw nbbECUbGS8yPYY05XgdjkgEVNV/gHF/Lj26cKG+iCtoc28THFopTJ/BYaAUz9VbWzuXC 6WjOAHwTCF/1saeDxJmjBMjb5lqUU4W2IDc13tuYsZEei+LkUYVm+j1/Kv6tNN7U9+oN DJfSNsKODrSRcv+3njAJe0LyXuPlA5wPkI6Y5eiTX6fb3AtqZ9AGjrebFCL7GeiAQ/sz JOBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z6J3QWAU; 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.46; Sun, 14 Mar 2021 04:14:47 -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=z6J3QWAU; 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 S235248AbhCNLOO (ORCPT + 7 others); Sun, 14 Mar 2021 07:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234904AbhCNLN5 (ORCPT ); Sun, 14 Mar 2021 07:13:57 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92516C061762 for ; Sun, 14 Mar 2021 04:13:55 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id k8so4171251wrc.3 for ; Sun, 14 Mar 2021 04:13:55 -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; bh=8xPAvMxHmY9pOZ0ZnygmV1N99XR+BZf8XBmni53ESgY=; b=z6J3QWAUD5nKc3yZCQ4Wg8qGFur7mKvRy0vsI5FRjSEuyhyNqQIBJpbVYu5BNT44dG hYVy3cZLFtt0f/aCvRmDJYchM9tg3u4qmGNJzekJrznushNnni1o/7434/rXMTAw5tYw fGVKjU8u1OPfVb4G+oq98lIeH6fZ2FxBY/Ox4e+fDhNRC2DOFI0yXtsjQAfEaKaekLXx oLdQVlc1HKIts44VvP3L+zYHe55HYCRpKslJV0cVpFL7Z2ShTjgeR5BRV54A4qTJvQjM vDZaJxxohTSGC5WEvgv5I+yPj1WGByZsK1u/os2O2uuE/ZDXVZQSFAIzT+UXpY29URqC Hyrg== 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=8xPAvMxHmY9pOZ0ZnygmV1N99XR+BZf8XBmni53ESgY=; b=eTRji/koID4GJg0cP6H/Si7rh7wUmNPVCtzS9aHgRdU7YUaNqPYxM8aawbyYxSj/To xkPlZENprrjJGQ/EnibR4pIaNyQllUuV18syBGrKOqkri57u5rM/apfxHssNI3Uj0OEr cxhtAULGLxfeVbuclYZcEVA3N+O1RMG0ti8wo/Wl8OEhVOrJLJ5Dar76waiBv17vx8HI MeIrgU8Ng1ANysmvE7voJPz9PhvbGdahS4SlEk3EoH833wsMbNDPR3KOLoKG5pt6d2Kb X98tB2eM75TFqNlZRl2YBFYRo+iKA5EavyhAmaxS5LrSc8ldFBoht9tihX7QC6Fowfkk PDeg== X-Gm-Message-State: AOAM533OFX/ZrPyXPjXAH+IrvpLDjIK+cs2zvaZs/rOE/7UKxDFdi0R3 m2ojs+Kkog8LHuz+gGHttyq0FQ== X-Received: by 2002:adf:e84f:: with SMTP id d15mr22660387wrn.394.1615720434029; Sun, 14 Mar 2021 04:13:54 -0700 (PDT) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id i8sm16828330wry.90.2021.03.14.04.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 04:13:53 -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, Jiri Pirko , Ido Schimmel , "David S. Miller" , Jakub Kicinski , Amit Kucheria , netdev@vger.kernel.org (open list:MELLANOX ETHERNET SWITCH DRIVERS) Subject: [PATCH v3 1/5] thermal/drivers/core: Use a char pointer for the cooling device name Date: Sun, 14 Mar 2021 12:13:29 +0100 Message-Id: <20210314111333.16551-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 We want to have any kind of name for the cooling devices as we do no longer want to rely on auto-numbering. Let's replace the cooling device's fixed array by a char pointer to be allocated dynamically when registering the cooling device, so we don't limit the length of the name. Rework the error path at the same time as we have to rollback the allocations in case of error. Tested with a dummy device having the name: "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch" A village on the island of Anglesey (Wales), known to have the longest name in Europe. Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba --- V3: - Inverted kfree() and put_device() when unregistering the cooling device (Reported by Ido Schimmel) --- .../ethernet/mellanox/mlxsw/core_thermal.c | 2 +- drivers/thermal/thermal_core.c | 38 +++++++++++-------- include/linux/thermal.h | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) -- 2.17.1 Tested-by: Ido Schimmel diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index bf85ce9835d7..7447c2a73cbd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -141,7 +141,7 @@ static int mlxsw_get_cooling_device_idx(struct mlxsw_thermal *thermal, /* Allow mlxsw thermal zone binding to an external cooling device */ for (i = 0; i < ARRAY_SIZE(mlxsw_thermal_external_allowed_cdev); i++) { if (strnstr(cdev->type, mlxsw_thermal_external_allowed_cdev[i], - sizeof(cdev->type))) + strlen(cdev->type))) return 0; } diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 996c038f83a4..c8d4010940ef 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -960,10 +960,7 @@ __thermal_cooling_device_register(struct device_node *np, { struct thermal_cooling_device *cdev; struct thermal_zone_device *pos = NULL; - int result; - - if (type && strlen(type) >= THERMAL_NAME_LENGTH) - return ERR_PTR(-EINVAL); + int ret; if (!ops || !ops->get_max_state || !ops->get_cur_state || !ops->set_cur_state) @@ -973,14 +970,17 @@ __thermal_cooling_device_register(struct device_node *np, if (!cdev) return ERR_PTR(-ENOMEM); - result = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL); - if (result < 0) { - kfree(cdev); - return ERR_PTR(result); + ret = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL); + if (ret < 0) + goto out_kfree_cdev; + cdev->id = ret; + + cdev->type = kstrdup(type ? type : "", GFP_KERNEL); + if (!cdev->type) { + ret = -ENOMEM; + goto out_ida_remove; } - cdev->id = result; - strlcpy(cdev->type, type ? : "", sizeof(cdev->type)); mutex_init(&cdev->lock); INIT_LIST_HEAD(&cdev->thermal_instances); cdev->np = np; @@ -990,12 +990,9 @@ __thermal_cooling_device_register(struct device_node *np, cdev->devdata = devdata; thermal_cooling_device_setup_sysfs(cdev); dev_set_name(&cdev->device, "cooling_device%d", cdev->id); - result = device_register(&cdev->device); - if (result) { - ida_simple_remove(&thermal_cdev_ida, cdev->id); - put_device(&cdev->device); - return ERR_PTR(result); - } + ret = device_register(&cdev->device); + if (ret) + goto out_kfree_type; /* Add 'this' new cdev to the global cdev list */ mutex_lock(&thermal_list_lock); @@ -1013,6 +1010,14 @@ __thermal_cooling_device_register(struct device_node *np, mutex_unlock(&thermal_list_lock); return cdev; + +out_kfree_type: + kfree(cdev->type); + put_device(&cdev->device); +out_ida_remove: + ida_simple_remove(&thermal_cdev_ida, cdev->id); +out_kfree_cdev: + return ERR_PTR(ret); } /** @@ -1171,6 +1176,7 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) ida_simple_remove(&thermal_cdev_ida, cdev->id); device_del(&cdev->device); thermal_cooling_device_destroy_sysfs(cdev); + kfree(cdev->type); put_device(&cdev->device); } EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 6ac7bb1d2b1f..169502164364 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -91,7 +91,7 @@ struct thermal_cooling_device_ops { struct thermal_cooling_device { int id; - char type[THERMAL_NAME_LENGTH]; + char *type; struct device device; struct device_node *np; void *devdata; 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); } From patchwork Sun Mar 14 11:13:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 400086 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2613049jai; Sun, 14 Mar 2021 04:14:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfRAGAvYzL66mfxUyiAUzK33u9cKJy0MKWI+j2/xlqefhiakSnceZNzQGCOXzZIb3zvq5a X-Received: by 2002:aa7:cd16:: with SMTP id b22mr24957052edw.357.1615720487611; Sun, 14 Mar 2021 04:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615720487; cv=none; d=google.com; s=arc-20160816; b=lGrUi6vMzcWVnBWNQH5hYGtLZlGPaoLJ9fOauzVlbPT4dpL5yauxuT3Qll/87Wz8zU u5S1/cBdHQW8qzuzBREM0YA6hJCb7fnlVhY0qh9KRunNq04JLPnUA/+7BJ98ydn21q0A gw2T3T2GaHcALonjLGkjfo+RDvXDFpY5dAJhaFVSui4f3nXPN4sC0UkgRlJq2bEJ5x7t e76owHPjFg48ZXJd068+xIbyhSI/A5LDQG4Al6rbymrSuGAu8+K1pDKnH5c4pQld2hH6 wwYj8rLevbznviTjkGrHpB4hp2o69p/GGKOJc7LdGrn751qXRAcfpW0xTPW40XuYo/xb 43HQ== 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=Und6/a+u/e43qwfpDbHhYJU3/UbWxvF+sZZzRPfE1rE=; b=VTD+tZ75bcDBeC4FWJhYgaFtfjgd9PWeB7p2u25Jecv/P4acLFalwBqlr6U+pXIxIw d0iEv0eARdJ1ijzBOcV1DYU6CC+Ki/jT5OC+rRv+m87txJVC/a35aCC4UnUZMGpzevt4 bKL5vb++k3/onXqtv0Hd8MpJBKh8mOKOme91+3WSg/P9lU7vw5o0cXGQ5CbdlXT4EW/U fYcPFSJIvGYT/k+9dWuEcSzJcwBvc8gZmU8BLteuP7yh6WNOxV8iHexeo7NkUC0NPKY1 6UuH+xEUt8urXk3F9P3D8gt3pjXJ6fu+fQmuCkxRDMS4LjenZTtpNjcXJXtxhkA0nCtU JKSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ILhvmOQR; 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:47 -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=ILhvmOQR; 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 S235212AbhCNLOP (ORCPT + 7 others); Sun, 14 Mar 2021 07:14:15 -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 S235219AbhCNLN7 (ORCPT ); Sun, 14 Mar 2021 07:13:59 -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 47E46C061764 for ; Sun, 14 Mar 2021 04:13:58 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id f22-20020a7bc8d60000b029010c024a1407so18453444wml.2 for ; Sun, 14 Mar 2021 04:13:58 -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=Und6/a+u/e43qwfpDbHhYJU3/UbWxvF+sZZzRPfE1rE=; b=ILhvmOQRVThFkn3DB3HkviSf7pFJZf+cm51BWhMtnwOR38FgBP3hJ+Db7xdOh5noev T+C4/xYXykuxLLsFU9QQ22OXAScO0dBnLemVqpmo5uyUTpXvhxwz+EsqhRQKGBEEM0sk pN9XxWrNWa3NR+z1+d/wHnunYKZiAGoDSzOwqbGziApiHt5QxjXMy6N3pIlfX7y5qWfO 4v9BQ+edLaEsLEaOPJpBdf6QqursOTr1ViNyW66GUR7l2Kv7P5a5P6oiHNgt7A33Xg8A jYRr2ip7CQBzURuURwvajVDdAKtykgPh0wfhrv0cGdKgGD8JNc4JolraX90vUMS/BRLz 2M8g== 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=Und6/a+u/e43qwfpDbHhYJU3/UbWxvF+sZZzRPfE1rE=; b=q0IbY6soVPktzq/E7MJUgIAXzFsiJZVKLwoERBKrolrA6rNV5eMxgwl017Yati9u29 NbUrex3ZS/UX6+tUHm0zFog37MemWtx88PIcSHb7gbSnUKtEHGp3s/Q4QIMUFDCqqszU C6MkSEaVuKbt7aQZ1pHKn1m8/phZ/y3Plr5qY4pbuUoJ1nQMtx4iesSfBxZlRnVLyknp dAAb0eWx7XVmHQoUPFix9f3OnS9TrejhUiBxBgesZTVlRhnZ4UdgJxe7MTG7BEDv7bjf b051TYRJ6Qe5qCS7GmG2suC+mR0xKmgRngOcpcuXVLlIjQSxRVaZo/xLX519+CGGLNlf FmbA== X-Gm-Message-State: AOAM531Lxhw/u1/egAi5wD6rrLsnbJHNPx5Vaa1aEJ/FOg9ZAefuCuJu gpTTgrEDRM5y6Wur2kzhWTR4qQ== X-Received: by 2002:a1c:4143:: with SMTP id o64mr21443454wma.50.1615720436916; Sun, 14 Mar 2021 04:13:56 -0700 (PDT) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id i8sm16828330wry.90.2021.03.14.04.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 04:13:56 -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 Kucheria Subject: [PATCH v3 3/5] thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering Date: Sun, 14 Mar 2021 12:13:31 +0100 Message-Id: <20210314111333.16551-3-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-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 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/devfreq_cooling.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index fed3121ff2a1..fb250ac16f50 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -25,11 +24,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 +47,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 +358,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; int err, num_opps; dfc = kzalloc(sizeof(*dfc), GFP_KERNEL); @@ -407,30 +402,27 @@ 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) + cdev = ERR_PTR(-ENOMEM); + name = kasprintf(GFP_KERNEL, "devfreq-%s", dev_name(dev)); + if (!name) goto remove_qos_req; - dfc->id = err; - - snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id); - - cdev = thermal_of_cooling_device_register(np, dev_name, dfc, + cdev = thermal_of_cooling_device_register(np, name, dfc, &devfreq_cooling_ops); + kfree(name); + 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 +519,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 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: From patchwork Sun Mar 14 11:13:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 400089 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2613075jai; Sun, 14 Mar 2021 04:14:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYCS8F5rVLx6wn18s9FOa3QlN35rqlA2ooWfvumkvK753NDigdWG3ygNfwm+XHvasHWLWJ X-Received: by 2002:a17:906:938f:: with SMTP id l15mr18068163ejx.15.1615720489761; 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=sefpPPTCkg6vwVHgAWMNRKxEOWVBSbrPiSnA6zCq9pHuMj8PQoWH8xQvoS4J3ajgsh 9QCHEFNg2Ct35SQADx1NVRrQ7xfeWUHZUjSixxOQllCtmBAIdfWQuYngJW+vk0cSJIIT 8B95rkL0AORS8TFoW7tJ/OAhWWoH2pYNbO9L2FvMYSHbJkcNerihJJV6oXHdKe5ZsgYS zXnLMCzBRI4WvkWpjM6IPrVStfKdACy8++jagUfQCzO1I8MBdMqAfazRpC4JOlE67OaK gC86vuPK0eT0ygWj6XZ4u0qisynFS/i1p5WVINv/pjeFUOkvxg4PFloWgPjgMwWO9O2E yx2A== 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=AIW5JdRiazsxMw3x5g28vgK5yNC5+8RelKPzLiP5l5I=; b=z1JHwUZkcG/QoGLLhfY+geVk3JcrQzAxXicIxo3W/BOwKxYRrMBpNADr1pcfq7b/KN hTNPhpErI+ImdZwoMyaxpNJk/jVErfNOPWu4QwPOaKPTDx251Y7obdT9erwm03e7OkeS 7wbYWlj+Eez0I06xrieIHzv324qhcpl9mFjwuStivfArxilvnORExvaIVBdDIv6qlLhh m5dqHtthMy7NPtoHzoDpw648mVhh20vJ1jpScOaCoL5hPJ3wooC7pOyKFAWABEe6+egb k+j+gTfU+s7A4B2I+Q5ith4BFNraQGsRSzvvqnRa1gM7tnwBgFFGrG3uc92chq2Pzzof kHUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bTzF53Dw; 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=bTzF53Dw; 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 S235230AbhCNLOQ (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 S235231AbhCNLOM (ORCPT ); Sun, 14 Mar 2021 07:14:12 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B01FC061763 for ; Sun, 14 Mar 2021 04:14:01 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 12so1360108wmf.5 for ; Sun, 14 Mar 2021 04:14:01 -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=AIW5JdRiazsxMw3x5g28vgK5yNC5+8RelKPzLiP5l5I=; b=bTzF53DwJpsYl5uU/6LFHN9EfBLcWe7eeiehJ9VJxk9fAR6L6CjVSsViyPDfxbBc6y Bmy6cU2dv2N0/J61rN8xXi1j6TKQ139RqC2+3vMvFwdsbNqYt1ij1RLsBOffB1Sk8j+g g0B85O2p6njVG2H5bIurwnGP3E+pxIgrP/voa4vzGXRO+wyOmThd27N0o0cHQ1SArR0T Yx7PV7RQ3U75mrzEpfHhzGJMRkIshJSJulHT1bVq48LrUc/R1Dc8HuEmSQMR0aCXXN40 9g53FRYLQJncIYke7+fQu+fxkYZI4S94fbbSQA2PG8RYS4Gld2pX/3ibRckUZ2NzYr/L pUcA== 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=AIW5JdRiazsxMw3x5g28vgK5yNC5+8RelKPzLiP5l5I=; b=uDnXKNx/SrvvFS+ILAltuqmUrFLzhRIjTYmFFub4Csi1x7Lv6kbv53W/6NM/PHpQS1 702hSqCrop0w2X+QXFSt3SkvOe9GCOoNj51oy+BRtdkAJHEc0Y4JUR8k7gZ1l9VtBLZs +QuWsk13dVIqB2PitRa8vevGzFpqrUEnYuN/7toJEQ9lwkQw2eitsbB/iP5XWR0Fxhmx wxj5MK6bSSRbGep1pUaNmX5NhN/QLtZQsX27+ulVyX62y1QrZAasKGv2RPwXM6JVWdJ1 XdqUxAvgF7dPnqgYz9c4RrvtxuubiRNtGu6N/s2WsIsf1PlgbPs8E8YCAn+dH+TyUPIE c84w== X-Gm-Message-State: AOAM532YB6Soh4M2IVddi3kV+YHEgU/JUIJOZkqfzzsf6J2nIQhq1AsW cmSZYJnckJ7v8yl2SXCG/VFwjQ== X-Received: by 2002:a7b:c407:: with SMTP id k7mr21829856wmi.136.1615720439841; Sun, 14 Mar 2021 04:13:59 -0700 (PDT) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id i8sm16828330wry.90.2021.03.14.04.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 04:13:59 -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 5/5] thermal/drivers/cpufreq_cooling: Remove unused list Date: Sun, 14 Mar 2021 12:13:33 +0100 Message-Id: <20210314111333.16551-5-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 There is a list with the purpose of grouping the cpufreq cooling device together as described in the comments but actually it is unused, the code evolved since 2012 and the list was no longer needed. Delete the remaining unused list related code. Signed-off-by: Daniel Lezcano Reviewed-by: Lukasz Luba --- drivers/thermal/cpufreq_cooling.c | 13 ------------- 1 file changed, 13 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index 3f5f1dce1320..f3d308427665 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -59,7 +59,6 @@ struct time_in_idle { * @cdev: thermal_cooling_device pointer to keep track of the * registered cooling device. * @policy: cpufreq policy. - * @node: list_head to link all cpufreq_cooling_device together. * @idle_time: idle time stats * @qos_req: PM QoS contraint to apply * @@ -72,16 +71,12 @@ struct cpufreq_cooling_device { unsigned int max_level; struct em_perf_domain *em; struct cpufreq_policy *policy; - struct list_head node; #ifndef CONFIG_SMP struct time_in_idle *idle_time; #endif struct freq_qos_request qos_req; }; -static DEFINE_MUTEX(cooling_list_lock); -static LIST_HEAD(cpufreq_cdev_list); - #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR /** * get_level: Find the level for a particular frequency @@ -602,10 +597,6 @@ __cpufreq_cooling_register(struct device_node *np, if (IS_ERR(cdev)) goto remove_qos_req; - mutex_lock(&cooling_list_lock); - list_add(&cpufreq_cdev->node, &cpufreq_cdev_list); - mutex_unlock(&cooling_list_lock); - return cdev; remove_qos_req: @@ -697,10 +688,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) cpufreq_cdev = cdev->devdata; - mutex_lock(&cooling_list_lock); - list_del(&cpufreq_cdev->node); - mutex_unlock(&cooling_list_lock); - thermal_cooling_device_unregister(cdev); freq_qos_remove_request(&cpufreq_cdev->qos_req); free_idle_time(cpufreq_cdev);