Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752543AbdGRXqf (ORCPT ); Tue, 18 Jul 2017 19:46:35 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35371 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751987AbdGRXqe (ORCPT ); Tue, 18 Jul 2017 19:46:34 -0400 Subject: Re: [PATCH] spmi: pmic-arb: Always allocate ppid_to_apid table To: kgunda@codeaurora.org, Stephen Boyd References: <20170627021746.22445-1-sboyd@codeaurora.org> <50b43f2e54cb0b2260a249ed07fe21ce@codeaurora.org> Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Abhijeet Dharmapurikar , linux-arm-msm-owner@vger.kernel.org From: Frank Rowand Message-ID: <596E9DCD.7030009@gmail.com> Date: Tue, 18 Jul 2017 16:46:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <50b43f2e54cb0b2260a249ed07fe21ce@codeaurora.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2675 Lines: 72 On 06/27/17 23:58, kgunda@codeaurora.org wrote: > On 2017-06-27 07:47, Stephen Boyd wrote: >> After commit 7f1d4e58dabb ("spmi: pmic-arb: optimize table >> lookups") we always need the ppid_to_apid table regardless of the >> version of pmic arbiter we have. Otherwise, we will try to deref >> the array when we don't allocate it on v2 hardware like the >> msm8974 SoCs. >> >> Cc: Abhijeet Dharmapurikar >> Cc: Kiran Gunda >> Fixes: 7f1d4e58dabb ("spmi: pmic-arb: optimize table lookups") >> Signed-off-by: Stephen Boyd > Reviewed-by: Kiran Gunda Tested on a qcom-apq8074-dragonboard on 4.13-rc1 Tested-by: Frank Rowand >> --- >> drivers/spmi/spmi-pmic-arb.c | 17 +++++++---------- >> 1 file changed, 7 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c >> index 2afe3597982e..f4b7a98a7913 100644 >> --- a/drivers/spmi/spmi-pmic-arb.c >> +++ b/drivers/spmi/spmi-pmic-arb.c >> @@ -134,7 +134,6 @@ struct apid_data { >> * @spmic: SPMI controller object >> * @ver_ops: version dependent operations. >> * @ppid_to_apid in-memory copy of PPID -> channel (APID) mapping table. >> - * v2 only. >> */ >> struct spmi_pmic_arb { >> void __iomem *rd_base; >> @@ -1016,6 +1015,13 @@ static int spmi_pmic_arb_probe(struct >> platform_device *pdev) >> goto err_put_ctrl; >> } >> >> + pa->ppid_to_apid = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PPID, >> + sizeof(*pa->ppid_to_apid), GFP_KERNEL); >> + if (!pa->ppid_to_apid) { >> + err = -ENOMEM; >> + goto err_put_ctrl; >> + } >> + >> hw_ver = readl_relaxed(core + PMIC_ARB_VERSION); >> >> if (hw_ver < PMIC_ARB_VERSION_V2_MIN) { >> @@ -1048,15 +1054,6 @@ static int spmi_pmic_arb_probe(struct >> platform_device *pdev) >> err = PTR_ERR(pa->wr_base); >> goto err_put_ctrl; >> } >> - >> - pa->ppid_to_apid = devm_kcalloc(&ctrl->dev, >> - PMIC_ARB_MAX_PPID, >> - sizeof(*pa->ppid_to_apid), >> - GFP_KERNEL); >> - if (!pa->ppid_to_apid) { >> - err = -ENOMEM; >> - goto err_put_ctrl; >> - } >> } >> >> dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n", > Thanks for the fix ! > -- > To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >