mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: rpmh: Return the first error from flush_batch()
@ 2026-11-27  9:31 getfeus
  2026-11-30  8:54 ` Konrad Dybcio
  0 siblings, 1 reply; 3+ messages in thread
From: getfeus @ 2026-11-27  9:31 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio; +Cc: linux-arm-msm, linux-kernel

When a TCS write fails, flush_batch() breaks out of the inner loop
and continues with the next cached batch. A later successful write can
overwrite the error and make rpmh_flush() proceed even though some
sleep or wake commands were skipped.

Return the error immediately so rpmh_flush() stops and leaves the
cache dirty for a retry.

A mocked TCS writer returning -ENOMEM for the first batch and success
for the second reproduced a zero return from flush_batch(). With this
change, flush_batch() returns -ENOMEM after a single write attempt.
The ARM64 kernel and modules also build successfully.

Signed-off-by: Lee Youngjoon <getfeus@gmail.com>
---
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -334,11 +334,11 @@
 			ret = rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr),
 						       &rpm_msg->msg);
 			if (ret)
-				break;
+				return ret;
 		}
 	}

-	return ret;
+	return 0;
 }

 /**

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] soc: qcom: rpmh: Return the first error from flush_batch()
  2026-11-27  9:31 [PATCH] soc: qcom: rpmh: Return the first error from flush_batch() getfeus
@ 2026-11-30  8:54 ` Konrad Dybcio
  2026-11-30  9:30   ` YoungJoon Lee
  0 siblings, 1 reply; 3+ messages in thread
From: Konrad Dybcio @ 2026-11-30  8:54 UTC (permalink / raw)
  To: getfeus, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, linux-kernel, Maulik Shah

On 11/27/26 10:31 AM, getfeus@gmail.com wrote:
> When a TCS write fails, flush_batch() breaks out of the inner loop
> and continues with the next cached batch. A later successful write can
> overwrite the error and make rpmh_flush() proceed even though some
> sleep or wake commands were skipped.
> 
> Return the error immediately so rpmh_flush() stops and leaves the
> cache dirty for a retry.
> 
> A mocked TCS writer returning -ENOMEM for the first batch and success
> for the second reproduced a zero return from flush_batch(). With this
> change, flush_batch() returns -ENOMEM after a single write attempt.
> The ARM64 kernel and modules also build successfully.
> 
> Signed-off-by: Lee Youngjoon <getfeus@gmail.com>
> ---
> --- a/drivers/soc/qcom/rpmh.c
> +++ b/drivers/soc/qcom/rpmh.c
> @@ -334,11 +334,11 @@
>  			ret = rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr),
>  						       &rpm_msg->msg);
>  			if (ret)
> -				break;
> +				return ret;
>  		}
>  	}
> 
> -	return ret;
> +	return 0;

I think this is intentional. We may have a number of disjoint
writes to different endpoints in the same batch, and some may
fail, while others may succeed (and not have any dependency on
the prior).

Konrad

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] soc: qcom: rpmh: Return the first error from flush_batch()
  2026-11-30  8:54 ` Konrad Dybcio
@ 2026-11-30  9:30   ` YoungJoon Lee
  0 siblings, 0 replies; 3+ messages in thread
From: YoungJoon Lee @ 2026-11-30  9:30 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Bjorn Andersson, Konrad Dybcio, Maulik Shah, linux-arm-msm, linux-kernel

Hi Konrad,

Thank you for pointing out that later batches can contain independent
requests. The proposed immediate return would prevent those writes, so
I agree that it changes more than the error handling.

I looked at retaining the first error while preserving the current
behavior of stopping the failed batch and trying subsequent batches.
However, returning that error would make rpmh_flush() skip the
individual cached requests and leave the cache dirty. Its power-domain
and CPU PM callers can then reject the low-power transition.

Is an incomplete sleep or wake batch expected to allow the transition
to proceed on some platforms? In particular, when an earlier batch fails
to find TCS space but a later independent batch succeeds, is the later
success intended to make the overall flush succeed, or should the
failure be retained and the transition rejected?

Knowing that contract would help determine whether to revise the patch
or leave the current behavior alone.

Thanks,
Youngjoon


On Mon, 30 Nov 2026 09:54:45 +0100, Konrad Dybcio
<konrad.dybcio@oss.qualcomm.com> wrote:
> On 11/27/26 10:31 AM, getfeus@gmail.com wrote:
> > When a TCS write fails, flush_batch() breaks out of the inner loop
> > and continues with the next cached batch. A later successful write can
> > overwrite the error and make rpmh_flush() proceed even though some
> > sleep or wake commands were skipped.
> >
> > Return the error immediately so rpmh_flush() stops and leaves the
> > cache dirty for a retry.
> >
> > A mocked TCS writer returning -ENOMEM for the first batch and success
> > for the second reproduced a zero return from flush_batch(). With this
> > change, flush_batch() returns -ENOMEM after a single write attempt.
> > The ARM64 kernel and modules also build successfully.
> >
> > Signed-off-by: Lee Youngjoon <getfeus@gmail.com>
> > ---
> > --- a/drivers/soc/qcom/rpmh.c
> > +++ b/drivers/soc/qcom/rpmh.c
> > @@ -334,11 +334,11 @@
> >  			ret = rpmh_rsc_write_ctrl_data(ctrlr_to_drv(ctrlr),
> >  						       &rpm_msg->msg);
> >  			if (ret)
> > -				break;
> > +				return ret;
> >  		}
> >  	}
> >
> > -	return ret;
> > +	return 0;
>
> I think this is intentional. We may have a number of disjoint
> writes to different endpoints in the same batch, and some may
> fail, while others may succeed (and not have any dependency on
> the prior).
>
> Konrad

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27  9:31 [PATCH] soc: qcom: rpmh: Return the first error from flush_batch() getfeus
2026-11-30  8:54 ` Konrad Dybcio
2026-11-30  9:30   ` YoungJoon Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®