LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Luca Weiss <luca@z3ntu.xyz>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Abhijeet Dharmapurikar <adharmap@codeaurora.org>,
	Kiran Gunda <kgunda@codeaurora.org>
Subject: Re: spmi: pmic-arb: Always allocate ppid_to_apid table
Date: Sun, 09 Jul 2017 13:31:07 +0200
Message-ID: <1570691.3NiRTdm5OM@g550jk> (raw)
In-Reply-To: <20170627021746.22445-1-sboyd@codeaurora.org>

On Dienstag, 27. Juni 2017 04:17:46 CEST 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 <adharmap@codeaurora.org>
> Cc: Kiran Gunda <kgunda@codeaurora.org>
> Fixes: 7f1d4e58dabb ("spmi: pmic-arb: optimize table lookups")
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> Reviewed-by: Kiran Gunda <kgunda@codeaurora.org>
> ---
>  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",

Tested-by: Luca Weiss <luca@z3ntu.xyz>

  parent reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27  2:17 [PATCH] " Stephen Boyd
2017-06-28  6:58 ` kgunda
2017-07-18 23:46   ` Frank Rowand
2017-07-09 11:31 ` Luca Weiss [this message]
2017-07-14 16:54 ` Andy Gross
2017-07-17 12:57   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1570691.3NiRTdm5OM@g550jk \
    --to=luca@z3ntu.xyz \
    --cc=adharmap@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kgunda@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git