phone-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem
@ 2023-03-05 10:32 Luca Weiss
  2023-03-05 10:32 ` [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid Luca Weiss
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Luca Weiss @ 2023-03-05 10:32 UTC (permalink / raw)
  To: ~postmarketos/upstreaming, phone-devel, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Loic Poulain
  Cc: linux-arm-msm, linux-kernel, Luca Weiss

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 <luca@z3ntu.xyz>
---
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 <luca@z3ntu.xyz>


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

* [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid
  2023-03-05 10:32 [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Luca Weiss
@ 2023-03-05 10:32 ` Luca Weiss
  2023-03-06 10:16   ` Konrad Dybcio
  2023-03-05 10:32 ` [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly Luca Weiss
  2023-03-07  4:20 ` (subset) [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Bjorn Andersson
  2 siblings, 1 reply; 6+ messages in thread
From: Luca Weiss @ 2023-03-05 10:32 UTC (permalink / raw)
  To: ~postmarketos/upstreaming, phone-devel, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Loic Poulain
  Cc: linux-arm-msm, linux-kernel, Luca Weiss

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 <luca@z3ntu.xyz>
---
 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


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

* [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly
  2023-03-05 10:32 [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Luca Weiss
  2023-03-05 10:32 ` [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid Luca Weiss
@ 2023-03-05 10:32 ` Luca Weiss
  2023-03-06 10:19   ` Konrad Dybcio
  2023-03-07  4:20 ` (subset) [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Bjorn Andersson
  2 siblings, 1 reply; 6+ messages in thread
From: Luca Weiss @ 2023-03-05 10:32 UTC (permalink / raw)
  To: ~postmarketos/upstreaming, phone-devel, Andy Gross,
	Bjorn Andersson, Konrad Dybcio, Loic Poulain
  Cc: linux-arm-msm, linux-kernel, Luca Weiss

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 <luca@z3ntu.xyz>
---
 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


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

* Re: [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid
  2023-03-05 10:32 ` [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid Luca Weiss
@ 2023-03-06 10:16   ` Konrad Dybcio
  0 siblings, 0 replies; 6+ messages in thread
From: Konrad Dybcio @ 2023-03-06 10:16 UTC (permalink / raw)
  To: Luca Weiss, ~postmarketos/upstreaming, phone-devel, Andy Gross,
	Bjorn Andersson, Loic Poulain
  Cc: linux-arm-msm, linux-kernel



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 <luca@z3ntu.xyz>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

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,
> 

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

* Re: [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly
  2023-03-05 10:32 ` [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly Luca Weiss
@ 2023-03-06 10:19   ` Konrad Dybcio
  0 siblings, 0 replies; 6+ messages in thread
From: Konrad Dybcio @ 2023-03-06 10:19 UTC (permalink / raw)
  To: Luca Weiss, ~postmarketos/upstreaming, phone-devel, Andy Gross,
	Bjorn Andersson, Loic Poulain
  Cc: linux-arm-msm, linux-kernel



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 <luca@z3ntu.xyz>
> ---
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 <konrad.dybcio@linaro.org>

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) {
> 

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

* Re: (subset) [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem
  2023-03-05 10:32 [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Luca Weiss
  2023-03-05 10:32 ` [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid Luca Weiss
  2023-03-05 10:32 ` [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly Luca Weiss
@ 2023-03-07  4:20 ` Bjorn Andersson
  2 siblings, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2023-03-07  4:20 UTC (permalink / raw)
  To: Konrad Dybcio, ~postmarketos/upstreaming, Luca Weiss,
	Loic Poulain, phone-devel, Andy Gross
  Cc: linux-arm-msm, linux-kernel

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 <andersson@kernel.org>

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

end of thread, other threads:[~2023-03-07  4:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-05 10:32 [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Luca Weiss
2023-03-05 10:32 ` [PATCH 1/2] soc: qcom: rmtfs: fix error handling reading qcom,vmid Luca Weiss
2023-03-06 10:16   ` Konrad Dybcio
2023-03-05 10:32 ` [PATCH 2/2] soc: qcom: rmtfs: handle optional qcom,vmid correctly Luca Weiss
2023-03-06 10:19   ` Konrad Dybcio
2023-03-07  4:20 ` (subset) [PATCH 0/2] Fix qcom,vmid handling in rmtfs_mem Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).