This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] AM6422:K3 AM6x/J7xxxx — 在 K3 RTI WDT 驱动程序(Linux 内核)中使用 CONFIG_WATCHDOG_NOWAYOUT?

Guru**** 2454880 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1536419/am6422-k3-am6x-j7xxxx---usage-of-config_watchdog_nowayout-in-k3-rti-wdt-driver-linux-kernel

器件型号:AM6422


工具/软件:

您好:

我想询问 在“K3 RTI WDT“驱动器中显式设置 CONFIG_WATCHDOG_NOWAYOUT 是否有、或者原因是什么?

static int rti_wdt_probe(struct platform_device *pdev)
{
    // ...
    
    watchdog_set_drvdata(wdd, wdt);
	watchdog_set_nowayout(wdd, 1);              // <--
	watchdog_set_restart_priority(wdd, 128);
}

“问题“(更好的调整)是、当我们关闭或重新启动电路板时、会收到以下消息:

kernel: watchdog: watchdog0: nowayout prevents watchdog being stopped!
kernel: watchdog: watchdog0: watchdog did not stop!

我被要求删除这些错误消息,似乎这种行为是与系统 D 从 wathdog 分离的那一刻相关的。 问题在于看门狗内核 在调用尝试.stop 函数(未在 K3 RTI WDT 驱动程序中实现)之前会评估 WDOG_NO_WAY_OUT。 因此、我的想法是在 RTI WDT 驱动器中使用 CONFIG_WATCHDOG_NOWAYOUT、而不是显式将其设置为 1:

static int rti_wdt_probe(struct platform_device *pdev)
{
    // ...
    
    watchdog_set_drvdata(wdd, wdt);
	watchdog_set_nowayout(wdd, IS_ENABLED(CONFIG_WATCHDOG_NOWAYOUT));   // <--
	watchdog_set_restart_priority(wdd, 128);
}

我试了一下、发现上面提到的信息已经消失了。 因此,我询问您这样做时是否有其他一些影响 — RTI WDT 似乎没有处理 WDOG_NO_WAY_OUT 位。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    某些看门狗硬件允许在运行期间暂停、停止和复位看门狗。 AM64x 上的看门狗不是这些看门狗之一。 AM64x 看门狗启动后、软件无法阻止其运行。 因此、无论您进行何种更改、都不希望软件尝试停止看门狗。

     is_enabled (CONFIG_WATCHDOG_NOWAYOUT) 的输出是什么?

    此致、

    Nick

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    首先感谢 yor 的答复。 我完全同意避免看门狗停止是有意义的。 我已经了解到这是关键应用中的一项要求。 如果驱动程序本身不支持停止看门狗、则驱动程序中不需要 WDOG_NO_WAY_OUT(?)。 这也可以通过 为单个应用设置 CONFIG_WATCHDOG_NOWAYOUT 来处理。

    如果实现了“watchdog_set_nowayout (WDD、1);“、会收到以下消息:

    ...
    systemd[1]: Shutting down.
    systemd[1]: Modifying watchdog hardware timeout is not supported, reusing the programmed timeout.
    kernel: watchdog: watchdog0: nowayout prevents watchdog being stopped!
    kernel: watchdog: watchdog0: watchdog did not stop!
    systemd[1]: Watchdog running with a hardware timeout of 1min.
    systemd-shutdown[1]: Using hardware watchdog 'K3 RTI Watchdog', version 0, device /dev/watchdog0
    ...

     相比之下、强制执行“WATCHDOG_SET_nowayout (WDD、is_enabled (CONFIG_WATCHDOG_NOWAYOUT))“会得到:

    systemd[1]: Shutting down.
    systemd[1]: Modifying watchdog hardware timeout is not supported, reusing the programmed timeout.
    systemd[1]: Watchdog running with a hardware timeout of 1min.
    systemd-shutdown[1]: Using hardware watchdog 'K3 RTI Watchdog', version 0, device /dev/watchdog0

    可以看到来自内核的两条消息已消失。 这种消息的“问题“是,有人可能认为有什么错误(实际上不是什么)。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Wilhelm、

    今天我没有机会浏览驱动程序代码。 如果我没有通过星期五回复、请 ping 通该线程。

    此致、

    Nick

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Nick、

    没有在这里从你,因此“ ping “线程请求.

    此致、
    Willy

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

     根据 CONFIG_WATCHDOG_NOWAYOUT 使用 WATCHDOG_SET_nowayout () 的另一种(更优雅的)方法是像许多其他看门狗驱动程序一样这样做:

    /* /drivers/watchdog/rti_wdt.c */
    
    /* ... */
    
    static int heartbeat = DEFAULT_HEARTBEAT;
    static bool nowayout = WATCHDOG_NOWAYOUT;
    
    /* ... */
    
    static int rti_wdt_probe(struct platform_device *pdev)
    {
        /* ... */
    
    	watchdog_set_drvdata(wdd, wdt);
    	watchdog_set_nowayout(wdd, nowayout);
    	watchdog_set_restart_priority(wdd, 128);
    
        /* ... */
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Wilhelm、

    对此处延迟的回复表示歉意。

    您的最新代码看起来不错、但我不明白为什么它会导致不同的行为。 无论哪一种方式、 watchdog_set_nowayout() 都会在探测函数中收到 1、对吧? 因此、我希望系统的运行方式完全相同:

    include/linux/watchdog.h
    
    /* Use the following function to set the nowayout feature */
    static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
    {
            if (nowayout)
                    set_bit(WDOG_NO_WAY_OUT, &wdd->status);
    }
    

    此致、

    Nick

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Nick、

    在建议的更改到位后、 只有在*。config 文件中设置了 CONFIG_WATCHDOG_NO_WAY_OUT(到 Y)时、WATCHDOG_SET_nowayout() 才会收到 1。

    由于默认情况下未设置该设置(参见 github.com/.../Kconfig) 、所以 watchdog_set_nowayout () 将收到 0、除非 在*。config 文件中显式设置了 CONFIG_WATCHDOG_NO_WAY_OUT。 这会导致 watchdog_stop()(watchdog_dev.c) 不会返回 0 而不是-EBUSY、并且内核不会记录上述错误消息。

    我同意、此更改会影响所有其他使用“K3 RTI WDT“看门狗的构建、但没有功能影响、只是(超动态)错误消息将从内核日志中消失。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    校正:

    由于默认情况下未设置该设置(参见 github.com/.../Kconfig) 、所以 watchdog_set_nowayout () 将收到 0、除非 在*。config 文件中显式设置了 CONFIG_WATCHDOG_NO_WAY_OUT。 这会导致 watchdog_stop()(watchdog_dev.c)会返回 0 而不是-EBUSY、并且内核不会记录上述错误消息。