From patchwork Wed Aug 17 07:52:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1667125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=DXnn3uWi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M70ck18r7z1ygF for ; Wed, 17 Aug 2022 17:53:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3765483ACA; Wed, 17 Aug 2022 09:52:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1660722775; bh=R7qKhno0X3NOYSX3R/ABoh8gOMoiqlclf2dh7P2Ds2w=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=DXnn3uWipHIA/IAtjZWmM+4rbU7I+rK+bjW/yxJn94YvTKGzquUYwCBm28N+NxBjG HvKHkSiypKDGvfn6Dnmq4s5K1m3YK9DjYk8mWXo3snLSff5A850T7Qobtmkk9l+l7y P5PA3tTPrMs310t5GC7zAGcoK4+v6s8yyiiVa4JVLCH0JPR2RAhs2X5HiSUbpVqpKa f6WF9QxgOqH+yEA9w8ESA51DACfKaLbZbHHBi0Kd1QGCeYyfac8hCj4iXN81TblbQu cO8/ioIG5Cq5dhWh961H93ZhzCPiGFsTT99FDCFMPo2H1Kw+eyoBw3goeFtKEWXWFh DyjPB+hrK6yiw== Received: by phobos.denx.de (Postfix, from userid 109) id C92958498D; Wed, 17 Aug 2022 09:52:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [80.241.59.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 55AF5840A9 for ; Wed, 17 Aug 2022 09:52:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4M70cF0Nggz9sQH; Wed, 17 Aug 2022 09:52:45 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, cchavva@marvell.com, awilliams@marvell.com Subject: [PATCH v5 0/8] Add support for cyclic function execution infrastruture Date: Wed, 17 Aug 2022 09:52:35 +0200 Message-Id: <20220817075243.3242445-1-sr@denx.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4M70cF0Nggz9sQH X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This patchset adds the basic infrastructure to periodically execute code, e.g. all 100ms. Examples for such functions might be LED blinking etc. The functions that are hooked into this cyclic list should be small timewise as otherwise the execution of the other code that relies on a high frequent polling (e.g. UART rx char ready check) might be delayed too much. This patch also adds the Kconfig option CONFIG_CYCLIC_MAX_CPU_TIME_US, which configures the max allowed time for such a cyclic function. If it's execution time exceeds this time, this cyclic function will get removed from the cyclic list. How is this cyclic functionality executed? This patchset integrates the main function responsible for calling all registered cyclic functions cyclic_run() into the common WATCHDOG_RESET macro. This guarantees that cyclic_run() is executed very often, which is necessary for the cyclic functions to get scheduled and executed at their configured periods. This cyclic infrastructure will be used by a board specific function on the NIC23 MIPS Octeon board, which needs to check periodically, if a PCIe FLR has occurred. Ideas how to continue: One idea is to rename WATCHDOG_RESET to something like SCHEDULE and move the watchdog_reset call into this cyclic infrastructure as well. Or to perhaps move the shell UART RX ready polling to a cyclic function. It's also possible to extend the "cyclic" command, to support the creation of periodically executed shell commands (for testing etc). Here the Azure build, without any issues: https://dev.azure.com/sr0718/u-boot/_build/results?buildId=229&view=results Aaron Williams (1): mips: octeon_nic23: Add PCIe FLR fixup via cyclic infrastructure Stefan Roese (7): time: Import time_after64() and friends from Linux cyclic: Add basic support for cyclic function execution infrastruture cyclic: Integrate cyclic infrastructure into WATCHDOG_RESET cyclic: Integrate cyclic functionality at bootup in board_r/f cyclic: Add 'cyclic list' and 'cyclic demo' commands cyclic: Add documentation cyclic: Add a simple test MAINTAINERS | 7 + board/Marvell/octeon_nic23/board.c | 197 +++++++++++++++++++++++++++++ cmd/Kconfig | 16 +++ cmd/Makefile | 1 + cmd/cyclic.c | 85 +++++++++++++ common/Kconfig | 20 +++ common/Makefile | 1 + common/board_f.c | 2 + common/board_r.c | 2 + common/cyclic.c | 113 +++++++++++++++++ configs/octeon_nic23_defconfig | 3 + doc/develop/cyclic.rst | 50 ++++++++ doc/develop/index.rst | 1 + doc/usage/cmd/cyclic.rst | 45 +++++++ doc/usage/index.rst | 1 + fs/cramfs/uncompress.c | 2 +- include/cyclic.h | 110 ++++++++++++++++ include/time.h | 19 +++ include/watchdog.h | 23 +++- test/common/Makefile | 1 + test/common/cyclic.c | 34 +++++ test/test-main.c | 3 + 22 files changed, 732 insertions(+), 4 deletions(-) create mode 100644 cmd/cyclic.c create mode 100644 common/cyclic.c create mode 100644 doc/develop/cyclic.rst create mode 100644 doc/usage/cmd/cyclic.rst create mode 100644 include/cyclic.h create mode 100644 test/common/cyclic.c