Add support to read the restart reason from IMEM
Subsystems (4)
v3 cover Add support to read the restart reason from IMEM
In Qualcomm IPQ SoC, if the system is rebooted due to the watchdog timeout, there is no way to identify it. Current approach of checking the EXPIRED_STATUS in WDT_STS is not working.
To achieve this, if the system is rebooted due to watchdog timeout, the information is captured in the IMEM by the bootloader (along with other reason codes as well).
This series attempts to address this by adding the support to read the IMEM and populate the information via bootstatus sysfs file. As of now, we are handling only the non secure watchdog timeout reason.
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
---
Changes in v3:
- Picked up the relevant tags
- Dropped the fallback compatible handling
- Split the driver changes into 2. Introduce the device data in one and extend the same in another for the use case
- Linke to v2:
https://lore.kernel.org/linux-arm-msm/[email protected]/
Changes in v2:
- Dropped the RFC tag
- Reworked the driver changes to use the syscon API
- Link to v1:
https://lore.kernel.org/linux-arm-msm/[email protected]/
---
Kathiravan Thirumoorthy (4):
dt-bindings: sram: qcom,imem: Document IPQ5424 compatible
arm64: dts: qcom: ipq5424: Add the IMEM node
watchdog: qcom: introduce the device data for IPQ5424 watchdog device
watchdog: qcom: add support to read the restart reason from IMEM
.../devicetree/bindings/sram/qcom,imem.yaml | 1 + arch/arm64/boot/dts/qcom/ipq5424.dtsi | 9 +++++ drivers/watchdog/qcom-wdt.c | 47 +++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-)
---
base-commit: 3e039dcc9c1320c0d33ddd51c372dcc91d3ea3c7
change-id: 20250408-wdt_reset_reason-e12921963fa6
Best regards,
Signature · 1 line
Kathiravan Thirumoorthy <[email protected]>
PATCH v3 1/4 dt-bindings: sram: qcom,imem: Document IPQ5424 compatible
Add compatible for Qualcomm's IPQ5424 IMEM.
---
Changes in v3:
- Picked up the A-b tag
--- Documentation/devicetree/bindings/sram/qcom,imem.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/sram/qcom,imem.yaml +1 -0
@@ -18,6 +18,7 @@ properties: items: - enum: - qcom,apq8064-imem + - qcom,ipq5424-imem - qcom,msm8226-imem - qcom,msm8974-imem - qcom,msm8976-imem
Signature · 1 line
2.34.1
PATCH v3 2/4 arm64: dts: qcom: ipq5424: Add the IMEM node
In reply to Kathiravan ThirumoorthyAdd the IMEM node to the device tree to extract debugging information like system restart reason, which is populated via IMEM. Define the IMEM region to enable this functionality.
As described, overall IMEM region is 112KB but only initial 4KB is accessible by all masters in the SoC.
---
Changes in v3:
- Picked up the R-b tag
Changes in v2:
- Describe the entire IMEM region in the node
- Explicitly call out that initial 4K only accessible by all masters in the commit message
--- arch/arm64/boot/dts/qcom/ipq5424.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/qcom/ipq5424.dtsi +9 -0
@@ -486,6 +486,15 @@ ssphy_0: phy@7d000 { status = "disabled"; }; + sram@8600000 { + compatible = "qcom,ipq5424-imem", "syscon", "simple-mfd"; + reg = <0 0x08600000 0 0x1c000>; + ranges = <0 0 0x08600000 0x1c000>; + + #address-cells = <1>; + #size-cells = <1>; + }; + usb3: usb3@8a00000 { compatible = "qcom,ipq5424-dwc3", "qcom,dwc3"; reg = <0 0x08af8800 0 0x400>;
Signature · 1 line
2.34.1
PATCH v3 3/4 watchdog: qcom: introduce the device data for IPQ5424 watchdog device
In reply to Kathiravan ThirumoorthyTo retrieve the restart reason from IMEM, certain device specific data like IMEM compatible to lookup, location of IMEM to read, etc should be defined. To achieve that, introduce the separate device data for IPQ5424 and add the required details subsequently.
---
Changes in v3:
- New patch
--- drivers/watchdog/qcom-wdt.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/watchdog/qcom-wdt.c +7 -0
@@ -181,6 +181,12 @@ static const struct qcom_wdt_match_data match_data_apcs_tmr = { .max_tick_count = 0x10000000U, }; +static const struct qcom_wdt_match_data match_data_ipq5424 = { + .offset = reg_offset_data_kpss, + .pretimeout = true, + .max_tick_count =0xFFFFFU , +}; +static const struct qcom_wdt_match_data match_data_kpss = { .offset = reg_offset_data_kpss, .pretimeout = true,
@@ -322,6 +328,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 },
Signature · 1 line
2.34.1
Re: [PATCH v3 3/4] watchdog: qcom: introduce the device data for IPQ5424 watchdog device
Quoted 6 lines · Kathiravan Thirumoorthy
To retrieve the restart reason from IMEM, certain device specific data like IMEM compatible to lookup, location of IMEM to read, etc should be defined. To achieve that, introduce the separate device data for IPQ5424 and add the required details subsequently.
Signed-off-by Kathiravan Thirumoorthy <[email protected]>
Re: [PATCH v3 3/4] watchdog: qcom: introduce the device data for IPQ5424 watchdog device
In reply to Kathiravan ThirumoorthyQuoted 31 lines · Kathiravan Thirumoorthy
To retrieve the restart reason from IMEM, certain device specific data like IMEM compatible to lookup, location of IMEM to read, etc should be defined. To achieve that, introduce the separate device data for IPQ5424 and add the required details subsequently.
Signed-off-by Kathiravan Thirumoorthy <[email protected]>---
Changes in v3:
- New patch--- drivers/watchdog/qcom-wdt.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/watchdog/qcom-wdt.c +6
-0@@ -181,6 +181,12 @@ static const struct qcom_wdt_match_data match_data_apcs_tmr = { .max_tick_count = 0x10000000U, }; +static const struct qcom_wdt_match_data match_data_ipq5424 = { + .offset = reg_offset_data_kpss, + .pretimeout = true, + .max_tick_count =0xFFFFFU , +}; +static const struct qcom_wdt_match_data match_data_kpss = { .offset = reg_offset_data_kpss, .pretimeout = true,
drivers/watchdog/qcom-wdt.c static const struct dev_pm_ops qcom_wdt_pm_ops = { · line 331
Quoted 4 lines
drivers/watchdog/qcom-wdt.c +1
-0@@ -322,6 +328,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 },
Shouldn't it be qcom,ipq5424-apss-wdt ?
Quoted 7 lines
drivers/watchdog/qcom-wdt.c +0
-0{ .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 },Signature · 2 lines
-- 2.34.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v3 3/4] watchdog: qcom: introduce the device data for IPQ5424 watchdog device
Quoted 34 lines · Dmitry Baryshkov
Quoted 33 lines · Kathiravan Thirumoorthy
To retrieve the restart reason from IMEM, certain device specific data like IMEM compatible to lookup, location of IMEM to read, etc should be defined. To achieve that, introduce the separate device data for IPQ5424 and add the required details subsequently.
Signed-off-by Kathiravan Thirumoorthy <[email protected]>---
Changes in v3:
- New patch--- drivers/watchdog/qcom-wdt.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/watchdog/qcom-wdt.c +6
-0@@ -181,6 +181,12 @@ static const struct qcom_wdt_match_data match_data_apcs_tmr = { .max_tick_count = 0x10000000U, }; +static const struct qcom_wdt_match_data match_data_ipq5424 = { + .offset = reg_offset_data_kpss, + .pretimeout = true, + .max_tick_count =0xFFFFFU , +}; +static const struct qcom_wdt_match_data match_data_kpss = { .offset = reg_offset_data_kpss, .pretimeout = true,@@ -322,6 +328,7 @@ static const struct dev_pm_ops qcom_wdt_pm_ops = { };
Quoted 3 lines
drivers/watchdog/qcom-wdt.c static const struct dev_pm_ops qcom_wdt_pm_ops = { · line 331
Quoted 2 lines
drivers/watchdog/qcom-wdt.c +1
-0static const struct of_device_id qcom_wdt_of_table[] = { + { .compatible ="qcom,apss-wdt-ipq5424" , .data = &match_data_ipq5424 },Shouldn't it be qcom,ipq5424-apss-wdt ?
Currently, the compatible string is "qcom,apss-wdt-ipq5424". So used as it is.
Quoted 8 lines
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +0
-0{ .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 },Signature · 2 lines
-- 2.34.1
PATCH v3 4/4 watchdog: qcom: add support to read the restart reason from IMEM
In reply to Kathiravan ThirumoorthyWhen 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_restart_reason() to read the restart reason from IMEM.
---
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 | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
drivers/watchdog/qcom-wdt.c +38 -2
@@ -7,9 +7,11 @@#include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/regmap.h> #include <linux/watchdog.h> enum wdt_reg {
@@ -42,6 +44,9 @@ struct qcom_wdt_match_data {const u32 *offset;bool pretimeout;u32 max_tick_count; +const char *imem_compatible; +unsigned int restart_reason_offset; +unsigned int non_secure_wdt_val; };struct qcom_wdt {
@@ -185,6 +190,9 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = { .offset = reg_offset_data_kpss, .pretimeout = true, .max_tick_count = 0xFFFFFU, + .imem_compatible = "qcom,ipq5424-imem", + .restart_reason_offset = 0x7b0, + .non_secure_wdt_val = 0x5, };static const struct qcom_wdt_match_data match_data_kpss = {
@@ -193,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->imem_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;
@@ -273,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
Signature · 1 line
2.34.1
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 9 lines · Kathiravan Thirumoorthy
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);
And how are you handling proper probe ordering? Use phandles and define this as an ABI.
Best regards,
Krzysztof
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 12 lines · Krzysztof Kozlowski
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 9 lines · Kathiravan Thirumoorthy
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);And how are you handling proper probe ordering? Use phandles and define this as an ABI.
Sure, I will follow the Konrad's suggestion.
Quoted 2 lines
Best regards,
Krzysztof
Guenter Roeck
maintainerRe: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
In reply to Kathiravan ThirumoorthyQuoted 104 lines · Kathiravan Thirumoorthy
When the system boots up after a watchdog reset, the
EXPIRED_STATUSbit in theWDT_STSregister 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_SYSFSenabled, user can extract the information as below:cat
/sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus32For backward compatibility, keep the
EXPIRED_STATUSbit check. Add a new functionqcom_wdt_get_restart_reason()to read the restart reason from IMEM.Signed-off-by Kathiravan Thirumoorthy <[email protected]>---
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 byqcom_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 | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)drivers/watchdog/qcom-wdt.c +31
-0@@ -7,9 +7,11 @@#include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/regmap.h> #include <linux/watchdog.h> enum wdt_reg {@@ -42,6 +44,9 @@ struct qcom_wdt_match_data {const u32 *offset;bool pretimeout;u32 max_tick_count; +const char *imem_compatible; +unsigned int restart_reason_offset; +unsigned int non_secure_wdt_val; };struct qcom_wdt {@@ -185,6 +190,9 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = { .offset = reg_offset_data_kpss, .pretimeout = true, .max_tick_count = 0xFFFFFU, + .imem_compatible = "qcom,ipq5424-imem", + .restart_reason_offset = 0x7b0, + .non_secure_wdt_val = 0x5, };static const struct qcom_wdt_match_data match_data_kpss = {@@ -193,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->imem_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;@@ -273,8 +304,13 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.parent = dev; wdt->layout = data->offset;
drivers/watchdog/qcom-wdt.c static int qcom_wdt_probe(struct platform_device *pdev) · line 313
Quoted 10 lines
drivers/watchdog/qcom-wdt.c +7
-2-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; + }
Seems odd to me that there is now a function qcom_wdt_get_restart_reason() but it doesn't handle all means to get the restart reason. Maybe I missed it, but what is the reason for that ? Why not move reading WDT_STS into qcom_wdt_get_restart_reason() as well ?
Guenter
Quoted 4 lines
drivers/watchdog/qcom-wdt.c +0
-0/* * If 'timeout-sec' unspecified in devicetree, assume a 30 second
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 13 lines · Guenter Roeck
Quoted 13 lines
static int
qcom_wdt_probe(struct platform_device *pdev){
struct device *dev =&pdev->dev;drivers/watchdog/qcom-wdt.c +4
-1@@ -273,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;
Quoted 8 lines
drivers/watchdog/qcom-wdt.c static int qcom_wdt_probe(struct platform_device *pdev) · line 313
Quoted 3 lines
drivers/watchdog/qcom-wdt.c +3
-0+ } else if (ret) { + return ret; + }Seems odd to me that there is now a function
qcom_wdt_get_restart_reason()but it doesn't handle all means to get the restart reason. Maybe I missed it, but what is the reason for that ? Why not move readingWDT_STSintoqcom_wdt_get_restart_reason()as well ?
No specific reason as such. I was little hesitant use "goto" statements and such as. So I thought this would be little cleaner approach. Please let me know if I have consolidate everything under qcom_wdt_get_restart_reason().
Quoted 6 lines
Guenter
Quoted 2 lines
drivers/watchdog/qcom-wdt.c +0
-0/** If 'timeout-sec' unspecified in devicetree, assume a 30 second
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 24 lines · Kathiravan Thirumoorthy
Quoted 12 lines · Guenter Roeck
Quoted 12 lines
static int
qcom_wdt_probe(struct platform_device *pdev){
struct device *dev =&pdev->dev;drivers/watchdog/qcom-wdt.c +4
-1@@ -273,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;Quoted 8 lines
drivers/watchdog/qcom-wdt.c static int qcom_wdt_probe(struct platform_device *pdev) · line 313
Quoted 3 lines
drivers/watchdog/qcom-wdt.c +3
-0+ } else if (ret) { + return ret; + }Seems odd to me that there is now a function
qcom_wdt_get_restart_reason()but it doesn't handle all means to get the restart reason. Maybe I missed it, but what is the reason for that ? Why not move readingWDT_STSintoqcom_wdt_get_restart_reason()as well ?
Quoted 1 line
No specific reason as such. I was little hesitant use "goto" statements and such as. So I thought this would be little cleaner approach. Please let me know if I have consolidate everything under
qcom_wdt_get_restart_reason().
You can try grabbing the syscon handle, and if absent, fall back to the common handling
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
In reply to Kathiravan ThirumoorthyQuoted 18 lines · Kathiravan Thirumoorthy
When the system boots up after a watchdog reset, the
EXPIRED_STATUSbit in theWDT_STSregister 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_SYSFSenabled, user can extract the information as below:cat
/sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus32For backward compatibility, keep the
EXPIRED_STATUSbit check. Add a new functionqcom_wdt_get_restart_reason()to read the restart reason from IMEM.Signed-off-by Kathiravan Thirumoorthy <[email protected]>---
[...]
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);
Try syscon_regmap_lookup_by_phandle_args() and pass a phandle, see e.g. drivers/phy/qualcomm/phy-qcom-qmp-pcie.c & phy@1bfc000 in x1e80100.dtsi
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 11 lines · Konrad Dybcio
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsi
Quoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support WDIOF_POWERUNDER and WDIOF_OVERHEAT cause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrate WDIOF_OVERHEAT. In any case, can I define the DT entry like below
imem,phandle = <&imem 0x7b0 <Non secure WDT value> <Power Under value> <Overheat value>>;
and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Is this approach fine. Please let me know your comments.
Quoted 2 lines
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 17 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem 0x7b0 <Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such as bootstatus-overheat, bootstatus-fanfault etc.
I'd much prefer to go with 1 really.. If we used nvmem, we could have a map of cell names to restart reasons, but we've already established IMEM is volatile and we shouldn't mess up the convention just because that subsystem has nicer APIs..
Unless we rename the subsystem to fuses, magic-values or something.. +Srini? :P
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 25 lines · Konrad Dybcio
Quoted 15 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem 0x7b0 <Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.
Thanks Konrad for the suggestions and the offline discussions.
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose WDIOF_CARDRESET, WDIOF_POWERUNDER, WDIOF_OVERHEAT reasons.
Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Quoted 10 lines
I'd much prefer to go with 1 really.. If we used nvmem, we could have a map of cell names to restart reasons, but we've already established IMEM is volatile and we shouldn't mess up the convention just because that subsystem has nicer APIs..
Unless we rename the subsystem to
fuses,magic-valuesor something.. +Srini? :PKonrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 37 lines · Kathiravan Thirumoorthy
Quoted 26 lines · Konrad Dybcio
Quoted 16 lines · Kathiravan Thirumoorthy
Quoted 12 lines · Konrad Dybcio
Quoted 9 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem
0x7b0<Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.
Quoted 6 lines
Thanks Konrad for the suggestions and the offline discussions.
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose
WDIOF_CARDRESET,WDIOF_POWERUNDER,WDIOF_OVERHEATreasons.Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Konrad / Guenter,
We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.
If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.
imem,phandle = <&phandle <imem_offset> <value>>;
Kindly share your thoughts and inputs on this to proceed further.
Quoted 12 lines
Quoted 12 lines
I'd much prefer to go with 1 really.. If we used nvmem, we could have a map of cell names to restart reasons, but we've already established IMEM is volatile and we shouldn't mess up the convention just because that subsystem has nicer APIs..
Unless we rename the subsystem to
fuses,magic-valuesor something.. +Srini? :PKonrad
Guenter Roeck
maintainerRe: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 40 lines · Kathiravan Thirumoorthy
Quoted 38 lines · Kathiravan Thirumoorthy
Quoted 25 lines · Konrad Dybcio
Quoted 15 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem
0x7b0<Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.Thanks Konrad for the suggestions and the offline discussions.
Quoted 9 lines
Quoted 3 lines
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose
WDIOF_CARDRESET,WDIOF_POWERUNDER,WDIOF_OVERHEATreasons.Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Konrad / Guenter,
We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.
Correct. The watchdog subsystem can only handle watchdog triggered reboots/resets.
Quoted 6 lines
If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.
imem,phandle = <&phandle <
imem_offset> <value>>;Kindly share your thoughts and inputs on this to proceed further.
Sounds good to me.
Guenter
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
I'd much prefer to go with 1 really.. If we used nvmem, we could have a map of cell names to restart reasons, but we've already established IMEM is volatile and we shouldn't mess up the convention just because that subsystem has nicer APIs..
Unless we rename the subsystem to
fuses,magic-valuesor something.. +Srini? :PKonrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
In reply to Kathiravan ThirumoorthyQuoted 45 lines · Kathiravan Thirumoorthy
Quoted 36 lines · Kathiravan Thirumoorthy
Quoted 25 lines · Konrad Dybcio
Quoted 15 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 211
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem
0x7b0<Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.Quoted 5 lines
Thanks Konrad for the suggestions and the offline discussions.
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose
WDIOF_CARDRESET,WDIOF_POWERUNDER,WDIOF_OVERHEATreasons.Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Quoted 7 lines
Konrad / Guenter,
We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.
If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.
imem,phandle = <&phandle <
imem_offset> <value>>;
the part before the comma is a vendor prefix, so that must be qcom,xyz
what are your plans for the other reboot reasons? are we scrapping them?
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 41 lines · Konrad Dybcio
Quoted 40 lines · Kathiravan Thirumoorthy
Quoted 38 lines · Kathiravan Thirumoorthy
Quoted 24 lines · Konrad Dybcio
Quoted 14 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
Review
Quoted 8 lines
(quoted diff) +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem
0x7b0<Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.Thanks Konrad for the suggestions and the offline discussions.
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose
WDIOF_CARDRESET,WDIOF_POWERUNDER,WDIOF_OVERHEATreasons.Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Quoted 8 lines
Quoted 7 lines
Konrad / Guenter,
We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.
If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.
imem,phandle = <&phandle <
imem_offset> <value>>;the part before the comma is a vendor prefix, so that must be qcom,xyz
Sure, will name it as qcom,imem-phandle. Hope this name is fine.
Quoted 2 lines
what are your plans for the other reboot reasons? are we scrapping them?
No, we are not scrapping it. We are exploring further on where to put this. May be we can put those logic in some simple driver named as ipq-restart-reason.c under drivers/soc/qcom/?
Quoted 2 lines
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 47 lines · Kathiravan Thirumoorthy
Quoted 45 lines · Konrad Dybcio
Quoted 44 lines · Kathiravan Thirumoorthy
Quoted 33 lines · Kathiravan Thirumoorthy
Quoted 24 lines · Konrad Dybcio
Quoted 14 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
Review
Quoted 8 lines
(quoted diff) +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem
0x7b0<Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.Quoted 5 lines
Thanks Konrad for the suggestions and the offline discussions.
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose
WDIOF_CARDRESET,WDIOF_POWERUNDER,WDIOF_OVERHEATreasons.Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Konrad / Guenter,
We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.
imem,phandle = <&phandle <
imem_offset> <value>>;the part before the comma is a vendor prefix, so that must be qcom,xyz
Sure, will name it as qcom,imem-phandle. Hope this name is fine.
just qcom,imem is fine, phandle is a datatype described in dt-bindings
Quoted 4 lines
Quoted 1 line
what are your plans for the other reboot reasons? are we scrapping them?
No, we are not scrapping it. We are exploring further on where to put this. May be we can put those logic in some simple driver named as
ipq-restart-reason.cunderdrivers/soc/qcom/?
I see drivers/power/reset/at91-reset.c does something like this
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 45 lines · Konrad Dybcio
Quoted 44 lines · Kathiravan Thirumoorthy
Quoted 43 lines · Konrad Dybcio
Quoted 42 lines · Kathiravan Thirumoorthy
Quoted 32 lines · Kathiravan Thirumoorthy
Quoted 24 lines · Konrad Dybcio
Quoted 14 lines · Kathiravan Thirumoorthy
Quoted 11 lines · Konrad Dybcio
Review
Quoted 8 lines
(quoted diff) +8
-0+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->imem_compatible);Try
syscon_regmap_lookup_by_phandle_args()and pass a phandle, see e.g.drivers/phy/qualcomm/phy-qcom-qmp-pcie.c& phy@1bfc000 inx1e80100.dtsiQuoted 2 lines
That way all platform specifics will live in the DT, requiring no hardcode-y driver changes on similar platforms
Quoted 7 lines
Thanks. I thought about this API but it didn't strike that I can use the args to fetch and match the value.
I need a suggestion here. There is a plan to extend this feature to other IPQ targets and also support
WDIOF_POWERUNDERandWDIOF_OVERHEATcause as well. For IPQ5424, all 3 cause will support and for other IPQ platforms, we are exploring how to integrateWDIOF_OVERHEAT. In any case, can I define the DT entry like belowimem,phandle = <&imem
0x7b0<Non secure WDT value> <Power Under value> <Overheat value>>;and store these in values args[1], args[2] and args[3] respectively and use it for manipulation? If any of the platform doesn't support all 3, I can update the bindings and define the number of args as required.
Let's call the property qcom,restart-reason and only pass the register value
Quoted 7 lines
Because we may have any number of crazy combinations of various restart reasons, we can go two paths:
1. promise really really really hard we won't be too crazy with the number of possible values and put them in the driver
2. go all out on DT properties (such asbootstatus-overheat,bootstatus-fanfaultetc.Quoted 5 lines
Thanks Konrad for the suggestions and the offline discussions.
@Guenter, I need a suggestion here. Currently as part of this series, we are planning to expose
WDIOF_CARDRESET,WDIOF_POWERUNDER,WDIOF_OVERHEATreasons.Once this is done, we do have the custom reason codes like Kernel Panic, Secure Watchdog Bite, Bus error timeout, Bus error access and few many. Is it okay to expose these values also via the bootstatus sysFS by extending the current list of reasons? Since these are outside the scope of watchdog, need your thoughts on this.
Konrad / Guenter,
We had a further discussion on this internally. Outcome is, it wouldn't be ideal to hook the custom restart reason codes in watchdog framework, since there is no involvement of watchdog in such cases. Also I don't find any references to hook the custom values in watchdog's bootstatus.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
If this is fine, I'm planning to resend the series to handle only the non secure watchdog timeout case. In that case, as suggested by Konrad, everything will be handled in DT like below to avoid the device data.
imem,phandle = <&phandle <
imem_offset> <value>>;the part before the comma is a vendor prefix, so that must be qcom,xyz
Sure, will name it as qcom,imem-phandle. Hope this name is fine.
just qcom,imem is fine, phandle is a datatype described in dt-bindings
Sure thanks.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
what are your plans for the other reboot reasons? are we scrapping them?
No, we are not scrapping it. We are exploring further on where to put this. May be we can put those logic in some simple driver named as
ipq-restart-reason.cunderdrivers/soc/qcom/?I see
drivers/power/reset/at91-reset.cdoes something like this
Thanks for the reference. I will submit the patches in a couple of weeks.
Quoted 2 lines
Konrad
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
In reply to Kathiravan ThirumoorthyQuoted 75 lines · Kathiravan Thirumoorthy
When the system boots up after a watchdog reset, the
EXPIRED_STATUSbit in theWDT_STSregister 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_SYSFSenabled, user can extract the information as below:cat
/sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus32For backward compatibility, keep the
EXPIRED_STATUSbit check. Add a new functionqcom_wdt_get_restart_reason()to read the restart reason from IMEM.Signed-off-by Kathiravan Thirumoorthy <[email protected]>---
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 byqcom_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 | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)drivers/watchdog/qcom-wdt.c +8
-0@@ -7,9 +7,11 @@#include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/regmap.h> #include <linux/watchdog.h> enum wdt_reg {@@ -42,6 +44,9 @@ struct qcom_wdt_match_data {const u32 *offset;bool pretimeout;u32 max_tick_count; +const char *imem_compatible; +unsigned int restart_reason_offset; +unsigned int non_secure_wdt_val; };struct qcom_wdt {@@ -185,6 +190,9 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = { .offset = reg_offset_data_kpss, .pretimeout = true, .max_tick_count = 0xFFFFFU, + .imem_compatible = "qcom,ipq5424-imem", + .restart_reason_offset = 0x7b0, + .non_secure_wdt_val = 0x5, };static const struct qcom_wdt_match_data match_data_kpss = {@@ -193,6 +201,29 @@ static const struct qcom_wdt_match_data match_data_kpss = { .max_tick_count = 0xFFFFFU, };
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 213
Quoted 10 lines
drivers/watchdog/qcom-wdt.c +10
-0+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->imem_compatible); +if (IS_ERR (imem)) +return PTR_ERR (imem);
Why? Just pass the syscon directly via DT.
Quoted 36 lines
drivers/watchdog/qcom-wdt.c +20
-2+ + 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;@@ -273,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 Signature · 2 lines
-- 2.34.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v3 4/4] watchdog: qcom: add support to read the restart reason from IMEM
Quoted 11 lines · Dmitry Baryshkov
drivers/watchdog/qcom-wdt.c static const struct qcom_wdt_match_data match_data_kpss = { · line 213
Quoted 10 lines
drivers/watchdog/qcom-wdt.c +10
-0+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->imem_compatible); +if (IS_ERR (imem)) +return PTR_ERR (imem);Why? Just pass the syscon directly via DT.
Ack. As replied to Konrad, will rework this.
Re: (subset) [PATCH v3 0/4] Add support to read the restart reason from IMEM
In reply to Kathiravan ThirumoorthyQuoted 9 lines · Kathiravan Thirumoorthy
In Qualcomm IPQ SoC, if the system is rebooted due to the watchdog timeout, there is no way to identify it. Current approach of checking the
EXPIRED_STATUSinWDT_STSis not working.To achieve this, if the system is rebooted due to watchdog timeout, the information is captured in the IMEM by the bootloader (along with other reason codes as well).
[...]
Applied, thanks!
[1/4] dt-bindings: sram: qcom,imem: Document IPQ5424 compatible
commit: 3fa1095979393d5b178264cc1bdfb473e80ab774
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Re: (subset) [PATCH v3 0/4] Add support to read the restart reason from IMEM
Quoted 9 lines · Bjorn Andersson
Quoted 8 lines · Kathiravan Thirumoorthy
In Qualcomm IPQ SoC, if the system is rebooted due to the watchdog timeout, there is no way to identify it. Current approach of checking the
EXPIRED_STATUSinWDT_STSis not working.To achieve this, if the system is rebooted due to watchdog timeout, the information is captured in the IMEM by the bootloader (along with other reason codes as well).
Quoted 5 lines
Quoted 1 line
[...]
Applied, thanks!
[1/4] dt-bindings: sram: qcom,imem: Document IPQ5424 compatible
commit: 3fa1095979393d5b178264cc1bdfb473e80ab774
Bjorn, IIUC, based on the discussion [1], moving forward we should describe the IMEM as "mmio-sram" rather than the "syscon" or "simple-mfd". So we need to drop this change from tree.
[1] https://lore.kernel.org/linux-arm-msm/[email protected]/
Quoted 2 lines
Best regards,