From patchwork Tue Jun 27 02:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9810723 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0A1B603D7 for ; Tue, 27 Jun 2017 02:18:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28E4128639 for ; Tue, 27 Jun 2017 02:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D98A28641; Tue, 27 Jun 2017 02:18:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE14128639 for ; Tue, 27 Jun 2017 02:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751656AbdF0CR7 (ORCPT ); Mon, 26 Jun 2017 22:17:59 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60936 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751456AbdF0CR6 (ORCPT ); Mon, 26 Jun 2017 22:17:58 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0AF9960723; Tue, 27 Jun 2017 02:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1498529868; bh=yBIPHRyy6lEZaiBIeMDa4mtZpnDVBVNvetzgrRaTivs=; h=From:To:Cc:Subject:Date:From; b=IQFJKWiQpMwXwid7h5UVqJxU7lXXxEXoS59vENN2rKs9e9dCF8OPSNs3Ylohj73Xc ReeTSwsR3Uby5AFtvGaucRTw/kikjMZ6YjIFWafIgZK8g+r24MiRZQI5x1Sfb2IQ6d lQMPyu3V+hBtilz23CVDb+2zyyEOcFM6ZZOwVB8Q= Received: from sboyd-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2A94F60723; Tue, 27 Jun 2017 02:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1498529867; bh=yBIPHRyy6lEZaiBIeMDa4mtZpnDVBVNvetzgrRaTivs=; h=From:To:Cc:Subject:Date:From; b=dCv7wh40qq0qyq1ZFwOsaU3h7+PoPzO4u0jzpCQcc/+1VmSxTId1DIOWFTmEKlD9X hbdkkjuZ76z9uZuivLioEHvIDOO3pvJQLqIPo5sao4jT0J3SWBc5YNI8M6WJfpLxtK 83ULSHKPPnKk1/fLJs6Ck5N102aXY3mElqeB9oE8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2A94F60723 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sboyd@codeaurora.org From: Stephen Boyd To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Abhijeet Dharmapurikar , Kiran Gunda Subject: [PATCH] spmi: pmic-arb: Always allocate ppid_to_apid table Date: Mon, 26 Jun 2017 19:17:46 -0700 Message-Id: <20170627021746.22445-1-sboyd@codeaurora.org> X-Mailer: git-send-email 2.13.0.67.g10c78a162fa8 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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-by: Luca Weiss 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",