From patchwork Thu Feb 28 04:10:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 159307 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp180117jad; Wed, 27 Feb 2019 20:10:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IbU/4/pJrke4W51bP1PBNLASYxh4fwpRzv9XYGWRoP0ZlmQRmvaLOr4PtouOtTbHTTNfl1E X-Received: by 2002:a17:902:44c:: with SMTP id 70mr5918409ple.318.1551327039920; Wed, 27 Feb 2019 20:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551327039; cv=none; d=google.com; s=arc-20160816; b=SbcerRmNR4GHlsZPPXMv5xEoSaw4ufpufd6fkpcIj8dQVjWD2D1VMnpDB4/pTSJPbS tZu2NkVNNPc2T5k6KTih4Dzq9/mpvwElS4zFEn09lifqs5TiDPaSs1rI6cfYt8cC10f7 Ws+WXvvSVJXnpNalUHh9cYmGVOyLNztpYAKK0NfWykkt/Y+BVSF4VNPGbxVEPqpcl8f2 x9nu+5ZqLn5lSUmzhaso61Os6nU/VyNZE+brZPAI/HCv62TsJPXdW8UODg/E6TK3OJPZ WqZBvfwfS8oLIVNWqmDIyUiafUoZzPHfIgSU4p1yryAvm/KprmK3AyhJRBCM0dkW9FSB aIFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tur0iSlfcnlVrz49pmZ+o4WEGS0vT8E32Az/XwHIWGg=; b=OANl3r1lwCZlnnNaGwU3G5hTgH0uG79Z0VLcKCoIOn0I3E/1FvFEYa1n/CGNTFTbev oQRAAkFYk76KQGZO0eCp5eAcfTC0im/PfmHMT5HvdUeSu5krOqQPiGJHbF7+5WUKcU2m Bljfz5Og8do0qTUuAYkwoaoBfyYOU+jDgmeoKHQmdvoZvjcbPQ8XHr7S4HF7e56X/nJS HbGUe4drh64Cjb4VAgYneO28UVJCozhFK/gd1WZcpfLxTiNcDY59d+WKleM/9ZPMAIKs HTN5uH3t5jqApgZxwg6xIcyM4nL78+STzrThEfYV7OCi6LYYBMpotmzBzK+nrJ5qp8wr uFCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M+mu7NZN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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. [209.132.180.67]) by mx.google.com with ESMTP id 30si17138102plb.161.2019.02.27.20.10.39; Wed, 27 Feb 2019 20:10:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M+mu7NZN; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1730706AbfB1EKi (ORCPT + 14 others); Wed, 27 Feb 2019 23:10:38 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45605 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730679AbfB1EKi (ORCPT ); Wed, 27 Feb 2019 23:10:38 -0500 Received: by mail-pl1-f194.google.com with SMTP id r14so9057436pls.12 for ; Wed, 27 Feb 2019 20:10:38 -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=tur0iSlfcnlVrz49pmZ+o4WEGS0vT8E32Az/XwHIWGg=; b=M+mu7NZN0r2R8EBTQ9KSztb1up1Hr/dgvOWV2Ca+GMdoo3BwvOAXz7PnsUD5gMQqC3 aNmTG4A7KOwF9v+aVvbIuVWVb6rjJwFIZWO7JsjUNGTxmGOp+Xv4pFt3+k/61LTvkYb0 sm0SVZIdlQj2FY/0943ewJRRtDAP5S6oVPkiNj8SZSMHh6idap49bgf7jeHf89OPzyQr BMEGl/ZqXTbClSkmrEXNx7Lt4rQuT0imPpfKbVllggwHZAXzDV7eD6rSMED4etX7/+3X fe/6ZBUT/JW+T7pDI7/JTdBsucqlvXIS6/QrGpLF0ExAOyuiJDEMi+2oB8MnXeJVIrJS 1GGA== 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:mime-version:content-transfer-encoding; bh=tur0iSlfcnlVrz49pmZ+o4WEGS0vT8E32Az/XwHIWGg=; b=MiBEK2ZduQSEWKJ+zAkyFI2aDnOXaHJ1qFle7lEfvRhDkhITpT0ivo7Dgc9lFDls0o Ejo0kRpufjdBjyu7Bl2skoKf/JwecOM6Fps1Nih9vI6uRgKwYx4VvR4Avxytsym5oaPR oDj1bSBrZrQWH9hAQ9p4hNjmbYes5UxsHblUsUXo4wL5fXgDUOvEbWTkprzg7Um3wPnz REslnVKuZBxSP9QfzahwPI9gR28vqOAC+7xXcBS256sNV3Vt+e58PgvwFK6SpA5+pTkJ S3GmRrPBS4m0K/PQXKQvJSO17XEwXQE3VS6qRTgBwEyV6bdPOY25OD2uGP/89BtjwCOU mghg== X-Gm-Message-State: AHQUAuaT1TqXI/wzmr/byDPSMz4e8KbgN8KEMK8kJ/KK2nlCsRkN5j9o YG0YvrEQ/TFIAnft3Zd7Nwq8/A== X-Received: by 2002:a17:902:4081:: with SMTP id c1mr5873349pld.297.1551327037557; Wed, 27 Feb 2019 20:10:37 -0800 (PST) Received: from localhost ([122.167.168.92]) by smtp.gmail.com with ESMTPSA id b70sm28606804pfm.6.2019.02.27.20.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 20:10:35 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ilia Lin Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Arnd Bergmann , amit.kucheria@linaro.org, georgi.djakov@linaro.org, "4 . 18+" , linux-kernel@vger.kernel.org Subject: [PATCH V3] cpufreq: kryo: Release OPP tables on module removal Date: Thu, 28 Feb 2019 09:40:12 +0530 Message-Id: <0334906c06967142c8805fbe88acf787f65d3d26.1551326937.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: <78f96969448b17e95b0b21cb78194bb9f709a897.1551261748.git.viresh.kumar@linaro.org> References: <78f96969448b17e95b0b21cb78194bb9f709a897.1551261748.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit 5ad7346b4ae2 ("cpufreq: kryo: Add module remove and exit") made it possible to build the kryo cpufreq driver as a module, but it failed to release all the resources, i.e. OPP tables, when the module is unloaded. This patch fixes it by releasing the OPP tables, by calling dev_pm_opp_put_supported_hw() for them, from the qcom_cpufreq_kryo_remove() routine. The array of pointers to the OPP tables is also allocated dynamically now in qcom_cpufreq_kryo_probe(), as the pointers will be required while releasing the resources. Compile tested only. Cc: 4.18+ # v4.18+ Fixes: 5ad7346b4ae2 ("cpufreq: kryo: Add module remove and exit") Reviewed-by: Georgi Djakov Signed-off-by: Viresh Kumar --- V2->V3: - s/kyro/kryo/ - s/unsigned/unsigned int/ - Added Reviewed-by tag drivers/cpufreq/qcom-cpufreq-kryo.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c index 2a3675c24032..a472b814058f 100644 --- a/drivers/cpufreq/qcom-cpufreq-kryo.c +++ b/drivers/cpufreq/qcom-cpufreq-kryo.c @@ -75,7 +75,7 @@ static enum _msm8996_version qcom_cpufreq_kryo_get_msm_id(void) static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) { - struct opp_table *opp_tables[NR_CPUS] = {0}; + struct opp_table **opp_tables; enum _msm8996_version msm8996_version; struct nvmem_cell *speedbin_nvmem; struct device_node *np; @@ -133,6 +133,10 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) } kfree(speedbin); + opp_tables = kcalloc(num_possible_cpus(), sizeof(*opp_tables), GFP_KERNEL); + if (!opp_tables) + return -ENOMEM; + for_each_possible_cpu(cpu) { cpu_dev = get_cpu_device(cpu); if (NULL == cpu_dev) { @@ -151,8 +155,10 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0); - if (!IS_ERR(cpufreq_dt_pdev)) + if (!IS_ERR(cpufreq_dt_pdev)) { + platform_set_drvdata(pdev, opp_tables); return 0; + } ret = PTR_ERR(cpufreq_dt_pdev); dev_err(cpu_dev, "Failed to register platform device\n"); @@ -163,13 +169,23 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) break; dev_pm_opp_put_supported_hw(opp_tables[cpu]); } + kfree(opp_tables); return ret; } static int qcom_cpufreq_kryo_remove(struct platform_device *pdev) { + struct opp_table **opp_tables = platform_get_drvdata(pdev); + unsigned int cpu; + platform_device_unregister(cpufreq_dt_pdev); + + for_each_possible_cpu(cpu) + dev_pm_opp_put_supported_hw(opp_tables[cpu]); + + kfree(opp_tables); + return 0; }