Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1774122img; Wed, 27 Feb 2019 05:16:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IbB4ZOz5rzOx47e12m4uZ6gOs5laiFQI5LuwwvCmZ46wXzpBDZTCho0ZvVyW7+gqPPE/19W X-Received: by 2002:a63:4c18:: with SMTP id z24mr3002455pga.62.1551273390205; Wed, 27 Feb 2019 05:16:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551273390; cv=none; d=google.com; s=arc-20160816; b=FgzDspr5SCUo3c5loUhT8Fq0TbQXcAPUSxygRInztInGNhvBIEwrkqAj+VmqFiE9/l ttYdpiaQGVJt0buRhOyPysgPudSXein9soYQdpIQDhhsVO2QSqnL77W7jGDUMkc0ImCa bs4dpLsY+VYp510vz4N82zCeyAExrgbMRDvnWkkivx85ZRjhArczRNh6Cq2KLBfquPr/ QxVynOdlAJYeqX2yJlIHUzoyww6Jh6IT2fgtohmB/diGUjxszGDaoQ5+n5/R8ebRV+0y HIj33qKTnAPemqFWFes/OwSpiEp//iCTctNUaAckJZvnyM9FWAKjvhKSXRg2sh/Y34Zq 9Bew== 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 :content-language:in-reply-to:mime-version:date:message-id:autocrypt :openpgp:from:references:cc:to:subject:dkim-signature; bh=Sja5VFo1EQDHP6qZ43IkInaQbb/huVQfu1jUcq5Lg7A=; b=kZZTtlxKBeAyJY+juzUM/hSNmo+tbPjeikm53p85tH+UexH1id1xyBVCc/M+HI24RX VZeGIn4+JG89Sv8QvdpAIkvv8djfyySo0Iiy0eVdmznA+1l/hx7v8y98AM65W6fcviiV rrBkGxQt2h2jbvMq3GPt6+rRCdJGI02yXDSEpPqOpYJpedVGkV5Skx6KWrylrmdYEjMf 5/oNgFWULdqKcSns42KmOsZ4GLuZPX+qwp5CsZLy7jsN0poVNdrpJ+Io8vpwJTtwm/Qu AKrFT7Ze62qu2soNneT9lhKV560Arw6aGnN2Oq/Rg7z4TZxHe7YFtemcRgp1x/WA2qEy gaYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pP80PnJm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y5si6577287pge.192.2019.02.27.05.16.14; Wed, 27 Feb 2019 05:16:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=pP80PnJm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730136AbfB0NK0 (ORCPT + 99 others); Wed, 27 Feb 2019 08:10:26 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40899 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729740AbfB0NKZ (ORCPT ); Wed, 27 Feb 2019 08:10:25 -0500 Received: by mail-wm1-f65.google.com with SMTP id g20so4779721wmh.5 for ; Wed, 27 Feb 2019 05:10:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Sja5VFo1EQDHP6qZ43IkInaQbb/huVQfu1jUcq5Lg7A=; b=pP80PnJmhleIBb1SHRTyGc5mwo8ODxhnElEjD78hXEc62DLGRV6bDoNRN1jwbL+Lf9 U5Uz2iSlSZxVWnfiITUFugdd/lJO6oSR2wbf4LJCs+Y34mfEj+JcubimF9clpHw725Ap tnsHCHt9KPiTy9+rU6xd35NhT8KB4HSEbVxL4Q4aNIwmx05Wysz8ZFv1aq53c4GjyFyd 7K9KtHVAamgkJAyxbHQlpSPV3vqoWzxNmADHPyh9zd152kOvYO339fDBhymzeuU6lAan SL79S2CfE3lkZObL8p2Qo3dObFULH43v93GxapCvrftw06j9LmL78t4kTzmPIRk0AMQ4 r64w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Sja5VFo1EQDHP6qZ43IkInaQbb/huVQfu1jUcq5Lg7A=; b=G7JKY5lEoHcRix8RHaWYmJgxL/AS8C57hZZBdAOnaJbxhTs+VDFHymWGwO9+ZKg71T 4J7u+5SNfXyW4xoXuiCxSoqP9JjhxnQkd2pmq6FiikrCeUJ+nBfZtgYlnmckZGPmBqvY 7AHUH/Vv5p8hfWYYUrqIW/4Ajh+zi4OHzwx67i2TvAJ2TMiSpJTpBpIOJgH5bASutw3b 3JC8UZUZ8nWwkeZWEhZfAlZKo+2/Y/SqPCAgsFv8ZlxegubGJbN0xubo+7m2KTnYErE3 dkIdQ4YvU8nfsdrWo6S1JlV6sakexvCJ6/TJrE5ZQ/t1nnNO381YZHkUNyy41JEz+P4B Jzbw== X-Gm-Message-State: AHQUAuY05o4VXVmeLSQBerIStFYoad1oMDYbofCNR2EcnG+rvdQSL0Og 27a2lIEU73zAya/6vHnvv7l16oSznpo= X-Received: by 2002:a1c:39d5:: with SMTP id g204mr2361578wma.17.1551273022185; Wed, 27 Feb 2019 05:10:22 -0800 (PST) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y20sm2278968wmi.34.2019.02.27.05.10.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 05:10:21 -0800 (PST) Subject: Re: [PATCH V2] cpufreq: kyro: Release OPP tables on module removal To: Viresh Kumar Cc: Rafael Wysocki , Ilia Lin , linux-pm@vger.kernel.org, Vincent Guittot , Arnd Bergmann , amit.kucheria@linaro.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org References: <78f96969448b17e95b0b21cb78194bb9f709a897.1551261748.git.viresh.kumar@linaro.org> From: Georgi Djakov Openpgp: preference=signencrypt Autocrypt: addr=georgi.djakov@linaro.org; prefer-encrypt=mutual; keydata= mQINBFjTuRcBEACyAOVzghvyN19Sa/Nit4LPBWkICi5W20p6bwiZvdjhtuh50H5q4ktyxJtp 1+s8dMSa/j58hAWhrc2SNL3fttOCo+MM1bQWwe8uMBQJP4swgXf5ZUYkSssQlXxGKqBSbWLB uFHOOBTzaQBaNgsdXo+mQ1h8UCgM0zQOmbs2ort8aHnH2i65oLs5/Xgv/Qivde/FcFtvEFaL 0TZ7odM67u+M32VetH5nBVPESmnEDjRBPw/DOPhFBPXtal53ZFiiRr6Bm1qKVu3dOEYXHHDt nF13gB+vBZ6x5pjl02NUEucSHQiuCc2Aaavo6xnuBc3lnd4z/xk6GLBqFP3P/eJ56eJv4d0B 0LLgQ7c1T3fU4/5NDRRCnyk6HJ5+HSxD4KVuluj0jnXW4CKzFkKaTxOp7jE6ZD/9Sh74DM8v etN8uwDjtYsM07I3Szlh/I+iThxe/4zVtUQsvgXjwuoOOBWWc4m4KKg+W4zm8bSCqrd1DUgL f67WiEZgvN7tPXEzi84zT1PiUOM98dOnmREIamSpKOKFereIrKX2IcnZn8jyycE12zMkk+Sc ASMfXhfywB0tXRNmzsywdxQFcJ6jblPNxscnGMh2VlY2rezmqJdcK4G4Lprkc0jOHotV/6oJ mj9h95Ouvbq5TDHx+ERn8uytPygDBR67kNHs18LkvrEex/Z1cQARAQABtChHZW9yZ2kgRGph a292IDxnZW9yZ2kuZGpha292QGxpbmFyby5vcmc+iQI+BBMBAgAoBQJ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hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: <23ab0431-de19-4f5d-219f-dbfa890b7946@linaro.org> Date: Wed, 27 Feb 2019 15:10:18 +0200 MIME-Version: 1.0 In-Reply-To: <78f96969448b17e95b0b21cb78194bb9f709a897.1551261748.git.viresh.kumar@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/27/19 12:04, Viresh Kumar wrote: > Commit 5ad7346b4ae2 ("cpufreq: kryo: Add module remove and exit") made > it possible to build the kyro cpufreq driver as a module, but it failed Nit: s/kyro/kryo/ above and in the subject > 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(-) > > 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; Nit: unsigned int > + > 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; > } > Reviewed-by: Georgi Djakov Thanks, Georgi