diff mbox series

[v12,4/4] soc: qcom: rpmh: Invalidate SLEEP and WAKE TCSes before flushing new data

Message ID 1583428023-19559-5-git-send-email-mkshah@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series Invoke rpmh_flush for non OSI targets | expand

Commit Message

Maulik Shah March 5, 2020, 5:07 p.m. UTC
TCSes have previously programmed data when rpmh_flush is called.
This can cause old data to trigger along with newly flushed.

Fix this by cleaning SLEEP and WAKE TCSes before new data is flushed.

Fixes: 600513dfeef3 ("drivers: qcom: rpmh: cache sleep/wake state requests")
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
---
 drivers/soc/qcom/rpmh.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Doug Anderson March 5, 2020, 10:20 p.m. UTC | #1
Hi,

On Thu, Mar 5, 2020 at 9:07 AM Maulik Shah <mkshah@codeaurora.org> wrote:
>
> TCSes have previously programmed data when rpmh_flush is called.
> This can cause old data to trigger along with newly flushed.
>
> Fix this by cleaning SLEEP and WAKE TCSes before new data is flushed.
>
> Fixes: 600513dfeef3 ("drivers: qcom: rpmh: cache sleep/wake state requests")
> Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
> ---
>  drivers/soc/qcom/rpmh.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
> index 1951f6a..63364ce 100644
> --- a/drivers/soc/qcom/rpmh.c
> +++ b/drivers/soc/qcom/rpmh.c
> @@ -472,6 +472,11 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
>                 return 0;
>         }
>
> +       /* Invalidate the TCSes first to avoid stale data */
> +       do {
> +               ret = rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr));
> +       } while (ret == -EAGAIN);
> +
>         /* First flush the cached batch requests */
>         ret = flush_batch(ctrlr);
>         if (ret)

I think you should make this patch 3/4 instead of 4/4, and then:

1. In this patch remove the call to rpmh_rsc_invalidate() in
rpmh_invalidate().  You've already marked things "dirty" in
invalidate_batch() so no need to actually program the hardware--it'll
happen in the flush.

2. In patch 4/4 (the flushing patch) add a call to rpmh_flush() to
rpmh_invalidate() if you're in non-OSI mode.  Presumably you'll need a
spinlock around the rpmh_flush() call?


The end result of that will be that rpmh_invalidate() will properly
leave the non-batch sleep/wake sets programmed.


-Doug
Maulik Shah March 9, 2020, 8:28 a.m. UTC | #2
On 3/6/2020 3:50 AM, Doug Anderson wrote:
> Hi,
>
> On Thu, Mar 5, 2020 at 9:07 AM Maulik Shah <mkshah@codeaurora.org> wrote:
>> TCSes have previously programmed data when rpmh_flush is called.
>> This can cause old data to trigger along with newly flushed.
>>
>> Fix this by cleaning SLEEP and WAKE TCSes before new data is flushed.
>>
>> Fixes: 600513dfeef3 ("drivers: qcom: rpmh: cache sleep/wake state requests")
>> Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
>> ---
>>  drivers/soc/qcom/rpmh.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
>> index 1951f6a..63364ce 100644
>> --- a/drivers/soc/qcom/rpmh.c
>> +++ b/drivers/soc/qcom/rpmh.c
>> @@ -472,6 +472,11 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
>>                 return 0;
>>         }
>>
>> +       /* Invalidate the TCSes first to avoid stale data */
>> +       do {
>> +               ret = rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr));
>> +       } while (ret == -EAGAIN);
>> +
>>         /* First flush the cached batch requests */
>>         ret = flush_batch(ctrlr);
>>         if (ret)
> I think you should make this patch 3/4 instead of 4/4, and then:
>
> 1. In this patch remove the call to rpmh_rsc_invalidate() in
> rpmh_invalidate().  You've already marked things "dirty" in
> invalidate_batch() so no need to actually program the hardware--it'll
> happen in the flush.
Done.
>
> 2. In patch 4/4 (the flushing patch) add a call to rpmh_flush() to
> rpmh_invalidate() if you're in non-OSI mode.  Presumably you'll need a
> spinlock around the rpmh_flush() call?

With (1) addressed and rpmh_start_transaction and rpmh_end_transaction introduced in v13, this is not required.

Thanks,
Maulik

>
>
> The end result of that will be that rpmh_invalidate() will properly
> leave the non-batch sleep/wake sets programmed.
>
>
> -Doug
diff mbox series

Patch

diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 1951f6a..63364ce 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -472,6 +472,11 @@  int rpmh_flush(struct rpmh_ctrlr *ctrlr)
 		return 0;
 	}
 
+	/* Invalidate the TCSes first to avoid stale data */
+	do {
+		ret = rpmh_rsc_invalidate(ctrlr_to_drv(ctrlr));
+	} while (ret == -EAGAIN);
+
 	/* First flush the cached batch requests */
 	ret = flush_batch(ctrlr);
 	if (ret)