From patchwork Wed Feb 27 10:04:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 159279 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4231945jad; Wed, 27 Feb 2019 02:04:48 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaf49fwLUC9Ik2aS7Hi1or5QpmLpJt1/LrsPWyZyUbGpcGgGOqMQoC6XvlDmddQl8qTon8i X-Received: by 2002:a63:4e57:: with SMTP id o23mr733961pgl.368.1551261888753; Wed, 27 Feb 2019 02:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551261888; cv=none; d=google.com; s=arc-20160816; b=Fg95Osd7gRFXrrH8QdduqpoxcrNnYsI3wx1H+Rd8cYXfVfRg66FtcmXju8IXRIOUSM 1iSKJsH3bjoTVEFSIZr7S52QCd92lGXgPPEdb2ihlbujcEcDvf42NYLmwuIkrzsZxj2+ Ngzw7K6rfY1AwOnWHL3bsMKD9XQ2SX5N1rPY+0Tp68BDSWiBv4beLBZt3/wxIJWzhILm 76KYzbY2evtzFc8XLk/suVq7JsBMJavPQNlOTBuvbXJj9Y2U+YbSzv9CkCaq6fPpOS0N Sa+2UM+OTCIOhSJBOP6bhoQKY4F/JA/EAsuzJu9Filmvq+E6tg7A8MO4hAV7LnB6FO3X fRHA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Zg0+GNn7Z6P9rpnhFL7IPuLh6JHfTMBGrvRxKokx2eg=; b=XZoVnBl0+d1cNe7zNit1i0s3rfR3pFbur7K/7HO/dnj25raGCz1xocJWHaf0joJWJP YaM/DJCXHDwRZrjt2aX1V0jCYb6cDjhxlP3aS9MH3REcZX2qmf24c3MWNWLcKNRDoJSo CUh48UuO2jXzECFPAchga0BoiNM/pd8LY2YbaZ6hGuC3G2oSJ5hsml98kAbZaWT4XiE0 DX98OUp+n/JI7F7WZTKApywNy+7FOV6ELAFH5MvfTkw5EJGAd5NbBYAZ/EF197Eeb3q8 7cQ+k/wjsIijGHMqErtnV2tk9rw2jC7fc4GXUDIsYyKBMjv1GZV+MAI7iDO/3dWYplWV 8JrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DoIancko; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l70si14461648pgd.470.2019.02.27.02.04.48; Wed, 27 Feb 2019 02:04:48 -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=DoIancko; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbfB0KEs (ORCPT + 14 others); Wed, 27 Feb 2019 05:04:48 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43076 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725983AbfB0KEr (ORCPT ); Wed, 27 Feb 2019 05:04:47 -0500 Received: by mail-pl1-f193.google.com with SMTP id m10so7758858plt.10 for ; Wed, 27 Feb 2019 02:04:47 -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=Zg0+GNn7Z6P9rpnhFL7IPuLh6JHfTMBGrvRxKokx2eg=; b=DoIanckoA0erRA0PrlnqWrq/AlZ2MR2T5dT4KJ1uwAxKjqAMMvCAyXZgqOa39Q8+Ku wvLF37wKlTMWykM2z8Mdizume3X79EjM7DYWseNCBbAQ7BsS4TANbBOP+QuQyl5D780R x1HWQlaa5kYCfd0PtTumQPUZR25ew2mWxJzfXIggKYBe+pxVIrsdZVHsVbfJS6hNR7kg KwCiH8y8ftEsxYCtv6OmgAm5BnERmJKSRLkCpdvAOI9DejMKEflD6pHCAupWfxfFR55A /ijfJbTbv79fGyZz9RoX4BDkqhB12vmRtCo4KUrydywmEHjkkjxOMggKpPLHkzqo0P6y NpPw== 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:mime-version :content-transfer-encoding; bh=Zg0+GNn7Z6P9rpnhFL7IPuLh6JHfTMBGrvRxKokx2eg=; b=OodMcSX7+/zhuW8g4ALRvi62g3z8W8zLjFRajKqYb1n0gcAN/JaphjulrvZiw/dNtx M/8qwQoeldi89u/oeE3CAjV/krrxhvqAtWdqsLamJkYjsxHlCzJDJNWULTisok7FJ9J1 bPNS96/aSWlaTMIDdI5u0TXwLZ8uxGySu+ZlivIe4Zub7+B+vKS7pzS5ZOUrC1rkicXl zQeTY+21Pz7V/qodzOselQpabW0l/sYgviWgj7BtqeMZRRY1CbHRHo2esRSVs6TV/osI qUPwST5oivu88J2xqjq9FC+2ieW4Ok1RfSVUuE7MI4DVfSnz1PMJZ66tFhDmrNyBuLh4 /YyA== X-Gm-Message-State: AHQUAubw9EOqg1SIVJRYr2Ou3p2dfN2sXdmUiI2KVtOrKAKf7KxSAh+/ UCeYIn723TapYBUbrGwBeQs6cg== X-Received: by 2002:a17:902:8690:: with SMTP id g16mr1285258plo.284.1551261886367; Wed, 27 Feb 2019 02:04:46 -0800 (PST) Received: from localhost ([122.167.168.92]) by smtp.gmail.com with ESMTPSA id v4sm12051216pff.181.2019.02.27.02.04.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 02:04:45 -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, "4 . 18+" , linux-kernel@vger.kernel.org Subject: [PATCH V2] cpufreq: kyro: Release OPP tables on module removal Date: Wed, 27 Feb 2019 15:34:27 +0530 Message-Id: <78f96969448b17e95b0b21cb78194bb9f709a897.1551261748.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b 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 kyro 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") Signed-off-by: Viresh Kumar --- V1->V2: - The previous version targeted a compile time issue of frame size but this fixes a bug in the driver and needs to get applied to 4.18+ kernels. - This may go in 5.0 release. - Haven't included any Reviewed-by tags as there were many changes in this version. drivers/cpufreq/qcom-cpufreq-kryo.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b Reviewed-by: Georgi Djakov diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c index 2a3675c24032..65edbfd4d4a5 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 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; }