2024-04-03 03:13:58

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH v2 0/2] soc: qcom: pmic_glink: fix client handling

Fix two issues with the way the pmic_glink driver handles its clients.
First issue is mostly theoretical, while the second issue can easily be
reproduced if the drivers are built as modules.

Signed-off-by: Dmitry Baryshkov <[email protected]>
---
Changes in v2:
- Also take a lock at pmic_glink_rpmsg_callback() (Andrew Halaney)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Dmitry Baryshkov (2):
soc: qcom: pmic_glink: don't traverse clients list without a lock
soc: qcom: pmic_glink: notify clients about the current state

drivers/soc/qcom/pmic_glink.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
change-id: 20240402-pmic-glink-fix-clients-5df0bab3e871

Best regards,
--
Dmitry Baryshkov <[email protected]>



2024-04-03 03:14:12

by Dmitry Baryshkov

[permalink] [raw]
Subject: [PATCH v2 2/2] soc: qcom: pmic_glink: notify clients about the current state

In case the client is registered after the pmic-glink recived a response
from the Protection Domain mapper, it is going to miss the notification
about the state. Notify clients about the current state upon
registration.

Fixes: 58ef4ece1e41 ("soc: qcom: pmic_glink: Introduce base PMIC GLINK driver")
Reviewed-by: Andrew Halaney <[email protected]>
Signed-off-by: Dmitry Baryshkov <[email protected]>
---
drivers/soc/qcom/pmic_glink.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c
index 2b2cdf479654..e85a12ec2aab 100644
--- a/drivers/soc/qcom/pmic_glink.c
+++ b/drivers/soc/qcom/pmic_glink.c
@@ -83,9 +83,14 @@ struct pmic_glink_client *devm_pmic_glink_register_client(struct device *dev,
client->pdr_notify = pdr;
client->priv = priv;

+ mutex_lock(&pg->state_lock);
mutex_lock(&pg->client_lock);
+
list_add(&client->node, &pg->clients);
+ client->pdr_notify(client->priv, pg->client_state);
+
mutex_unlock(&pg->client_lock);
+ mutex_unlock(&pg->state_lock);

devres_add(dev, client);


--
2.39.2


2024-04-05 15:43:40

by Xilin Wu

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] soc: qcom: pmic_glink: fix client handling


On 2024/4/3 11:10, Dmitry Baryshkov wrote:
> Fix two issues with the way the pmic_glink driver handles its clients.
> First issue is mostly theoretical, while the second issue can easily be
> reproduced if the drivers are built as modules.
>
> Signed-off-by: Dmitry Baryshkov <[email protected]>
> ---
> Changes in v2:
> - Also take a lock at pmic_glink_rpmsg_callback() (Andrew Halaney)
> - Link to v1: https://lore.kernel.org/r/[email protected]
>
> ---
> Dmitry Baryshkov (2):
> soc: qcom: pmic_glink: don't traverse clients list without a lock
> soc: qcom: pmic_glink: notify clients about the current state
>
> drivers/soc/qcom/pmic_glink.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
> ---
> base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
> change-id: 20240402-pmic-glink-fix-clients-5df0bab3e871
>
> Best regards,

Tested-by: Xilin Wu <[email protected]> # on QCS8550 AYN Odin 2
Fixes:
https://lore.kernel.org/all/[email protected]/


Thanks,
Xilin

2024-04-05 16:53:11

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] soc: qcom: pmic_glink: notify clients about the current state



On 4/3/2024 8:40 AM, Dmitry Baryshkov wrote:
> In case the client is registered after the pmic-glink recived a response

received

> from the Protection Domain mapper, it is going to miss the notification
> about the state. Notify clients about the current state upon
> registration.
>
> Fixes: 58ef4ece1e41 ("soc: qcom: pmic_glink: Introduce base PMIC GLINK driver")
> Reviewed-by: Andrew Halaney <[email protected]>
> Signed-off-by: Dmitry Baryshkov <[email protected]>
> ---
> drivers/soc/qcom/pmic_glink.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c
> index 2b2cdf479654..e85a12ec2aab 100644
> --- a/drivers/soc/qcom/pmic_glink.c
> +++ b/drivers/soc/qcom/pmic_glink.c
> @@ -83,9 +83,14 @@ struct pmic_glink_client *devm_pmic_glink_register_client(struct device *dev,
> client->pdr_notify = pdr;
> client->priv = priv;
>
> + mutex_lock(&pg->state_lock);
> mutex_lock(&pg->client_lock);
> +
> list_add(&client->node, &pg->clients);
> + client->pdr_notify(client->priv, pg->client_state);
> +
> mutex_unlock(&pg->client_lock);
> + mutex_unlock(&pg->state_lock);

LGTM,

Reviewed-by: Mukesh Ojha <[email protected]>

-Mukesh
>
> devres_add(dev, client);
>
>

2024-04-21 22:29:54

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] soc: qcom: pmic_glink: fix client handling


On Wed, 03 Apr 2024 06:10:56 +0300, Dmitry Baryshkov wrote:
> Fix two issues with the way the pmic_glink driver handles its clients.
> First issue is mostly theoretical, while the second issue can easily be
> reproduced if the drivers are built as modules.
>
>

Applied, thanks!

[1/2] soc: qcom: pmic_glink: don't traverse clients list without a lock
commit: 635ce0db89567ba62f64b79e8c6664ba3eff6516
[2/2] soc: qcom: pmic_glink: notify clients about the current state
commit: d6cbce2cd354c9a37a558f290a8f1dfd20584f99

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