All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: lee.jones@linaro.org, linux-kernel@vger.kernel.org,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mfd: qcom_rpm: fix offset error for msm8660
Date: Tue, 14 Jun 2016 11:51:08 -0700	[thread overview]
Message-ID: <20160614185108.GF28218@codeaurora.org> (raw)
In-Reply-To: <1465897725-16213-1-git-send-email-linus.walleij@linaro.org>

On 06/14, Linus Walleij wrote:
> The RPM in MSM8660/APQ8060 has different offsets to the selector
> ACK and request context ACK registers. Make all these register
> offsets part of the per-SoC data and assign the right values.
> 
> The bug was found by verifying backwards to the vendor tree in
> the out-of-tree files <mach/rpm-[8660|8064|8960]>: all were using
> offsets 3,11,15,23 except the MSM8660/APQ8060 which was using
> offsets 3,11,19,27.
> 
> Cc: stable@vger.kernel.org
> Fixes: 58e214382bdd ("mfd: qcom-rpm: Driver for the Qualcomm RPM")
> Cc: Björn Andersson <bjorn.andersson@linaro.org>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Good catch! That macro maze is fun.

> ---
>  drivers/mfd/qcom_rpm.c | 37 +++++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c
> index 4f589cf75549..82cc7986e1ca 100644
> --- a/drivers/mfd/qcom_rpm.c
> +++ b/drivers/mfd/qcom_rpm.c
> @@ -34,7 +34,11 @@ struct qcom_rpm_resource {
>  struct qcom_rpm_data {
>  	u32 version;
>  	const struct qcom_rpm_resource *resource_table;
> -	unsigned n_resources;
> +	unsigned int n_resources;
> +	unsigned int req_ctx_off;
> +	unsigned int req_sel_off;
> +	unsigned int ack_ctx_off;
> +	unsigned int ack_sel_off;
>  };
>  
>  struct qcom_rpm {
> @@ -61,10 +65,6 @@ struct qcom_rpm {
>  
>  #define RPM_REQUEST_TIMEOUT	(5 * HZ)
>  
> -#define RPM_REQUEST_CONTEXT	3
> -#define RPM_REQ_SELECT		11
> -#define RPM_ACK_CONTEXT		15
> -#define RPM_ACK_SELECTOR	23
>  #define RPM_SELECT_SIZE		7

The RPM_SELECT_SIZE is 7 on 8660, but now you've pointed out that
otherwise the size is 4. I think you've uncovered another bug.

>  
>  #define RPM_NOTIFICATION	BIT(30)
> @@ -398,10 +414,10 @@ int qcom_rpm_write(struct qcom_rpm *rpm,
>  	bitmap_set((unsigned long *)sel_mask, res->select_id, 1);
>  	for (i = 0; i < ARRAY_SIZE(sel_mask); i++) {
>  		writel_relaxed(sel_mask[i],
> -			       RPM_CTRL_REG(rpm, RPM_REQ_SELECT + i));
> +			       RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i));

Here we write from 0 to ARRAY_SIZE(sel_mask) which is 7. That
would mean we write into the ack context that starts at 15 (we
start writing at req_sel_off which is always 11). Oops.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

WARNING: multiple messages have this Message-ID (diff)
From: Stephen Boyd <sboyd@codeaurora.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: lee.jones@linaro.org, linux-kernel@vger.kernel.org,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mfd: qcom_rpm: fix offset error for msm8660
Date: Tue, 14 Jun 2016 11:51:08 -0700	[thread overview]
Message-ID: <20160614185108.GF28218@codeaurora.org> (raw)
In-Reply-To: <1465897725-16213-1-git-send-email-linus.walleij@linaro.org>

On 06/14, Linus Walleij wrote:
> The RPM in MSM8660/APQ8060 has different offsets to the selector
> ACK and request context ACK registers. Make all these register
> offsets part of the per-SoC data and assign the right values.
> 
> The bug was found by verifying backwards to the vendor tree in
> the out-of-tree files <mach/rpm-[8660|8064|8960]>: all were using
> offsets 3,11,15,23 except the MSM8660/APQ8060 which was using
> offsets 3,11,19,27.
> 
> Cc: stable@vger.kernel.org
> Fixes: 58e214382bdd ("mfd: qcom-rpm: Driver for the Qualcomm RPM")
> Cc: Bj�rn Andersson <bjorn.andersson@linaro.org>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Good catch! That macro maze is fun.

> ---
>  drivers/mfd/qcom_rpm.c | 37 +++++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c
> index 4f589cf75549..82cc7986e1ca 100644
> --- a/drivers/mfd/qcom_rpm.c
> +++ b/drivers/mfd/qcom_rpm.c
> @@ -34,7 +34,11 @@ struct qcom_rpm_resource {
>  struct qcom_rpm_data {
>  	u32 version;
>  	const struct qcom_rpm_resource *resource_table;
> -	unsigned n_resources;
> +	unsigned int n_resources;
> +	unsigned int req_ctx_off;
> +	unsigned int req_sel_off;
> +	unsigned int ack_ctx_off;
> +	unsigned int ack_sel_off;
>  };
>  
>  struct qcom_rpm {
> @@ -61,10 +65,6 @@ struct qcom_rpm {
>  
>  #define RPM_REQUEST_TIMEOUT	(5 * HZ)
>  
> -#define RPM_REQUEST_CONTEXT	3
> -#define RPM_REQ_SELECT		11
> -#define RPM_ACK_CONTEXT		15
> -#define RPM_ACK_SELECTOR	23
>  #define RPM_SELECT_SIZE		7

The RPM_SELECT_SIZE is 7 on 8660, but now you've pointed out that
otherwise the size is 4. I think you've uncovered another bug.

>  
>  #define RPM_NOTIFICATION	BIT(30)
> @@ -398,10 +414,10 @@ int qcom_rpm_write(struct qcom_rpm *rpm,
>  	bitmap_set((unsigned long *)sel_mask, res->select_id, 1);
>  	for (i = 0; i < ARRAY_SIZE(sel_mask); i++) {
>  		writel_relaxed(sel_mask[i],
> -			       RPM_CTRL_REG(rpm, RPM_REQ_SELECT + i));
> +			       RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i));

Here we write from 0 to ARRAY_SIZE(sel_mask) which is 7. That
would mean we write into the ack context that starts at 15 (we
start writing at req_sel_off which is always 11). Oops.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2016-06-14 18:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14  9:48 [PATCH] mfd: qcom_rpm: fix offset error for msm8660 Linus Walleij
2016-06-14 18:51 ` Stephen Boyd [this message]
2016-06-14 18:51   ` Stephen Boyd
2016-06-14 19:38   ` Linus Walleij
2016-06-14 19:38 ` Bjorn Andersson
2016-06-14 19:38   ` Bjorn Andersson

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=20160614185108.GF28218@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.