From patchwork Fri Mar 12 17:03:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 398655 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1362596jai; Fri, 12 Mar 2021 09:04:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKytG6iw/J+QAvx6xHTrq/2vr15dWOYl7FtE5gNRS0EvmI2VONCnv8664NJyyUwKiAiifb X-Received: by 2002:a17:906:6558:: with SMTP id u24mr9848297ejn.185.1615568648838; Fri, 12 Mar 2021 09:04:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615568648; cv=none; d=google.com; s=arc-20160816; b=Uh1vNGCVnzIRxm6GFTwwPBqfT631bxMTqIA2cFDT+1yedQeICfb/H6Qd3x42caCY0o QA8NHN8znfgC0TPXEQTmBzjhFGkCEgfOPV8vfqPRI78WugycGHmtW4KKen5vUlMQuTbk O4+MTbXf3ALNb5tbSfoQVVjdR+cYQzgfxQ2QObZwHc2H2J/pbNmNka5q+oZXASTuN65X t5tSGSXNiFyLymvIRshR2Hf0U4wtj+v/i0orNDlkSSnJ+lpvfBsnwrUH6wwuoD5oHbvn Z6zYo5XDlZ4VL0lFOE4eO/+mIeD679VYaA84qXfjUw5fmzk4HmiWq4IMg0uYhM1cYp+V R4sg== 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=UmJ+dlfL89soFWN/JEBNsBQA5pPbGuDlfbh0AQQPANw=; b=VGlo36qgfJT/mv6bjKqIsaDc0pbA9C/lefletfgaT4QrPfVlKZVygwVQnUoZMHEdiL +A8jnRbMPN9ag53uuNOO+pCb0EEFTqr7w/fxuFAhyyCYGy4jOnEANbGXDDqbUMD5S7sk CrTKrxUShWrqlK4VPGuc0HdskJW8IYHiqwVMDEWNF5dx81hGXDm8XGhQVXezYI72IoMb vFwMs600S748okNAAWnbUOub9XJRN3sMUrLFGH1iGuyFeXxskMKtLksHCRroh4MLoeft 3rft6hxB/K+0bAVGLzgkwBYvcD8LEGOAVU9VKXcY+XL1b14KXQkgAwOF1oKEkk7Vnq63 Ctbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ph3La2lx; 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 x27si4448981edi.240.2021.03.12.09.04.08; Fri, 12 Mar 2021 09:04:08 -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=ph3La2lx; 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 S229728AbhCLRDh (ORCPT + 7 others); Fri, 12 Mar 2021 12:03:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232697AbhCLRDa (ORCPT ); Fri, 12 Mar 2021 12:03:30 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D747C061762 for ; Fri, 12 Mar 2021 09:03:30 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id m20-20020a7bcb940000b029010cab7e5a9fso16211007wmi.3 for ; Fri, 12 Mar 2021 09:03:30 -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=UmJ+dlfL89soFWN/JEBNsBQA5pPbGuDlfbh0AQQPANw=; b=ph3La2lxZ9YM8An2w7eE8l8N8kYroB/fRE4bTPlrQIMleBr2beFZDadzryFA1IDg/v z0WScO60gsTlYnRWXVLxOHNiOFgsGNZfRWz5Tw+wmlsRB10Pfnt+BNeWmV61aNB62Ysl AYrLDMueNXjOIWECzDe0X0T+pZ3Vv1BZ313OKdWfmfWcPjjYdsUuEciIUBFXuEw4qLXP rSlT/VMGGtD+kkIo8r2RDc34ZmdZo/riGawaiHIIfNzTIPInkQOp9ffCTTuP5k3rPbC6 /tb/ZZBzjzM+9/V03jr/zHtlpmcQamo83QpQQxtw8v2HG8ziutZWro8nch7EVjvkYQWE 3enw== 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=UmJ+dlfL89soFWN/JEBNsBQA5pPbGuDlfbh0AQQPANw=; b=Lg6J8YZGuNYOYBfzemn7CtxuROnK0AarrOBDu1GKmXmgkGznaVZ00/FRZnu23nBpV5 2fqJ+gJ0WKcQrraIIQYHmZxccAmTU4R4fPpT8/i7PjOU2YgjyE0+sHKcijxTiMO6fKa0 VpXCHb4hptX7Zah5wXBJA4lrJ0bsLo8D0NTlIhGl78ghnr7ODAf+5vZc5ZpgsD0WzV60 F/TNhX4xYQRn2dZ338UUFb0iW1zkEisEEC2CKG+kLPKXp6tbdsKexS3tnjyKfv7tcsq4 VBnCJVWBBf3nW9xP8AWpPATp9xeRwegPGbbDzGQfLfW2JVPglVZoagK1eC14zPn3lF6u 3xOg== X-Gm-Message-State: AOAM5336thPwtyVZgsdQ2NKulrDU8QVs5C55ePPfCymMYqVOPIMgTUdm erSZS+maM+8dSk4OUcNi4sUlpQ== X-Received: by 2002:a7b:ce06:: with SMTP id m6mr13681917wmc.38.1615568608698; Fri, 12 Mar 2021 09:03:28 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id 1sm2854681wmj.2.2021.03.12.09.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:28 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Jiri Pirko , Ido Schimmel , "David S. Miller" , Jakub Kicinski , Zhang Rui , Amit Kucheria , netdev@vger.kernel.org (open list:MELLANOX ETHERNET SWITCH DRIVERS) Subject: [PATCH v2 1/5] thermal/drivers/core: Use a char pointer for the cooling device name Date: Fri, 12 Mar 2021 18:03:12 +0100 Message-Id: <20210312170316.3138-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 --- .../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 Reviewed-by: Lukasz Luba 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..9ef8090eb645 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); } /** @@ -1172,6 +1177,7 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) device_del(&cdev->device); thermal_cooling_device_destroy_sysfs(cdev); put_device(&cdev->device); + kfree(cdev->type); } 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 Fri Mar 12 17:03:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 398656 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1362628jai; Fri, 12 Mar 2021 09:04:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyip9CDrwBm+L2obIDFQXKAzJHKD53MFlbTnlxCKOhEOnkL+NHfkCPHGqP6qnjIj1A4uRuQ X-Received: by 2002:a17:906:2612:: with SMTP id h18mr9504788ejc.309.1615568650848; Fri, 12 Mar 2021 09:04:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615568650; cv=none; d=google.com; s=arc-20160816; b=I+RdRU0DbKeZxiJNy3Kdlps1wa4bxBmratIYXo0C3zEuhav1K0jddGaCeY+lWsb4U2 YzXfK+v6OUnpCg90FSh0lXJExsHZ9wtVGJHaXWnXVQiwZWgjxbfTB6tTIMIYyXwgJpoD Zr11QPzP6m8MHkcGtTWcUGExIzg5y9nS1h1I4ZCWPVF3jZHctP5ahKV+jF89v7fGGa5C ojUAsfYfUty0jrCHDRglMcfvAgYMEyvwTbU/9HH/XtdyQKzUwbjNWCcLgR89kVzlTELm wppzI3Br53QeIGcaGkV1NZClW7eLM+yi59qC5txVWxNLFYMsLdV9jSunrffTXkE3sGyL qQSw== 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=BpCsAKSKxqRCMNmfc75ZIJKG5g0DxvzCvX9Jc3sClrZPLNu1EBphw3MdJOZisFeUI7 awSrbZwq+8+rVNA3WvEJOIgR04Z4K5KO0dzlKTnF9wLQnDuLghiNK9asPJbtItrXabPK 6sU//m7ozjP/9eqhw67Vu9wuHUivQhm6MJw02ZegoL8+/hmgNIGhZtd+yJaqDO2jRLKe a8tGMNhKTEdvxdWov+gklRvZRHN43Sf6H7GRZz/Ct2Tfn7ouxX7IeIQR1XgjCvz8YtsK CPTC1bukdsqt2BaWgNzKHqHBISV2WUPwQbTQRyeExqjtU+GyrdYjvI1BooQIPGvUr326 aS5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X0lBMvAl; 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 x27si4448981edi.240.2021.03.12.09.04.10; Fri, 12 Mar 2021 09:04:10 -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=X0lBMvAl; 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 S232647AbhCLRDi (ORCPT + 7 others); Fri, 12 Mar 2021 12:03:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbhCLRDc (ORCPT ); Fri, 12 Mar 2021 12:03:32 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 993E9C061763 for ; Fri, 12 Mar 2021 09:03:31 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id c76-20020a1c9a4f0000b029010c94499aedso16227062wme.0 for ; Fri, 12 Mar 2021 09:03:31 -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=s7fCt8jAahXLsklhkFc/v9K2fCeNdzwdfE44cqbig58=; b=X0lBMvAlM/aI9s6P8gpDF/A2H6hRtLmQX0fu6RSroOLDo+GfgC5JMl46hETKXvJ+9E JfSuZ+xVrLucKcrdR6RseL/Hpv7SMTiseGuTidEInW56e1miGmBEWBWLRtQ/1DL07r7w MFWp1EtKUFh+jWd6/bg3j2hUlW1PZipr6ikhhpomDNbI5+mr84zY5Hb8J8Li4bMNYqxx i3dYvIQeXJrm20peNAiseQaBbaeTdEcR4NrqMLbKx+KETP7W1u7zxwnZ67IcWEIzy2aD 5Sr3+pBRXt5BtK8VoumFQi2vULgDs0C8pSrEXAi7b9Z1paRxQo9g3ym9bY89DcUWxgMe HYqg== 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=oktgeqx2W0XJt640KRYuLURP8voeXuZQRgWT0EfQGpPJw7CSbP9Yigk/Saf/BCtJCz ZXZ115hLf4UdAnSmOpInfFZWfnkBqdiYEBXuPrVKmpJhFdvoko7VdvRudEtFf1oFpYGE xJesJA1z3UVQQqnqfu2Rz6qU09prqMXmNj377w0CH2m8rD4MCa+iizLbkz/hrQZzp3rj 0xT0cIGE5OhtFxzgd0ySvsz0WhY4/xnonqLRfFyIFq9EPgZth50y+ieVjUm5M9cOFy2W I/1yzmzfx9aMS/iCHtbDPmOq+XO/8UVB2ZaX3j8QHo+b8LEtzK+MIeTeQi754Hn1chMn bdCg== X-Gm-Message-State: AOAM533pDCJEa/wK8CuL9j5KoD+RqXJ4fi0ldYNliNwAalR1g4YMwRS/ 5VErk5glLyAC1tMenc21luTHmeib06emHQ== X-Received: by 2002:a1c:1fc6:: with SMTP id f189mr14152756wmf.68.1615568610171; Fri, 12 Mar 2021 09:03:30 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id 1sm2854681wmj.2.2021.03.12.09.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:29 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Viresh Kumar , Amit Daniel Kachhap , Javi Merino , Zhang Rui , Amit Kucheria Subject: [PATCH v2 2/5] thermal/drivers/cpufreq_cooling: Use device name instead of auto-numbering Date: Fri, 12 Mar 2021 18:03:13 +0100 Message-Id: <20210312170316.3138-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210312170316.3138-1-daniel.lezcano@linaro.org> References: <20210312170316.3138-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 Fri Mar 12 17:03:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 398659 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1362690jai; Fri, 12 Mar 2021 09:04:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTWVrwZC1HFO2H21W+W6zKd+7dcSvVLZs7Ge7Gt9PNVbBGpT5CbAX/brKn9wgO8w0bn0wC X-Received: by 2002:a17:907:7249:: with SMTP id ds9mr9771537ejc.9.1615568654785; Fri, 12 Mar 2021 09:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615568654; cv=none; d=google.com; s=arc-20160816; b=GELzH2MNZCoNoGVN9geC6KSSHuusdzw+dlKfHwWQXoCsMOTbvZrH3aa+YJsAGyTSTr 7mojSKANyzMrqR5l9gDEs6G5/EseUKo82bo8O/s692fblhGbT4dThVMLf7657vT24nsy acVYqs7/+jpRE5Fr/OveewueCXLdl0oLN77VLZLhOwWerwEaxYcX8TOxvzxuNtm0ybYX I8hBSOjyJMOxS3MhcshrglkoG++RAVCtHB0JH9xZeJsne0cO1uNqe/fLIvbFUzgKDhJe mLxJinXRaGEemRAc5znvRKhIVuhQ62/qb+abkPwG8ipMu6djyDUXbjFVvF2h92L4Eroj ek8Q== 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=MotLWcKEAwk5d5cO6koO4+5PW/4j89nsIKT3D/mQf/k=; b=DpQm47h8qC9r3oJQaJbWV1r1eeH6ypiSNg4tgN63+fopDs0wCYKtpQ07z/F+7a2EUS NmtSXWGtG1tBAT8eoNXVzIozLpqUiHAGqzcYMBcO2LnYmryMlsyyZDnEogJufta0Awog Ye0tecCiLjFFhiWrGWnmmU56o6Gdyg4zrk2pnoeA5hKoSjkiNzqklIpO1tCY1pEUcG7B tcE+KR0C26n7lY8tSJ9GBdkrutr2iuCbzntKtgNiZRQSkkAlzxqxexmKdffEqwGghZea F1CTPkEpen9LvyPS/PYpoFjLAfX3jVs+tq7TbbjX/xwlAGFcNIUFM04PBYQPUnJqeuu3 IxwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uMtJEddo; 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 x27si4448981edi.240.2021.03.12.09.04.14; Fri, 12 Mar 2021 09:04: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=uMtJEddo; 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 S232699AbhCLRDj (ORCPT + 7 others); Fri, 12 Mar 2021 12:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232736AbhCLRDd (ORCPT ); Fri, 12 Mar 2021 12:03:33 -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 DB738C0613D7 for ; Fri, 12 Mar 2021 09:03:32 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id l19so4219477wmh.1 for ; Fri, 12 Mar 2021 09:03:32 -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=MotLWcKEAwk5d5cO6koO4+5PW/4j89nsIKT3D/mQf/k=; b=uMtJEddo/apKTRPUpOe2gBO64mOi6Yx8nCGsweTIrjBzQqQHeNSzCxx/SPxRKio4u/ U7BV3QGxk6DASUj8myYOxUyrTFoT0pzakXnV8hbPTE7UZLt8yQo6eO0viDSTU/qaC+qZ lAoe28FX8HqNtbXukl0zwTGL4OX+KSa8C2OmK0ccHrs5LCmDFJe2rV4Ww0DbK6pnELrM 1AS2u3vIxkWOA0mcbPVdGfdmDhRDHoJW/s6iv3ZGb9GdkAow2LIVMtyOg32zhRYQRFKf TgaV0+CUAVYL+D78Y0BYs3HcqjHPo5WlYL/UKYYu1vUrzjF1noh3lUSHqaw0uwUShVS4 scsw== 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=MotLWcKEAwk5d5cO6koO4+5PW/4j89nsIKT3D/mQf/k=; b=ZwKOopebT+Xc/3wL6kQOedKQKafH1VTPcycWbwa6x1AWl0xlImcsvcSolEtr3hHUDr obuJyq8+ScJWbTlWi7735C7oa4kHT5FMuXWGrgqjE9Y9UZktkwPt95229gIKQ3dd62Fg qlGM7jMywv/o5cT4z8p5NiSMNascnmOyl4JmVzsEXI6ec6OZqQd/EhxckXy9HU859iYh 9UrBrXW8yrA8OqlqFggs38VPkNUO0dxwWMUjnj+UUctScD8NWbcptrOE87V2I1mAZw1+ RviRChw6l0OLM7xp+gecpXaVrWpy98f32MICJoVlPOgQKQXaE8Q/oyzEBO3r2JfxaOp7 VtQw== X-Gm-Message-State: AOAM530fFGmwmdF4RcMmcxGI65tlRY7VHp5QvvvyVpihqeUS6V5wnLvQ 906h9bM37d+CqGvtEDA6F0VDpTYDpbmQKA== X-Received: by 2002:a1c:4182:: with SMTP id o124mr14271973wma.61.1615568611445; Fri, 12 Mar 2021 09:03:31 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id 1sm2854681wmj.2.2021.03.12.09.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:31 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Zhang Rui , Amit Kucheria Subject: [PATCH v2 3/5] thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering Date: Fri, 12 Mar 2021 18:03:14 +0100 Message-Id: <20210312170316.3138-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210312170316.3138-1-daniel.lezcano@linaro.org> References: <20210312170316.3138-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 --- 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 Reviewed-by: Lukasz Luba 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 Fri Mar 12 17:03:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 398657 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1362647jai; Fri, 12 Mar 2021 09:04:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnfrKgsIfouNylOUlfrPc4qEYkenHnSraT2K8YzKoiEqvbg41gp6n5/LI+A8HX9sO32I0i X-Received: by 2002:a05:6402:17d6:: with SMTP id s22mr15152422edy.232.1615568652310; Fri, 12 Mar 2021 09:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615568652; cv=none; d=google.com; s=arc-20160816; b=FObHT8CkLtosiBz/rMtH6gfmj44+eLWeRMn2az2yr5NO618xFShf4sEqAdHB6Q3azh a76ysJUqUAvrHayR34zwvZ84w6XZX2kU+fgqjOBNeZ7iO3N8JnIaW99QgTRMsZOEjqja pXTHgUHpQBP+ddJf7Zr+NVeAGjPPerLkvfbMVGqWPFYB4sBheQcPvOZ8HKFSWoL23M1N DkAxsX5W0Rj+JVgy4IMsNyCgB47DtQ2QVh/+Pzw/EgzkxhZgi02cO6ur5nvtNAcF4sGq zf6wcw1r1VPNYOQwO/fGrVm0TTScGSYmUt1JLCnRXT8ypVPscHf+CYhyP3U4C2Bnh+E9 M5rA== 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=kzA5esujeEoS4ApgQqD2Gaqd5+G1d0mUu/xfmtdeJOWHIwCpCudnshB52jjhRpD/YB DfE+otTVKt5V457d/oaYgUa42tJzq/NqnP1B1b+dJ6YHNnEDPIuHqoKjYlpmex7c9A50 W7+XhR3p1bvtlnDP8RhKLkE3cR+4ub4sspW8I6jkedE75KTDLyWvsBkeAN+NCuToENCG 26mhpt2KKB2m1UXrgAEIk9vOmsZ9/m22t7QngWxon4LMb46g1v71QMGaPkV4W+Wgyhpo ytWSm5aN52XMAOqWPQvtPMDfA7YpCvpKMECFGeTeDrqbOhIRvYVnuoZKl+OFpzPI4LK8 r5Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UR3krhYk; 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 x27si4448981edi.240.2021.03.12.09.04.12; Fri, 12 Mar 2021 09:04:12 -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=UR3krhYk; 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 S232747AbhCLRDj (ORCPT + 7 others); Fri, 12 Mar 2021 12:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbhCLRDe (ORCPT ); Fri, 12 Mar 2021 12:03:34 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1FCC061574 for ; Fri, 12 Mar 2021 09:03:34 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id y124-20020a1c32820000b029010c93864955so16224106wmy.5 for ; Fri, 12 Mar 2021 09:03:34 -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=DuYOMewCZUtcJ4+tVTYyeku7t/eSId6NRi7iq7c/+IU=; b=UR3krhYk1OkiuZslRgZbNmXQw0Uo7wx0N/Xc74UmSpEbAsJc6QGrlu7dQze9yNBJDJ lpS+NtBDBZ+d4FrfzPCd96WUxNvu5pCD8+vwyGmTfBCF3esMo/WPmTUib/R06sMV1j1O kI2GRSZcWLFZhtLe3AB6reIJNuYGdL3JSyIZs7eC3hJ+a2YEscA+z977dGNVrcYQesA/ Y9sQEnUNWowuuPLkEsc47miqqQkRR7pTr4XGrX85jT3jnUnvxbKiTNtg0C3YwRmLDifH IJBxxD+R/wf6aXTd4srnagSHEYDBF1sQC6thqWiF3xJZBDrVwH0EmUeVbTPUR4MA0fn8 BmBQ== 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=uapN2CfcYRAw8vHzyklX+M3ETwN6cc5FThLvAfi2qa6KaV7ZZ3pDJA3eigXix1MRfD w1MtwF+awSzRa8OaSSKjzQALQJCpy9/AHN+0O/DjNxsLABwse1aXgxKiNRAZ/ZKwsECq 7CoinTG9BIk0B9CVDjhE0bZr90XsAkInegyYZiQsatTNFFM3fNvanhTT4mVte9dDtajd hRw84g7Y/08K1CmgjyiJW8mMbch0tlFelfzaNCjvwGiX35scljXdI+HA4eO0qZrHNptd M4nMa/+Lg4A+vTrOzUEoToeJTEdUlnFvLU3VBoy0pSwgLGt+29Zm8PyagiO29Z9+HJrO vv1A== X-Gm-Message-State: AOAM5328S/OGWYNy2dpJTXYVaE8ExxN6j3jOG3U8tN4oP/K0aXWmwAr4 mmiDCmGC+R66vFe8R15DhIexmg== X-Received: by 2002:a1c:4e0f:: with SMTP id g15mr14267749wmh.144.1615568612905; Fri, 12 Mar 2021 09:03:32 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id 1sm2854681wmj.2.2021.03.12.09.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:32 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Amit Daniel Kachhap , Viresh Kumar , Javi Merino , Zhang Rui , Amit Kucheria Subject: [PATCH v2 4/5] thermal/drivers/cpuidle_cooling: Use device name instead of auto-numbering Date: Fri, 12 Mar 2021 18:03:15 +0100 Message-Id: <20210312170316.3138-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210312170316.3138-1-daniel.lezcano@linaro.org> References: <20210312170316.3138-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 Fri Mar 12 17:03:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 398658 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1362639jai; Fri, 12 Mar 2021 09:04:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9UEu58pVQOmtJ5S0q0Glps6fOyVUd3Ly90yjEdVKCE0lj0dDQnOwyfeNcGFr/fs7apeRS X-Received: by 2002:a17:907:216d:: with SMTP id rl13mr9488948ejb.362.1615568651930; Fri, 12 Mar 2021 09:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615568651; cv=none; d=google.com; s=arc-20160816; b=KoY+t2almiYHo2X8jldIpmpxKSo+0dYAhK7eFuMd3+02U6Wb7VuxaAOhvXonbUnIBD hIdJEDkDMYc+yBMt2+xRZmlmD/thuiR0liQVmWKQfx3e8E5f16lqNJJFc0p92MOvI+Th 6cwdlMgoVDz3ClN858ds0KltCK0YVDYXcOYPr2McIBb5N2JcLls88TeZAUcxkWMGFuDi kn6c81nwmQCdZVhHcmxxpcmyGNqM5uSWyRfASLJ/zr4FMsGmoMTXnX/McWeKknux0oCe AwoaiYhPbRoiEXysXkcoChNsDPLteh2saWCXV6gbJVEbIv7jppRDPS6vWrkKeej5VdVb LFnA== 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=0xkCbEvZITlI3FuObl7ojygKHKc8b/X8zJQNxRSg5U8=; b=BLbGPCSGNo8YnN2e4JuJASfr2xDun+vNB96LtZwyLManaa1hU87yu0KcyQCXUbWILS 3x7wpH/Zii/QWaBcPjDtqGjxxiXL5ZHIetEf3drcUOE3ADk0TcDt1bSEq2o1nN7IGQ/H 5QfdmXz5n9dzu+E06cSSGyBDCYnBIJfyYQmEvX9yneIwHUd1hwaQ1+1vnl+FT6hushJu hJFtstziHMYR1UZMYXbhrtet2OGWXag1V2/BmdRVoerz62+ST1fPXeyErzGs6wEnxdER +q3jEKiOhjzmx/T45rrX+TNgq/KqyV0hVA3N7EBEivmBhoblwkCiaLB784tieOSmKGgz imfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vSNwp16O; 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 x27si4448981edi.240.2021.03.12.09.04.11; Fri, 12 Mar 2021 09:04:11 -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=vSNwp16O; 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 S232764AbhCLRDj (ORCPT + 7 others); Fri, 12 Mar 2021 12:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232768AbhCLRDg (ORCPT ); Fri, 12 Mar 2021 12:03:36 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B43C061574 for ; Fri, 12 Mar 2021 09:03:35 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo15573064wmq.4 for ; Fri, 12 Mar 2021 09:03:35 -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=0xkCbEvZITlI3FuObl7ojygKHKc8b/X8zJQNxRSg5U8=; b=vSNwp16ODVdxzM23E/bgP/ktZVmMyV0r0DypdYvSkDZF1m9PRNfX52KlC9ibbZU6H9 TljQagWPlpVNGNVlZiEtawxLYbPSPFHaEK6eQurl0lFgXoDL7lv4wnUZ7Fh+4pYwym00 UEtQ4EaAw/4OQodzQN0QbNHmMyN1BNx5ZQ0BsKZ11rP/5Q2fmCkdScrEZj4i4fTz05ZA UmfzaJ1wYUwe7di/LY0x5LFMkn5efvM3H4ZwoeIwBoRjqWMAB3PUVBtWDzGNxmIaI26Y RjtC0rqhlw+aIJmDSNpf49h3Vy7xQe8iogeTHIozjnUQAO3wy+w+FfGyktTHmnH5oaMB w0bQ== 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=0xkCbEvZITlI3FuObl7ojygKHKc8b/X8zJQNxRSg5U8=; b=ZygWkgS2hconFLkXoo5zl+TW2b31SVNwhcf/+Fdb/tvq0l2/Lc+mSUllq3DjR+VPXD C+/Yo6MBKAsFY4dKmcsQPdHkM9JuQMaMUW7tZxTmUn3JGX6icjMOgwKxNLLA8q/F9JJ8 zzVAn6YBCCF6yrX+CyVbzkHoo8yAvbqF0JCC8F+MauYt5QnY+BgsfVz2tUJsMQl1AbJy GTylp6B6aY6lo976Ahok9SKbhQbAGlbcXNqHvtU4X1sJkLy+la2AYtWgdp17G0GjWZgk dY69bZ1O0p+P/S9Lo6Y34X3H41R4vijyNsis9wX8QmgTvLOEazGEVTwFgBQ3b5mGgu4r CV+Q== X-Gm-Message-State: AOAM531SDxC9rPZO16yiLwV8xB//NMarXllNyYSy/lIziXy853/JqcnY pWzAWIbC3Y7lZ8pcOiax5m69HA== X-Received: by 2002:a7b:c087:: with SMTP id r7mr14049213wmh.110.1615568614327; Fri, 12 Mar 2021 09:03:34 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id 1sm2854681wmj.2.2021.03.12.09.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:33 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com, Amit Daniel Kachhap , Viresh Kumar , Javi Merino , Zhang Rui , Amit Kucheria Subject: [PATCH v2 5/5] thermal/drivers/cpufreq_cooling: Remove unused list Date: Fri, 12 Mar 2021 18:03:16 +0100 Message-Id: <20210312170316.3138-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210312170316.3138-1-daniel.lezcano@linaro.org> References: <20210312170316.3138-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 --- drivers/thermal/cpufreq_cooling.c | 13 ------------- 1 file changed, 13 deletions(-) -- 2.17.1 Reviewed-by: Lukasz Luba 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);