2023-03-05 10:33:05

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem

The commit e656cd0bcf3d ("soc: qcom: rmtfs: Optionally map RMTFS to
more VMs") which landed for v6.3-rc1 caused some issues on platforms
such as msm8974. Fix both the error handling and behavior when qcom,vmid
property is missing.

Please include this (or another fix) in 6.3 still.

Signed-off-by: Luca Weiss <[email protected]>
---
Luca Weiss (2):
soc: qcom: rmtfs: fix error handling reading qcom,vmid
soc: qcom: rmtfs: handle optional qcom,vmid correctly

drivers/soc/qcom/rmtfs_mem.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
---
base-commit: 388bd72dfdc05abb319d86109a6edc9be5e0581d
change-id: 20230305-rmtfs-vmid-fix-0ec352b05040

Best regards,
--
Luca Weiss <[email protected]>



2023-03-05 10:33:08

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly

Older platforms don't have qcom,vmid set, handle -EINVAL return value
correctly. And since num_vmids is passed to of_property_read_u32_array
later we should make sure it has a sane value before continuing.

Fixes: e656cd0bcf3d ("soc: qcom: rmtfs: Optionally map RMTFS to more VMs")
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/soc/qcom/rmtfs_mem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
index 218397ab0c36f..fb6e4def8c78b 100644
--- a/drivers/soc/qcom/rmtfs_mem.c
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -229,7 +229,10 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
}

num_vmids = of_property_count_u32_elems(node, "qcom,vmid");
- if (num_vmids < 0) {
+ if (num_vmids == -EINVAL) {
+ /* qcom,vmid is optional */
+ num_vmids = 0;
+ } else if (num_vmids < 0) {
dev_err(&pdev->dev, "failed to count qcom,vmid elements: %d\n", num_vmids);
goto remove_cdev;
} else if (num_vmids > NUM_MAX_VMIDS) {

--
2.39.2


2023-03-05 10:33:10

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid

of_property_count_u32_elems returns a negative integer when an error
happens , but since the value was assigned to an unsigned integer, the
check never worked correctly. Also print the correct variable in the
error print, ret isn't used here.

Fixes: e656cd0bcf3d ("soc: qcom: rmtfs: Optionally map RMTFS to more VMs")
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/soc/qcom/rmtfs_mem.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
index 9d59ad509a5c7..218397ab0c36f 100644
--- a/drivers/soc/qcom/rmtfs_mem.c
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -176,7 +176,8 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
struct reserved_mem *rmem;
struct qcom_rmtfs_mem *rmtfs_mem;
u32 client_id;
- u32 num_vmids, vmid[NUM_MAX_VMIDS];
+ u32 vmid[NUM_MAX_VMIDS];
+ int num_vmids;
int ret, i;

rmem = of_reserved_mem_lookup(node);
@@ -229,7 +230,7 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)

num_vmids = of_property_count_u32_elems(node, "qcom,vmid");
if (num_vmids < 0) {
- dev_err(&pdev->dev, "failed to count qcom,vmid elements: %d\n", ret);
+ dev_err(&pdev->dev, "failed to count qcom,vmid elements: %d\n", num_vmids);
goto remove_cdev;
} else if (num_vmids > NUM_MAX_VMIDS) {
dev_warn(&pdev->dev,

--
2.39.2


2023-03-06 10:17:24

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid



On 5.03.2023 11:32, Luca Weiss wrote:
> of_property_count_u32_elems returns a negative integer when an error
> happens , but since the value was assigned to an unsigned integer, the
> check never worked correctly. Also print the correct variable in the
> error print, ret isn't used here.
>
> Fixes: e656cd0bcf3d ("soc: qcom: rmtfs: Optionally map RMTFS to more VMs")
> Signed-off-by: Luca Weiss <[email protected]>
> ---
Reviewed-by: Konrad Dybcio <[email protected]>

Konrad
> drivers/soc/qcom/rmtfs_mem.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> index 9d59ad509a5c7..218397ab0c36f 100644
> --- a/drivers/soc/qcom/rmtfs_mem.c
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -176,7 +176,8 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
> struct reserved_mem *rmem;
> struct qcom_rmtfs_mem *rmtfs_mem;
> u32 client_id;
> - u32 num_vmids, vmid[NUM_MAX_VMIDS];
> + u32 vmid[NUM_MAX_VMIDS];
> + int num_vmids;
> int ret, i;
>
> rmem = of_reserved_mem_lookup(node);
> @@ -229,7 +230,7 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
>
> num_vmids = of_property_count_u32_elems(node, "qcom,vmid");
> if (num_vmids < 0) {
> - dev_err(&pdev->dev, "failed to count qcom,vmid elements: %d\n", ret);
> + dev_err(&pdev->dev, "failed to count qcom,vmid elements: %d\n", num_vmids);
> goto remove_cdev;
> } else if (num_vmids > NUM_MAX_VMIDS) {
> dev_warn(&pdev->dev,
>

2023-03-06 10:20:06

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly



On 5.03.2023 11:32, Luca Weiss wrote:
> Older platforms don't have qcom,vmid set
Ugh, "evolution" :P

, handle -EINVAL return value
> correctly. And since num_vmids is passed to of_property_read_u32_array
> later we should make sure it has a sane value before continuing.
>
> Fixes: e656cd0bcf3d ("soc: qcom: rmtfs: Optionally map RMTFS to more VMs")
> Signed-off-by: Luca Weiss <[email protected]>
> ---
This needs to be sanctioned by bindings, (i.e. if !oldplatform
require qcom,vmid), as without this property new ones will simply
lock up..

But this change is correct on its own

Reviewed-by: Konrad Dybcio <[email protected]>

Konrad
> drivers/soc/qcom/rmtfs_mem.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> index 218397ab0c36f..fb6e4def8c78b 100644
> --- a/drivers/soc/qcom/rmtfs_mem.c
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -229,7 +229,10 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
> }
>
> num_vmids = of_property_count_u32_elems(node, "qcom,vmid");
> - if (num_vmids < 0) {
> + if (num_vmids == -EINVAL) {
> + /* qcom,vmid is optional */
> + num_vmids = 0;
> + } else if (num_vmids < 0) {
> dev_err(&pdev->dev, "failed to count qcom,vmid elements: %d\n", num_vmids);
> goto remove_cdev;
> } else if (num_vmids > NUM_MAX_VMIDS) {
>

2023-03-07 04:17:28

by Bjorn Andersson

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem

On Sun, 05 Mar 2023 11:32:32 +0100, Luca Weiss wrote:
> The commit e656cd0bcf3d ("soc: qcom: rmtfs: Optionally map RMTFS to
> more VMs") which landed for v6.3-rc1 caused some issues on platforms
> such as msm8974. Fix both the error handling and behavior when qcom,vmid
> property is missing.
>
> Please include this (or another fix) in 6.3 still.
>
> [...]

Applied, thanks!

[1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid
commit: 947007419b60d5e06aa54b0f411c123db7f45a44
[2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly
commit: 749d56bd5cf311dd9b50cfc092d7a39309454077

Best regards,
--
Bjorn Andersson <[email protected]>