Re: [PATCH v8 5/8] interconnect: qcom: rpm: Handle interface clocks

From: Konrad Dybcio
Date: Thu May 18 2023 - 15:55:32 EST




On 18.05.2023 17:59, Georgi Djakov wrote:
> Hi Konrad,
> Thanks for re-spinning the patches!
>
> On 7.04.23 23:14, Konrad Dybcio wrote:
>> Some (but not all) providers (or their specific nodes) require
>> specific clocks to be turned on before they can be accessed. Failure
>> to ensure that results in a seemingly random system crash (which
>> would usually happen at boot with the interconnect driver built-in),
>> resulting in the platform not booting up properly.
>>
>> Limit the number of bus_clocks to 2 (which is the maximum that SMD
>> RPM interconnect supports anyway) and handle non-scaling clocks
>> separately. Update MSM8996 and SDM660 drivers to make sure they do
>> not regress with this change.
>>
>> This unfortunately has to be done in one patch to prevent either
>> compile errors or broken bisect.
>>
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxx>
>> ---
>>   drivers/interconnect/qcom/icc-rpm.c | 40 ++++++++++++++++++++++++++++---------
>>   drivers/interconnect/qcom/icc-rpm.h | 14 +++++++++++--
>>   drivers/interconnect/qcom/msm8996.c | 22 +++++++++-----------
>>   drivers/interconnect/qcom/sdm660.c  | 16 ++++++---------
>>   4 files changed, 58 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
>> index d79e508cb717..419b2122bebd 100644
>> --- a/drivers/interconnect/qcom/icc-rpm.c
>> +++ b/drivers/interconnect/qcom/icc-rpm.c
>> @@ -424,21 +424,20 @@ int qnoc_probe(struct platform_device *pdev)
>>       qnodes = desc->nodes;
>>       num_nodes = desc->num_nodes;
>>   -    if (desc->num_bus_clocks) {
>> -        cds = desc->bus_clocks;
>> -        cd_num = desc->num_bus_clocks;
>> +    if (desc->num_intf_clocks) {
>> +        cds = desc->intf_clocks;
>> +        cd_num = desc->num_intf_clocks;
>>       } else {
>> -        cds = bus_clocks;
>> -        cd_num = ARRAY_SIZE(bus_clocks);
>> +        /* 0 intf clocks is perfectly fine */
>> +        cd_num = 0;
>>       }
>>   -    qp = devm_kzalloc(dev, struct_size(qp, bus_clks, cd_num), GFP_KERNEL);
>> +    qp = devm_kzalloc(dev, sizeof(*qp), GFP_KERNEL);
>>       if (!qp)
>>           return -ENOMEM;
>>   -    qp->bus_clk_rate = devm_kcalloc(dev, cd_num, sizeof(*qp->bus_clk_rate),
>> -                    GFP_KERNEL);
>> -    if (!qp->bus_clk_rate)
>> +    qp->intf_clks = devm_kzalloc(dev, sizeof(qp->intf_clks), GFP_KERNEL);
>> +    if (!qp->intf_clks)
>>           return -ENOMEM;
>>         data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes),
>> @@ -446,6 +445,18 @@ int qnoc_probe(struct platform_device *pdev)
>>       if (!data)
>>           return -ENOMEM;
>>   +    qp->num_intf_clks = cd_num;
>> +    for (i = 0; i < cd_num; i++)
>> +        qp->intf_clks[i].id = cds[i];
>
> Sadly, this is introducing a superfluous compiler warning, which is a bit annoying.
> Could you please add some initialization to silence it and re-send just this patch.
Ugh clang doesn't show it.. thanks

Konrad
>
> drivers/interconnect/qcom/icc-rpm.c: In function ‘qnoc_probe’:
> drivers/interconnect/qcom/icc-rpm.c:450:28: warning: ‘cds’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>   450 |   qp->intf_clks[i].id = cds[i];
>       |                         ~~~^~~
>
> BR,
> Georgi