mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Anjelique Melendez <anjelique.melendez@oss.qualcomm.com>,
	andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] soc: qcom: pmic_glink: Add support for subsystem restart (SSR)
Date: Wed, 25 Jun 2025 02:01:45 +0300	[thread overview]
Message-ID: <c887babc-4a6c-4f53-9501-1ae66cd25c51@oss.qualcomm.com> (raw)
In-Reply-To: <20250624225535.2013141-3-anjelique.melendez@oss.qualcomm.com>

On 25/06/2025 01:55, Anjelique Melendez wrote:
> Add support for PMIC Glink clients to receive notificiation when
> the subsystem goes down and comes up again.
> 
> Signed-off-by: Anjelique Melendez <anjelique.melendez@oss.qualcomm.com>
> ---
>   drivers/soc/qcom/pmic_glink.c | 43 +++++++++++++++++++++++++++++++++--
>   1 file changed, 41 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c
> index 0a6d325b195c..5121f19d63e5 100644
> --- a/drivers/soc/qcom/pmic_glink.c
> +++ b/drivers/soc/qcom/pmic_glink.c
> @@ -2,6 +2,7 @@
>   /*
>    * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
>    * Copyright (c) 2022, Linaro Ltd
> + * ​​​​Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
>    */
>   #include <linux/auxiliary_bus.h>
>   #include <linux/cleanup.h>
> @@ -9,6 +10,7 @@
>   #include <linux/module.h>
>   #include <linux/of.h>
>   #include <linux/platform_device.h>
> +#include <linux/remoteproc/qcom_rproc.h>
>   #include <linux/rpmsg.h>
>   #include <linux/slab.h>
>   #include <linux/soc/qcom/pdr.h>
> @@ -39,10 +41,14 @@ struct pmic_glink {
>   	struct mutex state_lock;
>   	unsigned int client_state;
>   	unsigned int pdr_state;
> +	unsigned int ssr_state;
>   
>   	/* serializing clients list updates */
>   	spinlock_t client_lock;
>   	struct list_head clients;
> +
> +	struct notifier_block ssr_nb;
> +	void *ssr_handle;
>   };
>   
>   static struct pmic_glink *__pmic_glink;
> @@ -205,10 +211,12 @@ static void pmic_glink_state_notify_clients(struct pmic_glink *pg)
>   	unsigned long flags;
>   
>   	if (pg->client_state != SERVREG_SERVICE_STATE_UP) {
> -		if (pg->pdr_state == SERVREG_SERVICE_STATE_UP && pg->ept)
> +		if ((pg->pdr_state == SERVREG_SERVICE_STATE_UP ||
> +		     pg->ssr_state == QCOM_SSR_AFTER_POWERUP) && pg->ept)

carriage return after &&

>   			new_state = SERVREG_SERVICE_STATE_UP;
>   	} else {
> -		if (pg->pdr_state == SERVREG_SERVICE_STATE_DOWN || !pg->ept)
> +		if (pg->pdr_state == SERVREG_SERVICE_STATE_DOWN ||
> +		    pg->ssr_state == QCOM_SSR_BEFORE_SHUTDOWN || !pg->ept)

carriage return after ||

>   			new_state = SERVREG_SERVICE_STATE_DOWN;
>   	}
>   
> @@ -231,6 +239,18 @@ static void pmic_glink_pdr_callback(int state, char *svc_path, void *priv)
>   	pmic_glink_state_notify_clients(pg);
>   }
>   
> +static int pmic_glink_ssr_callback(struct notifier_block *nb, unsigned long code, void *data)
> +{
> +	struct pmic_glink *pg = container_of(nb, struct pmic_glink, ssr_nb);
> +
> +	mutex_lock(&pg->state_lock);
> +	pg->ssr_state = code;
> +
> +	pmic_glink_state_notify_clients(pg);
> +	mutex_unlock(&pg->state_lock);
> +	return 0;
> +}
> +
>   static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)
>   {
>   	struct pmic_glink *pg;
> @@ -281,6 +301,7 @@ static struct rpmsg_driver pmic_glink_rpmsg_driver = {
>   static int pmic_glink_probe(struct platform_device *pdev)
>   {
>   	const unsigned long *match_data;
> +	const char *subsys_name = NULL;
>   	struct pdr_service *service;
>   	struct pmic_glink *pg;
>   	int ret;
> @@ -333,6 +354,22 @@ static int pmic_glink_probe(struct platform_device *pdev)
>   		goto out_release_aux_devices;
>   	}
>   
> +	if (device_property_present(&pdev->dev, "qcom,subsys-name")) {
> +		device_property_read_string(&pdev->dev, "qcom,subsys-name", &subsys_name);

No need to read it from DT. Use a static value here.
If it differs from platform to platform, then add it to platform data 
and select it depending on the compat string.

> +		if (!subsys_name) {
> +			ret = dev_err_probe(&pdev->dev, PTR_ERR(pg->ssr_handle),
> +					"failed to read subsys_name string from dt\n");
> +			goto out_release_aux_devices;
> +		}
> +		pg->ssr_nb.notifier_call = pmic_glink_ssr_callback;
> +		pg->ssr_handle = qcom_register_ssr_notifier(subsys_name, &pg->ssr_nb);
> +		if (IS_ERR(pg->ssr_handle)) {
> +			ret = dev_err_probe(&pdev->dev, PTR_ERR(pg->ssr_handle),
> +					"failed adding ssr notifier\n");
> +			goto out_release_aux_devices;
> +		}
> +	}
> +
>   	mutex_lock(&__pmic_glink_lock);
>   	__pmic_glink = pg;
>   	mutex_unlock(&__pmic_glink_lock);
> @@ -360,6 +397,8 @@ static void pmic_glink_remove(struct platform_device *pdev)
>   
>   	pdr_handle_release(pg->pdr);
>   
> +	if (pg->ssr_handle)
> +		qcom_unregister_ssr_notifier(pg->ssr_handle, &pg->ssr_nb);
>   	if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_BATT))
>   		pmic_glink_del_aux_device(pg, &pg->ps_aux);
>   	if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_ALTMODE))


-- 
With best wishes
Dmitry

  reply	other threads:[~2025-06-24 23:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 22:55 [PATCH 0/2] " Anjelique Melendez
2025-06-24 22:55 ` [PATCH 1/2] dt-bindings: soc: qcom: qcom,pmic-glink: Add qcom,subsys-name property Anjelique Melendez
2025-06-24 22:58   ` Dmitry Baryshkov
2025-06-24 22:55 ` [PATCH 2/2] soc: qcom: pmic_glink: Add support for subsystem restart (SSR) Anjelique Melendez
2025-06-24 23:01   ` Dmitry Baryshkov [this message]
2025-06-28  3:06   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c887babc-4a6c-4f53-9501-1ae66cd25c51@oss.qualcomm.com \
    --to=dmitry.baryshkov@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=anjelique.melendez@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®