From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
To restrict gunyah watchdog initialization to Qualcomm platforms,
register the watchdog device in the SMEM driver.
When Gunyah is not present or Gunyah emulates MMIO-based
watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
present in the devicetree. If none of these device nodes are detected,
we register the SMC-based Gunyah watchdog device.
Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
---
drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index cf425930539e..40e4749fab02 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
return 0;
}
+static int register_gunyah_wdt_device(void)
+{
+ struct platform_device *gunyah_wdt_dev;
+ struct device_node *np;
+
+ /*
+ * When Gunyah is not present or Gunyah is emulating a memory-mapped
+ * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
+ * present. Skip initialization of SMC-based Gunyah watchdog if that is
+ * the case.
+ */
+ np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
+ if (np) {
+ of_node_put(np);
+ return 0;
+ }
+
+ np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
+ if (np) {
+ of_node_put(np);
+ return 0;
+ }
+
+ gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
+ NULL, 0);
+ return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
+}
+
static int qcom_smem_probe(struct platform_device *pdev)
{
struct smem_header *header;
@@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
if (IS_ERR(smem->socinfo))
dev_dbg(&pdev->dev, "failed to register socinfo device\n");
+ ret = register_gunyah_wdt_device();
+ if (ret)
+ dev_dbg(&pdev->dev, "failed to register watchdog device\n");
+
return 0;
}
static void qcom_smem_remove(struct platform_device *pdev)
{
+ /*
+ * Gunyah watchdog is intended to be a persistent module. Hence, the
+ * watchdog device is not unregistered.
+ */
+
platform_device_unregister(__smem->socinfo);
hwspin_lock_free(__smem->hwlock);
--
2.43.0
On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
> From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>
> To restrict gunyah watchdog initialization to Qualcomm platforms,
> register the watchdog device in the SMEM driver.
>
> When Gunyah is not present or Gunyah emulates MMIO-based
> watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> present in the devicetree. If none of these device nodes are detected,
> we register the SMC-based Gunyah watchdog device.
>
> Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> ---
> drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index cf425930539e..40e4749fab02 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> return 0;
> }
>
> +static int register_gunyah_wdt_device(void)
> +{
> + struct platform_device *gunyah_wdt_dev;
> + struct device_node *np;
> +
> + /*
> + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> + * the case.
E.g. qcom-apq8064.dtsi doesn't define either qcom,kpss-wdt, nor
arm,sbsa-gwdt, does that imply that it implements the Gunyah watchdog?
> + */
> + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
> + if (np) {
> + of_node_put(np);
> + return 0;
> + }
> +
> + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
> + if (np) {
> + of_node_put(np);
> + return 0;
> + }
> +
> + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
> + NULL, 0);
> + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
> +}
> +
> static int qcom_smem_probe(struct platform_device *pdev)
> {
> struct smem_header *header;
> @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
> if (IS_ERR(smem->socinfo))
> dev_dbg(&pdev->dev, "failed to register socinfo device\n");
>
> + ret = register_gunyah_wdt_device();
> + if (ret)
> + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
> +
> return 0;
> }
>
> static void qcom_smem_remove(struct platform_device *pdev)
> {
> + /*
> + * Gunyah watchdog is intended to be a persistent module. Hence, the
> + * watchdog device is not unregistered.
> + */
Why? I don't see why the code needs to encode such policy, please
explain.
Regards,
Bjorn
> +
> platform_device_unregister(__smem->socinfo);
>
> hwspin_lock_free(__smem->hwlock);
>
> --
> 2.43.0
>
>
On 11/2/2025 12:15 AM, Bjorn Andersson wrote:
> On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
>> From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>>
>> To restrict gunyah watchdog initialization to Qualcomm platforms,
>> register the watchdog device in the SMEM driver.
>>
>> When Gunyah is not present or Gunyah emulates MMIO-based
>> watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
>> present in the devicetree. If none of these device nodes are detected,
>> we register the SMC-based Gunyah watchdog device.
>>
>> Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>> ---
>> drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
>> 1 file changed, 37 insertions(+)
>>
>> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
>> index cf425930539e..40e4749fab02 100644
>> --- a/drivers/soc/qcom/smem.c
>> +++ b/drivers/soc/qcom/smem.c
>> @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
>> return 0;
>> }
>>
>> +static int register_gunyah_wdt_device(void)
>> +{
>> + struct platform_device *gunyah_wdt_dev;
>> + struct device_node *np;
>> +
>> + /*
>> + * When Gunyah is not present or Gunyah is emulating a memory-mapped
>> + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
>> + * present. Skip initialization of SMC-based Gunyah watchdog if that is
>> + * the case.
> E.g. qcom-apq8064.dtsi doesn't define either qcom,kpss-wdt, nor
> arm,sbsa-gwdt, does that imply that it implements the Gunyah watchdog?
It doesn't implement Gunyah watchdog. For platforms like these we've
kept a STATUS SMC call in the gunyah_wdt_probe().
The SMC Call is expected to fail on platforms which do not have support
for SMC based Gunyah watchdog, which in turn will fail the probe.
Let us know if there's a better way to handle this.
>> + */
>> + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
>> + if (np) {
>> + of_node_put(np);
>> + return 0;
>> + }
>> +
>> + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
>> + if (np) {
>> + of_node_put(np);
>> + return 0;
>> + }
>> +
>> + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
>> + NULL, 0);
>> + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
>> +}
>> +
>> static int qcom_smem_probe(struct platform_device *pdev)
>> {
>> struct smem_header *header;
>> @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
>> if (IS_ERR(smem->socinfo))
>> dev_dbg(&pdev->dev, "failed to register socinfo device\n");
>>
>> + ret = register_gunyah_wdt_device();
>> + if (ret)
>> + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
>> +
>> return 0;
>> }
>>
>> static void qcom_smem_remove(struct platform_device *pdev)
>> {
>> + /*
>> + * Gunyah watchdog is intended to be a persistent module. Hence, the
>> + * watchdog device is not unregistered.
>> + */
> Why? I don't see why the code needs to encode such policy, please
> explain.
You're right, there is no such need. We're at wrong here. We had an
incorrect understanding of watchdog drivers being persistent. We will be
implementing the module_exit() for the Gunyah watchdog making it not
persistent.
Thanks,
Hrishabh
On Mon, Nov 03, 2025 at 04:03:44PM +0530, Hrishabh Rajput wrote:
>
> On 11/2/2025 12:15 AM, Bjorn Andersson wrote:
> > On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
> > > From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > >
> > > To restrict gunyah watchdog initialization to Qualcomm platforms,
> > > register the watchdog device in the SMEM driver.
> > >
> > > When Gunyah is not present or Gunyah emulates MMIO-based
> > > watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> > > present in the devicetree. If none of these device nodes are detected,
> > > we register the SMC-based Gunyah watchdog device.
> > >
> > > Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > ---
> > > drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 37 insertions(+)
> > >
> > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > > index cf425930539e..40e4749fab02 100644
> > > --- a/drivers/soc/qcom/smem.c
> > > +++ b/drivers/soc/qcom/smem.c
> > > @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> > > return 0;
> > > }
> > > +static int register_gunyah_wdt_device(void)
> > > +{
> > > + struct platform_device *gunyah_wdt_dev;
> > > + struct device_node *np;
> > > +
> > > + /*
> > > + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> > > + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> > > + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> > > + * the case.
> > E.g. qcom-apq8064.dtsi doesn't define either qcom,kpss-wdt, nor
> > arm,sbsa-gwdt, does that imply that it implements the Gunyah watchdog?
>
>
> It doesn't implement Gunyah watchdog. For platforms like these we've kept a
> STATUS SMC call in the gunyah_wdt_probe().
>
I think it would be good to make that call before registering the
platform driver.
> The SMC Call is expected to fail on platforms which do not have support for
> SMC based Gunyah watchdog, which in turn will fail the probe.
>
Perhaps I'm missing something, just looked quickly and it's been a while
since I looked at this code, but you're making a HVC (or SMC) call with
the function:
ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, ARM_SMCCC_OWNER_VENDOR_HYP, 6)
which doesn't look unique to Gunyah in my eyes.
If I read correctly, the ARM_SMCCC_SMC_32 is the only bit (literally)
that differentiates this from being a __vgic_v3_get_gic_config() call in
KVM, just as an example.
Regards,
Bjorn
> Let us know if there's a better way to handle this.
>
> > > + */
> > > + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
> > > + if (np) {
> > > + of_node_put(np);
> > > + return 0;
> > > + }
> > > +
> > > + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
> > > + if (np) {
> > > + of_node_put(np);
> > > + return 0;
> > > + }
> > > +
> > > + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
> > > + NULL, 0);
> > > + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
> > > +}
> > > +
> > > static int qcom_smem_probe(struct platform_device *pdev)
> > > {
> > > struct smem_header *header;
> > > @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
> > > if (IS_ERR(smem->socinfo))
> > > dev_dbg(&pdev->dev, "failed to register socinfo device\n");
> > > + ret = register_gunyah_wdt_device();
> > > + if (ret)
> > > + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
> > > +
> > > return 0;
> > > }
> > > static void qcom_smem_remove(struct platform_device *pdev)
> > > {
> > > + /*
> > > + * Gunyah watchdog is intended to be a persistent module. Hence, the
> > > + * watchdog device is not unregistered.
> > > + */
> > Why? I don't see why the code needs to encode such policy, please
> > explain.
>
>
> You're right, there is no such need. We're at wrong here. We had an
> incorrect understanding of watchdog drivers being persistent. We will be
> implementing the module_exit() for the Gunyah watchdog making it not
> persistent.
>
>
> Thanks,
>
> Hrishabh
>
On Mon, Nov 03, 2025 at 07:01:51PM -0600, Bjorn Andersson wrote:
> On Mon, Nov 03, 2025 at 04:03:44PM +0530, Hrishabh Rajput wrote:
> >
> > On 11/2/2025 12:15 AM, Bjorn Andersson wrote:
> > > On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
> > > > From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > >
> > > > To restrict gunyah watchdog initialization to Qualcomm platforms,
> > > > register the watchdog device in the SMEM driver.
> > > >
> > > > When Gunyah is not present or Gunyah emulates MMIO-based
> > > > watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> > > > present in the devicetree. If none of these device nodes are detected,
> > > > we register the SMC-based Gunyah watchdog device.
> > > >
> > > > Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > > ---
> > > > drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> > > > 1 file changed, 37 insertions(+)
> > > >
> > > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > > > index cf425930539e..40e4749fab02 100644
> > > > --- a/drivers/soc/qcom/smem.c
> > > > +++ b/drivers/soc/qcom/smem.c
> > > > @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> > > > return 0;
> > > > }
> > > > +static int register_gunyah_wdt_device(void)
> > > > +{
> > > > + struct platform_device *gunyah_wdt_dev;
> > > > + struct device_node *np;
> > > > +
> > > > + /*
> > > > + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> > > > + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> > > > + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> > > > + * the case.
> > > E.g. qcom-apq8064.dtsi doesn't define either qcom,kpss-wdt, nor
> > > arm,sbsa-gwdt, does that imply that it implements the Gunyah watchdog?
> >
> >
> > It doesn't implement Gunyah watchdog. For platforms like these we've kept a
> > STATUS SMC call in the gunyah_wdt_probe().
> >
>
> I think it would be good to make that call before registering the
> platform driver.
Did you mean platform device here? Becase we don't want the gunayh-wdt
module to do anything other than registering the platform driver on
platforms other than qcom.
>
> > The SMC Call is expected to fail on platforms which do not have support for
> > SMC based Gunyah watchdog, which in turn will fail the probe.
> >
>
> Perhaps I'm missing something, just looked quickly and it's been a while
> since I looked at this code, but you're making a HVC (or SMC) call with
> the function:
>
> ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, ARM_SMCCC_OWNER_VENDOR_HYP, 6)
>
> which doesn't look unique to Gunyah in my eyes.
>
> If I read correctly, the ARM_SMCCC_SMC_32 is the only bit (literally)
> that differentiates this from being a __vgic_v3_get_gic_config() call in
> KVM, just as an example.
>
Yes, you are right. This SMCC falls under ARM_SMCCC_OWNER_VENDOR_HYP
space, so it would behave differently on different hypervisors.
Please let me know what you think about this **defensive** approach.
- Move the Gunyah platform device registration to SCM driver.
- Checks to be done before registering the device
- Make ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID SMC [1] to verify that we are
running under gunyah
- check for the other wdt devices like kpss, sbsa in dT
ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID SMC will not be supported by all
versions of Gunyah, but atleast it would confirm the definitive presence
of Gunyah.
[1]
https://lore.kernel.org/all/20240222-gunyah-v17-4-1e9da6763d38@quicinc.com/
On Tue, Nov 04, 2025 at 09:00:27AM +0530, Pavan Kondeti wrote:
> On Mon, Nov 03, 2025 at 07:01:51PM -0600, Bjorn Andersson wrote:
> > On Mon, Nov 03, 2025 at 04:03:44PM +0530, Hrishabh Rajput wrote:
> > >
> > > On 11/2/2025 12:15 AM, Bjorn Andersson wrote:
> > > > On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
> > > > > From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > > >
> > > > > To restrict gunyah watchdog initialization to Qualcomm platforms,
> > > > > register the watchdog device in the SMEM driver.
> > > > >
> > > > > When Gunyah is not present or Gunyah emulates MMIO-based
> > > > > watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> > > > > present in the devicetree. If none of these device nodes are detected,
> > > > > we register the SMC-based Gunyah watchdog device.
> > > > >
> > > > > Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > > > ---
> > > > > drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> > > > > 1 file changed, 37 insertions(+)
> > > > >
> > > > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > > > > index cf425930539e..40e4749fab02 100644
> > > > > --- a/drivers/soc/qcom/smem.c
> > > > > +++ b/drivers/soc/qcom/smem.c
> > > > > @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> > > > > return 0;
> > > > > }
> > > > > +static int register_gunyah_wdt_device(void)
> > > > > +{
> > > > > + struct platform_device *gunyah_wdt_dev;
> > > > > + struct device_node *np;
> > > > > +
> > > > > + /*
> > > > > + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> > > > > + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> > > > > + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> > > > > + * the case.
> > > > E.g. qcom-apq8064.dtsi doesn't define either qcom,kpss-wdt, nor
> > > > arm,sbsa-gwdt, does that imply that it implements the Gunyah watchdog?
> > >
> > >
> > > It doesn't implement Gunyah watchdog. For platforms like these we've kept a
> > > STATUS SMC call in the gunyah_wdt_probe().
> > >
> >
> > I think it would be good to make that call before registering the
> > platform driver.
>
> Did you mean platform device here? Becase we don't want the gunayh-wdt
> module to do anything other than registering the platform driver on
> platforms other than qcom.
>
Yes, device, not driver.
So in SCM driver (I think that's a better match than SMEM), do a:
if (are_we_running_under_gunyah())
platform_device_register(gunya-wdt);
The Gunyah WDT _driver_ should based on that be autoloaded by the
platform:gunyah-wdt alias.
> >
> > > The SMC Call is expected to fail on platforms which do not have support for
> > > SMC based Gunyah watchdog, which in turn will fail the probe.
> > >
> >
> > Perhaps I'm missing something, just looked quickly and it's been a while
> > since I looked at this code, but you're making a HVC (or SMC) call with
> > the function:
> >
> > ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, ARM_SMCCC_OWNER_VENDOR_HYP, 6)
> >
> > which doesn't look unique to Gunyah in my eyes.
> >
> > If I read correctly, the ARM_SMCCC_SMC_32 is the only bit (literally)
> > that differentiates this from being a __vgic_v3_get_gic_config() call in
> > KVM, just as an example.
> >
>
> Yes, you are right. This SMCC falls under ARM_SMCCC_OWNER_VENDOR_HYP
> space, so it would behave differently on different hypervisors.
>
> Please let me know what you think about this **defensive** approach.
>
> - Move the Gunyah platform device registration to SCM driver.
> - Checks to be done before registering the device
> - Make ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID SMC [1] to verify that we are
> running under gunyah
> - check for the other wdt devices like kpss, sbsa in dT
>
> ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID SMC will not be supported by all
> versions of Gunyah, but atleast it would confirm the definitive presence
> of Gunyah.
>
Yes, this looks good.
I presume if we determine that Gunyah is present, and we haven't put
sbsa wdt in place (e.g. during bringup) Gunyah and Gunyah WDT will
handle the outcome gracefully...
Regards,
Bjorn
> [1]
> https://lore.kernel.org/all/20240222-gunyah-v17-4-1e9da6763d38@quicinc.com/
On Mon, Nov 03, 2025 at 09:52:25PM -0600, Bjorn Andersson wrote:
> On Tue, Nov 04, 2025 at 09:00:27AM +0530, Pavan Kondeti wrote:
> > On Mon, Nov 03, 2025 at 07:01:51PM -0600, Bjorn Andersson wrote:
> > > On Mon, Nov 03, 2025 at 04:03:44PM +0530, Hrishabh Rajput wrote:
> > > >
> > > > On 11/2/2025 12:15 AM, Bjorn Andersson wrote:
> > > > > On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
> > > > > > From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > > > >
> > > > > > To restrict gunyah watchdog initialization to Qualcomm platforms,
> > > > > > register the watchdog device in the SMEM driver.
> > > > > >
> > > > > > When Gunyah is not present or Gunyah emulates MMIO-based
> > > > > > watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> > > > > > present in the devicetree. If none of these device nodes are detected,
> > > > > > we register the SMC-based Gunyah watchdog device.
> > > > > >
> > > > > > Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > > > > ---
> > > > > > drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> > > > > > 1 file changed, 37 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > > > > > index cf425930539e..40e4749fab02 100644
> > > > > > --- a/drivers/soc/qcom/smem.c
> > > > > > +++ b/drivers/soc/qcom/smem.c
> > > > > > @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> > > > > > return 0;
> > > > > > }
> > > > > > +static int register_gunyah_wdt_device(void)
> > > > > > +{
> > > > > > + struct platform_device *gunyah_wdt_dev;
> > > > > > + struct device_node *np;
> > > > > > +
> > > > > > + /*
> > > > > > + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> > > > > > + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> > > > > > + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> > > > > > + * the case.
> > > > > E.g. qcom-apq8064.dtsi doesn't define either qcom,kpss-wdt, nor
> > > > > arm,sbsa-gwdt, does that imply that it implements the Gunyah watchdog?
> > > >
> > > >
> > > > It doesn't implement Gunyah watchdog. For platforms like these we've kept a
> > > > STATUS SMC call in the gunyah_wdt_probe().
> > > >
> > >
> > > I think it would be good to make that call before registering the
> > > platform driver.
> >
> > Did you mean platform device here? Becase we don't want the gunayh-wdt
> > module to do anything other than registering the platform driver on
> > platforms other than qcom.
> >
>
> Yes, device, not driver.
>
> So in SCM driver (I think that's a better match than SMEM), do a:
> if (are_we_running_under_gunyah())
> platform_device_register(gunya-wdt);
>
> The Gunyah WDT _driver_ should based on that be autoloaded by the
> platform:gunyah-wdt alias.
Thanks for the clarification.
>
> > >
> > > > The SMC Call is expected to fail on platforms which do not have support for
> > > > SMC based Gunyah watchdog, which in turn will fail the probe.
> > > >
> > >
> > > Perhaps I'm missing something, just looked quickly and it's been a while
> > > since I looked at this code, but you're making a HVC (or SMC) call with
> > > the function:
> > >
> > > ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, ARM_SMCCC_OWNER_VENDOR_HYP, 6)
> > >
> > > which doesn't look unique to Gunyah in my eyes.
> > >
> > > If I read correctly, the ARM_SMCCC_SMC_32 is the only bit (literally)
> > > that differentiates this from being a __vgic_v3_get_gic_config() call in
> > > KVM, just as an example.
> > >
> >
> > Yes, you are right. This SMCC falls under ARM_SMCCC_OWNER_VENDOR_HYP
> > space, so it would behave differently on different hypervisors.
> >
> > Please let me know what you think about this **defensive** approach.
> >
> > - Move the Gunyah platform device registration to SCM driver.
> > - Checks to be done before registering the device
> > - Make ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID SMC [1] to verify that we are
> > running under gunyah
> > - check for the other wdt devices like kpss, sbsa in dT
> >
> > ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID SMC will not be supported by all
> > versions of Gunyah, but atleast it would confirm the definitive presence
> > of Gunyah.
> >
>
> Yes, this looks good.
>
Thanks, I think QCM SCM driver hosting this would be a good idea.
> I presume if we determine that Gunyah is present, and we haven't put
> sbsa wdt in place (e.g. during bringup) Gunyah and Gunyah WDT will
> handle the outcome gracefully...
>
Yes, we are told Gunyah support SMCC based WDT even if it emulates
SBSA. Most importantly, we have STATUS SMC in gunyah-wdt probe before
registering the watchdog device.
The following two patches which merged recently will make the above
implementation simpler. Providing them here for the reference material
for v5.
- arm_smccc_hypervisor_has_uuid() API addition from
https://lore.kernel.org/all/20250428210742.435282-2-romank@linux.microsoft.com/
Please note that recent commit make this API available for SMC conduit
as well.
- qcom_scm_qtee_init() example from
https://lore.kernel.org/all/20250911-qcom-tee-using-tee-ss-without-mem-obj-v12-2-17f07a942b8d@oss.qualcomm.com/
Thanks,
Pavan
On Tue, Nov 04, 2025 at 10:33:52AM +0530, Pavan Kondeti wrote: > > > I presume if we determine that Gunyah is present, and we haven't put > > sbsa wdt in place (e.g. during bringup) Gunyah and Gunyah WDT will > > handle the outcome gracefully... > > > Yes, we are told Gunyah support SMCC based WDT even if it emulates > SBSA. Most importantly, we have STATUS SMC in gunyah-wdt probe before > registering the watchdog device. > Thanks Bjorn for asking this question. I have tested this scenario on Kaanapali. Since the initial platform support patches have added watchdog device, I don't see gunyah-wdt platform device created. When I removed the node, I see gunyah-wdt platform device is created and the driver is probed successfully. Since this patch checks the device node presence via of_find_compatible_node(), it does not cover the case where the node is present but marked as disabled/reserved etc. I think it would be good to add of_device_is_available() check as well to cover this case. Thanks, Pavan
On 10/31/25 03:18, Hrishabh Rajput via B4 Relay wrote:
> From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>
> To restrict gunyah watchdog initialization to Qualcomm platforms,
> register the watchdog device in the SMEM driver.
>
> When Gunyah is not present or Gunyah emulates MMIO-based
> watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> present in the devicetree. If none of these device nodes are detected,
> we register the SMC-based Gunyah watchdog device.
>
There should also be an explanation why there is no "qcom,gunyah-wdt"
devicetree node, both here and in the file.
> Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> ---
> drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index cf425930539e..40e4749fab02 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> return 0;
> }
>
> +static int register_gunyah_wdt_device(void)
> +{
> + struct platform_device *gunyah_wdt_dev;
> + struct device_node *np;
> +
> + /*
> + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> + * the case.
> + */
> + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
> + if (np) {
> + of_node_put(np);
> + return 0;
> + }
> +
> + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
> + if (np) {
> + of_node_put(np);
> + return 0;
> + }
> +
> + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
> + NULL, 0);
> + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
> +}
> +
> static int qcom_smem_probe(struct platform_device *pdev)
> {
> struct smem_header *header;
> @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
> if (IS_ERR(smem->socinfo))
> dev_dbg(&pdev->dev, "failed to register socinfo device\n");
>
> + ret = register_gunyah_wdt_device();
> + if (ret)
> + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
> +
> return 0;
> }
>
> static void qcom_smem_remove(struct platform_device *pdev)
> {
> + /*
> + * Gunyah watchdog is intended to be a persistent module. Hence, the
> + * watchdog device is not unregistered.
> + */
> +
Odd explanation. I would assume that the smem device is supposed to be
persistent as well. Since that is not the case, what happens if _this_
device is unregistered and registered again ?
Guenter
> platform_device_unregister(__smem->socinfo);
>
> hwspin_lock_free(__smem->hwlock);
>
On 10/31/2025 8:54 PM, Guenter Roeck wrote:
> On 10/31/25 03:18, Hrishabh Rajput via B4 Relay wrote:
>> From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>>
>> To restrict gunyah watchdog initialization to Qualcomm platforms,
>> register the watchdog device in the SMEM driver.
>>
>> When Gunyah is not present or Gunyah emulates MMIO-based
>> watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
>> present in the devicetree. If none of these device nodes are detected,
>> we register the SMC-based Gunyah watchdog device.
>>
>
> There should also be an explanation why there is no "qcom,gunyah-wdt"
> devicetree node, both here and in the file.
>
Ok sure, we'll include an explanation about this in the commit
description and in the file.
>> Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>> ---
>> drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
>> 1 file changed, 37 insertions(+)
>>
>> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
>> index cf425930539e..40e4749fab02 100644
>> --- a/drivers/soc/qcom/smem.c
>> +++ b/drivers/soc/qcom/smem.c
>> @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct
>> qcom_smem *smem, const char *name,
>> return 0;
>> }
>> +static int register_gunyah_wdt_device(void)
>> +{
>> + struct platform_device *gunyah_wdt_dev;
>> + struct device_node *np;
>> +
>> + /*
>> + * When Gunyah is not present or Gunyah is emulating a
>> memory-mapped
>> + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog
>> will be
>> + * present. Skip initialization of SMC-based Gunyah watchdog if
>> that is
>> + * the case.
>> + */
>> + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
>> + if (np) {
>> + of_node_put(np);
>> + return 0;
>> + }
>> +
>> + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
>> + if (np) {
>> + of_node_put(np);
>> + return 0;
>> + }
>> +
>> + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
>> + NULL, 0);
>> + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
>> +}
>> +
>> static int qcom_smem_probe(struct platform_device *pdev)
>> {
>> struct smem_header *header;
>> @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct
>> platform_device *pdev)
>> if (IS_ERR(smem->socinfo))
>> dev_dbg(&pdev->dev, "failed to register socinfo device\n");
>> + ret = register_gunyah_wdt_device();
>> + if (ret)
>> + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
>> +
>> return 0;
>> }
>> static void qcom_smem_remove(struct platform_device *pdev)
>> {
>> + /*
>> + * Gunyah watchdog is intended to be a persistent module. Hence,
>> the
>> + * watchdog device is not unregistered.
>> + */
>> +
>
> Odd explanation. I would assume that the smem device is supposed to be
> persistent as well. Since that is not the case, what happens if _this_
> device is unregistered and registered again ?
>
Thanks for pointing this out. qcom_smem_probe() will try to register the
watchdog device again while it is already registered. As per the
discussion in the other thread, we'll be implementing the module_exit()
for Gunyah watchdog driver so it will not be a persistent module
anymore. This problem will not exist then.
Thanks,
Hrishabh
On Fri, Oct 31, 2025 at 08:24:44AM -0700, Guenter Roeck wrote:
> On 10/31/25 03:18, Hrishabh Rajput via B4 Relay wrote:
> > From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> >
> > To restrict gunyah watchdog initialization to Qualcomm platforms,
> > register the watchdog device in the SMEM driver.
> >
> > When Gunyah is not present or Gunyah emulates MMIO-based
> > watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> > present in the devicetree. If none of these device nodes are detected,
> > we register the SMC-based Gunyah watchdog device.
> >
>
> There should also be an explanation why there is no "qcom,gunyah-wdt"
> devicetree node, both here and in the file.
>
> > Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > ---
> > drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> > 1 file changed, 37 insertions(+)
> >
> > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > index cf425930539e..40e4749fab02 100644
> > --- a/drivers/soc/qcom/smem.c
> > +++ b/drivers/soc/qcom/smem.c
> > @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> > return 0;
> > }
> > +static int register_gunyah_wdt_device(void)
> > +{
> > + struct platform_device *gunyah_wdt_dev;
> > + struct device_node *np;
> > +
> > + /*
> > + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> > + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> > + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> > + * the case.
> > + */
> > + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
> > + if (np) {
> > + of_node_put(np);
> > + return 0;
> > + }
> > +
> > + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
> > + if (np) {
> > + of_node_put(np);
> > + return 0;
> > + }
> > +
> > + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
> > + NULL, 0);
> > + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
> > +}
> > +
> > static int qcom_smem_probe(struct platform_device *pdev)
> > {
> > struct smem_header *header;
> > @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
> > if (IS_ERR(smem->socinfo))
> > dev_dbg(&pdev->dev, "failed to register socinfo device\n");
> > + ret = register_gunyah_wdt_device();
> > + if (ret)
> > + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
> > +
> > return 0;
> > }
> > static void qcom_smem_remove(struct platform_device *pdev)
> > {
> > + /*
> > + * Gunyah watchdog is intended to be a persistent module. Hence, the
> > + * watchdog device is not unregistered.
> > + */
> > +
>
> Odd explanation.
> I would assume that the smem device is supposed to be
> persistent as well.
Yes, but it's perfectly possible to run a modern Qualcomm device without
SMEM, with a fair amount of functionality. So, the reevaluation of this
decision is grinding in the back of my mind...
Regards,
Bjorn
> Since that is not the case, what happens if _this_
> device is unregistered and registered again ?
>
> Guenter
>
> > platform_device_unregister(__smem->socinfo);
> > hwspin_lock_free(__smem->hwlock);
> >
>
On 11/2/2025 12:20 AM, Bjorn Andersson wrote:
> On Fri, Oct 31, 2025 at 08:24:44AM -0700, Guenter Roeck wrote:
>> On 10/31/25 03:18, Hrishabh Rajput via B4 Relay wrote:
>>> From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>>>
>>> To restrict gunyah watchdog initialization to Qualcomm platforms,
>>> register the watchdog device in the SMEM driver.
>>>
>>> When Gunyah is not present or Gunyah emulates MMIO-based
>>> watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
>>> present in the devicetree. If none of these device nodes are detected,
>>> we register the SMC-based Gunyah watchdog device.
>>>
>> There should also be an explanation why there is no "qcom,gunyah-wdt"
>> devicetree node, both here and in the file.
>>
>>> Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>>> ---
>>> drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 37 insertions(+)
>>>
>>> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
>>> index cf425930539e..40e4749fab02 100644
>>> --- a/drivers/soc/qcom/smem.c
>>> +++ b/drivers/soc/qcom/smem.c
>>> @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
>>> return 0;
>>> }
>>> +static int register_gunyah_wdt_device(void)
>>> +{
>>> + struct platform_device *gunyah_wdt_dev;
>>> + struct device_node *np;
>>> +
>>> + /*
>>> + * When Gunyah is not present or Gunyah is emulating a memory-mapped
>>> + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
>>> + * present. Skip initialization of SMC-based Gunyah watchdog if that is
>>> + * the case.
>>> + */
>>> + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
>>> + if (np) {
>>> + of_node_put(np);
>>> + return 0;
>>> + }
>>> +
>>> + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
>>> + if (np) {
>>> + of_node_put(np);
>>> + return 0;
>>> + }
>>> +
>>> + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
>>> + NULL, 0);
>>> + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
>>> +}
>>> +
>>> static int qcom_smem_probe(struct platform_device *pdev)
>>> {
>>> struct smem_header *header;
>>> @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
>>> if (IS_ERR(smem->socinfo))
>>> dev_dbg(&pdev->dev, "failed to register socinfo device\n");
>>> + ret = register_gunyah_wdt_device();
>>> + if (ret)
>>> + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
>>> +
>>> return 0;
>>> }
>>> static void qcom_smem_remove(struct platform_device *pdev)
>>> {
>>> + /*
>>> + * Gunyah watchdog is intended to be a persistent module. Hence, the
>>> + * watchdog device is not unregistered.
>>> + */
>>> +
>> Odd explanation.
>> I would assume that the smem device is supposed to be
>> persistent as well.
> Yes, but it's perfectly possible to run a modern Qualcomm device without
> SMEM, with a fair amount of functionality. So, the reevaluation of this
> decision is grinding in the back of my mind...
One option can be the SCM driver which was suggested by Neil in v3 [1].
Let us know if you have any suggestions where we can register the
watchdog device?
[1]:
https://lore.kernel.org/lkml/321f5289-64c0-48f1-91b5-c45e82396ca9@linaro.org/
Thanks,
Hrishabh
On Mon, Nov 03, 2025 at 03:23:27PM +0530, Hrishabh Rajput wrote:
>
> On 11/2/2025 12:20 AM, Bjorn Andersson wrote:
> > On Fri, Oct 31, 2025 at 08:24:44AM -0700, Guenter Roeck wrote:
> > > On 10/31/25 03:18, Hrishabh Rajput via B4 Relay wrote:
> > > > From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > >
> > > > To restrict gunyah watchdog initialization to Qualcomm platforms,
> > > > register the watchdog device in the SMEM driver.
> > > >
> > > > When Gunyah is not present or Gunyah emulates MMIO-based
> > > > watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> > > > present in the devicetree. If none of these device nodes are detected,
> > > > we register the SMC-based Gunyah watchdog device.
> > > >
> > > There should also be an explanation why there is no "qcom,gunyah-wdt"
> > > devicetree node, both here and in the file.
> > >
> > > > Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> > > > ---
> > > > drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> > > > 1 file changed, 37 insertions(+)
> > > >
> > > > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > > > index cf425930539e..40e4749fab02 100644
> > > > --- a/drivers/soc/qcom/smem.c
> > > > +++ b/drivers/soc/qcom/smem.c
> > > > @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> > > > return 0;
> > > > }
> > > > +static int register_gunyah_wdt_device(void)
> > > > +{
> > > > + struct platform_device *gunyah_wdt_dev;
> > > > + struct device_node *np;
> > > > +
> > > > + /*
> > > > + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> > > > + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> > > > + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> > > > + * the case.
> > > > + */
> > > > + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
> > > > + if (np) {
> > > > + of_node_put(np);
> > > > + return 0;
> > > > + }
> > > > +
> > > > + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
> > > > + if (np) {
> > > > + of_node_put(np);
> > > > + return 0;
> > > > + }
> > > > +
> > > > + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
> > > > + NULL, 0);
> > > > + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
> > > > +}
> > > > +
> > > > static int qcom_smem_probe(struct platform_device *pdev)
> > > > {
> > > > struct smem_header *header;
> > > > @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
> > > > if (IS_ERR(smem->socinfo))
> > > > dev_dbg(&pdev->dev, "failed to register socinfo device\n");
> > > > + ret = register_gunyah_wdt_device();
> > > > + if (ret)
> > > > + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
> > > > +
> > > > return 0;
> > > > }
> > > > static void qcom_smem_remove(struct platform_device *pdev)
> > > > {
> > > > + /*
> > > > + * Gunyah watchdog is intended to be a persistent module. Hence, the
> > > > + * watchdog device is not unregistered.
> > > > + */
> > > > +
> > > Odd explanation.
> > > I would assume that the smem device is supposed to be
> > > persistent as well.
> > Yes, but it's perfectly possible to run a modern Qualcomm device without
> > SMEM, with a fair amount of functionality. So, the reevaluation of this
> > decision is grinding in the back of my mind...
>
> One option can be the SCM driver which was suggested by Neil in v3 [1].
>
> Let us know if you have any suggestions where we can register the watchdog
> device?
>
I think it makes more sense to tie it to the SCM driver, it's after all
related to the HVC-interface, which SMEM isn't.
But I don't think that answers our question of how do you determine if
Gunyah is there or not. Because qcom,scm-sc7280 is regardless of Linux
running under Gunyah, KVM, or directly in EL2.
I can't help feeling that this is a property of the hardware/firmware
interface that the OS finds itself in, which should be expressed in
DeviceTree - unless there's a bulletproof "Gunyah, are you there?"
check.
Regards,
Bjorn
> [1]:
> https://lore.kernel.org/lkml/321f5289-64c0-48f1-91b5-c45e82396ca9@linaro.org/
>
> Thanks,
>
> Hrishabh
>
On Fri, Oct 31, 2025 at 10:18:13AM +0000, Hrishabh Rajput via B4 Relay wrote:
> From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
>
> To restrict gunyah watchdog initialization to Qualcomm platforms,
> register the watchdog device in the SMEM driver.
>
> When Gunyah is not present or Gunyah emulates MMIO-based
> watchdog, we expect Qualcomm watchdog or ARM SBSA watchdog device to be
> present in the devicetree. If none of these device nodes are detected,
> we register the SMC-based Gunyah watchdog device.
>
> Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
> ---
> drivers/soc/qcom/smem.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index cf425930539e..40e4749fab02 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -1118,6 +1118,34 @@ static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
> return 0;
> }
>
> +static int register_gunyah_wdt_device(void)
> +{
> + struct platform_device *gunyah_wdt_dev;
> + struct device_node *np;
> +
> + /*
> + * When Gunyah is not present or Gunyah is emulating a memory-mapped
> + * watchdog, either of Qualcomm watchdog or ARM SBSA watchdog will be
> + * present. Skip initialization of SMC-based Gunyah watchdog if that is
> + * the case.
> + */
Should this also be limited to the platforms which had the particular
version of Gunyah?
> + np = of_find_compatible_node(NULL, NULL, "qcom,kpss-wdt");
> + if (np) {
> + of_node_put(np);
> + return 0;
> + }
> +
> + np = of_find_compatible_node(NULL, NULL, "arm,sbsa-gwdt");
> + if (np) {
> + of_node_put(np);
> + return 0;
> + }
> +
> + gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
> + NULL, 0);
> + return PTR_ERR_OR_ZERO(gunyah_wdt_dev);
> +}
> +
> static int qcom_smem_probe(struct platform_device *pdev)
> {
> struct smem_header *header;
> @@ -1236,11 +1264,20 @@ static int qcom_smem_probe(struct platform_device *pdev)
> if (IS_ERR(smem->socinfo))
> dev_dbg(&pdev->dev, "failed to register socinfo device\n");
>
> + ret = register_gunyah_wdt_device();
> + if (ret)
> + dev_dbg(&pdev->dev, "failed to register watchdog device\n");
> +
> return 0;
> }
>
> static void qcom_smem_remove(struct platform_device *pdev)
> {
> + /*
> + * Gunyah watchdog is intended to be a persistent module. Hence, the
> + * watchdog device is not unregistered.
> + */
> +
> platform_device_unregister(__smem->socinfo);
>
> hwspin_lock_free(__smem->hwlock);
>
> --
> 2.43.0
>
>
--
With best wishes
Dmitry
© 2016 - 2026 Red Hat, Inc.