From nobody Tue Apr 7 18:48:22 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 21B9A429819 for ; Thu, 26 Feb 2026 17:00:05 +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=1772125207; cv=none; b=MAnnlc4IvrbaFzMwpVjYUHvi04wMVQnMYUIVYAq0DO2Bo+HChic+NOnKXo9xHG+0Lszu2CaIt9NFwNirVKHWd5loR46sGQOgp4Pp47mjmEA4aOh6n/+uq6GUMWpckbAI+M7Hq56uHwXcrjVzkZNmHC6YPL5XuNInemeEYZP+Z9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772125207; c=relaxed/simple; bh=6Fee7+x2CpYKxxzavdQpk3tVNfJGvkPuDAkp3K1SF9A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RMQ5wtWYdjDfYkJmp0aEmtfi53LYmtmSLSgsnXOUv1BWK4w57KjE+8QeIhqHJkq84BrgjBvf/aTPBC5EyYPpCIGDaxxcgsBgvQELbAh7X1OiCgjG7ZRnjdFUjhO6BqyaYA7NshmnSXbY6hFCbYHTGpX5BjkzA64fmDyTQIkIwHI= 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=cAlmcSzD; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Ada8WXCG; 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="cAlmcSzD"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Ada8WXCG" 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 61QGhweR1171092 for ; Thu, 26 Feb 2026 17:00:05 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= 9Q16nQkOnRJHOXiE4YfbTbTmYN1CH7kro/6L9igRkpo=; b=cAlmcSzD4QAgnBhQ 3z3LReSRHCbMem74WZearzFzbS+vJWG0Yr3WE8FMM1X2QWYJyjbARkppbnLh/c4d G1S2WMcsAJ1x8yCFJJQDN/vO8qv6JLBUuIhvr+vTJAu4G3jDJDFHOPD89Eexi40A 92lBdInEdGKamkezoBdEIT0N+VC47N3KGWCtqioAm6KEVKdt/1AJwazJw8nmLY4R PEWK9rj88T5iOGvC0QqGjKSpHBsRg6ZysNeP7AlBFVgpRf4HRQGRHOIS2LoppIK/ coD4+ZWcRUKrF9qIbNN7Uce31gearSO8tKAhdwdB4vAor/IvM10L2hagWUPkxzhU jFLfCw== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cjae0u3bs-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 26 Feb 2026 17:00:04 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2adb085735bso12682455ad.1 for ; Thu, 26 Feb 2026 09:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772125204; x=1772730004; 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=9Q16nQkOnRJHOXiE4YfbTbTmYN1CH7kro/6L9igRkpo=; b=Ada8WXCGcgnCKMUzsQ58Hr/WYRYx8/FWCvnSUqFj6UQCWqbqnRnXjIcEPgortXCO/g I/JN9lb750vy6vngCdn0PY6KDCjEXX7ogqAMalu81oLEjaD7x/0RfRbx1BEQINrB/Tj3 izF2NeZsrp6mnKI2buJASuDw6B6EXMsNUTDIZscY1pQSO8n+rHj/zUMZl+DDeZJhns3l iF9s9zpqBf0ZiTVBZVImjzORc5EPooMbUX21TKyC3lgaFNUVsotVVWayZryBp8tyQrw4 KYMQvuJaGgSNOc9R96YmTWysMyHkXtoH9TuALFZhaNr+cDS78pnimp9b9EuPsi29D3sQ xYpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772125204; x=1772730004; 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=9Q16nQkOnRJHOXiE4YfbTbTmYN1CH7kro/6L9igRkpo=; b=sqkALW09dlYCk8VLprXYB+tm2N4joeJaLJQqS8zAN2SrslYkoqcq+b8ntPTMBs3uCU n9TdCzAZsrWo8mIRHlBgKY1VHk9G07fNnKY+RIbEy/rAz16hHGHTXZRD389aEyJ9kUxs JK72Lnx5egsFHotSdUszayC4gJJ9IkPPNvdua6H2i/VAGqR0gFprRkt0MgGn2ZD/0L0x kgXJHSGHVNNUn37hn+53BE4qqvVon1DK3TimHxppjyAjrO67UixFf+uiHwtTpTSukPgd sNQFdU0udBzYYVC8TRjCBeRZYEBFFee+XGmUd8KuvoidrTdb1wglKTXVwFff68MOvqCt tBIg== X-Forwarded-Encrypted: i=1; AJvYcCVcuk7nXgRjrw6jl9iDW5IyPQsKfRwnVuDGqIHmnA2R4vzrxD9+H3Za5P5zhlr1Lyrfb63cso4PzJMsg/8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6B99DYWV8FuOpMKGynZvqJjCUphxxa79MBachit70+BHl2Kx9 yzefCrlTvI5cxbnhT3hpCfNs3SZ3jgfCaEfleLI7kB3E/RHLroqmBWbporgp60QNcB9W0DkM3pS P4zuQa6oRFvUiOhv2/8UWyCpWj0nKFcaOXrM5OkdXAJNtOBgNWkkpLcAA/oxrbeoD1QxycuuSG9 E= X-Gm-Gg: ATEYQzxbbsAEWwhlLaA2igatjMMoTbH9wMgqZu9JEN7/JAGfnmCW/t8h6CsL9zSBpkg NmBwUNPgrR75NW7Ro0cpEuGx6z54oJ18jX9el0Myj6LpkcHM8C0aPrPg8AU4QyHdXlA2Kl4NBHU JqD9ew6U5Q/PRuIiTJ9i5j7sUo/oQzIZQJg3ZcXpI2x7+CBk9qYpKpOd/MzA1YQyEw3hScu1ZWD e+WjD4QR3t2LkZ+sA0c8CABU4+zDnKbZiWrzTyxtIn4BzKKib5Kb+UnPebjQu7gfA2p/NNu9K4t xgvIT/NK1OCSUJL88bTsK7A1yPrh8jUnYxY2uCaTgRr3z9B6N6WplqgtPzD+rzPSGm1X2KxeFRU RT+QEzKjBg8hAwnmeBtvaaKLHdLsgdSUPMKPLnwxr9SaJ1U6ttmyDmC+zGLAhc9jSzf/kn/FtId qtvaQEIZlvQ1cS3FrHp02ktTMvQR1EQFHzv42sArltzeuKXC6aT1RVpSXI X-Received: by 2002:a17:902:d54c:b0:2a0:e80e:b118 with SMTP id d9443c01a7336-2ad74418adfmr202249825ad.7.1772125203681; Thu, 26 Feb 2026 09:00:03 -0800 (PST) X-Received: by 2002:a17:902:d54c:b0:2a0:e80e:b118 with SMTP id d9443c01a7336-2ad74418adfmr202249475ad.7.1772125203190; Thu, 26 Feb 2026 09:00:03 -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-8273a01054dsm3626286b3a.43.2026.02.26.08.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 09:00:02 -0800 (PST) From: Kathiravan Thirumoorthy Date: Thu, 26 Feb 2026 22:29:39 +0530 Subject: [PATCH v8 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: <20260226-wdt_reset_reason-v8-4-011c3a8cb6ff@oss.qualcomm.com> References: <20260226-wdt_reset_reason-v8-0-011c3a8cb6ff@oss.qualcomm.com> In-Reply-To: <20260226-wdt_reset_reason-v8-0-011c3a8cb6ff@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=1772125179; l=4295; i=kathiravan.thirumoorthy@oss.qualcomm.com; s=20230906; h=from:subject:message-id; bh=6Fee7+x2CpYKxxzavdQpk3tVNfJGvkPuDAkp3K1SF9A=; b=thnjRai3jt11X3QyYVbmsPcVAnbvcJGpXoWlJ8DSuJ/X72rsKQOYU1H7nBH9M8b9uzVMg+ILH 4aCQlmZVuA6AEMS/CNZHUxrUcwBANXKfWsYRnt6eqy3wDHrNP83iULJ X-Developer-Key: i=kathiravan.thirumoorthy@oss.qualcomm.com; a=ed25519; pk=xWsR7pL6ch+vdZ9MoFGEaP61JUaRf0XaZYWztbQsIiM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI2MDE1MyBTYWx0ZWRfX+oal5NPpcf4U zEYsMc0RMbzDYN4XpoBwRFLuFIhY6IO4561ue1QklDXdBrz9YKK6eFHhwWmo5Qdr+pvCLbjAnfc Qi1Uq9jhPAgoqHOHR+WME3DXP4RGZOA4QBO8KrFCGCf1OsBdLwqeKj62m5pvr/d1s2yoGi4X75V gvbPOciWNrRJCzTrMAdMCW1gLyOwX1mVxpw9gx0GEiXEMffFwVSmpTyscjAAIvE2EI8B9WgnvOv BvmCJH70fsJ9qHnk4hMZioun1g/YCQdfAiOBKheyMihIzq/OGHDhmFz9yn6Fikr148CSEf9S4Yp 8As6YLfMWYV4staYE/F/PN7gVdTVafcWf/0xd1WChuunSLJpy/A4sYa6A1WHRU+cdxoVQDzaeeh 4j6Sv7QvsqCLSkDWTrNeDtpwG2dkdXKxojixawALkN/3em0ctZnoNgjwtPV/3BtPF/xiX1uZ7W+ gXi9cFQUAy7M0HnllRw== X-Authority-Analysis: v=2.4 cv=O7Q0fR9W c=1 sm=1 tr=0 ts=69a07c14 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=qKWHfwwlgvfnR6H4MV8A:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-ORIG-GUID: ytNEWU2epfOF8nWYGgIumE9tHlYBwErC X-Proofpoint-GUID: ytNEWU2epfOF8nWYGgIumE9tHlYBwErC 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-26_01,2026-02-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602260153 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 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..bbf229a7b5840714b9429f4b092= ec3f7a6a26961 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) + return ret; =20 /* * If 'timeout-sec' unspecified in devicetree, assume a 30 second --=20 2.34.1