* [PATCH v6 0/5] Increase max timeout value of s3c2410 watchdog [not found] <CGME20250818022433epcas2p37fe2cdc20b32b23ee894ceb636717a53@epcas2p3.samsung.com> @ 2025-08-18 2:18 ` Sangwook Shin [not found] ` <CGME20250818022433epcas2p2a14d0a2ebe8c421dc63ddc8371f8bc50@epcas2p2.samsung.com> ` (4 more replies) 0 siblings, 5 replies; 12+ messages in thread From: Sangwook Shin @ 2025-08-18 2:18 UTC (permalink / raw) To: krzk, alim.akhtar, wim, linux, semen.protsenko, dongil01.park, khwan.seo Cc: linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel, Sangwook Shin The ExynosAutoV9 and ExynosAutoV920 SoCs have a 32-bit counter register, but due to code constraints, only 16-bit values could be used. This series enables these SoCs to use the 32-bit counter. Additionally, it addresses the issue where the ExynosAutoV9 SoC supports the DBGACK bit but it was not set. V5->V6: - Replace hard-coded 0x8000 with calculated value. - Link to v5: https://lore.kernel.org/linux-watchdog/20250806065514.3688485-1-sw617.shin@samsung.com/ V4->V5: - Update s3c2410wdt_max_timeout with Sam Protsenko and Guenter Roeck's sugestion. - Break [v4 3/4] into two [v5 3/5] and [v5 4/5]. - Rename S3C2410_WTCNT_MAXCNT to S3C2410_WTCNT_MAXCNT_16. - Rename QUIRK_HAS_32BIT_MAXCNT to QUIRK_HAS_32BIT_CNT. - Minor Typographical Errors and Style Adjustments. - Link to v4: https://lore.kernel.org/linux-watchdog/20250724080854.3866566-1-sw617.shin@samsung.com/ V3->V4: - Merge patches [v3 3/5] and [v3 4/5] into one so that Quirk and its consumer are part of the same patch. - Link to v3: https://lore.kernel.org/linux-watchdog/20250714055440.3138135-1-sw617.shin@samsung.com/ https://lore.kernel.org/linux-watchdog/20250515075350.3368635-1-sw617.shin@samsung.com/ V2->V3: - Correct the incorrect tag information. - Link to v2: https://lore.kernel.org/linux-watchdog/20250514094220.1561378-1-sw617.shin@samsung.com/ V1->V2: - Modify the max_timeout calculation considering overflow - Separate tha max_timeout calculation into a separate patch - Add max_cnt in struct s3c2410_wdt - Set max_cnt once in probe function - Add patch that uses S3C2410_WTCON_PRESCALE_MAX instead of hardcoded one - Remove unnecessary inner parentheses - Link to v1: https://lore.kernel.org/linux-watchdog/20250513094711.2691059-1-sw617.shin@samsung.com/ Sangwook Shin (5): watchdog: s3c2410_wdt: Replace hardcoded values with macro definitions watchdog: s3c2410_wdt: Fix max_timeout being calculated larger watchdog: s3c2410_wdt: Increase max timeout value of watchdog watchdog: s3c2410_wdt: exynosautov920: Enable QUIRK_HAS_32BIT_CNT watchdog: s3c2410_wdt: exynosautov9: Enable supported features drivers/watchdog/s3c2410_wdt.c | 46 ++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) -- 2.25.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <CGME20250818022433epcas2p2a14d0a2ebe8c421dc63ddc8371f8bc50@epcas2p2.samsung.com>]
* [PATCH v6 1/5] watchdog: s3c2410_wdt: Replace hardcoded values with macro definitions [not found] ` <CGME20250818022433epcas2p2a14d0a2ebe8c421dc63ddc8371f8bc50@epcas2p2.samsung.com> @ 2025-08-18 2:18 ` Sangwook Shin 2025-08-21 15:34 ` Guenter Roeck 0 siblings, 1 reply; 12+ messages in thread From: Sangwook Shin @ 2025-08-18 2:18 UTC (permalink / raw) To: krzk, alim.akhtar, wim, linux, semen.protsenko, dongil01.park, khwan.seo Cc: linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel, Sangwook Shin Modify the code to utilize macro-defined values instead of hardcoded values. The value 0x100 in the s3c2410wdt_set_heartbeat function represents S3C2410_WTCON_PRESCALE_MAX + 1, but it is hardcoded, making its meaning difficult to understand and reducing code readability. Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> --- drivers/watchdog/s3c2410_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 40901bdac426..95f7207e390a 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -587,7 +587,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, if (count >= 0x10000) { divisor = DIV_ROUND_UP(count, 0xffff); - if (divisor > 0x100) { + if (divisor > S3C2410_WTCON_PRESCALE_MAX + 1) { dev_err(wdt->dev, "timeout %d too big\n", timeout); return -EINVAL; } -- 2.25.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v6 1/5] watchdog: s3c2410_wdt: Replace hardcoded values with macro definitions 2025-08-18 2:18 ` [PATCH v6 1/5] watchdog: s3c2410_wdt: Replace hardcoded values with macro definitions Sangwook Shin @ 2025-08-21 15:34 ` Guenter Roeck 0 siblings, 0 replies; 12+ messages in thread From: Guenter Roeck @ 2025-08-21 15:34 UTC (permalink / raw) To: Sangwook Shin Cc: krzk, alim.akhtar, wim, semen.protsenko, dongil01.park, khwan.seo, linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel On Mon, Aug 18, 2025 at 11:18:22AM +0900, Sangwook Shin wrote: > Modify the code to utilize macro-defined values instead of hardcoded > values. The value 0x100 in the s3c2410wdt_set_heartbeat function represents > S3C2410_WTCON_PRESCALE_MAX + 1, but it is hardcoded, making its meaning > difficult to understand and reducing code readability. > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> > Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/watchdog/s3c2410_wdt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > index 40901bdac426..95f7207e390a 100644 > --- a/drivers/watchdog/s3c2410_wdt.c > +++ b/drivers/watchdog/s3c2410_wdt.c > @@ -587,7 +587,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, > if (count >= 0x10000) { > divisor = DIV_ROUND_UP(count, 0xffff); > > - if (divisor > 0x100) { > + if (divisor > S3C2410_WTCON_PRESCALE_MAX + 1) { > dev_err(wdt->dev, "timeout %d too big\n", timeout); > return -EINVAL; > } > -- > 2.25.1 > > ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <CGME20250818022433epcas2p3fc48febfa6729645af6ebd088937c80c@epcas2p3.samsung.com>]
* [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger [not found] ` <CGME20250818022433epcas2p3fc48febfa6729645af6ebd088937c80c@epcas2p3.samsung.com> @ 2025-08-18 2:18 ` Sangwook Shin 2025-08-18 22:27 ` Sam Protsenko 2025-08-21 15:34 ` Guenter Roeck 0 siblings, 2 replies; 12+ messages in thread From: Sangwook Shin @ 2025-08-18 2:18 UTC (permalink / raw) To: krzk, alim.akhtar, wim, linux, semen.protsenko, dongil01.park, khwan.seo Cc: linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel, Sangwook Shin Fix the issue of max_timeout being calculated larger than actual value. The calculation result of freq / (S3C2410_WTCON_PRESCALE_MAX + 1) / S3C2410_WTCON_MAXDIV is smaller than the actual value because the remainder is discarded during the calculation process. This leads to a larger calculated value for max_timeout compared to the actual settable value. To resolve this issue, the order of calculations in the computation process has been adjusted. Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> --- drivers/watchdog/s3c2410_wdt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 95f7207e390a..1e8cf0299713 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -27,6 +27,7 @@ #include <linux/mfd/syscon.h> #include <linux/regmap.h> #include <linux/delay.h> +#include <linux/math64.h> #define S3C2410_WTCON 0x00 #define S3C2410_WTDAT 0x04 @@ -410,9 +411,14 @@ static inline unsigned long s3c2410wdt_get_freq(struct s3c2410_wdt *wdt) static inline unsigned int s3c2410wdt_max_timeout(struct s3c2410_wdt *wdt) { const unsigned long freq = s3c2410wdt_get_freq(wdt); + const u64 n_max = (u64)(S3C2410_WTCON_PRESCALE_MAX + 1) * + S3C2410_WTCON_MAXDIV * S3C2410_WTCNT_MAXCNT; + u64 t_max = div64_ul(n_max, freq); - return S3C2410_WTCNT_MAXCNT / (freq / (S3C2410_WTCON_PRESCALE_MAX + 1) - / S3C2410_WTCON_MAXDIV); + if (t_max > UINT_MAX) + t_max = UINT_MAX; + + return t_max; } static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask) -- 2.25.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger 2025-08-18 2:18 ` [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger Sangwook Shin @ 2025-08-18 22:27 ` Sam Protsenko 2025-08-21 15:34 ` Guenter Roeck 1 sibling, 0 replies; 12+ messages in thread From: Sam Protsenko @ 2025-08-18 22:27 UTC (permalink / raw) To: Sangwook Shin Cc: krzk, alim.akhtar, wim, linux, dongil01.park, khwan.seo, linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel On Sun, Aug 17, 2025 at 9:24 PM Sangwook Shin <sw617.shin@samsung.com> wrote: > > Fix the issue of max_timeout being calculated larger than actual value. > The calculation result of freq / (S3C2410_WTCON_PRESCALE_MAX + 1) / > S3C2410_WTCON_MAXDIV is smaller than the actual value because the remainder > is discarded during the calculation process. This leads to a larger > calculated value for max_timeout compared to the actual settable value. > To resolve this issue, the order of calculations in the computation process > has been adjusted. > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> > --- > drivers/watchdog/s3c2410_wdt.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > index 95f7207e390a..1e8cf0299713 100644 > --- a/drivers/watchdog/s3c2410_wdt.c > +++ b/drivers/watchdog/s3c2410_wdt.c > @@ -27,6 +27,7 @@ > #include <linux/mfd/syscon.h> > #include <linux/regmap.h> > #include <linux/delay.h> > +#include <linux/math64.h> > > #define S3C2410_WTCON 0x00 > #define S3C2410_WTDAT 0x04 > @@ -410,9 +411,14 @@ static inline unsigned long s3c2410wdt_get_freq(struct s3c2410_wdt *wdt) > static inline unsigned int s3c2410wdt_max_timeout(struct s3c2410_wdt *wdt) > { > const unsigned long freq = s3c2410wdt_get_freq(wdt); > + const u64 n_max = (u64)(S3C2410_WTCON_PRESCALE_MAX + 1) * > + S3C2410_WTCON_MAXDIV * S3C2410_WTCNT_MAXCNT; > + u64 t_max = div64_ul(n_max, freq); > > - return S3C2410_WTCNT_MAXCNT / (freq / (S3C2410_WTCON_PRESCALE_MAX + 1) > - / S3C2410_WTCON_MAXDIV); > + if (t_max > UINT_MAX) > + t_max = UINT_MAX; > + > + return t_max; > } > Thanks for working on this, Sangwook! It looks much better now. > static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask) > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger 2025-08-18 2:18 ` [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger Sangwook Shin 2025-08-18 22:27 ` Sam Protsenko @ 2025-08-21 15:34 ` Guenter Roeck 1 sibling, 0 replies; 12+ messages in thread From: Guenter Roeck @ 2025-08-21 15:34 UTC (permalink / raw) To: Sangwook Shin Cc: krzk, alim.akhtar, wim, semen.protsenko, dongil01.park, khwan.seo, linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel On Mon, Aug 18, 2025 at 11:18:23AM +0900, Sangwook Shin wrote: > Fix the issue of max_timeout being calculated larger than actual value. > The calculation result of freq / (S3C2410_WTCON_PRESCALE_MAX + 1) / > S3C2410_WTCON_MAXDIV is smaller than the actual value because the remainder > is discarded during the calculation process. This leads to a larger > calculated value for max_timeout compared to the actual settable value. > To resolve this issue, the order of calculations in the computation process > has been adjusted. > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/watchdog/s3c2410_wdt.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > index 95f7207e390a..1e8cf0299713 100644 > --- a/drivers/watchdog/s3c2410_wdt.c > +++ b/drivers/watchdog/s3c2410_wdt.c > @@ -27,6 +27,7 @@ > #include <linux/mfd/syscon.h> > #include <linux/regmap.h> > #include <linux/delay.h> > +#include <linux/math64.h> > > #define S3C2410_WTCON 0x00 > #define S3C2410_WTDAT 0x04 > @@ -410,9 +411,14 @@ static inline unsigned long s3c2410wdt_get_freq(struct s3c2410_wdt *wdt) > static inline unsigned int s3c2410wdt_max_timeout(struct s3c2410_wdt *wdt) > { > const unsigned long freq = s3c2410wdt_get_freq(wdt); > + const u64 n_max = (u64)(S3C2410_WTCON_PRESCALE_MAX + 1) * > + S3C2410_WTCON_MAXDIV * S3C2410_WTCNT_MAXCNT; > + u64 t_max = div64_ul(n_max, freq); > > - return S3C2410_WTCNT_MAXCNT / (freq / (S3C2410_WTCON_PRESCALE_MAX + 1) > - / S3C2410_WTCON_MAXDIV); > + if (t_max > UINT_MAX) > + t_max = UINT_MAX; > + > + return t_max; > } > > static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask) > -- > 2.25.1 > > ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <CGME20250818022433epcas2p1bf8e6a335be945822721b8db1e9571e9@epcas2p1.samsung.com>]
* [PATCH v6 3/5] watchdog: s3c2410_wdt: Increase max timeout value of watchdog [not found] ` <CGME20250818022433epcas2p1bf8e6a335be945822721b8db1e9571e9@epcas2p1.samsung.com> @ 2025-08-18 2:18 ` Sangwook Shin 2025-08-21 15:35 ` Guenter Roeck 0 siblings, 1 reply; 12+ messages in thread From: Sangwook Shin @ 2025-08-18 2:18 UTC (permalink / raw) To: krzk, alim.akhtar, wim, linux, semen.protsenko, dongil01.park, khwan.seo Cc: linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel, Sangwook Shin Increase max_timeout value from 55s to 3665038s (1018h 3min 58s) with 38400000 frequency system if the system has 32-bit WTCNT register. cat /sys/class/watchdog/watchdog0/max_timeout 3665038 [ 0.330082] s3c2410-wdt 10060000.watchdog_cl0: Heartbeat: count=1099511400000, timeout=3665038, freq=300000 [ 0.330087] s3c2410-wdt 10060000.watchdog_cl0: Heartbeat: timeout=3665038, divisor=256, count=1099511400000 (fffffc87) [ 0.330127] s3c2410-wdt 10060000.watchdog_cl0: starting watchdog timer [ 0.330134] s3c2410-wdt 10060000.watchdog_cl0: Starting watchdog: count=0xfffffc87, wtcon=0001ff39 [ 0.330319] s3c2410-wdt 10060000.watchdog_cl0: watchdog active, reset enabled, irq disabled If the system has a 32-bit WTCNT, add QUIRK_HAS_32BIT_CNT to its quirk flags, and it will operate with a 32-bit counter. If not, it will operate with a 16-bit counter like in the previous version. Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> --- drivers/watchdog/s3c2410_wdt.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 1e8cf0299713..d983cbcb975c 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -34,7 +34,8 @@ #define S3C2410_WTCNT 0x08 #define S3C2410_WTCLRINT 0x0c -#define S3C2410_WTCNT_MAXCNT 0xffff +#define S3C2410_WTCNT_MAXCNT_16 0xffff +#define S3C2410_WTCNT_MAXCNT_32 0xffffffff #define S3C2410_WTCON_RSTEN BIT(0) #define S3C2410_WTCON_INTEN BIT(2) @@ -124,6 +125,10 @@ * %QUIRK_HAS_DBGACK_BIT: WTCON register has DBGACK_MASK bit. Setting the * DBGACK_MASK bit disables the watchdog outputs when the SoC is in debug mode. * Debug mode is determined by the DBGACK CPU signal. + * + * %QUIRK_HAS_32BIT_CNT: WTDAT and WTCNT are 32-bit registers. With these + * 32-bit registers, larger values will be set, which means that larger timeouts + * value can be set. */ #define QUIRK_HAS_WTCLRINT_REG BIT(0) #define QUIRK_HAS_PMU_MASK_RESET BIT(1) @@ -131,6 +136,7 @@ #define QUIRK_HAS_PMU_AUTO_DISABLE BIT(3) #define QUIRK_HAS_PMU_CNT_EN BIT(4) #define QUIRK_HAS_DBGACK_BIT BIT(5) +#define QUIRK_HAS_32BIT_CNT BIT(6) /* These quirks require that we have a PMU register map */ #define QUIRKS_HAVE_PMUREG \ @@ -199,6 +205,7 @@ struct s3c2410_wdt { struct notifier_block freq_transition; const struct s3c2410_wdt_variant *drv_data; struct regmap *pmureg; + u32 max_cnt; }; static const struct s3c2410_wdt_variant drv_data_s3c2410 = { @@ -412,7 +419,7 @@ static inline unsigned int s3c2410wdt_max_timeout(struct s3c2410_wdt *wdt) { const unsigned long freq = s3c2410wdt_get_freq(wdt); const u64 n_max = (u64)(S3C2410_WTCON_PRESCALE_MAX + 1) * - S3C2410_WTCON_MAXDIV * S3C2410_WTCNT_MAXCNT; + S3C2410_WTCON_MAXDIV * wdt->max_cnt; u64 t_max = div64_ul(n_max, freq); if (t_max > UINT_MAX) @@ -572,7 +579,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, { struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd); unsigned long freq = s3c2410wdt_get_freq(wdt); - unsigned int count; + unsigned long count; unsigned int divisor = 1; unsigned long wtcon; @@ -582,7 +589,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, freq = DIV_ROUND_UP(freq, 128); count = timeout * freq; - dev_dbg(wdt->dev, "Heartbeat: count=%d, timeout=%d, freq=%lu\n", + dev_dbg(wdt->dev, "Heartbeat: count=%lu, timeout=%d, freq=%lu\n", count, timeout, freq); /* if the count is bigger than the watchdog register, @@ -590,8 +597,8 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, actually make this value */ - if (count >= 0x10000) { - divisor = DIV_ROUND_UP(count, 0xffff); + if (count > wdt->max_cnt) { + divisor = DIV_ROUND_UP(count, wdt->max_cnt); if (divisor > S3C2410_WTCON_PRESCALE_MAX + 1) { dev_err(wdt->dev, "timeout %d too big\n", timeout); @@ -599,7 +606,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, } } - dev_dbg(wdt->dev, "Heartbeat: timeout=%d, divisor=%d, count=%d (%08x)\n", + dev_dbg(wdt->dev, "Heartbeat: timeout=%d, divisor=%d, count=%lu (%08lx)\n", timeout, divisor, count, DIV_ROUND_UP(count, divisor)); count = DIV_ROUND_UP(count, divisor); @@ -807,6 +814,11 @@ static int s3c2410wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->src_clk)) return dev_err_probe(dev, PTR_ERR(wdt->src_clk), "failed to get source clock\n"); + if (wdt->drv_data->quirks & QUIRK_HAS_32BIT_CNT) + wdt->max_cnt = S3C2410_WTCNT_MAXCNT_32; + else + wdt->max_cnt = S3C2410_WTCNT_MAXCNT_16; + wdt->wdt_device.min_timeout = 1; wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt); -- 2.25.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v6 3/5] watchdog: s3c2410_wdt: Increase max timeout value of watchdog 2025-08-18 2:18 ` [PATCH v6 3/5] watchdog: s3c2410_wdt: Increase max timeout value of watchdog Sangwook Shin @ 2025-08-21 15:35 ` Guenter Roeck 0 siblings, 0 replies; 12+ messages in thread From: Guenter Roeck @ 2025-08-21 15:35 UTC (permalink / raw) To: Sangwook Shin Cc: krzk, alim.akhtar, wim, semen.protsenko, dongil01.park, khwan.seo, linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel On Mon, Aug 18, 2025 at 11:18:24AM +0900, Sangwook Shin wrote: > Increase max_timeout value from 55s to 3665038s (1018h 3min 58s) with > 38400000 frequency system if the system has 32-bit WTCNT register. > > cat /sys/class/watchdog/watchdog0/max_timeout > 3665038 > > [ 0.330082] s3c2410-wdt 10060000.watchdog_cl0: Heartbeat: count=1099511400000, timeout=3665038, freq=300000 > [ 0.330087] s3c2410-wdt 10060000.watchdog_cl0: Heartbeat: timeout=3665038, divisor=256, count=1099511400000 (fffffc87) > [ 0.330127] s3c2410-wdt 10060000.watchdog_cl0: starting watchdog timer > [ 0.330134] s3c2410-wdt 10060000.watchdog_cl0: Starting watchdog: count=0xfffffc87, wtcon=0001ff39 > [ 0.330319] s3c2410-wdt 10060000.watchdog_cl0: watchdog active, reset enabled, irq disabled > > If the system has a 32-bit WTCNT, add QUIRK_HAS_32BIT_CNT to its quirk flags, > and it will operate with a 32-bit counter. If not, it will operate with a 16-bit > counter like in the previous version. > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/watchdog/s3c2410_wdt.c | 26 +++++++++++++++++++------- > 1 file changed, 19 insertions(+), 7 deletions(-) > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > index 1e8cf0299713..d983cbcb975c 100644 > --- a/drivers/watchdog/s3c2410_wdt.c > +++ b/drivers/watchdog/s3c2410_wdt.c > @@ -34,7 +34,8 @@ > #define S3C2410_WTCNT 0x08 > #define S3C2410_WTCLRINT 0x0c > > -#define S3C2410_WTCNT_MAXCNT 0xffff > +#define S3C2410_WTCNT_MAXCNT_16 0xffff > +#define S3C2410_WTCNT_MAXCNT_32 0xffffffff > > #define S3C2410_WTCON_RSTEN BIT(0) > #define S3C2410_WTCON_INTEN BIT(2) > @@ -124,6 +125,10 @@ > * %QUIRK_HAS_DBGACK_BIT: WTCON register has DBGACK_MASK bit. Setting the > * DBGACK_MASK bit disables the watchdog outputs when the SoC is in debug mode. > * Debug mode is determined by the DBGACK CPU signal. > + * > + * %QUIRK_HAS_32BIT_CNT: WTDAT and WTCNT are 32-bit registers. With these > + * 32-bit registers, larger values will be set, which means that larger timeouts > + * value can be set. > */ > #define QUIRK_HAS_WTCLRINT_REG BIT(0) > #define QUIRK_HAS_PMU_MASK_RESET BIT(1) > @@ -131,6 +136,7 @@ > #define QUIRK_HAS_PMU_AUTO_DISABLE BIT(3) > #define QUIRK_HAS_PMU_CNT_EN BIT(4) > #define QUIRK_HAS_DBGACK_BIT BIT(5) > +#define QUIRK_HAS_32BIT_CNT BIT(6) > > /* These quirks require that we have a PMU register map */ > #define QUIRKS_HAVE_PMUREG \ > @@ -199,6 +205,7 @@ struct s3c2410_wdt { > struct notifier_block freq_transition; > const struct s3c2410_wdt_variant *drv_data; > struct regmap *pmureg; > + u32 max_cnt; > }; > > static const struct s3c2410_wdt_variant drv_data_s3c2410 = { > @@ -412,7 +419,7 @@ static inline unsigned int s3c2410wdt_max_timeout(struct s3c2410_wdt *wdt) > { > const unsigned long freq = s3c2410wdt_get_freq(wdt); > const u64 n_max = (u64)(S3C2410_WTCON_PRESCALE_MAX + 1) * > - S3C2410_WTCON_MAXDIV * S3C2410_WTCNT_MAXCNT; > + S3C2410_WTCON_MAXDIV * wdt->max_cnt; > u64 t_max = div64_ul(n_max, freq); > > if (t_max > UINT_MAX) > @@ -572,7 +579,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, > { > struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd); > unsigned long freq = s3c2410wdt_get_freq(wdt); > - unsigned int count; > + unsigned long count; > unsigned int divisor = 1; > unsigned long wtcon; > > @@ -582,7 +589,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, > freq = DIV_ROUND_UP(freq, 128); > count = timeout * freq; > > - dev_dbg(wdt->dev, "Heartbeat: count=%d, timeout=%d, freq=%lu\n", > + dev_dbg(wdt->dev, "Heartbeat: count=%lu, timeout=%d, freq=%lu\n", > count, timeout, freq); > > /* if the count is bigger than the watchdog register, > @@ -590,8 +597,8 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, > actually make this value > */ > > - if (count >= 0x10000) { > - divisor = DIV_ROUND_UP(count, 0xffff); > + if (count > wdt->max_cnt) { > + divisor = DIV_ROUND_UP(count, wdt->max_cnt); > > if (divisor > S3C2410_WTCON_PRESCALE_MAX + 1) { > dev_err(wdt->dev, "timeout %d too big\n", timeout); > @@ -599,7 +606,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, > } > } > > - dev_dbg(wdt->dev, "Heartbeat: timeout=%d, divisor=%d, count=%d (%08x)\n", > + dev_dbg(wdt->dev, "Heartbeat: timeout=%d, divisor=%d, count=%lu (%08lx)\n", > timeout, divisor, count, DIV_ROUND_UP(count, divisor)); > > count = DIV_ROUND_UP(count, divisor); > @@ -807,6 +814,11 @@ static int s3c2410wdt_probe(struct platform_device *pdev) > if (IS_ERR(wdt->src_clk)) > return dev_err_probe(dev, PTR_ERR(wdt->src_clk), "failed to get source clock\n"); > > + if (wdt->drv_data->quirks & QUIRK_HAS_32BIT_CNT) > + wdt->max_cnt = S3C2410_WTCNT_MAXCNT_32; > + else > + wdt->max_cnt = S3C2410_WTCNT_MAXCNT_16; > + > wdt->wdt_device.min_timeout = 1; > wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt); > > -- > 2.25.1 > > ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <CGME20250818022433epcas2p4fec1cccd280fc73dccc5b00e2236f836@epcas2p4.samsung.com>]
* [PATCH v6 4/5] watchdog: s3c2410_wdt: exynosautov920: Enable QUIRK_HAS_32BIT_CNT [not found] ` <CGME20250818022433epcas2p4fec1cccd280fc73dccc5b00e2236f836@epcas2p4.samsung.com> @ 2025-08-18 2:18 ` Sangwook Shin 2025-08-21 15:35 ` Guenter Roeck 0 siblings, 1 reply; 12+ messages in thread From: Sangwook Shin @ 2025-08-18 2:18 UTC (permalink / raw) To: krzk, alim.akhtar, wim, linux, semen.protsenko, dongil01.park, khwan.seo Cc: linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel, Sangwook Shin Enable QUIRK_HAS_32BIT_CNT to ExynosAutov920 SoC which has 32-bit WTCNT. Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> --- drivers/watchdog/s3c2410_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index d983cbcb975c..915d3c88565a 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -357,7 +357,7 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl0 = { .cnt_en_bit = 8, .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | - QUIRK_HAS_DBGACK_BIT, + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, }; static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl1 = { @@ -370,7 +370,7 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl1 = { .cnt_en_bit = 8, .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | - QUIRK_HAS_DBGACK_BIT, + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, }; static const struct of_device_id s3c2410_wdt_match[] = { -- 2.25.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v6 4/5] watchdog: s3c2410_wdt: exynosautov920: Enable QUIRK_HAS_32BIT_CNT 2025-08-18 2:18 ` [PATCH v6 4/5] watchdog: s3c2410_wdt: exynosautov920: Enable QUIRK_HAS_32BIT_CNT Sangwook Shin @ 2025-08-21 15:35 ` Guenter Roeck 0 siblings, 0 replies; 12+ messages in thread From: Guenter Roeck @ 2025-08-21 15:35 UTC (permalink / raw) To: Sangwook Shin Cc: krzk, alim.akhtar, wim, semen.protsenko, dongil01.park, khwan.seo, linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel On Mon, Aug 18, 2025 at 11:18:25AM +0900, Sangwook Shin wrote: > Enable QUIRK_HAS_32BIT_CNT to ExynosAutov920 SoC which has 32-bit WTCNT. > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/watchdog/s3c2410_wdt.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > index d983cbcb975c..915d3c88565a 100644 > --- a/drivers/watchdog/s3c2410_wdt.c > +++ b/drivers/watchdog/s3c2410_wdt.c > @@ -357,7 +357,7 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl0 = { > .cnt_en_bit = 8, > .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | > QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | > - QUIRK_HAS_DBGACK_BIT, > + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, > }; > > static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl1 = { > @@ -370,7 +370,7 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov920_cl1 = { > .cnt_en_bit = 8, > .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | > QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | > - QUIRK_HAS_DBGACK_BIT, > + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, > }; > > static const struct of_device_id s3c2410_wdt_match[] = { > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <CGME20250818022433epcas2p15ec2e45f26f6ff5fb69f0b1e377616f4@epcas2p1.samsung.com>]
* [PATCH v6 5/5] watchdog: s3c2410_wdt: exynosautov9: Enable supported features [not found] ` <CGME20250818022433epcas2p15ec2e45f26f6ff5fb69f0b1e377616f4@epcas2p1.samsung.com> @ 2025-08-18 2:18 ` Sangwook Shin 2025-08-21 15:35 ` Guenter Roeck 0 siblings, 1 reply; 12+ messages in thread From: Sangwook Shin @ 2025-08-18 2:18 UTC (permalink / raw) To: krzk, alim.akhtar, wim, linux, semen.protsenko, dongil01.park, khwan.seo Cc: linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel, Sangwook Shin Enable supported features for ExynosAutov9 SoC. - QUIRK_HAS_DBGACK_BIT - QUIRK_HAS_32BIT_CNT Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> --- drivers/watchdog/s3c2410_wdt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 915d3c88565a..b774477190b6 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -306,7 +306,8 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl0 = { .cnt_en_reg = EXYNOS850_CLUSTER0_NONCPU_OUT, .cnt_en_bit = 7, .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | - QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN, + QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, }; static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl1 = { @@ -318,7 +319,8 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl1 = { .cnt_en_reg = EXYNOSAUTOV9_CLUSTER1_NONCPU_OUT, .cnt_en_bit = 7, .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | - QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN, + QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, }; static const struct s3c2410_wdt_variant drv_data_gs101_cl0 = { -- 2.25.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v6 5/5] watchdog: s3c2410_wdt: exynosautov9: Enable supported features 2025-08-18 2:18 ` [PATCH v6 5/5] watchdog: s3c2410_wdt: exynosautov9: Enable supported features Sangwook Shin @ 2025-08-21 15:35 ` Guenter Roeck 0 siblings, 0 replies; 12+ messages in thread From: Guenter Roeck @ 2025-08-21 15:35 UTC (permalink / raw) To: Sangwook Shin Cc: krzk, alim.akhtar, wim, semen.protsenko, dongil01.park, khwan.seo, linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel On Mon, Aug 18, 2025 at 11:18:26AM +0900, Sangwook Shin wrote: > Enable supported features for ExynosAutov9 SoC. > - QUIRK_HAS_DBGACK_BIT > - QUIRK_HAS_32BIT_CNT > > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Signed-off-by: Sangwook Shin <sw617.shin@samsung.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/watchdog/s3c2410_wdt.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c > index 915d3c88565a..b774477190b6 100644 > --- a/drivers/watchdog/s3c2410_wdt.c > +++ b/drivers/watchdog/s3c2410_wdt.c > @@ -306,7 +306,8 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl0 = { > .cnt_en_reg = EXYNOS850_CLUSTER0_NONCPU_OUT, > .cnt_en_bit = 7, > .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | > - QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN, > + QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | > + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, > }; > > static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl1 = { > @@ -318,7 +319,8 @@ static const struct s3c2410_wdt_variant drv_data_exynosautov9_cl1 = { > .cnt_en_reg = EXYNOSAUTOV9_CLUSTER1_NONCPU_OUT, > .cnt_en_bit = 7, > .quirks = QUIRK_HAS_WTCLRINT_REG | QUIRK_HAS_PMU_MASK_RESET | > - QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN, > + QUIRK_HAS_PMU_RST_STAT | QUIRK_HAS_PMU_CNT_EN | > + QUIRK_HAS_DBGACK_BIT | QUIRK_HAS_32BIT_CNT, > }; > > static const struct s3c2410_wdt_variant drv_data_gs101_cl0 = { > -- > 2.25.1 > > ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-08-21 15:35 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CGME20250818022433epcas2p37fe2cdc20b32b23ee894ceb636717a53@epcas2p3.samsung.com> 2025-08-18 2:18 ` [PATCH v6 0/5] Increase max timeout value of s3c2410 watchdog Sangwook Shin [not found] ` <CGME20250818022433epcas2p2a14d0a2ebe8c421dc63ddc8371f8bc50@epcas2p2.samsung.com> 2025-08-18 2:18 ` [PATCH v6 1/5] watchdog: s3c2410_wdt: Replace hardcoded values with macro definitions Sangwook Shin 2025-08-21 15:34 ` Guenter Roeck [not found] ` <CGME20250818022433epcas2p3fc48febfa6729645af6ebd088937c80c@epcas2p3.samsung.com> 2025-08-18 2:18 ` [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger Sangwook Shin 2025-08-18 22:27 ` Sam Protsenko 2025-08-21 15:34 ` Guenter Roeck [not found] ` <CGME20250818022433epcas2p1bf8e6a335be945822721b8db1e9571e9@epcas2p1.samsung.com> 2025-08-18 2:18 ` [PATCH v6 3/5] watchdog: s3c2410_wdt: Increase max timeout value of watchdog Sangwook Shin 2025-08-21 15:35 ` Guenter Roeck [not found] ` <CGME20250818022433epcas2p4fec1cccd280fc73dccc5b00e2236f836@epcas2p4.samsung.com> 2025-08-18 2:18 ` [PATCH v6 4/5] watchdog: s3c2410_wdt: exynosautov920: Enable QUIRK_HAS_32BIT_CNT Sangwook Shin 2025-08-21 15:35 ` Guenter Roeck [not found] ` <CGME20250818022433epcas2p15ec2e45f26f6ff5fb69f0b1e377616f4@epcas2p1.samsung.com> 2025-08-18 2:18 ` [PATCH v6 5/5] watchdog: s3c2410_wdt: exynosautov9: Enable supported features Sangwook Shin 2025-08-21 15:35 ` Guenter Roeck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).