From patchwork Sun Jan 30 21:02:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730120 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7527BC433F5 for ; Sun, 30 Jan 2022 21:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347634AbiA3VCQ (ORCPT ); Sun, 30 Jan 2022 16:02:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243746AbiA3VCQ (ORCPT ); Sun, 30 Jan 2022 16:02:16 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AEF9C06173B for ; Sun, 30 Jan 2022 13:02:16 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id m26so2577770wms.0 for ; Sun, 30 Jan 2022 13:02:16 -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:mime-version :content-transfer-encoding; bh=zgN4kboK6BDi4j8PdQgM4+rnAZo/EbE+mRU5+LkdX5I=; b=M/RIeWVvt1ILqz4YX0HR2Qt8Kvbj0WY/BF3eVcE1RalbZnfNLEy/jueZPykje3r2tw IZUwziPCwJFmd2Ch+F1gaPcrMbwfRSy7RSNjvFrkPYDFTkeZX+ZDpY/sn1LIWnYQcqJ5 zdBCfTvQVLkoGpocGrgSJ2VCHftcLvvdgY8EMhn2Q1Jq5GHHZzZVgSaoqtA3ltsQUla5 bleYRO+Qmr2irw117KzrVrBDbpy0TXNdjhADSBga3vZN0fw0KFPzb1AkBkp3YH48WlaK JXjo3mA0kTN0jx7Q8XKU+7y1WCcCdEJcEYAFuApb7GKYTLhFl5dJIgEg47LO+uEzBh1J Pm7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zgN4kboK6BDi4j8PdQgM4+rnAZo/EbE+mRU5+LkdX5I=; b=dP/THpYfExC/zaHN1MFdVj+nqgM0LsVQs7vsuymhBgVT64opynOScAGjDufFvSon9W +9ROI214581zGjJS4C0tdUL09C7kD8POATFdk1BISqxLZVuiMCpH8TqohnvQGPTfA7Y6 v76rN9n55LlS5B8xQLhaMvjRurVe0nIorOuOitlHc3owVj1rEK9HLiK/d6egLry/OuwQ FAbCGE+6KQLmtJicO8ouxFpQ6HPJ+lUquZmNwg60EA7d0eFipmHrvwXoFgMbwhGPdNPB rZjrHPtI59uHYSnJHPXECIydOQRytUDINrMkO7xm9OnOJ/iASSad4LRIhLIS1gyUSHIH ceyQ== X-Gm-Message-State: AOAM530U7T1OxIFdkcWu4x+nb0XU6EqY7ONOw+MMEWioh75g3flV6hRO i7vI8dQVh5Iy+RnpE44Y0npZkQ== X-Google-Smtp-Source: ABdhPJwnuWOR0GnzVxtJ/hx7eZAn0y6Hp7MDGqzH0Qs+meRUlepIIhnQDaIGi1drQWL04J8IJeHP2w== X-Received: by 2002:a7b:c153:: with SMTP id z19mr23962932wmi.118.1643576534603; Sun, 30 Jan 2022 13:02:14 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:13 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, Daniel Lezcano , "Rafael J. Wysocki" Subject: [PATCH v1 1/7] powercap/dtpm: Change locking scheme Date: Sun, 30 Jan 2022 22:02:03 +0100 Message-Id: <20220130210210.549877-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The different functions are all called through the dtpm_create_hierarchy() which handle the mutex. The different functions are used in this context, consequently with the lock always held. Remove all locks taken in the function and add the lock in the hierarchy creation function. Signed-off-by: Daniel Lezcano Reviewed-by: Ulf Hansson --- drivers/powercap/dtpm.c | 95 ++++++++++++----------------------------- 1 file changed, 27 insertions(+), 68 deletions(-) diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c index 414826a1509b..0b0121c37a1b 100644 --- a/drivers/powercap/dtpm.c +++ b/drivers/powercap/dtpm.c @@ -51,9 +51,7 @@ static int get_max_power_range_uw(struct powercap_zone *pcz, u64 *max_power_uw) { struct dtpm *dtpm = to_dtpm(pcz); - mutex_lock(&dtpm_lock); *max_power_uw = dtpm->power_max - dtpm->power_min; - mutex_unlock(&dtpm_lock); return 0; } @@ -83,14 +81,7 @@ static int __get_power_uw(struct dtpm *dtpm, u64 *power_uw) static int get_power_uw(struct powercap_zone *pcz, u64 *power_uw) { - struct dtpm *dtpm = to_dtpm(pcz); - int ret; - - mutex_lock(&dtpm_lock); - ret = __get_power_uw(dtpm, power_uw); - mutex_unlock(&dtpm_lock); - - return ret; + return __get_power_uw(to_dtpm(pcz), power_uw); } static void __dtpm_rebalance_weight(struct dtpm *dtpm) @@ -133,7 +124,16 @@ static void __dtpm_add_power(struct dtpm *dtpm) } } -static int __dtpm_update_power(struct dtpm *dtpm) +/** + * dtpm_update_power - Update the power on the dtpm + * @dtpm: a pointer to a dtpm structure to update + * + * Function to update the power values of the dtpm node specified in + * parameter. These new values will be propagated to the tree. + * + * Return: zero on success, -EINVAL if the values are inconsistent + */ +int dtpm_update_power(struct dtpm *dtpm) { int ret; @@ -155,26 +155,6 @@ static int __dtpm_update_power(struct dtpm *dtpm) return ret; } -/** - * dtpm_update_power - Update the power on the dtpm - * @dtpm: a pointer to a dtpm structure to update - * - * Function to update the power values of the dtpm node specified in - * parameter. These new values will be propagated to the tree. - * - * Return: zero on success, -EINVAL if the values are inconsistent - */ -int dtpm_update_power(struct dtpm *dtpm) -{ - int ret; - - mutex_lock(&dtpm_lock); - ret = __dtpm_update_power(dtpm); - mutex_unlock(&dtpm_lock); - - return ret; -} - /** * dtpm_release_zone - Cleanup when the node is released * @pcz: a pointer to a powercap_zone structure @@ -191,20 +171,14 @@ int dtpm_release_zone(struct powercap_zone *pcz) struct dtpm *dtpm = to_dtpm(pcz); struct dtpm *parent = dtpm->parent; - mutex_lock(&dtpm_lock); - - if (!list_empty(&dtpm->children)) { - mutex_unlock(&dtpm_lock); + if (!list_empty(&dtpm->children)) return -EBUSY; - } if (parent) list_del(&dtpm->sibling); __dtpm_sub_power(dtpm); - mutex_unlock(&dtpm_lock); - if (dtpm->ops) dtpm->ops->release(dtpm); @@ -216,23 +190,12 @@ int dtpm_release_zone(struct powercap_zone *pcz) return 0; } -static int __get_power_limit_uw(struct dtpm *dtpm, int cid, u64 *power_limit) -{ - *power_limit = dtpm->power_limit; - return 0; -} - static int get_power_limit_uw(struct powercap_zone *pcz, int cid, u64 *power_limit) { - struct dtpm *dtpm = to_dtpm(pcz); - int ret; - - mutex_lock(&dtpm_lock); - ret = __get_power_limit_uw(dtpm, cid, power_limit); - mutex_unlock(&dtpm_lock); - - return ret; + *power_limit = to_dtpm(pcz)->power_limit; + + return 0; } /* @@ -292,7 +255,7 @@ static int __set_power_limit_uw(struct dtpm *dtpm, int cid, u64 power_limit) ret = __set_power_limit_uw(child, cid, power); if (!ret) - ret = __get_power_limit_uw(child, cid, &power); + ret = get_power_limit_uw(&child->zone, cid, &power); if (ret) break; @@ -310,8 +273,6 @@ static int set_power_limit_uw(struct powercap_zone *pcz, struct dtpm *dtpm = to_dtpm(pcz); int ret; - mutex_lock(&dtpm_lock); - /* * Don't allow values outside of the power range previously * set when initializing the power numbers. @@ -323,8 +284,6 @@ static int set_power_limit_uw(struct powercap_zone *pcz, pr_debug("%s: power limit: %llu uW, power max: %llu uW\n", dtpm->zone.name, dtpm->power_limit, dtpm->power_max); - mutex_unlock(&dtpm_lock); - return ret; } @@ -335,11 +294,7 @@ static const char *get_constraint_name(struct powercap_zone *pcz, int cid) static int get_max_power_uw(struct powercap_zone *pcz, int id, u64 *max_power) { - struct dtpm *dtpm = to_dtpm(pcz); - - mutex_lock(&dtpm_lock); - *max_power = dtpm->power_max; - mutex_unlock(&dtpm_lock); + *max_power = to_dtpm(pcz)->power_max; return 0; } @@ -442,8 +397,6 @@ int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent) if (IS_ERR(pcz)) return PTR_ERR(pcz); - mutex_lock(&dtpm_lock); - if (parent) { list_add_tail(&dtpm->sibling, &parent->children); dtpm->parent = parent; @@ -459,8 +412,6 @@ int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent) pr_debug("Registered dtpm node '%s' / %llu-%llu uW, \n", dtpm->zone.name, dtpm->power_min, dtpm->power_max); - mutex_unlock(&dtpm_lock); - return 0; } @@ -605,8 +556,12 @@ int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table) struct device_node *np; int i, ret; - if (pct) - return -EBUSY; + mutex_lock(&dtpm_lock); + + if (pct) { + ret = -EBUSY; + goto out_unlock; + } pct = powercap_register_control_type(NULL, "dtpm", NULL); if (IS_ERR(pct)) { @@ -648,12 +603,16 @@ int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table) dtpm_subsys[i]->name, ret); } + mutex_unlock(&dtpm_lock); + return 0; out_err: powercap_unregister_control_type(pct); out_pct: pct = NULL; +out_unlock: + mutex_unlock(&dtpm_lock); return ret; } From patchwork Sun Jan 30 21:02:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730121 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9BD2C433FE for ; Sun, 30 Jan 2022 21:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356338AbiA3VCT (ORCPT ); Sun, 30 Jan 2022 16:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356297AbiA3VCS (ORCPT ); Sun, 30 Jan 2022 16:02:18 -0500 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 9283DC061714 for ; Sun, 30 Jan 2022 13:02:17 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id v123so8859106wme.2 for ; Sun, 30 Jan 2022 13:02:17 -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 :mime-version:content-transfer-encoding; bh=LuuKJA9f7YLqLdO+mCS1Ti2MxJr1lgIYr2C1PeNLK3o=; b=LbWR9zg7i3nGEVZfAWrd8y9KBE6WPoaZlzZMNezQfJDsHfPZRQQtgiktinT+/vS1eZ +UY3n/PqmpUdGOzOz5Aozq5DdIkf2+jj8Cdd63SLp/J04iN3p3mVFPSvkzqG76x72d8j tLcyE2g7Bzpmh5wcr+S1hjbV1KJ9m9fXw/Dr21UNoCBYdWEJclqzFUI7UEikNZ7lkazU leW6VN9weB8m9JEMqgXytYAJpTfamaR4Xre6JtDemJ7zB3QpCZvXRcBNVBaPBYAIiV1E 9oxcQAWa2NggJ3uSlxchQWdlRHvj4x38j/LwzqGI+y9vwYE0RCheOrbTAPx4GCTEviJx fOMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LuuKJA9f7YLqLdO+mCS1Ti2MxJr1lgIYr2C1PeNLK3o=; b=WeVSpQwx8CPAZR+o+zcQOo0t9OcNvnQQ4L6A70IpOPMi8zaTqMvaZxoUaUF5JLOPoF TN0B02s2jv3XzVxAA+pKpiF2HNYpt4KIEcO6M01ml4rGSP9Jhm+LqmpKNWZuGBmXCph4 Odtix05P8VO60yKEhCpthGJ25CORxpSA7Iwk676xRJKk6Ie4kSEcv57fs6zdwVbY7+MG 2EwKxqRiobC2V1pAetWBpyd2fLoG1LuuNJTqdpKAVOPQab4n6YjWIl0HEN5GXoThdkdC O3CcWkX4FJkn8H+zPL8QzVtwunzx2jKY0FiaDe+DE2IBQqJywCO7P5qZ1+NJgqfLEfF9 enLg== X-Gm-Message-State: AOAM532Zv+NXRkFNvwmKfLfXYlVVAuRpXlZbPzl7J2HW3HyfD7ABDcHv K22q+hsrTcKxyPlzCJOtU+2zuQ== X-Google-Smtp-Source: ABdhPJyWDx9xdG/aa6AnVmD8qw4WCzO4tJnIyuqpp5B3OJMmIPBunA3OFRRAHgysZmgFcQTbJRShXg== X-Received: by 2002:a05:600c:3494:: with SMTP id a20mr16200921wmq.129.1643576536119; Sun, 30 Jan 2022 13:02:16 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:15 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, Daniel Lezcano , "Rafael J. Wysocki" Subject: [PATCH v1 2/7] powercap/dtpm_cpu: Reset per_cpu variable in the release function Date: Sun, 30 Jan 2022 22:02:04 +0100 Message-Id: <20220130210210.549877-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130210210.549877-1-daniel.lezcano@linaro.org> References: <20220130210210.549877-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The release function does not reset the per cpu variable when it is called. That will prevent creation again as the variable will be already from the previous creation. Fix it by resetting them. Signed-off-by: Daniel Lezcano Reviewed-by: Ulf Hansson --- drivers/powercap/dtpm_cpu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c index eed5ad688d46..71f45d2f5a60 100644 --- a/drivers/powercap/dtpm_cpu.c +++ b/drivers/powercap/dtpm_cpu.c @@ -151,10 +151,17 @@ static int update_pd_power_uw(struct dtpm *dtpm) static void pd_release(struct dtpm *dtpm) { struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm); + struct cpufreq_policy *policy; if (freq_qos_request_active(&dtpm_cpu->qos_req)) freq_qos_remove_request(&dtpm_cpu->qos_req); + policy = cpufreq_cpu_get(dtpm_cpu->cpu); + if (policy) { + for_each_cpu(dtpm_cpu->cpu, policy->related_cpus) + per_cpu(dtpm_per_cpu, dtpm_cpu->cpu) = NULL; + } + kfree(dtpm_cpu); } From patchwork Sun Jan 30 21:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730122 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C39FC433F5 for ; Sun, 30 Jan 2022 21:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356336AbiA3VCT (ORCPT ); Sun, 30 Jan 2022 16:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356342AbiA3VCT (ORCPT ); Sun, 30 Jan 2022 16:02:19 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C18EC06173B for ; Sun, 30 Jan 2022 13:02:19 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id k18so21619269wrg.11 for ; Sun, 30 Jan 2022 13:02:19 -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 :mime-version:content-transfer-encoding; bh=Ur09E2BAlQbHBoQW12ExIyAlHsPuIZyNSXmQmRscxHA=; b=uWIG+K0iME4rkTZkYIgbY/4+Hof+QfUMh3mg5kMss2eZstXyZG1tM3uSYXzcIu0TST 23KujVjT3bt3WCHwDFArIheZTGDbxKjouuIWjUKxpinYqP4gGaoIii4UfW6G7EUsG8Dt fstHaN/XVoYXffyG9HeWlE4kzWkdXt6HZDDxe25qvJ18fyw9rBUmnHAlZU9FX5q85cdq oAmz3x3nBdGfpeaqw1Xvc4jheNHhb/GuGD4AX3FgvVkAnRZ9YNdN5EcmXrA3OtMqKjcP AmXil7+1fHGKy5eLrkF8wsawIOKLY9sYDz1Zd/EvDcm+ngOUJZretssOOEP/x6h6F8DG hmEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ur09E2BAlQbHBoQW12ExIyAlHsPuIZyNSXmQmRscxHA=; b=XzdJfvwsfJrHZwy5WAjnwgdS/qvWUzbKX5LqySguTKRZRE0rP+r/eMPE9/sqMzjNP0 uWCpBpm4075N32fK1cHhi2S+uINeTm8wz5HtyC/XrqRi46AVvmuzo2+03Sp3quLlJapi 28ZcWeswENoCkuiWfIB4Tvj1SHz5wcvetN/BVe9GetBbbbIDXVqG8AZ0Hi9zPgYnZaUF Q4HaA/gnmu+yXf39U7p4niqzamejsf5cYLIO6/P73ahp84ZrP7mtNCnU2VHYjrCeHoM/ lklfTX8RbZ9VFr+q0SI+Br0I6QJzOO/Qw4bNYYbfdP9C46GD+dLyd8IBzofTeJZH8zPp ZSDg== X-Gm-Message-State: AOAM531CTYBnDsvsjHkjEbviv0KpFHw3nHgE7jYaNZtgyd4+Ytm3FF4k 7jZdK/Z5tyz//q1vrQrhHHCVuQ== X-Google-Smtp-Source: ABdhPJwC78R0INZHCPq73eDSe/F+I905pCVnyo0D0UxRSUWb5HkQMAacwtObO31ze84S9e+T4zW44w== X-Received: by 2002:a05:6000:388:: with SMTP id u8mr14483475wrf.688.1643576537727; Sun, 30 Jan 2022 13:02:17 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:17 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, Daniel Lezcano , "Rafael J. Wysocki" Subject: [PATCH v1 3/7] powercap/dtpm: Fixup kfree for virtual node Date: Sun, 30 Jan 2022 22:02:05 +0100 Message-Id: <20220130210210.549877-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130210210.549877-1-daniel.lezcano@linaro.org> References: <20220130210210.549877-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When the node is virtual there is no release function associated which can free the memory. Free the memory when no 'ops' exists. Signed-off-by: Daniel Lezcano --- drivers/powercap/dtpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c index 0b0121c37a1b..7bddd25a6767 100644 --- a/drivers/powercap/dtpm.c +++ b/drivers/powercap/dtpm.c @@ -181,12 +181,12 @@ int dtpm_release_zone(struct powercap_zone *pcz) if (dtpm->ops) dtpm->ops->release(dtpm); + else + kfree(dtpm); if (root == dtpm) root = NULL; - kfree(dtpm); - return 0; } From patchwork Sun Jan 30 21:02:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730123 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B2AAC4332F for ; Sun, 30 Jan 2022 21:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232758AbiA3VCW (ORCPT ); Sun, 30 Jan 2022 16:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbiA3VCV (ORCPT ); Sun, 30 Jan 2022 16:02:21 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C964BC06173D for ; Sun, 30 Jan 2022 13:02:20 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id l12-20020a7bc34c000000b003467c58cbdfso12323871wmj.2 for ; Sun, 30 Jan 2022 13:02:20 -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 :mime-version:content-transfer-encoding; bh=ithO/SYTnsee84comcLV1v8xrhItpMkDguw8atTZK/s=; b=pzxLkgSIDPizAvQzi/Z4rkcv9NnVAZUlnC7Xguxppjx+JOs1+blnWBzFAo0bW7wBHD GFNugIclNSwYRf11usjqo2OzHfSV7n2X4wFnXFSedyzuMtuJB4l5ZXUAK8RjG5GJjSgf UwnjgCRbYNvbDyetKo4KgomsuMyzmWzHgu8NUcXWtOwc8TWNQoteXKvp6WFTuQW8rTyJ o2J05bnnBwrWi4CtNhzNEH+lTYMaFOWsINcikp1i74eITClupp1F2bCXZqGs3PsL1EDm PxIaJBtt1BSVcZNUW2XiKie4EbS44JX0HDR071hB30F0QpOf+TMHLXA2l665kTYZwaeI VrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ithO/SYTnsee84comcLV1v8xrhItpMkDguw8atTZK/s=; b=ymqyixyFt3HQEXRwQMrryr9Mb28lXHU1sO7ww98Q61a87vyNRkj7tMYUsGkYrWUj7W brqyi3GHX4Y864Mja6K+j7omYiICw7I7UhQoEAjWTmmxOXoA9QLRPRsYEExbXIHkBepp p/oqimSirV0KfYW6eta2cIX0OlAFz/UvflDab2EqapR01pPfb6qdPWx3zGuBaFWJZxvN gyxDpHXn6sbnUJSl2C7n47xcYNzYj3anGai6f+95bNlvtVS1KVu5X43O2JtMhAhBGQPv 1nh31/O7kYVMgt2a9201hsZHBklUSLgZc2TEZRCjVYFH/o9liuO5Q5iBMAq481dKAtN7 JUBQ== X-Gm-Message-State: AOAM530ozB36l3NVF3zGi2na09cxKor5F03Kr/lz2Noq9WLx93lFCe97 SbbTdcp7Jb3UoM2ax3nLPkM1bg== X-Google-Smtp-Source: ABdhPJzQBkb2Ykpl/FUs+I+2wd7ewr2SsnlQsLiH22Tebb5rc9YByWShua6Tl+JcrGciTh/6avWD5A== X-Received: by 2002:a05:600c:694:: with SMTP id a20mr15648018wmn.186.1643576539319; Sun, 30 Jan 2022 13:02:19 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:18 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, Daniel Lezcano , "Rafael J. Wysocki" Subject: [PATCH v1 4/7] powercap/dtpm: Destroy hierarchy function Date: Sun, 30 Jan 2022 22:02:06 +0100 Message-Id: <20220130210210.549877-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130210210.549877-1-daniel.lezcano@linaro.org> References: <20220130210210.549877-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The hierarchy creation function exits but without a destroy hierarchy function. Due to that, the modules creating the hierarchy can not be unloaded properly because they don't have an exit callback. Provide the dtpm_destroy_hierarchy() function to remove the previously created hierarchy. The function relies on all the release mechanisms implemented by the underlying powercap framework. Signed-off-by: Daniel Lezcano Reviewed-by: Ulf Hansson --- drivers/powercap/dtpm.c | 43 +++++++++++++++++++++++++++++++++++++++++ include/linux/dtpm.h | 3 +++ 2 files changed, 46 insertions(+) diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c index 7bddd25a6767..d9d74f981118 100644 --- a/drivers/powercap/dtpm.c +++ b/drivers/powercap/dtpm.c @@ -617,3 +617,46 @@ int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table) return ret; } EXPORT_SYMBOL_GPL(dtpm_create_hierarchy); + +static void __dtpm_destroy_hierarchy(struct dtpm *dtpm) +{ + struct dtpm *child, *aux; + + list_for_each_entry_safe(child, aux, &dtpm->children, sibling) + __dtpm_destroy_hierarchy(child); + + /* + * At this point, we know all children were removed from the + * recursive call before + */ + dtpm_unregister(dtpm); +} + +void dtpm_destroy_hierarchy(void) +{ + int i; + + mutex_lock(&dtpm_lock); + + if (!pct) + goto out_unlock; + + __dtpm_destroy_hierarchy(root); + + + for (i = 0; i < ARRAY_SIZE(dtpm_subsys); i++) { + + if (!dtpm_subsys[i]->exit) + continue; + + dtpm_subsys[i]->exit(); + } + + powercap_unregister_control_type(pct); + + pct = NULL; + +out_unlock: + mutex_unlock(&dtpm_lock); +} +EXPORT_SYMBOL_GPL(dtpm_destroy_hierarchy); diff --git a/include/linux/dtpm.h b/include/linux/dtpm.h index f7a25c70dd4c..a4a13514b730 100644 --- a/include/linux/dtpm.h +++ b/include/linux/dtpm.h @@ -37,6 +37,7 @@ struct device_node; struct dtpm_subsys_ops { const char *name; int (*init)(void); + void (*exit)(void); int (*setup)(struct dtpm *, struct device_node *); }; @@ -67,4 +68,6 @@ void dtpm_unregister(struct dtpm *dtpm); int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent); int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table); + +void dtpm_destroy_hierarchy(void); #endif From patchwork Sun Jan 30 21:02:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730124 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7E13C433FE for ; Sun, 30 Jan 2022 21:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356361AbiA3VCX (ORCPT ); Sun, 30 Jan 2022 16:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbiA3VCW (ORCPT ); Sun, 30 Jan 2022 16:02:22 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5328BC06173B for ; Sun, 30 Jan 2022 13:02:22 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id c2so8846362wml.1 for ; Sun, 30 Jan 2022 13:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PRlA2mW2VZ0B7IKeYTrrJglGZpUD87Qspht3pCuXF60=; b=s4poMru3W116uAHW4cFJKcEjX0Hw2P5QiUgwieczodybEcf5nPtZA4OeDuqaZB/w70 UBwKIaSVwXslwXVnrDGe7vX2uRfHVpSgpDhO4wjSNaemdgLOfUyNFYaOHSR5MobInWyj Cz1jEIoO1mqVobQWHbWauKgvvs4uud+9fQkuNmT7E6FEdswU8XUqph0qDK1N6HI30at4 ZCFaVWYmJpYV8Qe4sQIWbGhCrA/QbOQzAP+mcqdeBlt5gClWAb38xsAz+vr3mqgVUWe7 hXFMOdq/MUMj5kbSfwF4lB9bxp5Anzpglq/eeKibWaiB1RVPJr4PSfnp6q5X/rK06z05 A7Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PRlA2mW2VZ0B7IKeYTrrJglGZpUD87Qspht3pCuXF60=; b=SWfqBMdyExO7sDJqHzYFKQz1tbojo5W20Kk7swYEUNi8o3wFz+7dzVgD2kqA0y1NmL T0PhT/ntI7lhiq7rv86Yj6/Qu4o6qG5JyvsE9SDafwr6CY2NSOwlNsJ6fI1aujy5WUma yTCgGoGbqw4Wdafed9l77I6zKeIlic66o2njEPNnS7txFx863VqCENhbFzKBvAYIf8tR 0Dzd0vSJ3sZyPF7syyatfKlkUIBFlZkZWRPQNy1lNgPpgbEyVoc/ne8En82woTwaY65I 0ASRBXY+nNtmFZXFD+WT6/EbYYB1TY91WwGGzfJDLYSV52f7pY1UYDfhQo0jGNKjKQxF wzcw== X-Gm-Message-State: AOAM531RAMj5dllxme0rusqAb3GL24RbRgSvbdK1Nbqc0ds/uvVF50ek G5YUI2XzbQfSUpNhA7zZPOyV/A== X-Google-Smtp-Source: ABdhPJyms0o/aq6IjOZs+4GOCYsm+xmkn2HDMprqxPuL3cCmBVwz3Tog10rmEdQ5oe57II3F/ow6mQ== X-Received: by 2002:a05:600c:4808:: with SMTP id i8mr7723214wmo.23.1643576540890; Sun, 30 Jan 2022 13:02:20 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:20 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, Daniel Lezcano , "Rafael J. Wysocki" Subject: [PATCH v1 5/7] powercap/dtpm: Move the 'root' reset place Date: Sun, 30 Jan 2022 22:02:07 +0100 Message-Id: <20220130210210.549877-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130210210.549877-1-daniel.lezcano@linaro.org> References: <20220130210210.549877-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The 'root' node is checked everytime a dtpm node is destroyed. When we reach the end of the hierarchy destruction function, we can unconditionnaly set the 'root' node to NULL again. Signed-off-by: Daniel Lezcano Reviewed-by: Ulf Hansson --- drivers/powercap/dtpm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c index d9d74f981118..ec931a06d90a 100644 --- a/drivers/powercap/dtpm.c +++ b/drivers/powercap/dtpm.c @@ -184,9 +184,6 @@ int dtpm_release_zone(struct powercap_zone *pcz) else kfree(dtpm); - if (root == dtpm) - root = NULL; - return 0; } @@ -656,6 +653,8 @@ void dtpm_destroy_hierarchy(void) pct = NULL; + root = NULL; + out_unlock: mutex_unlock(&dtpm_lock); } From patchwork Sun Jan 30 21:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730125 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7433C433EF for ; Sun, 30 Jan 2022 21:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356376AbiA3VCZ (ORCPT ); Sun, 30 Jan 2022 16:02:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356380AbiA3VCY (ORCPT ); Sun, 30 Jan 2022 16:02:24 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A03C06173B for ; Sun, 30 Jan 2022 13:02:24 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id n8so8851542wmk.3 for ; Sun, 30 Jan 2022 13:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8cWPqnuW+Zg66Vr4iSn8qLu3H5+h06l8a0hGtLAknWg=; b=cZHZhTccn2hbg7ktHjSg0CRhqTvQxcDiHYXdlm01ktRZK8oCI1whTseKVOZOoR4Ihh dV1GSFlK5GzLq5dS7UlrCW9X/hpdVjSYzQi9mvSrwJQ+82KfpcY5z2X12VSEBc8vcDD9 mhXmdAg39mrkV6G/b3Sy1eosrkLL8iduggMPakIdbFvSuvU39x+wauek4P7KYKkcxizk SyyFFnInW5uXarWujd+Fg+eR99Vv0CyDYDgmHKjyC1kU0qPFkFn8d0OtJtHnpTiwuU6u solUKUvj2FipgkX3A1MfRxHbjuDPo0v3GgbL5N3MociQ75/lRCyhwc6Zwb334j5OmogE Yp9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8cWPqnuW+Zg66Vr4iSn8qLu3H5+h06l8a0hGtLAknWg=; b=lvdx6rgVHc9kIvzwoPL7NwgQPJRn1nOvcdLgQSzWgcX6zNqducRbF6zT3qmTAv5t0S oFlfifOMlC2Y7ft0uVyD+qVnQvCFGWCrhgKzwppioyOHZT6cNckGZxnpQy1oercF1+hU SA0IBZH2Z2Td7f4fPwgipS70XfNsN2Uu2RkrFi4L/MbSWZ7ZtUkhb7Xnrbjkv/7KEv05 x1mXIScOn1HNlXWN+HM6PfVt6sYIuLxpwXOrFVVjSJorCZx6jbYU77y4Sy2yQzaf002N GIBWdQvkcBxc9x/BLYHOmwW09kTWhY7C1e6ZDACasrvX6W5jDpxxB1oNtP+AMB1BpMN4 z89w== X-Gm-Message-State: AOAM531Bn0PUGUE49bLVn9PeY+0bWKhTJZG5vwxSHSMHG7Hk4fX3GKZw +ujUxYw9KRJtwpTQLt3MD0jJ3A== X-Google-Smtp-Source: ABdhPJzwUtuKgb1uWNz9UUnzE+Fi7SoOUIyGplaM3rWp/eKpXB/QwTP2IUG3LBsNy98m1QCKnIS43w== X-Received: by 2002:a05:600c:2251:: with SMTP id a17mr24622958wmm.102.1643576542485; Sun, 30 Jan 2022 13:02:22 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:21 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, Daniel Lezcano , "Rafael J. Wysocki" Subject: [PATCH v1 6/7] powercap/dtpm/dtpm_cpu: Add exit function Date: Sun, 30 Jan 2022 22:02:08 +0100 Message-Id: <20220130210210.549877-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130210210.549877-1-daniel.lezcano@linaro.org> References: <20220130210210.549877-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that we can destroy the hierarchy, the code must remove what it had put in place at the creation. In our case, the cpu hotplug callbacks. Signed-off-by: Daniel Lezcano Reviewed-by: Ulf Hansson --- drivers/powercap/dtpm_cpu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c index 71f45d2f5a60..bca2f912d349 100644 --- a/drivers/powercap/dtpm_cpu.c +++ b/drivers/powercap/dtpm_cpu.c @@ -299,8 +299,15 @@ static int dtpm_cpu_init(void) return 0; } +static void dtpm_cpu_exit(void) +{ + cpuhp_remove_state_nocalls(CPUHP_AP_ONLINE_DYN); + cpuhp_remove_state_nocalls(CPUHP_AP_DTPM_CPU_DEAD); +} + struct dtpm_subsys_ops dtpm_cpu_ops = { .name = KBUILD_MODNAME, .init = dtpm_cpu_init, + .exit = dtpm_cpu_exit, .setup = dtpm_cpu_setup, }; From patchwork Sun Jan 30 21:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12730126 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02329C433F5 for ; Sun, 30 Jan 2022 21:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356436AbiA3VCe (ORCPT ); Sun, 30 Jan 2022 16:02:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356391AbiA3VC1 (ORCPT ); Sun, 30 Jan 2022 16:02:27 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06291C06173B for ; Sun, 30 Jan 2022 13:02:27 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id c23so21621780wrb.5 for ; Sun, 30 Jan 2022 13:02:26 -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 :mime-version:content-transfer-encoding; bh=MNQUuQFFfpeWugiolZqopaG6OtAWAYvBDQU1DSusnnk=; b=kHh6+rnAfh1UicGsC+iJz9NJQum0K2Cxfwo4EqwieSebI9JjCzku9c+/47G38UUuuS OMZ9UMlxqVkK1n1TuEvSgEESwt2BSbn2IfkLx4Rc8qxW9NOrdgJ/bSED5jAOrNXM3EtJ lTZLyHJEufuRQdpYbgHsGC8Ts4qncbAug9thUjRUm2n0kk/1iO4QT3pUHZVbWtTF7hIf /HnMPGBos/MHr+Zx2okCr8mjdtkGr2cy7Akp+A1jIHwsnaGDpwFnEo6zggRlT1jKt4Y1 wFfs6rICskTLjQE2VCdu021HMul+hsBRy6s8mvrCRO4+hvrbUvoTzDAcYnaM8XTEJsAq 7k/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MNQUuQFFfpeWugiolZqopaG6OtAWAYvBDQU1DSusnnk=; b=GdUYOTvH4htj24MXmqnJH65RvyHfIaTHM0WF0o2sUI+5O32l89iyaD9zpa51FwxAu/ 89N3DoBm9lkSco82kCJYNO+kK8QIM2TKIy7WC7FeS+45Sv7xYJVNTk2TtPw93yI8iDlW 0evg1ueegqaju+QK8hqTENU64lB2lJcrWyQsyhbcVT27RZ7plcgdGLDGEhKsEaj8AD1d SibpJm4qA+JOKI9DBeX4CO1utiAYpJsf1fD6J6CDlMmWowieEXN+9fuO3kpfhXgUa3ub 8P9TnuK0fBZJerFOiGVEsU7yJ/GkoTuj3UohF49l/zyHpHPsc5h+o+nYNRNH2vQqEn/z 1QqQ== X-Gm-Message-State: AOAM532xt8/XYYpgM3/ni2shifym1LdVmETm7+2npmEI1O8ocy1lgTdt 6orpHAY8aCYJtZTfClnoKZxeNw== X-Google-Smtp-Source: ABdhPJwnWuziiq1f4PdtrcCYU1OtKdjwSfYjmTBoTDV76XQcm47JlfCtRFtPAz9INT1cD5L8qeIjoQ== X-Received: by 2002:adf:fe01:: with SMTP id n1mr15207083wrr.141.1643576545483; Sun, 30 Jan 2022 13:02:25 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:d3c5:fe0:78a4:5227]) by smtp.gmail.com with ESMTPSA id i6sm9845185wrw.8.2022.01.30.13.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 13:02:24 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rjw@rjwysocki.net Cc: heiko@sntech.de, lukasz.luba@arm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ulf.hansson@linaro.org, linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support) Subject: [PATCH v1 7/7] dtpm/soc/rk3399: Add the ability to unload the module Date: Sun, 30 Jan 2022 22:02:09 +0100 Message-Id: <20220130210210.549877-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220130210210.549877-1-daniel.lezcano@linaro.org> References: <20220130210210.549877-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The dtpm hierarchy can now be removed with the dtpm_destroy_hierarchy() function. Add the module_exit() callback so the module can be unloaded by removing the previously created hierarchy. Signed-off-by: Daniel Lezcano Reviewed-by: Ulf Hansson --- drivers/soc/rockchip/dtpm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/rockchip/dtpm.c b/drivers/soc/rockchip/dtpm.c index ebebb748488b..5a23784b5221 100644 --- a/drivers/soc/rockchip/dtpm.c +++ b/drivers/soc/rockchip/dtpm.c @@ -52,6 +52,12 @@ static int __init rockchip_dtpm_init(void) } module_init(rockchip_dtpm_init); +static void __exit rockchip_dtpm_exit(void) +{ + return dtpm_destroy_hierarchy(); +} +module_exit(rockchip_dtpm_exit); + MODULE_SOFTDEP("pre: panfrost cpufreq-dt"); MODULE_DESCRIPTION("Rockchip DTPM driver"); MODULE_LICENSE("GPL");