From mboxrd@z Thu Jan 1 00:00:00 1970 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 B0F091A3156 for ; Fri, 2 May 2025 04:42:11 +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=1746160933; cv=none; b=hU8xNmG4RCQ9qtaj7Ff2qqnqxF8HEyye5G++8sOAGUksDBw76TOfM4qK7Zkb1iBw79fu4X5bN69aNe/i3LwQCKccP2FGKf8kRuFGxwjrH219En/kb5QIdLO2PkBQeQJBxoTyTbF8GnDuFlkoMzz1ZmiCC6/iAgRbbNR3mXeDkQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746160933; c=relaxed/simple; bh=AS5GCwcO4Mg8AL75Z9J2FHBKkN5+JSl/LX+VBO7oJqQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Krb6jFlUmBlMGdijcO9rCSjYTjp5levExNvqvgv9aVApKVhjwr8ejFponGIo/CMSV3jG0SRXGUin4K1qrbkKjPjx4/sWM4ZimwXY4oIzjpyf12PeiOE0RJUKs+I6W4laccyWiBxtCGEYa2nw3SLHC0r4UW4rBr88vlAJVtIXeU4= 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=lD93qQm0; 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="lD93qQm0" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5421OAjj018172 for ; Fri, 2 May 2025 04:42:10 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= 7j5UxYN6C9Dd6qHXGE97a7YLEYkg4By51iUOqA+ylAQ=; b=lD93qQm0lfGtQu2b Qol+d3LR4qo4+nRMOn5UzV0/SgDWNud83Pb+Tb1RKqYAJjqowwungs3q4s2MUfb6 7PXzNa05DwwAk2Rj1KaQsViGT+LbFMTslw56wXt5S4ADZssd0iVNijqc72MCH2l6 30Ndlv6aAvcHhBga9oSw6ybxw3mAwHQpEIpS1CiwVdJO29HkpbWoihIBbqjIwyKC UBZ30zVcfnRHVBUtSNVVIBEI6fDQvOe3F6REV3Q6NwDIuRC03LCduxDPZfxwG8Cu n1Int1HTfaIThrO4uv7x/l7f9t2By+WhIdTJpAy3ufJ9pyI+4lyiGiJNNFzybgLG wm+Kow== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 46b6u3y5xs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 02 May 2025 04:42:10 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-736c1ea954fso979618b3a.3 for ; Thu, 01 May 2025 21:42:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746160929; x=1746765729; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7j5UxYN6C9Dd6qHXGE97a7YLEYkg4By51iUOqA+ylAQ=; b=sfvywepJmRwDqyiipmtEtApC7Rps1JWFrSwHlG1N41BTU+i/XfP+LZbTHAjvo/91IZ jKRcpkqRE6HyBN5YqaKC+PdfMXNIku3rfqBKADKz5E2BTzHmYv0NaM65eHypsxzBp3PI GgwgjBNvrsrgMtVaQ6WjHNATgy0iTXWg2h9T87sILDbzFukV6AuojG9oROg0kHe1jhdf tfgLbsQSS+EKeznWmM8nqP7IxOqWYSss8ANHf74Ssy/8y8gDKiAG4MtkaN+WJJ6zJOof r7YIxTKAvAM2BpP7oP2P9BEQN5M+MhpXHgCO8jH0dS8FIWnz9cNAlcW7IUYrjrXtpDhH i5rQ== X-Forwarded-Encrypted: i=1; AJvYcCUnEkZvZMyC633shLGwU4qaTo5VhEjKmVMPFIROLqUcVvlNV7vHFik6WOyzBr6Kaor+3f6/jdxsEdfBe98=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3s+54QT/BSD3TRDuq/isEmmQteR1FPx+NOh95ratlkMjc++9f zKkoRObXCB4l07rSdpdNR+HHszsNX8Las7aKWGoDEeYNOrQjyUV3LTpPjIT+YBqJ9y3CFswnbwY 7gpxhAGk6fcfpOhDnIDWyjPVM5r6dHEe0/gt08q/UqFD+8Q4t/ReFrdxulHD5K/8= X-Gm-Gg: ASbGncubOUlud7E81XDT+cxaulm+1GFq01NTqpatfkcS1hY9EzKu/aiHNN8UVG+OwMQ c+HaSdrcFemMP0ofHrZRgcQOqTRgPXdBGdjPyG42FO5CLq0fVKYz82owlJjAlm3lg1ywHnu6WwM xOCKnsMjGXKYWpgIlgFfEGecccYOZYWjDoVkghJUXApw9CNk224VqIUqcTirtbqTGNGFjEJLmbq C+nl9lwaU1KD98EtlrtemE35X4Ow/q4wN5/FbXNeBb8/0AJd7vpJARpNDHCEbZ7+sS4cryQsKhR SQIxaTLk5lcZBN4W6YetDF4beSQiM4E3jq50dCO9OoLdzA50A/21 X-Received: by 2002:a05:6a00:4294:b0:736:6ecd:8e32 with SMTP id d2e1a72fcca58-74058b23ef3mr1866200b3a.21.1746160928682; Thu, 01 May 2025 21:42:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBQrj67WLhBG3Hq96DBg+5Opa1dABnH/Q1s+TspcF/KflEqOJ5Mrv0bnI/pESCH+hoqmXB/g== X-Received: by 2002:a05:6a00:4294:b0:736:6ecd:8e32 with SMTP id d2e1a72fcca58-74058b23ef3mr1866183b3a.21.1746160928305; Thu, 01 May 2025 21:42:08 -0700 (PDT) Received: from [10.151.37.217] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-74059021483sm590790b3a.93.2025.05.01.21.42.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 May 2025 21:42:07 -0700 (PDT) Message-ID: <09579b2c-f312-4c8a-b57a-b240204cd733@oss.qualcomm.com> Date: Fri, 2 May 2025 10:12:02 +0530 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 v2 5/5] watchdog: qcom: add support to read the restart reason from IMEM Content-Language: en-US To: Bryan O'Donoghue , 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 References: <20250416-wdt_reset_reason-v2-0-c65bba312914@oss.qualcomm.com> <20250416-wdt_reset_reason-v2-5-c65bba312914@oss.qualcomm.com> From: Kathiravan Thirumoorthy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=Bv6dwZX5 c=1 sm=1 tr=0 ts=68144d22 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=EUspDBNiAAAA:8 a=Amq28VNnWxlBxfWyqssA:9 a=QEXdDO2ut3YA:10 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-GUID: sYPSWLeLJuc5Fi0Isa39HAFqQGEKPcVl X-Proofpoint-ORIG-GUID: sYPSWLeLJuc5Fi0Isa39HAFqQGEKPcVl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTAyMDAzNCBTYWx0ZWRfX6J4hxEwf2BnW MDkW6wBmxyOY8uTqy/gioCQZJLgA7BAdHKKnxQ6ulgAS62Vf2JlT2s5RuRFoTZz8ywVEPIn7Jwf JGz0NxLBsHrma7ls1ydmCo4r6KePLnyI6bN38FpnB3u4dT/RpicreV3NKXgQwVtzPQj7SMIwd1l u3Rexxgi449whI3UrBssTw7pAVyNCP0rqdEzFot0PUcKfdv43rb+wnV0f7MQrgH7q5rlojK+FFl 1mU95RXeV7nKiad9lStGbwxwvWQN4ipf4aqAJNIBm7cxOYT6kBKFXB2UMGV58ZpqGbymjDRu04F oWE05klJdcZYSU43b/0LDd2D0wY3o6aO+0SehmJf3lkKQKvnK9KVYb6dUABPfjrQRBq2i6+R8cB +MOgeNZ0bf6SJTvZiaiJ7xzJRf0bRMAVe6h8KvD9QWyYwLTNNW1/kVsOlsQM7wrOv2CDemuU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-01_06,2025-04-24_02,2025-02-21_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2504070000 definitions=main-2505020034 On 5/1/2025 5:31 AM, Bryan O'Donoghue wrote: > On 16/04/2025 09:29, 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, bootloaders update the information in the IMEM region. >> Update the driver to read the restart reason from IMEM and populate the >> bootstatus accordingly. > Which bootloaders ? > > Do you mean bootrom or one of the subsequent phase bootloaders ? It is updated by the XBL. I shall mention it explicitly. > > Please be specific about which bootloader populates this data i.e. if I > switch my bootloader to u-boot do I loose the added flag ? > >> For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new >> function qcom_wdt_get_restart_reason() to read the restart reason from >> IMEM. >> >> Signed-off-by: Kathiravan Thirumoorthy > What I'd really love to see here is an example of reading out the data > from sysfs. > > How do I as a user/consumer of this new functionality parse the new data > it provides ? > > Ideally do this in the commit log and recommend doing it in the cover > letter to, as people don't always read both when commenting on patches. Sure, will mention the sysfs path and its output in the commit log and cover letter. > >> --- >> 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 | 47 +++++++++++++++++++++++++++++++++++++++++++-- >> 1 file changed, 45 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c >> index 006f9c61aa64fd2b4ee9db493aeb54c8fafac818..94ba9ec9907a19854cd45a94f8da17d6e6eb33bc 100644 >> --- a/drivers/watchdog/qcom-wdt.c >> +++ b/drivers/watchdog/qcom-wdt.c >> @@ -7,9 +7,11 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> +#include >> #include >> >> enum wdt_reg { >> @@ -39,6 +41,9 @@ static const u32 reg_offset_data_kpss[] = { >> }; >> >> struct qcom_wdt_match_data { >> + const char *compatible; >> + unsigned int restart_reason_offset; >> + unsigned int non_secure_wdt_val; >> const u32 *offset; >> bool pretimeout; >> u32 max_tick_count; >> @@ -175,6 +180,15 @@ static const struct watchdog_info qcom_wdt_pt_info = { >> .identity = KBUILD_MODNAME, >> }; >> >> +static const struct qcom_wdt_match_data match_data_ipq5424 = { >> + .compatible = "qcom,ipq5424-imem", >> + .restart_reason_offset = 0x7b0, >> + .non_secure_wdt_val = 0x5, >> + .offset = reg_offset_data_kpss, >> + .pretimeout = true, >> + .max_tick_count = 0xFFFFFU, >> +}; >> + > You should separate the addition of your compatibles and their > descriptor tables from generic functional extensions. > > i.e. add the compat string and the above table in a subsequent patch. Got it. Will split the patch into 2. > >> static const struct qcom_wdt_match_data match_data_apcs_tmr = { >> .offset = reg_offset_data_apcs_tmr, >> .pretimeout = false, >> @@ -187,6 +201,29 @@ static const struct qcom_wdt_match_data match_data_kpss = { >> .max_tick_count = 0xFFFFFU, >> }; >> >> +static int qcom_wdt_get_restart_reason(struct qcom_wdt *wdt, >> + const struct qcom_wdt_match_data *data) >> +{ >> + struct regmap *imem; >> + unsigned int val; >> + int ret; >> + >> + imem = syscon_regmap_lookup_by_compatible(data->compatible); >> + if (IS_ERR(imem)) >> + return PTR_ERR(imem); >> + >> + ret = regmap_read(imem, data->restart_reason_offset, &val); >> + if (ret) { >> + dev_err(wdt->wdd.parent, "failed to read the restart reason info\n"); >> + return ret; >> + } >> + >> + if (val == data->non_secure_wdt_val) >> + wdt->wdd.bootstatus = WDIOF_CARDRESET; >> + >> + return 0; >> +} >> + >> static int qcom_wdt_probe(struct platform_device *pdev) >> { >> struct device *dev = &pdev->dev; >> @@ -267,8 +304,13 @@ 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_restart_reason(wdt, data); >> + if (ret == -ENODEV) { >> + if (readl(wdt_addr(wdt, WDT_STS)) & 1) >> + wdt->wdd.bootstatus = WDIOF_CARDRESET; >> + } else if (ret) { >> + return ret; >> + } >> >> /* >> * If 'timeout-sec' unspecified in devicetree, assume a 30 second >> @@ -322,6 +364,7 @@ static const struct dev_pm_ops qcom_wdt_pm_ops = { >> }; >> >> static const struct of_device_id qcom_wdt_of_table[] = { >> + { .compatible = "qcom,apss-wdt-ipq5424", .data = &match_data_ipq5424 }, >> { .compatible = "qcom,kpss-timer", .data = &match_data_apcs_tmr }, >> { .compatible = "qcom,scss-timer", .data = &match_data_apcs_tmr }, >> { .compatible = "qcom,kpss-wdt", .data = &match_data_kpss }, >> >> -- >> 2.34.1 >> >>