[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <374addd2-e336-4625-9e0c-45e5efe1eb47@linaro.org>
Date: Mon, 11 Dec 2023 10:37:27 +0100
From: Neil Armstrong <neil.armstrong@...aro.org>
To: Konrad Dybcio <konrad.dybcio@...aro.org>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Manivannan Sadhasivam <mani@...nel.org>
Cc: linux-arm-msm@...r.kernel.org, linux-remoteproc@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Mukesh Ojha <quic_mojha@...cinc.com>
Subject: Re: [PATCH v4 2/3] remoteproc: qcom: pas: make region assign more
generic
On 09/12/2023 19:06, Konrad Dybcio wrote:
> On 8.12.2023 16:04, Neil Armstrong wrote:
>> The current memory region assign only supports a single
>> memory region.
>>
>> But new platforms introduces more regions to make the
>> memory requirements more flexible for various use cases.
>> Those new platforms also shares the memory region between the
>> DSP and HLOS.
>>
>> To handle this, make the region assign more generic in order
>> to support more than a single memory region and also permit
>> setting the regions permissions as shared.
>>
>> Reviewed-by: Mukesh Ojha <quic_mojha@...cinc.com>
>> Signed-off-by: Neil Armstrong <neil.armstrong@...aro.org>
>> ---
> [...]
>
>> + for (offset = 0; offset < adsp->region_assign_count; ++offset) {
>> + struct reserved_mem *rmem = NULL;
>> +
>> + node = of_parse_phandle(adsp->dev->of_node, "memory-region",
>> + adsp->region_assign_idx + offset);
>> + if (node)
>> + rmem = of_reserved_mem_lookup(node);
>> + of_node_put(node);
> Shouldn't this only be called when parse_phandle succeeds? (separate
> patch with a fix + cc stable if so?)
It's not a bug, it was added like that because of_node_put() already
checks for a NULL pointer:
https://elixir.bootlin.com/linux/v6.7-rc5/source/drivers/of/dynamic.c#L45
>
>> + if (!rmem) {
>> + dev_err(adsp->dev, "unable to resolve shareable memory-region index %d\n",
>> + offset);
>> + return -EINVAL;
>> + }
>>
>> - perm.vmid = QCOM_SCM_VMID_MSS_MSA;
>> - perm.perm = QCOM_SCM_PERM_RW;
>> + if (adsp->region_assign_shared) {
>> + perm[0].vmid = QCOM_SCM_VMID_HLOS;
>> + perm[0].perm = QCOM_SCM_PERM_RW;
>> + perm[1].vmid = adsp->region_assign_vmid;
>> + perm[1].perm = QCOM_SCM_PERM_RW;
>> + perm_size = 2;
>> + } else {
>> + perm[0].vmid = adsp->region_assign_vmid;
>> + perm[0].perm = QCOM_SCM_PERM_RW;
>> + perm_size = 1;
>> + }
>>
>> - adsp->region_assign_phys = rmem->base;
>> - adsp->region_assign_size = rmem->size;
>> - adsp->region_assign_perms = BIT(QCOM_SCM_VMID_HLOS);
>> + adsp->region_assign_phys[offset] = rmem->base;
>> + adsp->region_assign_size[offset] = rmem->size;
>> + adsp->region_assign_perms[offset] = BIT(QCOM_SCM_VMID_HLOS);
>>
>> - ret = qcom_scm_assign_mem(adsp->region_assign_phys,
>> - adsp->region_assign_size,
>> - &adsp->region_assign_perms,
> I think this should be renamed to region_assign_owner(s)
Why ? this bitfield is names "perms" everywhere qcom_scm_assign_mem is used
>
>> - &perm, 1);
>> - if (ret < 0) {
>> - dev_err(adsp->dev, "assign memory failed\n");
>> - return ret;
>> + ret = qcom_scm_assign_mem(adsp->region_assign_phys[offset],
>> + adsp->region_assign_size[offset],
>> + &adsp->region_assign_perms[offset],
>> + perm, perm_size);
>> + if (ret < 0) {
>> + dev_err(adsp->dev, "assign memory %d failed\n", offset);
>> + return ret;
>> + }
>> }
>>
>> return 0;
>> @@ -629,20 +653,23 @@ static int adsp_assign_memory_region(struct qcom_adsp *adsp)
>> static void adsp_unassign_memory_region(struct qcom_adsp *adsp)
>> {
>> struct qcom_scm_vmperm perm;
>> + int offset;
>> int ret;
>>
>> - if (!adsp->region_assign_idx)
>> + if (!adsp->region_assign_idx || adsp->region_assign_shared)
> So when it's *shared*, we don't want to un-assign it?
Exact, when shared the region stays shared, as downstream does, un-assigning will fail
in this case.
>
> Konrad
Thanks,
Neil
Powered by blists - more mailing lists