From nobody Fri Apr 3 07:15:49 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2FFB346E55 for ; Wed, 11 Mar 2026 05:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773208009; cv=none; b=PawAyeMajzM5U/2jwcFQF99Z6+s1yH6TrmiVsdCDvckzHawmjzXizzZ7ais7s854fWT2ilswo4yasSvhbxmhFjD5afrhL1HsF6yMeIGOWfrP8ALGi0Mth0Za186inODEgM3QecMYY1YpAv44QVbjGDMvY0nWloFAix5ipBaEBRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773208009; c=relaxed/simple; bh=cVVG4MkyscY1qtPoUsoyn8mWMRvlJbKMwxOJCEj7VLg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k/gVOGlCRQphX8ULsaXVy1XjCsPTjvs4pT0ZyYSRSOOlNmEzB745kenGIby7CO1d8h6wlf9wwbuhBRT1IlqGtXiwj/5jD9orl4H//bOOzn+sIyE6paIgUJ63eGku7MHH3a9M5Ep/M2xThKjrlZcAreZe+3NTH/Yf/rIM4Xg7kGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=erMPqiE6; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=A/qQSC+6; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="erMPqiE6"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="A/qQSC+6" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62B2tn8F249216 for ; Wed, 11 Mar 2026 05:46:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= RGjJZDCOw/JM7x4VTsDtjQl0GpiD3yXd9P4Ux06z21k=; b=erMPqiE6z4nLBgSL YYh5dZelzYYFOdO7oJN2sicJ2NDagoQsRCMGhRVO0o1lkux18AMWeyD0fL4yQJ44 BsxtfMTgeZa+NQAldjqcauT1dHZ/5F4MZyslGwfA73fs5exfSdufXq7UI3/+GuWL sGIcjBHTIZxVYG6UHgPp+HPXjhNQIQ/bNhi9aCtYbqliODHfOpmRBabprjjXEtgQ TDtIrMQS32W7HmGwIu23vMdyrf43yDHmxy64WBrAEj/XR1tntjAyCcZ8p+JCq5MR 5joRlSH8mT9zOb4AuIf6LvJYgSwwNilMp9ii2cC6wmiUbGahugEpyP5fV8P4GLfo 4D52OQ== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ctqv12258-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 11 Mar 2026 05:46:45 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c737b6686ddso4225752a12.3 for ; Tue, 10 Mar 2026 22:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773208005; x=1773812805; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RGjJZDCOw/JM7x4VTsDtjQl0GpiD3yXd9P4Ux06z21k=; b=A/qQSC+6IxQeSuJCPWEiVG61B/CbY5Qr1CoUU7YgZdXhrCNtkCwiZPFrdj0bdiEVOc owosN599LcjXY+4126ilPnOl8Tyn48ce/If6qhhWUrAX74Mj6Vvqqwp6KBVVOwuyUFSF Id4kAU46kEW3mitJ5edGzuuVpACWCkMA9QicE1mLhP2ctMzRA2APszQ9sBfBCZVL+CXH 7ztieUWCyhasv0lcf7/1S2O9BNzC3sUp8kZcjDGsD5wT+pvitsLe/K7Za16tXQ2sDXQS lDV/DrUy37seESE+JzwVUPot5GDp15XychWV8u06/08oX/xG88DGa/YP12L+6my8kfw8 AdnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773208005; x=1773812805; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=RGjJZDCOw/JM7x4VTsDtjQl0GpiD3yXd9P4Ux06z21k=; b=GpWvANlITvcNuto2DK++6+EuzE24NfYw+nOBiAdhYetU28XsbtG97LdXHzBxaPds5S WXM2+O4HVtTDTelNSmm376iCvdvxPsXYIsS1RQrUAKQiSLVZ/x8rW4dDUIgwPC1/Bj9i twlgNTsTB3DoH5bKIkJDrJEZ68cZRHWuWdekDILpf0c8SAdvLz2AOh6quvH6XMIknk+g dgc4G3K0ZQlA9pM5EtmVSF5wEXsFvbJC+EMjWn2C59l6TccBE3mENa+H7derGdJ4qo8m aAnvh0PZ2qSBU7gEDTTNnBuVWp8rd3zBTjxJ4FQyXpwxW5suH8uINeMbeZkOU+khw31f 9ozw== X-Forwarded-Encrypted: i=1; AJvYcCWWr8OjkaZ2uvuem4rL/6lD+HySiUJYtC4vyIE0eCIX3D0abvCRX5SDtzcitPK1t98Q9y7gPy3H/srh/ZA=@vger.kernel.org X-Gm-Message-State: AOJu0YzbOMwoo0Ghw3Hviec8TJz9W9R14EF0tW/dN8IaXDzykhjAGxSX VSd8rMUhec2wlWiuT3zrDq93ouGU2JiQqVpcdtXB1ul2Q1IADk3Vle5b/mwhuhfNxwKS3sdSDMS oUUyW3jnK+WhOxhNFHGr+sr+5fvQGxIlROI4w/8LX/t/VeQWLv9hZwJM5Wj5f511vRX/gKWR0Cv g= X-Gm-Gg: ATEYQzwXoMKn+7h+wDCaTJVMj5oy9YySa1e9JsJP5BRie6+RWmttMxiepR3JDucQevU SsZMgEQPBfvy/T3cpdofx9UxUbmaCIqV7l4NnT8V3w1pmdYvUcXhEIJpaTfJanPSmaHt0Ijh6KU FcQKhVRpgWJXiCuZua1uLcDrj9XZjrkhBWpYPXFGfXcWUe6hNUADUgUmHhdyo9BzQoPMeQ3ukG7 QN/7q+g6iUjkM9BzuES+e748Gaql+QO2cNOrYzf0IsnJFxetZiSSC1f+DXfZN82DPHUXsvVyJ1b ZsXiW4BzOaLLBQGsho4d7z9yAqlZpnme8Jw8huPDw8Eg/+53rpLbkFoYZDHqys+D0JCK3gK1kyx Mg/1bYPpyy37LbHs63KqO/A+ArKLEiwxiEksFJV5H6GCYzlun8B1Y8cc= X-Received: by 2002:a05:6a00:f04:b0:829:9ea2:3e17 with SMTP id d2e1a72fcca58-829f6e68c8bmr1376787b3a.9.1773208004748; Tue, 10 Mar 2026 22:46:44 -0700 (PDT) X-Received: by 2002:a05:6a00:f04:b0:829:9ea2:3e17 with SMTP id d2e1a72fcca58-829f6e68c8bmr1376770b3a.9.1773208004254; Tue, 10 Mar 2026 22:46:44 -0700 (PDT) Received: from hu-pkondeti-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829f6eebf43sm1114108b3a.39.2026.03.10.22.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 22:46:43 -0700 (PDT) From: Pavankumar Kondeti Date: Wed, 11 Mar 2026 11:16:30 +0530 Subject: [PATCH RESEND v8 1/2] firmware: qcom: scm: Register gunyah watchdog device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260311-gunyah_watchdog-v8-1-4c1c0689de22@oss.qualcomm.com> References: <20260311-gunyah_watchdog-v8-0-4c1c0689de22@oss.qualcomm.com> In-Reply-To: <20260311-gunyah_watchdog-v8-0-4c1c0689de22@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio , Wim Van Sebroeck , Guenter Roeck Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, Hrishabh Rajput , Pavankumar Kondeti , Dmitry Baryshkov , Shivendra Pratap , Neil Armstrong X-Mailer: b4 0.15-dev-dd521 X-Developer-Signature: v=1; a=ed25519-sha256; t=1773207995; l=3227; i=pavan.kondeti@oss.qualcomm.com; s=20260311; h=from:subject:message-id; bh=Ixc7jFfJtf3sYdNbi1DoA+ted+UPWdZsOBlvyEIVFtk=; b=kaXDlCTlXIpFBqcbs0fuEmRqJ3g7Ex/Y1wLPSAa8uN54wY7kFMvphZCwNmf7qDdPkUBkzq76F yVhrewOPHYYC5us3GUJDdJ6gN6r24Uii+rqF83sKb7nyUvFg50bvPPq X-Developer-Key: i=pavan.kondeti@oss.qualcomm.com; a=ed25519; pk=Pdl9NnQpMlqbYaAGGkgBGpURTnZFe2de5LRZSGHkbHY= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzExMDA0NiBTYWx0ZWRfX07pjIxqzrwjN SqPuvYraK0XyZuafojRBsDTMJLvZtK5/LgM7IeF0xfEHyrHYC475F54qRfDu3PMJ8vujnBfZbVU VsVtVRjaMTnX7+0FtiFgKJFeBMe4QS+1BQPRL8/N475q7jVPz3gWUsnhMSGDR2LPln5DWk7LtT2 TUjojaoCsdidvF+MsZfSlVls+D8KJtt4N9Q9VxLERykacNm8KZCECT6SSBqiIzGuPH66H5JauJI 3doo8ZusEPcGLAGuY0Dec5HMziAD9D9LoH7LdlAfaIz3IGgU3iKVQhWl1k0zvWag9sFrOSfQUoA SmHm5iyQYgczOG2glyITt5zuNZiLjv/eiVfGDLUKnv4J/fo8ax0KTQDvVPOrxsxv7tH0/aSvNM5 LRLcNqOaDwBcyvl+bj6L3vUVO2pHtHO4uaxuhWakBPq92u2k7JV518fSKQrVHn5ThG7qiEnP5d6 3HPVNPIkwOuPRIFvKUg== X-Proofpoint-GUID: lvNopAH1Q5K4ztrjLty-NOrwDtObXDUu X-Authority-Analysis: v=2.4 cv=S5vUAYsP c=1 sm=1 tr=0 ts=69b101c5 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=g8_2rFH-n0ZcawzQyqcA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: lvNopAH1Q5K4ztrjLty-NOrwDtObXDUu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-10_05,2026-03-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603110046 From: Hrishabh Rajput To restrict Gunyah watchdog initialization to Qualcomm platforms running under the Gunyah Hypervisor, register the watchdog device in the QCOM SCM 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. First, we make sure we're running under the Gunyah Hypervisor. Then we move to check if any of the above mentioned watchdog device nodes are present, if not then we proceed to register the SMC-based Gunyah watchdog device. Reviewed-by: Dmitry Baryshkov Tested-by: Shivendra Pratap Tested-by: Neil Armstrong Signed-off-by: Hrishabh Rajput Signed-off-by: Pavankumar Kondeti Tested-by: Mukesh Ojha --- drivers/firmware/qcom/qcom_scm.c | 53 ++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 53 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index 8fbc96693a55..1611e1ab3a31 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -2467,6 +2467,56 @@ int qcom_scm_qtee_callback_response(phys_addr_t buf,= size_t buf_size, } EXPORT_SYMBOL(qcom_scm_qtee_callback_response); =20 +static void qcom_scm_gunyah_wdt_free(void *data) +{ + struct platform_device *gunyah_wdt_dev =3D data; + + platform_device_unregister(gunyah_wdt_dev); +} + +static void qcom_scm_gunyah_wdt_init(struct qcom_scm *scm) +{ + struct platform_device *gunyah_wdt_dev; + struct device_node *np; + bool of_wdt_available; + int i; + static const uuid_t gunyah_uuid =3D UUID_INIT(0xc1d58fcd, 0xa453, 0x5fdb, + 0x92, 0x65, 0xce, 0x36, + 0x67, 0x3d, 0x5f, 0x14); + static const char * const of_wdt_compatible[] =3D { + "qcom,kpss-wdt", + "arm,sbsa-gwdt", + }; + + /* Bail out if we are not running under Gunyah */ + if (!IS_ENABLED(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) || + !arm_smccc_hypervisor_has_uuid(&gunyah_uuid)) + return; + + /* + * Gunyah emulates either of Qualcomm watchdog or ARM SBSA watchdog on + * newer platforms. Bail out if we find them in the devicetree. + */ + for (i =3D 0; i < ARRAY_SIZE(of_wdt_compatible); i++) { + np =3D of_find_compatible_node(NULL, NULL, of_wdt_compatible[i]); + of_wdt_available =3D of_device_is_available(np); + of_node_put(np); + if (of_wdt_available) + return; + } + + gunyah_wdt_dev =3D platform_device_register_simple("gunyah-wdt", -1, + NULL, 0); + if (IS_ERR(gunyah_wdt_dev)) { + dev_err(scm->dev, "Failed to register Gunyah watchdog device: %ld\n", + PTR_ERR(gunyah_wdt_dev)); + return; + } + + devm_add_action_or_reset(scm->dev, qcom_scm_gunyah_wdt_free, + gunyah_wdt_dev); +} + static void qcom_scm_qtee_free(void *data) { struct platform_device *qtee_dev =3D data; @@ -2811,6 +2861,9 @@ static int qcom_scm_probe(struct platform_device *pde= v) /* Initialize the QTEE object interface. */ qcom_scm_qtee_init(scm); =20 + /* Initialize the Gunyah watchdog platform device. */ + qcom_scm_gunyah_wdt_init(scm); + return 0; } =20 --=20 2.34.1 From nobody Fri Apr 3 07:15:49 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADFCA345757 for ; Wed, 11 Mar 2026 05:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773208013; cv=none; b=Vg+oM9L9yIG6mkWVy++AKze/wSnDUbj5avOx9XsVWUgGzGX8ilQ9a/GFXjHrO0Jxt2qCSqMXbR7fAfxEf5brFkwgwS+nICAaNH9CeGwMZd9JDA00G3g2KLfxN43FFqI+dKoWe5coUxOsK6CvqMwXIVzkm/ksSAXLJOCuPPLEmh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773208013; c=relaxed/simple; bh=HXTzUVUWHHI9t+jZnXs1tFKVOZiz2FaIEWHfeEPLanw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YctQWLewSAKCbN7LzRGh0op9rbFsp+DEFNhs+wOn49aOxWKeKqNBuUSHKP2hRFJfU49wbdHQP1BJhQwHQDnaZoqq9PTBwQOO/gQpiaZGtw7rUUUPRpK+wGkMrQqFz6vk07SN0QF+OonIKV4Yq4Z+jJSr4JCR/NIXx1JyQ2llIIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=C5gG9g2j; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Ee7eoyPp; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="C5gG9g2j"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Ee7eoyPp" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62B1gtOu508501 for ; Wed, 11 Mar 2026 05:46:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= E1Q4XFB39ddq7htOB8iFfiUhkv9bnXZHIaXV0U9eiRE=; b=C5gG9g2jdG8T+HOI CpCPHp686o3hEUs43od/E/z0Dfh6xp9PVCq0D4oBjX2rstjGCYMttsdY1xoxYbAZ S3EgAnhEcD1brKFnoWRUD5thUuvY44xMTr44Ol83/SOvv4xBI6vX3y1spjf/QIsu +2DVzNLc9RU2mtORSOFujefZrhL6YJVLrEdsUXmp4qMGtyZo9ZEKB3WGnBcZr3U+ KOZGTWLVm3jxhlDQRD/Ib4jk3V2VKGm512g6GVzInasjbADezxwRv1eMt/U+QYFF Wi4eT2weApPIVT3sxp01c1RKRQAQt2cZX48j8vSQt26hLV5tznlBr3rCqiHXpIaE M9Z5Lg== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ctppajd9v-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 11 Mar 2026 05:46:50 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-354c44bf176so13184066a91.0 for ; Tue, 10 Mar 2026 22:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773208009; x=1773812809; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=E1Q4XFB39ddq7htOB8iFfiUhkv9bnXZHIaXV0U9eiRE=; b=Ee7eoyPpaGrEI+rXjxIK/de2P4Jpe+0ONUrNXPLxhWBsVWnI7gG2PBcjDbMhYG0Ohz 9osSfozrtcPbneszj/ff/pWrnL8huKfZDF9fXV9X1uOBb7OXrtrDnYchFJsU0stQlP/5 GVqeV/4xz+JY4XCT44t6DfumPf7VVgnMjWlKaX75GbVZwb45UjFmG/aJNskcxHMO74bC rOzM0elJ9vhC95f0traeqIFjn7VyGCqtIjBs9PNx2gjMA2fbCW2qq/DN5Z01jL7tc3Dg nIrJ2KJqaNaf6g1lIuWgwDKJhqJkweNF/mKgIRP7RdzTqO+S5/cAX0mCjTbpUtRQiNmF i5Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773208009; x=1773812809; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=E1Q4XFB39ddq7htOB8iFfiUhkv9bnXZHIaXV0U9eiRE=; b=vl7kMhgBdkj03cPDZUAFuU7hQNmadIsFm5KWcfxsV+OD0XRYHnP+CDqgVHLlwlL+1Z FZMXL+S4MdOZLKwzuYb0EJIEUXnLTJZlpT+BpMcob2LIr3ZEtdyigYJJkfdORrgXN8wc hP0ELcxeSz4+tIISHBfZXF0tWLMX+qsxq7uEHGwodF1+9ysde5NGhDkbdFczzkk5luTu 2KqdJM5Q44BoKgk2jvQC4DGp06EHaKA1cAl75rtUk8vtD3FQCOFjzpGrc2D3kjFdvm9F gIbxpb2PJnKnoX3eJZ1V+vnFtT+yinhAvBX6SX8zoPCI+sOSCbKWbhrHiQ4ciuwBNpFp D9Sg== X-Forwarded-Encrypted: i=1; AJvYcCU8M87staWI+FjmlxpxpL+kRNpeDrVPb9UyRH84DVJs0Aa32yxz3hZexCdd0jX9H+RbaGJyxpT0X/657t0=@vger.kernel.org X-Gm-Message-State: AOJu0YzXxWlautoe8q/B7u0D5EPK3KMindOASH9akdZWJ+Idya6bhIFZ vGPy42zeSFmkrGbqNovwHSmgsdTYdGsMB4nQ47Tei3j7e2xfJhMuTK1E6PrNW2mZMkQXUqMtlzS Kw8HUxktETwbIU96lNs7GAO12Akugmeauw2JaYqxVv4OeWnffb9NabdQhR3M81f7KZIXxcFLbtw s= X-Gm-Gg: ATEYQzzXCwd3eb9Mso8qFm6bXOlPIoy805S/cRSf3thhGxmJfO/PwLZ/zi1Ua1VpH00 2IuMbfGiEREBlA1dlq39D8xrkQl+AXvcY3hk8dC4v6rs5Hs24PgNiIRLlAMGVPzbUvmsoexSe+u hAInRu6lF73Rog0QlW3NaL+EScofH/MA1qgJeyuBRW/g4d1yXkRLf/5bBinYSEz81JQp6xxGqJ5 kpPRdp418wttWYMIkTqBeUAmvaCLGTtQnJ6Q3mQ5haUb8IGpzg16EyZviBwJI8gBHJuD0LNEOEM Jv47QAU/w3ELEm0CpzPbiqpwpp/+BXqAGvVcohY5IfJCYqXZGmRNOFUAiKn1h//Xd2rTQqwPCZO 1e8lWCG0SgJ8ey4FhZbahfbu+g5dFSaRzZIPt7izWiydM5i5QYVhQj7M= X-Received: by 2002:a05:6a21:700e:b0:398:71b6:33aa with SMTP id adf61e73a8af0-398c61698b3mr1065921637.64.1773208009312; Tue, 10 Mar 2026 22:46:49 -0700 (PDT) X-Received: by 2002:a05:6a21:700e:b0:398:71b6:33aa with SMTP id adf61e73a8af0-398c61698b3mr1065883637.64.1773208008746; Tue, 10 Mar 2026 22:46:48 -0700 (PDT) Received: from hu-pkondeti-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829f6eebf43sm1114108b3a.39.2026.03.10.22.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 22:46:48 -0700 (PDT) From: Pavankumar Kondeti Date: Wed, 11 Mar 2026 11:16:31 +0530 Subject: [PATCH RESEND v8 2/2] watchdog: Add driver for Gunyah Watchdog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260311-gunyah_watchdog-v8-2-4c1c0689de22@oss.qualcomm.com> References: <20260311-gunyah_watchdog-v8-0-4c1c0689de22@oss.qualcomm.com> In-Reply-To: <20260311-gunyah_watchdog-v8-0-4c1c0689de22@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio , Wim Van Sebroeck , Guenter Roeck Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, Hrishabh Rajput , Pavankumar Kondeti , Shivendra Pratap , Neil Armstrong , Mukesh Ojha , Dmitry Baryshkov X-Mailer: b4 0.15-dev-dd521 X-Developer-Signature: v=1; a=ed25519-sha256; t=1773207995; l=10652; i=pavan.kondeti@oss.qualcomm.com; s=20260311; h=from:subject:message-id; bh=AkD6Bx3QmX4ZCXK1sI5kNwmAIUv8jyMHiiakfJwVVFE=; b=FtAr0y2zCMhnE4sE7CCC8Ex1SyPEmd0r0yJeT1aYilu1SurYGDiUcNvss/UNcEDrvuF4+eO/N GPwax495BuUCkVRGWEwRu/qyHLvG13uVaITv11NFetuTr3Bi0Z1dnXt X-Developer-Key: i=pavan.kondeti@oss.qualcomm.com; a=ed25519; pk=Pdl9NnQpMlqbYaAGGkgBGpURTnZFe2de5LRZSGHkbHY= X-Proofpoint-GUID: RiNWbq-Fo5oCjRDlCOO6h7MDYcaoaA4r X-Authority-Analysis: v=2.4 cv=D7BK6/Rj c=1 sm=1 tr=0 ts=69b101ca cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=_jlGtV7tAAAA:8 a=uHUF2ZwmFKjH5m5PrtYA:9 a=QEXdDO2ut3YA:10 a=O8hF6Hzn-FEA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 a=cvBusfyB2V15izCimMoJ:22 a=nlm17XC03S6CtCLSeiRr:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzExMDA0NiBTYWx0ZWRfXyqKJ5gRnT2KQ s9JGChw50ntgPrXJarn3+g5r1hv+IgSwgP7xf6JMd1GGEfkMXMd7hLa1r2kkRPntlp+hQ94u3Tq y5sWywPEQLdtQHPmQeeiqz344iV05a1YyxjYtz8pScpj1Ebn5BnREvWGUni/xx4yQ42ZtyzJbjn /RZhqAanrsBx2uQDGuBa7yVUafSNDvcNhHrNOALnBa5Kd5E5x/jLvyOS3yMy8lHQIyNkCau3LCi FwyPTZ1TnKPw1q+xaC2RDXrPjyflpLIbm7XWLDdt4WIWwEsq+de862aDXEh80GmfUKro1D012Zp Qo4JmEt7NBWMjDZLbbLxzgixVVCDZaQGJ7gBr6RLMaTb67YrWx457f9a/F2O6D7ErqSBnedD4R0 cxAH6dJGilk88/9ewRHmAlztX9AaJSvlYYAcHCQQ1+iUfhnbGJg+2DRVlBvooXPqyImI2Dhl/I3 TiVPzEvDb4aGa/PK7qw== X-Proofpoint-ORIG-GUID: RiNWbq-Fo5oCjRDlCOO6h7MDYcaoaA4r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-10_05,2026-03-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 impostorscore=0 spamscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603110046 From: Hrishabh Rajput On Qualcomm SoCs running under the Gunyah hypervisor, access to watchdog through MMIO is not available on all platforms. Depending on the hypervisor configuration, the watchdog is either fully emulated or exposed via ARM's SMC Calling Conventions (SMCCC) through the Vendor Specific Hypervisor Service Calls space. Add driver to support the SMC-based watchdog provided by the Gunyah Hypervisor. Device registration is done in the QCOM SCM driver after checks to restrict the watchdog initialization to Qualcomm devices running under Gunyah. Gunyah watchdog is not a hardware but an SMC-based vendor-specific hypervisor interface provided by the Gunyah hypervisor. The design involving QCOM SCM driver for registering the platform device has been devised to avoid adding non-hardware nodes to devicetree. Tested-by: Shivendra Pratap Tested-by: Neil Armstrong Tested-by: Mukesh Ojha Reviewed-by: Guenter Roeck Reviewed-by: Dmitry Baryshkov Signed-off-by: Hrishabh Rajput Signed-off-by: Pavankumar Kondeti --- MAINTAINERS | 1 + drivers/watchdog/Kconfig | 13 +++ drivers/watchdog/Makefile | 1 + drivers/watchdog/gunyah_wdt.c | 261 ++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 276 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 77fdfcb55f06..842306623b1d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3325,6 +3325,7 @@ F: arch/arm64/boot/dts/qcom/ F: drivers/bus/qcom* F: drivers/firmware/qcom/ F: drivers/soc/qcom/ +F: drivers/watchdog/gunyah_wdt.c F: include/dt-bindings/arm/qcom,ids.h F: include/dt-bindings/firmware/qcom,scm.h F: include/dt-bindings/soc/qcom* diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index dc78729ba2a5..5f1dfb6ac41b 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -2354,4 +2354,17 @@ config KEEMBAY_WATCHDOG To compile this driver as a module, choose M here: the module will be called keembay_wdt. =20 +config GUNYAH_WATCHDOG + tristate "Qualcomm Gunyah Watchdog" + depends on ARCH_QCOM || COMPILE_TEST + depends on HAVE_ARM_SMCCC + select WATCHDOG_CORE + help + Say Y here to include support for watchdog timer provided by the + Gunyah hypervisor. The driver uses ARM SMC Calling Convention (SMCCC) + to interact with Gunyah Watchdog. + + To compile this driver as a module, choose M here: the + module will be called gunyah_wdt. + endif # WATCHDOG diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index d2fb16b9f9ce..4d1547702ef0 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -103,6 +103,7 @@ obj-$(CONFIG_MSC313E_WATCHDOG) +=3D msc313e_wdt.o obj-$(CONFIG_APPLE_WATCHDOG) +=3D apple_wdt.o obj-$(CONFIG_SUNPLUS_WATCHDOG) +=3D sunplus_wdt.o obj-$(CONFIG_MARVELL_GTI_WDT) +=3D marvell_gti_wdt.o +obj-$(CONFIG_GUNYAH_WATCHDOG) +=3D gunyah_wdt.o =20 # X86 (i386 + ia64 + x86_64) Architecture obj-$(CONFIG_ACQUIRE_WDT) +=3D acquirewdt.o diff --git a/drivers/watchdog/gunyah_wdt.c b/drivers/watchdog/gunyah_wdt.c new file mode 100644 index 000000000000..49dfef459e84 --- /dev/null +++ b/drivers/watchdog/gunyah_wdt.c @@ -0,0 +1,261 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define GUNYAH_WDT_SMCCC_CALL_VAL(func_id) \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32,\ + ARM_SMCCC_OWNER_VENDOR_HYP, func_id) + +/* SMCCC function IDs for watchdog operations */ +#define GUNYAH_WDT_CONTROL GUNYAH_WDT_SMCCC_CALL_VAL(0x0005) +#define GUNYAH_WDT_STATUS GUNYAH_WDT_SMCCC_CALL_VAL(0x0006) +#define GUNYAH_WDT_PING GUNYAH_WDT_SMCCC_CALL_VAL(0x0007) +#define GUNYAH_WDT_SET_TIME GUNYAH_WDT_SMCCC_CALL_VAL(0x0008) + +/* + * Control values for GUNYAH_WDT_CONTROL. + * Bit 0 is used to enable or disable the watchdog. If this bit is set, + * then the watchdog is enabled and vice versa. + * Bit 1 should always be set to 1 as this bit is reserved in Gunyah and + * it's expected to be 1. + */ +#define WDT_CTRL_ENABLE (BIT(1) | BIT(0)) +#define WDT_CTRL_DISABLE BIT(1) + +enum gunyah_error { + GUNYAH_ERROR_OK =3D 0, + GUNYAH_ERROR_UNIMPLEMENTED =3D -1, + GUNYAH_ERROR_ARG_INVAL =3D 1, +}; + +/** + * gunyah_error_remap() - Remap Gunyah hypervisor errors into a Linux erro= r code + * @gunyah_error: Gunyah hypercall return value + */ +static inline int gunyah_error_remap(enum gunyah_error gunyah_error) +{ + switch (gunyah_error) { + case GUNYAH_ERROR_OK: + return 0; + case GUNYAH_ERROR_UNIMPLEMENTED: + return -EOPNOTSUPP; + default: + return -EINVAL; + } +} + +static int gunyah_wdt_call(unsigned long func_id, unsigned long arg1, + unsigned long arg2) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_smc(func_id, arg1, arg2, &res); + return gunyah_error_remap(res.a0); +} + +static int gunyah_wdt_start(struct watchdog_device *wdd) +{ + unsigned int timeout_ms; + struct device *dev =3D wdd->parent; + int ret; + + ret =3D gunyah_wdt_call(GUNYAH_WDT_CONTROL, WDT_CTRL_DISABLE, 0); + if (ret && watchdog_active(wdd)) { + dev_err(dev, "%s: Failed to stop gunyah wdt %d\n", __func__, ret); + return ret; + } + + timeout_ms =3D wdd->timeout * 1000; + ret =3D gunyah_wdt_call(GUNYAH_WDT_SET_TIME, timeout_ms, timeout_ms); + if (ret) { + dev_err(dev, "%s: Failed to set timeout for gunyah wdt %d\n", + __func__, ret); + return ret; + } + + ret =3D gunyah_wdt_call(GUNYAH_WDT_CONTROL, WDT_CTRL_ENABLE, 0); + if (ret) + dev_err(dev, "%s: Failed to start gunyah wdt %d\n", __func__, ret); + + return ret; +} + +static int gunyah_wdt_stop(struct watchdog_device *wdd) +{ + return gunyah_wdt_call(GUNYAH_WDT_CONTROL, WDT_CTRL_DISABLE, 0); +} + +static int gunyah_wdt_ping(struct watchdog_device *wdd) +{ + return gunyah_wdt_call(GUNYAH_WDT_PING, 0, 0); +} + +static int gunyah_wdt_set_timeout(struct watchdog_device *wdd, + unsigned int timeout_sec) +{ + wdd->timeout =3D timeout_sec; + + if (watchdog_active(wdd)) + return gunyah_wdt_start(wdd); + + return 0; +} + +static int gunyah_wdt_get_time_since_last_ping(void) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_smc(GUNYAH_WDT_STATUS, 0, 0, &res); + if (res.a0) + return gunyah_error_remap(res.a0); + + return res.a2 / 1000; +} + +static unsigned int gunyah_wdt_get_timeleft(struct watchdog_device *wdd) +{ + int seconds_since_last_ping; + + seconds_since_last_ping =3D gunyah_wdt_get_time_since_last_ping(); + if (seconds_since_last_ping < 0 || + seconds_since_last_ping > wdd->timeout) + return 0; + + return wdd->timeout - seconds_since_last_ping; +} + +static int gunyah_wdt_restart(struct watchdog_device *wdd, + unsigned long action, void *data) +{ + /* Set timeout to 1ms and send a ping */ + gunyah_wdt_call(GUNYAH_WDT_CONTROL, WDT_CTRL_DISABLE, 0); + gunyah_wdt_call(GUNYAH_WDT_SET_TIME, 1, 1); + gunyah_wdt_call(GUNYAH_WDT_CONTROL, WDT_CTRL_ENABLE, 0); + gunyah_wdt_call(GUNYAH_WDT_PING, 0, 0); + + /* Wait to make sure reset occurs */ + mdelay(100); + + return 0; +} + +static const struct watchdog_info gunyah_wdt_info =3D { + .identity =3D "Gunyah Watchdog", + .options =3D WDIOF_SETTIMEOUT + | WDIOF_KEEPALIVEPING + | WDIOF_MAGICCLOSE, +}; + +static const struct watchdog_ops gunyah_wdt_ops =3D { + .owner =3D THIS_MODULE, + .start =3D gunyah_wdt_start, + .stop =3D gunyah_wdt_stop, + .ping =3D gunyah_wdt_ping, + .set_timeout =3D gunyah_wdt_set_timeout, + .get_timeleft =3D gunyah_wdt_get_timeleft, + .restart =3D gunyah_wdt_restart +}; + +static int gunyah_wdt_probe(struct platform_device *pdev) +{ + struct watchdog_device *wdd; + struct device *dev =3D &pdev->dev; + int ret; + + ret =3D gunyah_wdt_call(GUNYAH_WDT_STATUS, 0, 0); + if (ret =3D=3D -EOPNOTSUPP) + return -ENODEV; + + if (ret) + return dev_err_probe(dev, ret, "status check failed\n"); + + wdd =3D devm_kzalloc(dev, sizeof(*wdd), GFP_KERNEL); + if (!wdd) + return -ENOMEM; + + wdd->info =3D &gunyah_wdt_info; + wdd->ops =3D &gunyah_wdt_ops; + wdd->parent =3D dev; + + /* + * Although Gunyah expects 16-bit unsigned int values as timeout values + * in milliseconds, values above 0x8000 are reserved. This limits the + * max timeout value to 32 seconds. + */ + wdd->max_timeout =3D 32; /* seconds */ + wdd->min_timeout =3D 1; /* seconds */ + wdd->timeout =3D wdd->max_timeout; + + gunyah_wdt_stop(wdd); + platform_set_drvdata(pdev, wdd); + watchdog_set_restart_priority(wdd, 0); + + return devm_watchdog_register_device(dev, wdd); +} + +static void gunyah_wdt_remove(struct platform_device *pdev) +{ + struct watchdog_device *wdd =3D platform_get_drvdata(pdev); + + gunyah_wdt_stop(wdd); +} + +static int gunyah_wdt_suspend(struct device *dev) +{ + struct watchdog_device *wdd =3D dev_get_drvdata(dev); + + if (watchdog_active(wdd)) + gunyah_wdt_stop(wdd); + + return 0; +} + +static int gunyah_wdt_resume(struct device *dev) +{ + struct watchdog_device *wdd =3D dev_get_drvdata(dev); + + if (watchdog_active(wdd)) + gunyah_wdt_start(wdd); + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(gunyah_wdt_pm_ops, gunyah_wdt_suspend, gun= yah_wdt_resume); + +/* + * Gunyah watchdog is a vendor-specific hypervisor interface provided by t= he + * Gunyah hypervisor. Using QCOM SCM driver to detect Gunyah watchdog SMCCC + * hypervisor service and register platform device when the service is ava= ilable + * allows this driver to operate independently of the devicetree and avoids + * adding the non-hardware nodes to the devicetree. + */ +static const struct platform_device_id gunyah_wdt_id[] =3D { + { .name =3D "gunyah-wdt" }, + {} +}; +MODULE_DEVICE_TABLE(platform, gunyah_wdt_id); + +static struct platform_driver gunyah_wdt_driver =3D { + .driver =3D { + .name =3D "gunyah-wdt", + .pm =3D pm_sleep_ptr(&gunyah_wdt_pm_ops), + }, + .id_table =3D gunyah_wdt_id, + .probe =3D gunyah_wdt_probe, + .remove =3D gunyah_wdt_remove, +}; + +module_platform_driver(gunyah_wdt_driver); + +MODULE_DESCRIPTION("Gunyah Watchdog Driver"); +MODULE_LICENSE("GPL"); --=20 2.34.1