From nobody Thu Apr 2 20:26:59 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 BB64042DFE5 for ; Sat, 28 Feb 2026 12:29:28 +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=1772281770; cv=none; b=O8Ie7Ra5qh2OEMX7AFX/fIvUlmnjtrjN+JCFOPACo2s9Nv6gHXK5k0teJ/Gl+tjNY5fWr4q1Ylnzc498zazrdZJ73ExmU1XSnBrLtWS3dN4lbAnoRJXPJKxYOyefFlUB5mg0deta6Zr7Yvt1vQuielrP4u2e9w/BmC/caFZ8SzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772281770; c=relaxed/simple; bh=KhA6l9FXGGh1ADW//4d+9pqBGmS+IoxIsdsRwnaryCs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hfGA2CTJAUAewepGmVNfeTwWEe2Ns/aMu61AAwgjAL+oCO2Z9hHqpiQsZmJ3fzjvtr8fIcClXvVLf1iojkYGnG1L6leMJKkpxcXM/l/MEDz3cYgppfGxjpo+q9lqf6Rlg4Cjussr4MwlyANeVsPYBTfFY8AU5RwB/2ZAWVFzKi0= 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=O/z0w9Dx; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=USOYEAzM; 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="O/z0w9Dx"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="USOYEAzM" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61SCQrg92413647 for ; Sat, 28 Feb 2026 12:29:28 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= rya4IV21avMOXB0mD3SUe4rEM7SkGdmLQR0mPNFOS+M=; b=O/z0w9DxagjN1BJP X0xVL6J0CanHxIz26uriFKDMtZPz5+ARomrYdXw8XZEY+KRweFT48cweLf+CoqeQ LI5gHZJWo59n3zIffnypQ7+qkeYlFgXq91eQ5G+ushFpmtU9yQ7eUUpVv567brXg QUatnHVPabytU+d4/pK9pCe+fTcRzzohYKKPEcOTvnHvmNhAkHl0W/3Kax86I0iE 9Cx6ckgJLYPMJT2VKtUYm9EjBiESIs89VTDaamKalWLKBrGdlGfIP8OXG8ebX30s +0WFqtzHJfQOWl3QqJ5ednOl1iMpQOeUx6rKWMmQO5GBPksv/48/YKBCaC7vY4da ulx8Bw== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cksg70sus-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 28 Feb 2026 12:29:27 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-824bf5fe8cbso1299766b3a.1 for ; Sat, 28 Feb 2026 04:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772281767; x=1772886567; 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=rya4IV21avMOXB0mD3SUe4rEM7SkGdmLQR0mPNFOS+M=; b=USOYEAzMBbq5+1ov8fZ4e7R90sH9ua2VI70T3n4+NplqUBQdhApJmatJQZsF+2kdn4 wVwIRVuZjw50oWnWgIWtcYvuSVfjutZVIAlU9jnbOdfSZ/u1N05+PeXIbdpN6Ce+nMT0 35o+ieBgWEB+zyYBsmgqmhOswmbnG4qW4PPgOpe67khlVp4JSEnv2MmIskmRzu4SnTlp PKuFAP2+Ax/E0g0R/5QVCqTRk9kH4cSUBFPFl/+wVkZ5pTNlNS03WYRwppCIPbSar866 GkFzdOnsNppWCZ5E8t4JbDoyog7vsYSAsnLldiVYbkEc8SoMxWzc4XbjfpOFiHqBU4xP 46iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772281767; x=1772886567; 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=rya4IV21avMOXB0mD3SUe4rEM7SkGdmLQR0mPNFOS+M=; b=wdjNIIDmD/OtfjJW18X7tzGWzxXsaDrIP5roz69LsRdPEIwaQcTnZiGeIqkiX8AttX repZSlf9dMZ0Oi5yGZoQVbE/y/JYc/CqtzJnjddGGjmaEkjqbr6R6xX4BNJojlVrUYQj DxABaEmF8KIyhjY3PKghCugI+DmP+cIy4dtdP4dbQ3rFKbBgb/QAd3uX0IGcSu4tfXmc Z5KteUssGg/ZMRxsKexCMMQxY7rxJq4yY6PMIImEtYZXkuNSB8Oo08ExSzwvzVMZn+ML iQDeGyI+pPieb7y/j5gXZLfOHITyoQ3XEiMHTz1odbRNq4AiTUwSO6NWpidVwm10hpio ZbcQ== X-Forwarded-Encrypted: i=1; AJvYcCWoovblaOQ56XaXmiFH2p94CUhUVBfikwXqxrYU/d5rrO0XDbUbsTxBEaqAKPtvKOOtxeBu7RLK/pjr1zc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9lCKZKzOs2tXrYD/EQtElDTRw1HxINQwK3B3lw09LO8lj+fmQ XHOjvRSD/KxmZCMjJ0vIUnzY2rb/mQUypfXIalBAdoqpIJeniIISRGFxFQYI03CLhqkUrp7+vxu P4ROxYjdEfGcpXIDkaBB0PfsZ0eixtIZppoW/LndpPhW8BLbCWjtu2t9mVKuNJp7Kqg0= X-Gm-Gg: ATEYQzztDwB0AL/xERWvGN6cBE3wIwCLYcv6gNbqiCx0mW/EfiOL6t4mNoO0IxEjwVt ajgmg64P1Otr5kVbyNfsLsjlHZx7/EiEDO9HTih+uuHwEkYfnfhsRbrIEoCLzMIKypgZUG5MLpv C83yMVswlUEogDDKfpctp1Iz1fxAJXK+4F2gcIUdH+24y3JAevOFrmK2S4n68bqHUX3wGw9WdTY t78404d7fes8lXT10ONXNzlT6XuT2SwMCuQWdgCCSvcDOz1J67Wb/kDqpBqU2StaK3jBBKYxP1q T88bRLAZw9O20Q/DWEdmgzM+AkybNRUaFqC0PpWcmLmEszT+p+R4gbZ6F8C7tzKhg3Cn/+qhBPm Wu7pgIhI1Ous44FI7d+Ibu8dRTVt3H4hoXxH0w5vSRgPrvF7p89Mu1mPJMSe2u3VoNHKAvpil54 +gMN//YFcW5skKS9w1htRw+dXP6j8aDhGeMD/YXIIFuAT2R1Ast1aETkR9 X-Received: by 2002:a05:6a00:2e04:b0:821:a7b6:10a3 with SMTP id d2e1a72fcca58-8274d9e67cfmr6018751b3a.34.1772281766776; Sat, 28 Feb 2026 04:29:26 -0800 (PST) X-Received: by 2002:a05:6a00:2e04:b0:821:a7b6:10a3 with SMTP id d2e1a72fcca58-8274d9e67cfmr6018721b3a.34.1772281766150; Sat, 28 Feb 2026 04:29:26 -0800 (PST) Received: from hu-kathirav-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82739d4e10csm8130048b3a.1.2026.02.28.04.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 04:29:25 -0800 (PST) From: Kathiravan Thirumoorthy Date: Sat, 28 Feb 2026 17:59:03 +0530 Subject: [PATCH v9 4/5] watchdog: qcom: add support to get the bootstatus from IMEM 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: <20260228-wdt_reset_reason-v9-4-f96d7a4825d3@oss.qualcomm.com> References: <20260228-wdt_reset_reason-v9-0-f96d7a4825d3@oss.qualcomm.com> In-Reply-To: <20260228-wdt_reset_reason-v9-0-f96d7a4825d3@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Wim Van Sebroeck , Guenter Roeck , Rajendra Nayak Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, Kathiravan Thirumoorthy , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1772281742; l=4446; i=kathiravan.thirumoorthy@oss.qualcomm.com; s=20230906; h=from:subject:message-id; bh=KhA6l9FXGGh1ADW//4d+9pqBGmS+IoxIsdsRwnaryCs=; b=4fzwpqhxnxVE/nAu54V8k30XAvehg6JkE1Enc+3pgcvas0+Ei60lm2jG67Z7ndJwsSe8r9qjB bkEaawbfoWCChJUP3h/sjCEBsiAno1+0q1gZDo1D8k7HjGfoPejd8x5 X-Developer-Key: i=kathiravan.thirumoorthy@oss.qualcomm.com; a=ed25519; pk=xWsR7pL6ch+vdZ9MoFGEaP61JUaRf0XaZYWztbQsIiM= X-Proofpoint-ORIG-GUID: lJlArCczO8NDPTDmuxZwabnyeulwgOxq X-Proofpoint-GUID: lJlArCczO8NDPTDmuxZwabnyeulwgOxq X-Authority-Analysis: v=2.4 cv=FaA6BZ+6 c=1 sm=1 tr=0 ts=69a2dfa7 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=qKWHfwwlgvfnR6H4MV8A:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI4MDExNiBTYWx0ZWRfX9r+JIOfXhruU iCfJClXVM1FV/1U/6Ed2WIyhCfnsubmu17+n5P6j/ja06z8/X9Oc5Gwn9o+ZS9uTdjZZIEBE1Am N/2wM0aTRMYYQ+JnM4NvVvd2/Mu1KPYBw/VkFRnaKHoa8m/dygcWD2QzlKObCLj8UC19DHHkxk+ 7uRiQT+C9vFbpApBxSTxm2YdVsAykwbg3ytrERALgZhh4LZWznAJpH2aFnEJo0kHOO3tGnuu35d dlb2zKx1ee7YypumNX+PeTEWyX87jsLBz5MUctrBmyYlHl78BjbrDDzJ8ztCukimrniT5aEiRga GzT03+bi13HC56v4xetbhNhs5ebMkIhq/Bp9TKZFh4ku8B8TU6C5HSaQ0ki82ISfWYAs9fClBoq aF2Y/laNjlmzL3Fc1zb1ajVpPFeTQx0SFe1OMcR1fACYAx6ns5hgPMdG7aYuZZplKdSoqJB+zAy RwWV/XuLVj2kLEmn5pg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-28_04,2026-02-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602280116 When the system boots up after a watchdog reset, the EXPIRED_STATUS bit in the WDT_STS register is cleared. To identify if the system was restarted due to WDT expiry, XBL update the information in the IMEM region. Update the driver to read the restart reason from IMEM and populate the bootstatus accordingly. With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information as below: cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootsta= tus 32 For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new function qcom_wdt_get_bootstatus() to read the restart reason from IMEM. Reviewed-by: Konrad Dybcio Signed-off-by: Kathiravan Thirumoorthy --- Changes in v9: - Log the error message and continue with probe instead of returning from the probe Changes in v8: - Picked up the R-b tag - Updated the comment as suggested by Konrad Changes in v7: - no changes Changes in v6: - Reworked to get the restart reason code from SRAM region Changes in v5: - Use dev_err_probe instead of dev_err Changes in v4: - Kept only WDIOF_CARDRESET and dropped other codes - Renamed qcom_wdt_get_reason_reason() to qcom_wdt_get_bootstatus() - Moved the existing check inside qcom_wdt_get_bootstatus() - Dropped the device data and put all the details in the DT node Changes in v3: - Split the introduction of device data into separate patch - s/bootloaders/XBL - for clarity of which bootloader is involved - Mention the sysfs path on to extract this information - s/compatible/imem_compatible in the device data structure to avoid the confusion / better naming Changes in v2: - Use the syscon API to access the IMEM region - Handle the error cases returned by qcom_wdt_get_restart_reason - Define device specific data to retrieve the IMEM compatible, offset and the value for non secure WDT, which allows to extend the support for other SoCs --- drivers/watchdog/qcom-wdt.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index dfaac5995c84c1f377023e6e62770c5548528a4c..49bd04841f0c8c4c5eb4e6b3a48= 64586aa9dbf5f 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include =20 @@ -42,6 +43,7 @@ struct qcom_wdt_match_data { const u32 *offset; bool pretimeout; u32 max_tick_count; + u32 wdt_reason_val; }; =20 struct qcom_wdt { @@ -185,6 +187,7 @@ static const struct qcom_wdt_match_data match_data_ipq5= 424 =3D { .offset =3D reg_offset_data_kpss, .pretimeout =3D true, .max_tick_count =3D 0xFFFFFU, + .wdt_reason_val =3D 5, }; =20 static const struct qcom_wdt_match_data match_data_kpss =3D { @@ -193,6 +196,40 @@ static const struct qcom_wdt_match_data match_data_kps= s =3D { .max_tick_count =3D 0xFFFFFU, }; =20 +static int qcom_wdt_get_bootstatus(struct device *dev, struct qcom_wdt *wd= t, + u32 val) +{ + struct device_node *imem; + struct resource res; + void __iomem *addr; + int ret; + + imem =3D of_parse_phandle(dev->of_node, "sram", 0); + if (!imem) { + /* Read the EXPIRED_STATUS bit as a fallback */ + if (readl(wdt_addr(wdt, WDT_STS)) & 1) + wdt->wdd.bootstatus =3D WDIOF_CARDRESET; + + return 0; + } + + ret =3D of_address_to_resource(imem, 0, &res); + of_node_put(imem); + if (ret) + return ret; + + addr =3D ioremap(res.start, resource_size(&res)); + if (!addr) + return -ENOMEM; + + if (readl(addr) =3D=3D val) + wdt->wdd.bootstatus =3D WDIOF_CARDRESET; + + iounmap(addr); + + return 0; +} + static int qcom_wdt_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -273,8 +310,9 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.parent =3D dev; wdt->layout =3D data->offset; =20 - if (readl(wdt_addr(wdt, WDT_STS)) & 1) - wdt->wdd.bootstatus =3D WDIOF_CARDRESET; + ret =3D qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val); + if (ret) + dev_err(dev, "failed to get the bootstatus, %d\n", ret); =20 /* * If 'timeout-sec' unspecified in devicetree, assume a 30 second --=20 2.34.1