From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EF1C33EB1A for ; Fri, 27 Feb 2026 07:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772178146; cv=none; b=V6mRxfcNvxJMtI+G62PC82cwe7ynJnWlNPW2C1o/+UXG8XGlOiV6RxZwxYfRbMBcSxIYuS5AF42iMBWkeWofxP74DsmVel1RHRTlTPhPrRKw0b1Fq/2M1+oGsMr3EjgQOjuXUYfoZX9e2DGCWvFjyIEMEGgZOy97HfIElfTYbiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772178146; c=relaxed/simple; bh=wnp1Lq8mmX33B8twyR7sFcRofmw9bR6EbHCp61lLaCo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qxAKvs6YZsrxdAe0Xkxf8g3LUVaIHvtTVAgab/kRyJtptu2WgRDZgYqh7KQ1cSRz1vfo9gP63VeWDigdAkHpsy/qviQgoWC4XxpdL911+ACyu/eeOd5wPIVZDysJmLJBsa0gjW+V2C62T23fAwnwXJZ+XqtDCSGRsaTowEh+otw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AUeZZOls; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AUeZZOls" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-82746ed8cb1so669642b3a.3 for ; Thu, 26 Feb 2026 23:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772178143; x=1772782943; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=RSpBFk6h7GjXDnU1XJIlOR6UlooIlnl0CsiskOpIsE0=; b=AUeZZOlswcxNYNsbOtVIhiYMSPkhC4p/SX0dSp6mcCHcDMIxNmYAaDRyHNtrFenQX0 kfq8wG+527JGC6Zx24Lmo6Mrz8TatvNLUsBbjzQxmt5/soQvXfmH3lsRnxNE+m4H0KCF Nd6e2PAxAN0kYdXbI/OgA1kVGbHP2edHExna4e3VgDRiJf7JfUfPDf6C2blD1Ml23jbl ISY1PNDmgmm3iaPvUaHQW3mM31erqql5sPIL4vwjY9lDg9X+CF154pPQ8g5KaEtYa9oc V40hWyW9I3vV7bkQyauvKQV6KTQmPsOYwPV07vKUJ0CDNODNehemaovl0jTuBsvRZH7B /VGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772178143; x=1772782943; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RSpBFk6h7GjXDnU1XJIlOR6UlooIlnl0CsiskOpIsE0=; b=djGL1AglKnf8u4WCQWGb85PHz/gcKOA+dXHFxfdJjNcXiiil2aP90FkzmR8Oz2OQDE xWycfDGArgtdx2LjqVt93yxHI08HMEfNYqRnQvH9MHQ40NT3IwhO+cANZy7nQxN1Cs6u J/hCdThJXRuhCAphwDRUXEPazCOFY1mHkaObLgaQ+eDjQTQL0aSlqTIEYb6hx7lsiovi iZzDhuZBD40OWTpDqsOhnK8gqEGjbMYweT0NWp0uuFk2eyNS521LtKrbxFMPxEghnjAI cy3b61J0ODqzmVKDeEe4NFUVvrFNlkU0cGKUL2zvV156ztRt5iFDvGpaRIvzjwexePli rEuA== X-Forwarded-Encrypted: i=1; AJvYcCVQJ3LIG0FWf5O5TlNYeFAvza4Q/MXkvRclPEbq+9JVt9IWH+GFD1FjrjxVaoyx0YNCYSjfFT30fBfJflg=@vger.kernel.org X-Gm-Message-State: AOJu0YyeMVdMnVebnfBxOkTzzaT8QTPpxMeIvZo4tmqgJz6KAQa/j+uX wGkMCoBFk2OWrR3TExp+i1ZLFqEqpFEJrfNjBCyknP3ptXAldOwE1b9J X-Gm-Gg: ATEYQzyxn3K1ACRtjQmGd/M9R1TrjGZ5wXuFTynLXS+TZ/yuQscrmNudjfbLJH6FGGl iM2Q5DNKKcMPBc4RO3Y2c1jK2+UqtloEYqUxeyX6eUf3TSs3GKSrpeobTPfm4xVgfbooP8Ig5NM vxn2onV+7JJ2b3m9QQCGrMfW8t8vPSjNx4UaTsCECFumkPX2MDKp1T+RyE1EfPoD8E3A5T/hc7Q 4Fady38VsbZIKjzbc8lZJa8fGyWnUui1Z/Eb1bwQtgMe4DoKDvBKcJDv89SBm/UK6KLU7Pfu2DE PLzxoXiborrRmN3VTvLU4cfs9iMnILVSaY6KzogXAMaKGDh7mBIxgrxVpPBTxcfCm2f6J5SrQdm 8QCq7Fwe3oTplELXw6J6s8+Bwi82iFKqqHxZHazS7AmFMCxhCAgQQz49a6pYeQPEjnvHWLD2Hfy WVeyEWiyETnDyCLVdQe6P2dHVViZoNZ7GK29gBY0PelbUv/sHLq40RMXu+Y/TcdyqCgvON5uiid SxV9UGBogk= X-Received: by 2002:a05:6a00:301f:b0:81f:852b:a91e with SMTP id d2e1a72fcca58-8274da3a29emr1774463b3a.59.1772178142752; Thu, 26 Feb 2026 23:42:22 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:da43:aeff:fecc:bfd5? ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82739d87e78sm5139592b3a.17.2026.02.26.23.42.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Feb 2026 23:42:20 -0800 (PST) Sender: Guenter Roeck Message-ID: <52bf19af-7cf3-4e20-89ad-813fad8aa9c1@roeck-us.net> Date: Thu, 26 Feb 2026 23:42:19 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM To: Kathiravan Thirumoorthy , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Wim Van Sebroeck , Rajendra Nayak Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, Konrad Dybcio References: <20260226-wdt_reset_reason-v8-0-011c3a8cb6ff@oss.qualcomm.com> <20260226-wdt_reset_reason-v8-4-011c3a8cb6ff@oss.qualcomm.com> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RT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VP25Z2hMkHBwx6BlW6EZLNgzGI2rswSZ7SKcsBd1IRHVf0miwIFYy j/UEfAFNW+tbtKPNn3xZTLs3quQN7GdYLh+J0XxITpBZaFOpwEKV+VS36pSLnNl0T5wm0E/y scPJ0OVY7ly5Vm1nnoH4licaU5Y1nSkFR/j2douI5P7Cj687WuNMC6CcFd6j72kRfxklOqXw zvy+2NEcXyziiLXp84130yxAKXfluax9sZhhrhKT6VrD45S6N3HxJpXQ/RY/EX35neH2/F7B RgSloce2+zWfpELyS1qRkCUTt1tlGV2p+y2BPfXzrHn2vxvbhEn1QpQ6t+85FKN8YEhJEygJ F0WaMvQMNrk9UAUziVcUkLU52NS9SXqpVg8vgrO0JKx97IXFPcNh0DWsSj/0Y8HO/RDkGXYn FDMj7fZSPKyPQPmEHg+W/KzxSSfdgWIHF2QaQ0b2q1wOSec4Rti52ohmNSY+KNIW/zODhugJ np3900V20aS7eD9K8GTU0TGC1pyz6IVJwIE= In-Reply-To: <20260226-wdt_reset_reason-v8-4-011c3a8cb6ff@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/26/26 08:59, Kathiravan Thirumoorthy wrote: > 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/bootstatus > 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..bbf229a7b5840714b9429f4b092ec3f7a6a26961 100644 > --- a/drivers/watchdog/qcom-wdt.c > +++ b/drivers/watchdog/qcom-wdt.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -42,6 +43,7 @@ struct qcom_wdt_match_data { > const u32 *offset; > bool pretimeout; > u32 max_tick_count; > + u32 wdt_reason_val; > }; > > struct qcom_wdt { > @@ -185,6 +187,7 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = { > .offset = reg_offset_data_kpss, > .pretimeout = true, > .max_tick_count = 0xFFFFFU, > + .wdt_reason_val = 5, > }; > > static const struct qcom_wdt_match_data match_data_kpss = { > @@ -193,6 +196,40 @@ static const struct qcom_wdt_match_data match_data_kpss = { > .max_tick_count = 0xFFFFFU, > }; > > +static int qcom_wdt_get_bootstatus(struct device *dev, struct qcom_wdt *wdt, > + u32 val) > +{ > + struct device_node *imem; > + struct resource res; > + void __iomem *addr; > + int ret; > + > + imem = 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 = WDIOF_CARDRESET; > + > + return 0; > + } > + > + ret = of_address_to_resource(imem, 0, &res); > + of_node_put(imem); > + if (ret) > + return ret; > + > + addr = ioremap(res.start, resource_size(&res)); > + if (!addr) > + return -ENOMEM; > + > + if (readl(addr) == val) > + wdt->wdd.bootstatus = WDIOF_CARDRESET; > + > + iounmap(addr); > + > + return 0; > +} > + > static int qcom_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -273,8 +310,9 @@ static int qcom_wdt_probe(struct platform_device *pdev) > wdt->wdd.parent = dev; > wdt->layout = data->offset; > > - if (readl(wdt_addr(wdt, WDT_STS)) & 1) > - wdt->wdd.bootstatus = WDIOF_CARDRESET; > + ret = qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val); > + if (ret) > + return ret; > Why is reporting the boot status so important that the failure to read it results in refusing to instantiate the driver ? That warrants a detailed explanation, even more so since it is not backward compatible. Guenter > /* > * If 'timeout-sec' unspecified in devicetree, assume a 30 second >