Re: [PATCH v2 19/22] interconnect: qcom: icc-rpm: Fix bucket number

From: Stephan Gerhold
Date: Sat Jun 10 2023 - 13:46:36 EST


On Fri, Jun 09, 2023 at 10:19:24PM +0200, Konrad Dybcio wrote:
> SMD RPM only provides two buckets, one each for the active-only and
> active-sleep RPM contexts. Use the correct constant to allocate and
> operate on them.
>
> Fixes: dcbce7b0a79c ("interconnect: qcom: icc-rpm: Support multiple buckets")
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxx>
> ---
> drivers/interconnect/qcom/icc-rpm.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> index 6d40815c5401..3ac47b818afe 100644
> --- a/drivers/interconnect/qcom/icc-rpm.c
> +++ b/drivers/interconnect/qcom/icc-rpm.c
> [...]
> @@ -275,7 +275,7 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
> if (!tag)
> tag = QCOM_ICC_TAG_ALWAYS;
>
> - for (i = 0; i < QCOM_ICC_NUM_BUCKETS; i++) {
> + for (i = 0; i < QCOM_SMD_RPM_STATE_NUM; i++) {
> if (tag & BIT(i)) {

Hm, I think QCOM_ICC_NUM_BUCKETS is actually intentional here. There is
a hint about this in the description of the commit in your Fixes line:

> This patch studies the implementation from interconnect rpmh driver to
> support multiple buckets. The rpmh driver provides three buckets for
> AMC, WAKE, and SLEEP; this driver only needs to use WAKE and SLEEP
> buckets, but we keep the same way with rpmh driver, this can allow us
> to reuse the DT binding and avoid to define duplicated data structures.

As far as I understand, the idea was to reuse the definitions in
qcom,icc.h and just ignore the AMC bucket for now. AFAIU AMC (or rather
the lack thereof) is basically caching: Sending requests without AMC bit
set is delayed until the next rpmh_flush() call that happens when
entering a deep idle state. It requires some work but I guess
theoretically one could implement exactly the same for RPM.

What you're actually doing here is not fixing the commit but changing
the bindings. On MSM8909 I defined the ICC path for CPU<->RAM like this:

interconnects = <&bimc MAS_APPS_PROC QCOM_ICC_TAG_ACTIVE_ONLY
&bimc SLV_EBI QCOM_ICC_TAG_ACTIVE_ONLY>;

Per definition in qcom,icc.h:

QCOM_ICC_TAG_ACTIVE_ONLY = (AMC | WAKE) = (BIT(0) | BIT(1))

Without your patch series this behaves correctly. It results in an
active-only vote.

The change of behavior is in PATCH 17/22 "interconnect: qcom: icc-rpm:
Control bus rpmcc from icc". It silently switches from
QCOM_ICC_BUCKET_WAKE (1) and QCOM_ICC_BUCKET_SLEEP (2) to
QCOM_SMD_RPM_ACTIVE_STATE (0) and QCOM_SMD_RPM_SLEEP_STATE (1).

In other words, QCOM_ICC_TAG_ACTIVE_ONLY (BIT(0) | BIT(1)) now results
in an active+sleep vote, not an active-only one. :)

There doesn't seem to be an upstream user of the ICC tags/buckets for
icc-rpm yet so personally I would be fine with changing it. However,
then qcom,icc.h should get a clear comment that it's rpmh-only and we
should define a new qcom,icc-rpm.h.

Or perhaps we should just drop this patch and continue using
QCOM_ICC_BUCKET_WAKE and QCOM_ICC_BUCKET_SLEEP as before?

Thanks,
Stephan