Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2638465pxb; Tue, 9 Mar 2021 07:24:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR83IOj7pIa2cz7TmCVaCMbafWovRXtqcs40YnV2xFcG1+jxdxX2yficKQom42/xoQjW9K X-Received: by 2002:a17:906:1ecc:: with SMTP id m12mr20722473ejj.4.1615303472148; Tue, 09 Mar 2021 07:24:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615303472; cv=none; d=google.com; s=arc-20160816; b=jCJH4tBB0Hyzm21+nvoZ7vdIHLKellrpsyNFhl6km1jMhw9rxA/saT0GpjirIi2XTo 5aF4fwgGNcI4pw8t5f7Q3VTZYqkqaKphCurbeKKfyTCtBuueDLkhCRwPYpgNYqBc7PLE Gd3wFTaIuWOR3pUNb/ba0CGAzANpUDv6u3iIxGlB2f6wwrWHuyQpwCYev7l6ZqQSJn46 Fp/jeu53z7TdBC/IHXrH0Hwjdq6X/y5GdPKyV5ZRv2xCEddOlqTk62nbSo1EWtYuhQeg AZRj1lL0q1jKoIoSYGZ0M+myAii6mFvE89Cpq3DWHJ7YYNdMmLYK0o+lpgN4wV2s6eAF S2tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject:sender:dkim-signature; bh=EtHomTVspR07IV8b/4l9dOODkuDLjrBPgQ+KxU14Jyo=; b=S3FdkB5NGVYrpvTOE3N6xNN0F0F7HSPrJIrj46DwyOMluqIxJT3auEMg5xgpmIx6ak oEic9menEtOn0jg45G++sZjmMa7GnWU2K9QkkYQ1VQjkrCEzpLsgDkPjoYGsLgPu6vDv VMuUrK7ee944VZVnxjxPZ14dDh6tSHG12UOfXv2ZVtf52NvTgoYJ0Rn2sgCRAHd9bYWU uVGqIQEnYP0WXYisi76s1M0AvYuqVmZ69xyYZcHnh/vEEwMZAO4mhC0qJ336Up71/DE5 g/lKuEWF9G96rEcPARsSO5gJmfyjinBiqoKOXKfcN0K3QDFoWG9cC4XW23PGPc35l51t XjrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=looSU4kC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv19si8938731ejc.109.2021.03.09.07.24.08; Tue, 09 Mar 2021 07:24:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=looSU4kC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231986AbhCIPWl (ORCPT + 99 others); Tue, 9 Mar 2021 10:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbhCIPWc (ORCPT ); Tue, 9 Mar 2021 10:22:32 -0500 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01583C06174A; Tue, 9 Mar 2021 07:22:32 -0800 (PST) Received: by mail-oi1-x22a.google.com with SMTP id y131so12431766oia.8; Tue, 09 Mar 2021 07:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EtHomTVspR07IV8b/4l9dOODkuDLjrBPgQ+KxU14Jyo=; b=looSU4kCO7lnZ8qNcF26UVkoNrpWa+j5Vuf+34HbRgwah8JztFHNUu1Ulh4lckFWkC 5bu4rUpENW5DJsTWusAYwNgtR1NaTBQvdG6dKtljyXPVSSD8YO+8jAw0T69cda7LmHgw xSerBQoqknzA+rifPav6D1PQnCOuUVVgCl4Dmdm9GRsUxbHIuH5BKuLHxo1qITs0tKl3 sutk6vc2Sq7IiafxEc+IB1oU7mWY0/v74kzMXE3UviX1WeC2qs1Yh4f/laA922USpbJT ljKXtPao+huGAITr81DA4etG0d6w8cAIDpovPdNZ32Xo7RGL0qvRDhJdriAfYKC6+bHA N7TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=EtHomTVspR07IV8b/4l9dOODkuDLjrBPgQ+KxU14Jyo=; b=GHHY1YTovyoOS0RryD/nMfCf6QLr1br403ohbjrVYTge7+uhjbu40rDqvzEpDLKM2G h2ZX/uHPstNBJwTHOYuMAyg+xMRIV8zyAopnyfNps5C+8b95vxk42mYEgx9U1BGJWU8f 5N/nLAwSLa2uupY3Z9/hX/p7PHPOQICWO48sfYqmV5E+RquwjRH9GdMloso/hd2QTV32 NRZNEkCo+HevEMfvtxN/GFAovy4s+cHWQ2gkQyyM5Xyom/QjkxkK+4HGdbL9ctwBn1xD L4nXhEwjb4YBy8YRFhG5FgqnCQI8h5Mn9nYXCdnTdDfJRM0SddZAatd7Zp5c0oRjDnLP +4dQ== X-Gm-Message-State: AOAM532IjsFkCMeeMeC1NVy4f2/Y8+f/UrroSSful0AD0V7xjC+SbAiY hObvuZbgbIvCdm++fCj0WZk= X-Received: by 2002:aca:39d5:: with SMTP id g204mr3347242oia.63.1615303351387; Tue, 09 Mar 2021 07:22:31 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l191sm1928400oih.16.2021.03.09.07.22.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 07:22:30 -0800 (PST) Sender: Guenter Roeck Subject: Re: [PATCH v1 0/2] Watchdog Core Global Parameters To: Flavio Suligoi Cc: "linux-watchdog@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Wim Van Sebroeck , Mika Westerberg References: <20210308112151.716315-1-f.suligoi@asem.it> <984953abc23c4cd6a4a6a5b77ae72e66@asem.it> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf3EArDlDShwR2+D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n7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: <1500d5fe-5228-1671-2008-4b7e30e856ea@roeck-us.net> Date: Tue, 9 Mar 2021 07:22:28 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <984953abc23c4cd6a4a6a5b77ae72e66@asem.it> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/9/21 2:26 AM, Flavio Suligoi wrote: > Hi Guenter, > >>> Instead of adding this kind of module parameters independently to each >>> driver, the best solution is declaring each feature only once, in the >>> watchdog core. >>> >> >> I agree to and like the idea, but I don't see the point of letting drivers opt in >> or opt out. This adds a lot of complexity for little if any gain. > > Do you mean that all the support for this "global parameters" should be done > in the watchdog-core only, without write any code in each single > "hardware" driver? Correct. It should not be up to the driver author to decide if they want to opt out from global parameters or not. It should be up to users, and users can opt out by not providing the parameters. Guenter >> >> Guenter > > Regards, > > Flavio > >> >>> Additionally, I added a implementation example of this "global" >>> parameters using the module "wdat_wdt" >>> >>> In details: >>> >>> =============================== >>> Watchdog Core Global Parameters >>> =============================== >>> >>> Information for watchdog kernel modules developers. >>> >>> Introduction >>> ============ >>> >>> Different watchdog modules frequently require the same type of >>> parameters (for example: *timeout*, *nowayout* feature, >>> *start_enabled* to start the watchdog on module insertion, etc.). >>> Instead of adding this kind of module parameters independently to each >>> driver, the best solution is declaring each feature only once, in the >>> watchdog core. >>> >>> In this way, each driver can read these "global" parameters and then, >>> if needed, can implement them, according to the particular hw watchdog >>> characteristic. >>> >>> Using this approach, it is possible reduce some duplicate code in the >>> *new* watchdog drivers and simplify the code maintenance. Moreover, >>> the code will be clearer, since the same kind of parameters are often >>> called with different names (see Documentation/watchdog/watchdog- >> parameters.rst). >>> Obviously, for compatibility reasons, we cannot remove the already >>> existing parameters from the code of the various watchdog modules, but >>> we can use this "global" approach for the new watchdog drivers. >>> >>> >>> Global parameters declaration >>> ============================== >>> >>> The global parameters data structure is declared in >>> include/linux/watchdog.h, as:: >>> >>> struct watchdog_global_parameters_struct { >>> int timeout; >>> int ioport; >>> int irq; >>> unsigned long features; >>> /* Bit numbers for features flags */ >>> #define WDOG_GLOBAL_PARAM_VERBOSE 0 >>> #define WDOG_GLOBAL_PARAM_TEST_MODE 1 >>> #define WDOG_GLOBAL_PARAM_START_ENABLED 2 >>> #define WDOG_GLOBAL_PARAM_NOWAYOUT 3 >>> }; >>> >>> The variable "feature" is a bitwise flags container, to store boolean >>> features, such as: >>> >>> * nowayout >>> * start_enable >>> * etc... >>> >>> Other variables can be added, to store some numerical values and other >>> data required. >>> >>> The global parameters are declared (as usual for the module >>> parameters) in the first part of drivers/watchdog/watchdog_core.c file. >>> The above global data structure is then managed by the function *void >>> global_parameters_init()*, in the same file. >>> >>> Global parameters use >>> ===================== >>> >>> Each watchdog driver, to check if one of the global parameters is >>> enabled, can use the corresponding in-line function declared in >>> include/linux/watchdog.h. >>> At the moment the following functions are ready to use: >>> >>> * watchdog_global_param_verbose_enabled() >>> * watchdog_global_param_test_mode_enabled() >>> * watchdog_global_param_start_enabled() >>> * watchdog_global_param_nowayout_enabled() >>> >>> >>> >>> Flavio Suligoi (2): >>> watchdog: add global watchdog kernel module parameters structure >>> watchdog: wdat: add start_enable global parameter >>> >>> Documentation/watchdog/index.rst | 1 + >>> .../watchdog-core-global-parameters.rst | 74 +++++++++++++++++++ >>> drivers/watchdog/watchdog_core.c | 74 +++++++++++++++++++ >>> drivers/watchdog/wdat_wdt.c | 2 + >>> include/linux/watchdog.h | 42 +++++++++++ >>> 5 files changed, 193 insertions(+) >>> create mode 100644 >>> Documentation/watchdog/watchdog-core-global-parameters.rst >>> >