From patchwork Tue Jun 9 10:45:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595219 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DA44618 for ; Tue, 9 Jun 2020 10:50:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3FCC2078D for ; Tue, 9 Jun 2020 10:50:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FRLTeeLV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728926AbgFIKuI (ORCPT ); Tue, 9 Jun 2020 06:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728852AbgFIKri (ORCPT ); Tue, 9 Jun 2020 06:47:38 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883CAC08C5CA for ; Tue, 9 Jun 2020 03:47:36 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id c35so15970291edf.5 for ; Tue, 09 Jun 2020 03:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U9rt/3Vl/6zlHKoX8Sru+cTCnsVpfXdCh6OHWoOo9RE=; b=FRLTeeLV+htxuHSVemMkC/H0jDbDMDBVLljGbI5nXTP0IhqF5MnV9KiofVJzjeP4z4 0zwVRhu75Q4no06LDdOJshGV1LHb0S3tOA05xbRD40Dma+wJmAO9YFhwn5dctpuYIEWq ZLG3B+MAt29+JMNIQpeV11RNkNvsbXBA5Qgnm/0GE1KBf7nXFDBsqux+9o5VA0MU1ZWv AXpnSTeeFLZAnaiYcjBmlBixwTTthdz+l8s1TM87XZiEztoLc5XuK1HttYXUW9jSdJRS axs60D+IuuCnv1d2SKcZyZLFlz73Q6gnl4DPgbVQDWWCv71BwouRU8hzz7qDRGuGQR6V gaYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U9rt/3Vl/6zlHKoX8Sru+cTCnsVpfXdCh6OHWoOo9RE=; b=ea1CGlaReYDQVOJ38oM8hb3Oxz5JorhM1pPUbyvxpQAs8zub3xbxs82VnxIFSUiOLs Pz63W9iDcr7hgzrkGfqPgYdJqCh4dadqhmD2uEPkLBX0iSO01hUXvlTXwp0ViPOdaiSX pZmFoHpr/YUUTxqwkgJ0W/4Xoe6bjwr6yuV8dRnYXi3Tx5bYHPswp6jNw/dtrcR0jRBu 4QXerzE+G0uPnoyVh9GVDh5AX3NMHOIAHvh10jZh87rbJFXIKhAyZoMqhqdHExS5/kZe IwA3oZUr/hkCnZt0rQTj19jnlogru42vKz6HE+SLOVCUmSuQUDwmyR6eT7fIC2oAZy6k S6Sg== X-Gm-Message-State: AOAM530MxhBC+1hbO/5L8srpKl9XB1pUqO5FMM5PrNKJCS95/RWZ/zlq lddKiZwmv4ly3aB4ypTGSrWvNw== X-Google-Smtp-Source: ABdhPJz+fdaUtgiiLd8gXAw1zn+Ihd7jWg7g+4P4sGhrrGs3vMrDi8lIPiEbt8jFBzavbp4Ebo9fZw== X-Received: by 2002:a50:b0e2:: with SMTP id j89mr26765993edd.257.1591699655083; Tue, 09 Jun 2020 03:47:35 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:34 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov , Jonathan Corbet Subject: [PATCH v3 1/7] Documentation: dynamic-debug: Add description of level bitmask Date: Tue, 9 Jun 2020 13:45:58 +0300 Message-Id: <20200609104604.1594-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This adds description of the level bitmask feature. Cc: Jonathan Corbet (maintainer:DOCUMENTATION) Signed-off-by: Stanimir Varbanov --- Documentation/admin-guide/dynamic-debug-howto.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index 0dc2eb8e44e5..c2b751fc8a17 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -208,6 +208,12 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file +level + The given level will be a bitmask ANDed with the level of the each ``pr_debug()`` + callsite. This will allow to group debug messages and show only those of the + same level. The -p flag takes precedence over the given level. Note that we can + have up to five groups of debug messages. + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: @@ -346,6 +352,10 @@ Examples // add module, function to all enabled messages nullarbor:~ # echo -n '+mf' > /dynamic_debug/control + // enable all messages in file with 0x01 level bitmask + nullarbor:~ # echo -n 'file foo.c level 0x01 +p' > + /dynamic_debug/control + // boot-args example, with newlines and comments for readability Kernel command line: ... // see whats going on in dyndbg=value processing From patchwork Tue Jun 9 10:45:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9DCA1391 for ; Tue, 9 Jun 2020 10:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A62E72078D for ; Tue, 9 Jun 2020 10:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QhdV7PMa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbgFIKuE (ORCPT ); Tue, 9 Jun 2020 06:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728855AbgFIKrj (ORCPT ); Tue, 9 Jun 2020 06:47:39 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCAF2C08C5C3 for ; Tue, 9 Jun 2020 03:47:38 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id mb16so21824852ejb.4 for ; Tue, 09 Jun 2020 03:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4/0Vkm5vDfo1bNDCqLsz+PhAJXt0YTLeInxH19lPC3A=; b=QhdV7PMawCedJj6lnvoPx0JPU8A93/u1U0uXlVTjpCXvh5CxZKNLOPT/mYxcCWE/A1 Y1RnVAXRL5dikNKzGKX40hNXN8gniQqI8orbHE5fEG9HpiM+hHCBGDkvCR4kjgifAMnX qL9apEeFsd4xVmR8MqopEemPmnGTqCDmt7lhrSnQg5H9GC5khbx9GttIWiZo3VYjK58l +IYSN4R6LZWlY66jV79ZjQStPnNZ9k3CNQ4NJrN4wKa4xvaz/kcxPDHePCEGZ00KZuX6 G7f41RyhV/v33Ocp/09xS45klC7rXm2t86Y0tPAKwsSnFiu1yWXUIsFy2NIABrrw+aqT XwuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4/0Vkm5vDfo1bNDCqLsz+PhAJXt0YTLeInxH19lPC3A=; b=LLxHHW2bD5hYdORy73BnMSlLu2NVvlGsSObid8W4MwxQgdrb0EpspZ4NA3osRZw0f0 btRA2FcFi4693nyBXXuelG2hykhDt5cIylrrrjyl4aNlgGjFHMfxUpk7QohaGOxVkB4v DtXr3HxHl026uhb0ZWBvznSjKD19BzHEFj5fuypTNR3MdXua93FO81E5usdjzBDWunua 96BnXFXKswAql/+LG68tu2Rp+ldsJ8rledWSQmQYaY77aLDimMOsEvmZeYzwQ82r4y8h Z2f9NEuuZgt3CByy2JE276KeDswdFhDyoov6IrlXbKTk2YEqXMzHNJi5mW9IBBMM5nzo LYDQ== X-Gm-Message-State: AOAM531zxbLUZoFoIhau/ngOjA7tI7ZBMRl8c1ts3J1k0Mq7xmAbITWk u8a3Pbb1+ybo9ypVQ6K6S1eGbA== X-Google-Smtp-Source: ABdhPJypj4I58d5TLz8Xdh5fIHk7lhmauggjZSsXsMJ+fyzaf+ai9uzB3MPfXxtvkYH9C+7Bn3qKGw== X-Received: by 2002:a17:906:7712:: with SMTP id q18mr859739ejm.140.1591699657572; Tue, 09 Jun 2020 03:47:37 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:37 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov , Chris Mason , Josef Bacik , David Sterba , "Rafael J. Wysocki" , Len Brown , "David S. Miller" , Jakub Kicinski , Petr Mladek , Sergey Senozhatsky , Steven Rostedt Subject: [PATCH v3 2/7] dynamic_debug: Group debug messages by level bitmask Date: Tue, 9 Jun 2020 13:45:59 +0300 Message-Id: <20200609104604.1594-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This will allow dynamic debug users and driver writers to group debug messages by level bitmask. The level bitmask should be a hex number. Done this functionality by extending dynamic debug metadata with new level member and propagate it over all the users. Also introduce new dynamic_pr_debug_level and dynamic_dev_dbg_level macros to be used by the drivers. Cc: Jason Baron Cc: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Greg Kroah-Hartman Suggested-by: Joe Perches Signed-off-by: Stanimir Varbanov --- fs/btrfs/ctree.h | 12 +++++--- include/linux/acpi.h | 3 +- include/linux/dev_printk.h | 3 +- include/linux/dynamic_debug.h | 55 ++++++++++++++++++++++++----------- include/linux/net.h | 3 +- include/linux/printk.h | 3 +- lib/dynamic_debug.c | 30 +++++++++++++++++++ 7 files changed, 84 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 161533040978..f6a778789056 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3081,16 +3081,20 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...); #if defined(CONFIG_DYNAMIC_DEBUG) #define btrfs_debug(fs_info, fmt, args...) \ - _dynamic_func_call_no_desc(fmt, btrfs_printk, \ + _dynamic_func_call_no_desc(fmt, _DPRINTK_LEVEL_DEFAULT, \ + btrfs_printk, \ fs_info, KERN_DEBUG fmt, ##args) #define btrfs_debug_in_rcu(fs_info, fmt, args...) \ - _dynamic_func_call_no_desc(fmt, btrfs_printk_in_rcu, \ + _dynamic_func_call_no_desc(fmt, _DPRINTK_LEVEL_DEFAULT, \ + btrfs_printk_in_rcu, \ fs_info, KERN_DEBUG fmt, ##args) #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ - _dynamic_func_call_no_desc(fmt, btrfs_printk_rl_in_rcu, \ + _dynamic_func_call_no_desc(fmt, _DPRINTK_LEVEL_DEFAULT, \ + btrfs_printk_rl_in_rcu, \ fs_info, KERN_DEBUG fmt, ##args) #define btrfs_debug_rl(fs_info, fmt, args...) \ - _dynamic_func_call_no_desc(fmt, btrfs_printk_ratelimited, \ + _dynamic_func_call_no_desc(fmt, _DPRINTK_LEVEL_DEFAULT, \ + btrfs_printk_ratelimited, \ fs_info, KERN_DEBUG fmt, ##args) #elif defined(DEBUG) #define btrfs_debug(fs_info, fmt, args...) \ diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d661cd0ee64d..6e51438f7635 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1043,7 +1043,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c #else #if defined(CONFIG_DYNAMIC_DEBUG) #define acpi_handle_debug(handle, fmt, ...) \ - _dynamic_func_call(fmt, __acpi_handle_debug, \ + _dynamic_func_call(fmt, _DPRINTK_LEVEL_DEFAULT, \ + __acpi_handle_debug, \ handle, pr_fmt(fmt), ##__VA_ARGS__) #else #define acpi_handle_debug(handle, fmt, ...) \ diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h index 5aad06b4ca7b..7b50551833e1 100644 --- a/include/linux/dev_printk.h +++ b/include/linux/dev_printk.h @@ -188,7 +188,8 @@ do { \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ - DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt, \ + _DPRINTK_LEVEL_DEFAULT); \ if (DYNAMIC_DEBUG_BRANCH(descriptor) && \ __ratelimit(&_rs)) \ __dynamic_dev_dbg(&descriptor, dev, dev_fmt(fmt), \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4cf02ecd67de..95e97260c517 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -38,6 +38,8 @@ struct _ddebug { #define _DPRINTK_FLAGS_DEFAULT 0 #endif unsigned int flags:8; +#define _DPRINTK_LEVEL_DEFAULT 0 + unsigned int level:5; #ifdef CONFIG_JUMP_LABEL union { struct static_key_true dd_key_true; @@ -78,7 +80,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, const struct ib_device *ibdev, const char *fmt, ...); -#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt, lvl) \ static struct _ddebug __aligned(8) \ __attribute__((section("__verbose"))) name = { \ .modname = KBUILD_MODNAME, \ @@ -87,6 +89,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .format = (fmt), \ .lineno = __LINE__, \ .flags = _DPRINTK_FLAGS_DEFAULT, \ + .level = (lvl), \ _DPRINTK_KEY_INIT \ } @@ -119,16 +122,16 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #endif -#define __dynamic_func_call(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(&id, ##__VA_ARGS__); \ +#define __dynamic_func_call(id, fmt, level, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt, level); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(&id, ##__VA_ARGS__); \ } while (0) -#define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ - if (DYNAMIC_DEBUG_BRANCH(id)) \ - func(__VA_ARGS__); \ +#define __dynamic_func_call_no_desc(id, fmt, level, func, ...) do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt, level); \ + if (DYNAMIC_DEBUG_BRANCH(id)) \ + func(__VA_ARGS__); \ } while (0) /* @@ -139,35 +142,49 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * the varargs. Note that fmt is repeated in invocations of this * macro. */ -#define _dynamic_func_call(fmt, func, ...) \ - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call(fmt, lvl, func, ...) \ + __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, lvl, func, ##__VA_ARGS__) /* * A variant that does the same, except that the descriptor is not * passed as the first argument to the function; it is only called * with precisely the macro's varargs. */ -#define _dynamic_func_call_no_desc(fmt, func, ...) \ - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc(fmt, lvl, func, ...) \ + __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, lvl, \ + func, ##__VA_ARGS__) #define dynamic_pr_debug(fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_pr_debug, \ + _dynamic_func_call(fmt, _DPRINTK_LEVEL_DEFAULT, \ + __dynamic_pr_debug, \ + pr_fmt(fmt), ##__VA_ARGS__) + +#define dynamic_pr_debug_level(lvl, fmt, ...) \ + _dynamic_func_call(fmt, lvl, __dynamic_pr_debug, \ pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_dev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt,__dynamic_dev_dbg, \ + _dynamic_func_call(fmt, _DPRINTK_LEVEL_DEFAULT, \ + __dynamic_dev_dbg, \ + dev, fmt, ##__VA_ARGS__) + +#define dynamic_dev_dbg_level(dev, lvl, fmt, ...) \ + _dynamic_func_call(fmt, lvl, __dynamic_dev_dbg, \ dev, fmt, ##__VA_ARGS__) #define dynamic_netdev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_netdev_dbg, \ + _dynamic_func_call(fmt, _DPRINTK_LEVEL_DEFAULT, \ + __dynamic_netdev_dbg, \ dev, fmt, ##__VA_ARGS__) #define dynamic_ibdev_dbg(dev, fmt, ...) \ - _dynamic_func_call(fmt, __dynamic_ibdev_dbg, \ + _dynamic_func_call(fmt, _DPRINTK_LEVEL_DEFAULT, \ + __dynamic_ibdev_dbg, \ dev, fmt, ##__VA_ARGS__) #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ groupsize, buf, len, ascii) \ _dynamic_func_call_no_desc(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \ + _DPRINTK_LEVEL_DEFAULT, \ print_hex_dump, \ KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) @@ -202,8 +219,12 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, #define dynamic_pr_debug(fmt, ...) \ do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) +#define dynamic_pr_debug_level(lvl, fmt, ...) \ + do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) #define dynamic_dev_dbg(dev, fmt, ...) \ do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) +#define dynamic_dev_dbg_level(dev, lvl, fmt, ...) \ + do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ groupsize, buf, len, ascii) \ do { if (0) \ diff --git a/include/linux/net.h b/include/linux/net.h index e10f378194a5..bcf6f010bc67 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -267,7 +267,8 @@ do { \ #if defined(CONFIG_DYNAMIC_DEBUG) #define net_dbg_ratelimited(fmt, ...) \ do { \ - DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt, \ + _DPRINTK_LEVEL_DEFAULT); \ if (DYNAMIC_DEBUG_BRANCH(descriptor) && \ net_ratelimit()) \ __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \ diff --git a/include/linux/printk.h b/include/linux/printk.h index 3cc2f178bf06..ceea84aa705b 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -542,7 +542,8 @@ do { \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ - DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt)); \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, pr_fmt(fmt), \ + _DPRINTK_LEVEL_DEFAULT); \ if (DYNAMIC_DEBUG_BRANCH(descriptor) && \ __ratelimit(&_rs)) \ __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8f199f403ab5..5d28d388f6dd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -55,6 +55,7 @@ struct ddebug_query { const char *function; const char *format; unsigned int first_lineno, last_lineno; + unsigned int level; }; struct ddebug_iter { @@ -187,6 +188,18 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; +#ifdef CONFIG_JUMP_LABEL + if (query->level && query->level & dp->level) { + if (flags & _DPRINTK_FLAGS_PRINT) + static_branch_enable(&dp->key.dd_key_true); + else + static_branch_disable(&dp->key.dd_key_true); + } else if (query->level && + flags & _DPRINTK_FLAGS_PRINT) { + static_branch_disable(&dp->key.dd_key_true); + continue; + } +#endif newflags = (dp->flags & mask) | flags; if (newflags == dp->flags) continue; @@ -289,6 +302,20 @@ static inline int parse_lineno(const char *str, unsigned int *val) return 0; } +static inline int parse_level(const char *str, unsigned int *val) +{ + WARN_ON(str == NULL); + if (*str == '\0') { + *val = 0; + return 0; + } + if (kstrtouint(str, 0, val) < 0) { + pr_err("bad level-number: %s\n", str); + return -EINVAL; + } + return 0; +} + static int check_set(const char **dest, char *src, char *name) { int rc = 0; @@ -375,6 +402,9 @@ static int ddebug_parse_query(char *words[], int nwords, } else { query->last_lineno = query->first_lineno; } + } else if (!strcmp(words[i], "level")) { + if (parse_level(words[i+1], &query->level) < 0) + return -EINVAL; } else { pr_err("unknown keyword \"%s\"\n", words[i]); return -EINVAL; From patchwork Tue Jun 9 10:46:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20846913 for ; Tue, 9 Jun 2020 10:49:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 064FC20814 for ; Tue, 9 Jun 2020 10:49:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hS4A2h3J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgFIKtp (ORCPT ); Tue, 9 Jun 2020 06:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728878AbgFIKrq (ORCPT ); Tue, 9 Jun 2020 06:47:46 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DDCEC008632 for ; Tue, 9 Jun 2020 03:47:41 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id o15so21789014ejm.12 for ; Tue, 09 Jun 2020 03:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/5WnBa7fJn+pPKP5P8jfdYigZEMgAeAJ+nmAq9FbnZM=; b=hS4A2h3J+Pci4Lw+anaXS2PuQgAH2hIHxpqd0ezXZxBZ9me+hfgdQg5mvHjcq8SUiO EuY6p0NBvRb45UuQrdbwSLXcPmCxwBvC1lHF5LyVoiaJ8Sx7LThvB+VK7ZsHRno9Y2uz 6SBK2Nd8vb3GB5GOe8DWi6HPJvQeRk3hvhBy5OICiWc0tGOHQHpN2pIM2xv/FIUgpWI6 D+4lRUw0r9eb4u0Y5WU5nkzEVplGGsS2HlRlIsldw/wj3Ik+gd67w1NVDuyHJGq/QF/p 77MD86DPubivo8gbrQsAWCFwqMs/4ctENZres/LCUYw3JixwjJNmIkS6ZdOBqPwqK80t UO9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/5WnBa7fJn+pPKP5P8jfdYigZEMgAeAJ+nmAq9FbnZM=; b=lrkeYfLA51VqrpOUrbGANPSW97NhYWMRM9OvbZJ/EpN4CRLAR1+dXIg/na5gh6ABS/ JH48aBC7KurV6WK/VKd5ixDGkdCyTHaxF153Hmr+RSTx1ZxeAVu5C/w364YX+hy9XmrX 4+ciSX3UGeSCPHQOjF2sUNaW89+IJLDTv8ha45G2z8HJiXnPc0h81h+aZ0lGpNjWtLol qcem4s+5VC+YeBG8LDPVLrkSpE6y5vzClyxOZ5aGnwwC46jFlIGyx0CIPHePXORdgULz SiYDet7hkgrVaRE15kzk6otCBWX3H1gXLbYIWsGCgaS24BftGkzIYtyjFLf4UHLKZEAF rxKQ== X-Gm-Message-State: AOAM533orcMjBNebzcvKXe2EVzIkRhVoVpa6JDPYJdRCwPNIMa+PNlkQ IbTjUIeH5EJV+yv82W6LBqKyNQ== X-Google-Smtp-Source: ABdhPJzH/K2NQQ2rv61OJWPAnFYGeM8y8y32U0bjShreSrArNp7+PSoZt2khzLblWMU0Eg0n23fgQA== X-Received: by 2002:a17:907:ab9:: with SMTP id bz25mr24488816ejc.39.1591699659825; Tue, 09 Jun 2020 03:47:39 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:39 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov Subject: [PATCH v3 3/7] dev_printk: Add dev_dbg_level macro over dynamic one Date: Tue, 9 Jun 2020 13:46:00 +0300 Message-Id: <20200609104604.1594-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add dev_dbg_level macro wrapper over dynamic debug one for dev_dbg variants. Signed-off-by: Stanimir Varbanov --- include/linux/dev_printk.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h index 7b50551833e1..d639dc60d84d 100644 --- a/include/linux/dev_printk.h +++ b/include/linux/dev_printk.h @@ -112,15 +112,24 @@ void _dev_info(const struct device *dev, const char *fmt, ...) #if defined(CONFIG_DYNAMIC_DEBUG) #define dev_dbg(dev, fmt, ...) \ dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__) +#define dev_dbg_level(dev, lvl, fmt, ...) \ + dynamic_dev_dbg_level(dev, lvl, dev_fmt(fmt), ##__VA_ARGS__) #elif defined(DEBUG) #define dev_dbg(dev, fmt, ...) \ dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) +#define dev_dbg_level(dev, lvl, fmt, ...) \ + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) #else #define dev_dbg(dev, fmt, ...) \ ({ \ if (0) \ dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ }) +#define dev_dbg_level(dev, lvl, fmt, ...) \ +({ \ + if (0) \ + dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ +}) #endif #ifdef CONFIG_PRINTK From patchwork Tue Jun 9 10:46:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14DCD913 for ; Tue, 9 Jun 2020 10:49:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFCC4207F9 for ; Tue, 9 Jun 2020 10:49:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q35TGCGg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbgFIKtf (ORCPT ); Tue, 9 Jun 2020 06:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728893AbgFIKrt (ORCPT ); Tue, 9 Jun 2020 06:47:49 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20FC3C008635 for ; Tue, 9 Jun 2020 03:47:43 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id x1so21785118ejd.8 for ; Tue, 09 Jun 2020 03:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nJBKYN0yMS8AJgBotdxC1qOHMAr254b0bdL2BOSVBX8=; b=q35TGCGg2mkkEjc2wKlEhVaWy46yXIz+7jdW6N6OkmJb73py5fZiUzxTInYQq0bo+F D97pelWumzAAEdcO8aFTs9/xmUjvxBzF5dgRrVlNpV0QPs4BmirmqiXT60dogulqVqDk /2/8mlHTtSWjanvIyzfTh11muRWkGWkVC1kL+s9b3aXLnqcsYKp4KBrqOK4Gd54yPPet n8MSEc59ajB3s538tDFCCfQD/bylg4wisxrZJMp9ApiHtzVsi+QMSeyoo0xeNqwe8zhv TTgpCcwVcQ1EuY5KZIhARuAFN4xdFt8NdIM8OlX4WRiuMtUaKoYHy93CvXg2HxkKZOv8 12mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nJBKYN0yMS8AJgBotdxC1qOHMAr254b0bdL2BOSVBX8=; b=Z/fKb0M+DH2hB92ud/KwsZqakUV5e5nwZDP1bHC97D13buzNRBzEGGovaZF8fSway3 8V2Str7Y3xgBIXtx0PlhI5UXj0dJk8oliEOvM2pr+ZT+ErbnPHVaJ1/qkjPp8ZLMnuni V66B7el9VkYbqjVKmWuxwaP7dcxmJlF5OzM64a9eFwJejaFa93NdBOMULguNDAjM0ohP Zw65ACjRS3eeFANu8Z7vy2JhWkT2EhBTyvA+KtYdmolGB6vxzGUHPUZQHEVoEf8u1CV8 ZkewLhVVz8qYev0sT2LMMjkCmAdCYb8y6WP0ZEmxKlV5xiVVo0iRnTBabWGtESTcjAPo kVng== X-Gm-Message-State: AOAM532qcXY+JpUZWAV+Lu+3hKeyliPGxPsE3d1ZWClDtCJwhhu1EQUj l1DOLsG/AS3PuKHRrtmSIbKu7y/3vO8= X-Google-Smtp-Source: ABdhPJwbs89Sxz204nqQDsKgXCoF+iaDYcP3btNQRBahLuS6eOL/DHBbG2RDImrJGYxnwGfYKSDVQg== X-Received: by 2002:a17:906:e247:: with SMTP id gq7mr24263420ejb.107.1591699661849; Tue, 09 Jun 2020 03:47:41 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:41 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov Subject: [PATCH v3 4/7] printk: Add pr_debug_level macro over dynamic one Date: Tue, 9 Jun 2020 13:46:01 +0300 Message-Id: <20200609104604.1594-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Introduce new pr_debug_level macro over dynamic_debug level one to allow dynamic debugging to show only important messages. Signed-off-by: Stanimir Varbanov --- include/linux/printk.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/printk.h b/include/linux/printk.h index ceea84aa705b..2a6eca56010f 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -416,12 +416,18 @@ extern int kptr_restrict; */ #define pr_debug(fmt, ...) \ dynamic_pr_debug(fmt, ##__VA_ARGS__) +#define pr_debug_level(lvl, fmt, ...) \ + dynamic_pr_debug_level(lvl, fmt, ##__VA_ARGS__) #elif defined(DEBUG) #define pr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_debug_level(lvl, fmt, ...) \ + printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_debug_level(lvl, fmt, ...) \ + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #endif /* From patchwork Tue Jun 9 10:46:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D0741391 for ; Tue, 9 Jun 2020 10:48:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BBAC207C3 for ; Tue, 9 Jun 2020 10:48:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UPvX5QPG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbgFIKsS (ORCPT ); Tue, 9 Jun 2020 06:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728906AbgFIKrz (ORCPT ); Tue, 9 Jun 2020 06:47:55 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C552C00863B for ; Tue, 9 Jun 2020 03:47:45 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id p18so15924305eds.7 for ; Tue, 09 Jun 2020 03:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KgK4P2m0HWbcss1X1BSEkxtN1Ke/4iUpNFB9xpmQCOg=; b=UPvX5QPGLBD6wvTceu7r+wBSYknWrZ9OGRE9Zsl1g3in+7vsnsuoDklsiQJvGe//YE 4hp574BPc7X4I70eobXw2nqhV1cp4ZVml9EZKW+ssvr0HYPdUT2gOYlNmU03rEfZ09dy UrosjQag9MDC2HScC/txdU/oi9AsxXODKDZdc8MgzX1qiCtvVf8hfimibs725xMslHRN kqHri+t64zKu4DE+9m9rlqW523rF8qoQP0EhH4GM17uui6B9dx1lP/yllSCGSHz56a7L oNSz7+n+3zEhU8wVrL86XpV4bqhvQ6LRu39MQYd/yuVod/e5ELFg7Jn1cnOaUvR++hW7 EM1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KgK4P2m0HWbcss1X1BSEkxtN1Ke/4iUpNFB9xpmQCOg=; b=JIMR3HS53MWm5+JqOAJL6/qIuBDMiYvJi1I1lcawXVzd4mWkaw3MYv+YqUFtf6K3Eq nKWsXxgjgVFoTpHREOHwk1v5uTwzoI5VMfxDfT6ZkAqraXaDrfsxBgJnG30wkNLrHnfN XyCJKnFi7iMWqRbRO/88uTWMDlkx7lfLflGsr9kZJPLsJGmXSub3OKWRJttnHZRzE/IY yy0xABx6QjKUneojl1dCFHt3ZJ/OgQOxTUNvKsjS/iGvZ3auwxcDhDdaloS/ykyFvQ0J iBbEMJnJaHMrPJkTPuMOjdzTvKd3arTdyCLdG/VmmIma054rS+lkGBPCz1z5jAP6Jhwy GAvg== X-Gm-Message-State: AOAM532qgxgU+rEVsP5gox3VtQZSaujwxpK4YAotBRwVNNVSp0ViSsl1 blOXozUPn0yTkw73mh1dgiGO2Q== X-Google-Smtp-Source: ABdhPJzhW/FuUGYzWYiWQfrwNgrP7hBIs7fJIRdVHuyLuLXWjZ/RasdGZG4rvQtmuhDFDz63vVvStA== X-Received: by 2002:aa7:da17:: with SMTP id r23mr27104020eds.261.1591699664011; Tue, 09 Jun 2020 03:47:44 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:43 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov Subject: [PATCH v3 5/7] venus: Add debugfs interface to set firmware log level Date: Tue, 9 Jun 2020 13:46:02 +0300 Message-Id: <20200609104604.1594-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This will be useful when debugging specific issues related to firmware HFI interface. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/Makefile | 2 +- drivers/media/platform/qcom/venus/core.c | 5 ++++ drivers/media/platform/qcom/venus/core.h | 3 +++ drivers/media/platform/qcom/venus/dbgfs.c | 26 +++++++++++++++++++ drivers/media/platform/qcom/venus/dbgfs.h | 12 +++++++++ drivers/media/platform/qcom/venus/hfi_venus.c | 7 ++++- 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 drivers/media/platform/qcom/venus/dbgfs.c create mode 100644 drivers/media/platform/qcom/venus/dbgfs.h diff --git a/drivers/media/platform/qcom/venus/Makefile b/drivers/media/platform/qcom/venus/Makefile index 64af0bc1edae..dfc636865709 100644 --- a/drivers/media/platform/qcom/venus/Makefile +++ b/drivers/media/platform/qcom/venus/Makefile @@ -3,7 +3,7 @@ venus-core-objs += core.o helpers.o firmware.o \ hfi_venus.o hfi_msgs.o hfi_cmds.o hfi.o \ - hfi_parser.o pm_helpers.o + hfi_parser.o pm_helpers.o dbgfs.o venus-dec-objs += vdec.o vdec_ctrls.o venus-enc-objs += venc.o venc_ctrls.o diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 203c6538044f..bbb394ca4175 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -290,6 +290,10 @@ static int venus_probe(struct platform_device *pdev) if (ret) goto err_dev_unregister; + ret = venus_dbgfs_init(core); + if (ret) + goto err_dev_unregister; + return 0; err_dev_unregister: @@ -337,6 +341,7 @@ static int venus_remove(struct platform_device *pdev) v4l2_device_unregister(&core->v4l2_dev); mutex_destroy(&core->pm_lock); mutex_destroy(&core->lock); + venus_dbgfs_deinit(core); return ret; } diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 7118612673c9..b48782f9aa95 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -12,6 +12,7 @@ #include #include +#include "dbgfs.h" #include "hfi.h" #define VIDC_CLKS_NUM_MAX 4 @@ -136,6 +137,7 @@ struct venus_caps { * @priv: a private filed for HFI operations * @ops: the core HFI operations * @work: a delayed work for handling system fatal error + * @root: debugfs root directory */ struct venus_core { void __iomem *base; @@ -185,6 +187,7 @@ struct venus_core { unsigned int codecs_count; unsigned int core0_usage_count; unsigned int core1_usage_count; + struct dentry *root; }; struct vdec_controls { diff --git a/drivers/media/platform/qcom/venus/dbgfs.c b/drivers/media/platform/qcom/venus/dbgfs.c new file mode 100644 index 000000000000..a2465fe8e20b --- /dev/null +++ b/drivers/media/platform/qcom/venus/dbgfs.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2020 Linaro Ltd. + */ + +#include + +#include "core.h" + +extern int venus_fw_debug; + +int venus_dbgfs_init(struct venus_core *core) +{ + core->root = debugfs_create_dir("venus", NULL); + if (IS_ERR(core->root)) + return IS_ERR(core->root); + + debugfs_create_x32("fw_level", 0644, core->root, &venus_fw_debug); + + return 0; +} + +void venus_dbgfs_deinit(struct venus_core *core) +{ + debugfs_remove_recursive(core->root); +} diff --git a/drivers/media/platform/qcom/venus/dbgfs.h b/drivers/media/platform/qcom/venus/dbgfs.h new file mode 100644 index 000000000000..4e35bd7db15f --- /dev/null +++ b/drivers/media/platform/qcom/venus/dbgfs.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2020 Linaro Ltd. */ + +#ifndef __VENUS_DBGFS_H__ +#define __VENUS_DBGFS_H__ + +struct venus_core; + +int venus_dbgfs_init(struct venus_core *core); +void venus_dbgfs_deinit(struct venus_core *core); + +#endif diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 0d8855014ab3..3a04b08ab85a 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -130,7 +130,7 @@ struct venus_hfi_device { }; static bool venus_pkt_debug; -static int venus_fw_debug = HFI_DEBUG_MSG_ERROR | HFI_DEBUG_MSG_FATAL; +int venus_fw_debug = HFI_DEBUG_MSG_ERROR | HFI_DEBUG_MSG_FATAL; static bool venus_sys_idle_indicator; static bool venus_fw_low_power_mode = true; static int venus_hw_rsp_timeout = 1000; @@ -1130,9 +1130,14 @@ static int venus_session_init(struct venus_inst *inst, u32 session_type, u32 codec) { struct venus_hfi_device *hdev = to_hfi_priv(inst->core); + struct device *dev = hdev->core->dev; struct hfi_session_init_pkt pkt; int ret; + ret = venus_sys_set_debug(hdev, venus_fw_debug); + if (ret) + dev_warn(dev, "setting fw debug msg ON failed (%d)\n", ret); + ret = pkt_session_init(&pkt, inst, session_type, codec); if (ret) goto err; From patchwork Tue Jun 9 10:46:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC7021391 for ; Tue, 9 Jun 2020 10:49:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A69B020812 for ; Tue, 9 Jun 2020 10:49:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QqlwZZ1p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728104AbgFIKtE (ORCPT ); Tue, 9 Jun 2020 06:49:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728025AbgFIKsD (ORCPT ); Tue, 9 Jun 2020 06:48:03 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3410BC0085C0 for ; Tue, 9 Jun 2020 03:47:48 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id c35so15970679edf.5 for ; Tue, 09 Jun 2020 03:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/vhjcAyaSP+fFENsTVdne6RaJjcWYPGb/KpPSiQkDDk=; b=QqlwZZ1pt4CJ76xcslyUeKUhDrISzZkvnFfW1P4Y59RwsQWGgEzTm3KnKMtrIr6r0g CDO2ROEnmzkjVthDV+ivBF737BGpfIHaMxLuTJ1vZ/AcZkf0DqzfcTei6jW5L++iYYSU ntsX8bxdWFrIrWfGz1mrfSoI3dvZK+ofHWzXeiigGsN0MPS4SdMP1koT/G6z8DnlYR6r Gls/Z7nhk4qGtMGEtuWPWr5Xup+47bQO4hnLNnZIsw/LUbCQ/8R+58rnD/X7f9j1Coy4 S0Ed+unKDncvCs9X9OU++T79GBqLf7lUnBmMOvBeXlbteLsp7vjlD5eyTP1hUKfopGV4 7KIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/vhjcAyaSP+fFENsTVdne6RaJjcWYPGb/KpPSiQkDDk=; b=XSgo/bfKdD4tI99VaEoFmHkLCdBsaaux2GLgP5OBZEQAe8Z8vRZ7lo9T205t2hwjGj DFOa1/Y/e0sEf3hnvwU6ZfhmuufY7Z3SC0JxoaAYgK0guKmVMDZ9tvFWBKk/tl9baLgt IUkzLRVA8trZdKbdBhF1a9Bzj/mVm2SlIafh6tkEL6buJJKmvm6L0PKswEdjHU3R1+ZJ vYsENm8Xxi0BPGbyQE5rTAoJPsHg+ay4x4yCiwbDOdeImfPkC50Y33SSdN55FkufmJFO uFDl6AlD7958Y41KlGEtr1jOqliRLtrl2w/I0qEqLU0OQUENrb0INYFByo01BuflhDew /Q2Q== X-Gm-Message-State: AOAM530uTUhClIpNcXTIt0zvYYj3FLAwJFhKzVMTFVhm6v2d7a9yeNd2 mcs6NWxQdoihQjLlryD4vbPgseuPvqc= X-Google-Smtp-Source: ABdhPJwUX9lI9Wae9nHSZ+xDR8S5SLSENhJDrnz9nyVJrVOuyKuIbVlT38HJYwxLDZuWfMZb4T1P5g== X-Received: by 2002:aa7:c6d1:: with SMTP id b17mr27564357eds.39.1591699666029; Tue, 09 Jun 2020 03:47:46 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:45 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov Subject: [PATCH v3 6/7] venus: Make debug infrastructure more flexible Date: Tue, 9 Jun 2020 13:46:03 +0300 Message-Id: <20200609104604.1594-7-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Here we introduce few debug macros with levels (low, medium and high) and debug macro for firmware. Enabling the particular level will be done by dynamic debug with levels. For example to enable debug messages with low level: echo 'module venus_dec level 0x01 +p' > debugfs/dynamic_debug/control If you want to enable all levels: echo 'module venus_dec level 0x07 +p' > debugfs/dynamic_debug/control All the features which dynamic debugging provide are preserved. And finaly all dev_dbg are translated to VDBGX with appropriate debug levels. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 5 ++ drivers/media/platform/qcom/venus/helpers.c | 2 +- drivers/media/platform/qcom/venus/hfi_msgs.c | 30 ++++----- drivers/media/platform/qcom/venus/hfi_venus.c | 20 ++++-- .../media/platform/qcom/venus/pm_helpers.c | 3 +- drivers/media/platform/qcom/venus/vdec.c | 63 +++++++++++++++++-- drivers/media/platform/qcom/venus/venc.c | 4 ++ 7 files changed, 96 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index b48782f9aa95..63eabf5ff96d 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -15,6 +15,11 @@ #include "dbgfs.h" #include "hfi.h" +#define VDBGL(fmt, args...) pr_debug_level(0x01, fmt, ##args) +#define VDBGM(fmt, args...) pr_debug_level(0x02, fmt, ##args) +#define VDBGH(fmt, args...) pr_debug_level(0x04, fmt, ##args) +#define VDBGFW(fmt, args...) pr_debug_level(0x08, fmt, ##args) + #define VIDC_CLKS_NUM_MAX 4 #define VIDC_VCODEC_CLKS_NUM_MAX 2 #define VIDC_PMDOMAINS_NUM_MAX 3 diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 0143af7822b2..115a9a2af1d6 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -396,7 +396,7 @@ put_ts_metadata(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf) } if (slot == -1) { - dev_dbg(inst->core->dev, "%s: no free slot\n", __func__); + VDBGH("no free slot for timestamp\n"); return; } diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index 279a9d6fe737..36986d402c96 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -138,10 +138,9 @@ static void event_sys_error(struct venus_core *core, u32 event, struct hfi_msg_event_notify_pkt *pkt) { if (pkt) - dev_dbg(core->dev, - "sys error (session id:%x, data1:%x, data2:%x)\n", - pkt->shdr.session_id, pkt->event_data1, - pkt->event_data2); + VDBGH("sys error (session id: %x, data1: %x, data2: %x)\n", + pkt->shdr.session_id, pkt->event_data1, + pkt->event_data2); core->core_ops->event_notify(core, event); } @@ -152,8 +151,8 @@ event_session_error(struct venus_core *core, struct venus_inst *inst, { struct device *dev = core->dev; - dev_dbg(dev, "session error: event id:%x, session id:%x\n", - pkt->event_data1, pkt->shdr.session_id); + VDBGH("session error: event id: %x, session id: %x\n", + pkt->event_data1, pkt->shdr.session_id); if (!inst) return; @@ -236,8 +235,7 @@ static void hfi_sys_init_done(struct venus_core *core, struct venus_inst *inst, } static void -sys_get_prop_image_version(struct device *dev, - struct hfi_msg_sys_property_info_pkt *pkt) +sys_get_prop_image_version(struct hfi_msg_sys_property_info_pkt *pkt) { int req_bytes; @@ -247,26 +245,25 @@ sys_get_prop_image_version(struct device *dev, /* bad packet */ return; - dev_dbg(dev, "F/W version: %s\n", (u8 *)&pkt->data[1]); + VDBGL("F/W version: %s\n", (u8 *)&pkt->data[1]); } static void hfi_sys_property_info(struct venus_core *core, struct venus_inst *inst, void *packet) { struct hfi_msg_sys_property_info_pkt *pkt = packet; - struct device *dev = core->dev; if (!pkt->num_properties) { - dev_dbg(dev, "%s: no properties\n", __func__); + VDBGM("no properties\n"); return; } switch (pkt->data[0]) { case HFI_PROPERTY_SYS_IMAGE_VERSION: - sys_get_prop_image_version(dev, pkt); + sys_get_prop_image_version(pkt); break; default: - dev_dbg(dev, "%s: unknown property data\n", __func__); + VDBGM("unknown property data\n"); break; } } @@ -297,7 +294,7 @@ static void hfi_sys_ping_done(struct venus_core *core, struct venus_inst *inst, static void hfi_sys_idle_done(struct venus_core *core, struct venus_inst *inst, void *packet) { - dev_dbg(core->dev, "sys idle\n"); + VDBGL("sys idle\n"); } static void hfi_sys_pc_prepare_done(struct venus_core *core, @@ -305,7 +302,7 @@ static void hfi_sys_pc_prepare_done(struct venus_core *core, { struct hfi_msg_sys_pc_prep_done_pkt *pkt = packet; - dev_dbg(core->dev, "pc prepare done (error %x)\n", pkt->error_type); + VDBGL("pc prepare done (error %x)\n", pkt->error_type); } static unsigned int @@ -387,8 +384,7 @@ static void hfi_session_prop_info(struct venus_core *core, case HFI_PROPERTY_CONFIG_VDEC_ENTROPY: break; default: - dev_dbg(dev, "%s: unknown property id:%x\n", __func__, - pkt->data[0]); + VDBGH("unknown property id: %x\n", pkt->data[0]); return; } diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 3a04b08ab85a..9aef62f9b59a 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -467,7 +467,6 @@ static int venus_boot_core(struct venus_hfi_device *hdev) static u32 venus_hwversion(struct venus_hfi_device *hdev) { - struct device *dev = hdev->core->dev; u32 ver = venus_readl(hdev, WRAPPER_HW_VERSION); u32 major, minor, step; @@ -477,7 +476,7 @@ static u32 venus_hwversion(struct venus_hfi_device *hdev) minor = minor >> WRAPPER_HW_VERSION_MINOR_VERSION_SHIFT; step = ver & WRAPPER_HW_VERSION_STEP_VERSION_MASK; - dev_dbg(dev, "venus hw version %x.%x.%x\n", major, minor, step); + VDBGL("venus hw version %x.%x.%x\n", major, minor, step); return major; } @@ -897,7 +896,6 @@ static int venus_session_cmd(struct venus_inst *inst, u32 pkt_type) static void venus_flush_debug_queue(struct venus_hfi_device *hdev) { - struct device *dev = hdev->core->dev; void *packet = hdev->dbg_buf; while (!venus_iface_dbgq_read(hdev, packet)) { @@ -906,7 +904,7 @@ static void venus_flush_debug_queue(struct venus_hfi_device *hdev) if (pkt->hdr.pkt_type != HFI_MSG_SYS_COV) { struct hfi_msg_sys_debug_pkt *pkt = packet; - dev_dbg(dev, "%s", pkt->msg_data); + VDBGFW("%s", pkt->msg_data); } } } @@ -1230,6 +1228,11 @@ static int venus_session_etb(struct venus_inst *inst, ret = -EINVAL; } + VDBGM("etb: %s: itag: %u, flen: %u, addr: %x\n", + session_type == VIDC_SESSION_TYPE_DEC ? "dec" : "enc", + in_frame->clnt_data, in_frame->filled_len, + in_frame->device_addr); + return ret; } @@ -1244,7 +1247,14 @@ static int venus_session_ftb(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt); + + VDBGM("ftb: %s: otag: %u, flen: %u, addr: %x\n", + inst->session_type == VIDC_SESSION_TYPE_DEC ? "dec" : "enc", + out_frame->clnt_data, out_frame->filled_len, + out_frame->device_addr); + + return ret; } static int venus_session_set_buffers(struct venus_inst *inst, diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index abf93158857b..ec7394615ef8 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -212,8 +212,7 @@ static int load_scale_bw(struct venus_core *core) } mutex_unlock(&core->lock); - dev_dbg(core->dev, "total: avg_bw: %u, peak_bw: %u\n", - total_avg, total_peak); + VDBGL("total: avg_bw: %u, peak_bw: %u\n", total_avg, total_peak); return icc_set_bw(core->video_path, total_avg, total_peak); } diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 7c4c483d5438..7959e452fbf3 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -225,7 +225,7 @@ static int vdec_check_src_change(struct venus_inst *inst) if (!(inst->codec_state == VENUS_DEC_STATE_CAPTURE_SETUP) || !inst->reconfig) - dev_dbg(inst->core->dev, "%s: wrong state\n", __func__); + VDBGM("wrong codec state %u\n", inst->codec_state); done: return 0; @@ -790,6 +790,10 @@ static int vdec_queue_setup(struct vb2_queue *q, unsigned int in_num, out_num; int ret = 0; + VDBGM("vb2: queue_setup: %s: begin (codec_state: %u)\n", + V4L2_TYPE_IS_OUTPUT(q->type) ? "out" : "cap", + inst->codec_state); + if (*num_planes) { unsigned int output_buf_size = venus_helper_get_opb_size(inst); @@ -859,6 +863,10 @@ static int vdec_queue_setup(struct vb2_queue *q, break; } + VDBGM("vb2: queue_setup: %s: end (codec_state: %u, ret: %d)\n", + V4L2_TYPE_IS_OUTPUT(q->type) ? "out" : "cap", + inst->codec_state, ret); + return ret; put_power: @@ -897,6 +905,8 @@ static int vdec_start_capture(struct venus_inst *inst) { int ret; + VDBGM("on: cap: begin (codec_state: %u)\n", inst->codec_state); + if (!inst->streamon_out) return 0; @@ -955,11 +965,16 @@ static int vdec_start_capture(struct venus_inst *inst) inst->sequence_cap = 0; inst->reconfig = false; + VDBGM("on: cap: end (codec_state: %u)\n", inst->codec_state); + return 0; free_dpb_bufs: venus_helper_free_dpb_bufs(inst); err: + VDBGM("on: cap: end (codec_state: %u, ret: %d)\n", + inst->codec_state, ret); + return ret; } @@ -967,6 +982,8 @@ static int vdec_start_output(struct venus_inst *inst) { int ret; + VDBGM("on: out: begin (codec_state: %u)\n", inst->codec_state); + if (inst->codec_state == VENUS_DEC_STATE_SEEK) { ret = venus_helper_process_initial_out_bufs(inst); inst->codec_state = VENUS_DEC_STATE_DECODING; @@ -1015,6 +1032,10 @@ static int vdec_start_output(struct venus_inst *inst) done: inst->streamon_out = 1; + + VDBGM("on: out: end (codec_state: %u, ret: %d)\n", + inst->codec_state, ret); + return ret; } @@ -1069,6 +1090,8 @@ static int vdec_stop_capture(struct venus_inst *inst) { int ret = 0; + VDBGM("off: cap: begin (codec_state: %u)\n", inst->codec_state); + switch (inst->codec_state) { case VENUS_DEC_STATE_DECODING: ret = hfi_session_flush(inst, HFI_FLUSH_ALL, true); @@ -1090,6 +1113,9 @@ static int vdec_stop_capture(struct venus_inst *inst) INIT_LIST_HEAD(&inst->registeredbufs); + VDBGM("off: cap: end (codec_state: %u, ret: %d)\n", + inst->codec_state, ret); + return ret; } @@ -1097,6 +1123,8 @@ static int vdec_stop_output(struct venus_inst *inst) { int ret = 0; + VDBGM("off: out: begin (codec_state: %u)\n", inst->codec_state); + switch (inst->codec_state) { case VENUS_DEC_STATE_DECODING: case VENUS_DEC_STATE_DRAIN: @@ -1112,6 +1140,9 @@ static int vdec_stop_output(struct venus_inst *inst) break; } + VDBGM("off: out: end (codec_state: %u, ret %d)\n", + inst->codec_state, ret); + return ret; } @@ -1146,6 +1177,8 @@ static void vdec_session_release(struct venus_inst *inst) struct venus_core *core = inst->core; int ret, abort = 0; + VDBGM("rel: begin (codec_state: %u)\n", inst->codec_state); + vdec_pm_get(inst); mutex_lock(&inst->lock); @@ -1175,15 +1208,23 @@ static void vdec_session_release(struct venus_inst *inst) venus_pm_release_core(inst); vdec_pm_put(inst, false); + + VDBGM("rel: end (codec_state: %u)\n", inst->codec_state); } static int vdec_buf_init(struct vb2_buffer *vb) { struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + int ret; inst->buf_count++; - return venus_helper_vb2_buf_init(vb); + ret = venus_helper_vb2_buf_init(vb); + + VDBGM("vb2: buf_init: %s: done (codec_state: %u)\n", + V4L2_TYPE_IS_OUTPUT(vb->type) ? "out" : "cap", inst->codec_state); + + return ret; } static void vdec_buf_cleanup(struct vb2_buffer *vb) @@ -1193,6 +1234,9 @@ static void vdec_buf_cleanup(struct vb2_buffer *vb) inst->buf_count--; if (!inst->buf_count) vdec_session_release(inst); + + VDBGM("vb2: buf_cleanup: %s: done (codec_state: %u)\n", + V4L2_TYPE_IS_OUTPUT(vb->type) ? "out" : "cap", inst->codec_state); } static void vdec_vb2_buf_queue(struct vb2_buffer *vb) @@ -1281,6 +1325,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, } v4l2_m2m_buf_done(vbuf, state); + + VDBGH("done: %s, idx: %02u, flen: %08u, flags: hfi: %08x, v4l2: %08x\n", + V4L2_TYPE_IS_OUTPUT(type) ? "out" : "cap", + vbuf->vb2_buf.index, bytesused, hfi_flags, vbuf->flags); } static void vdec_event_change(struct venus_inst *inst, @@ -1289,7 +1337,6 @@ static void vdec_event_change(struct venus_inst *inst, static const struct v4l2_event ev = { .type = V4L2_EVENT_SOURCE_CHANGE, .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION }; - struct device *dev = inst->core->dev_dec; struct v4l2_format format = {}; mutex_lock(&inst->lock); @@ -1310,8 +1357,12 @@ static void vdec_event_change(struct venus_inst *inst, if (inst->bit_depth != ev_data->bit_depth) inst->bit_depth = ev_data->bit_depth; - dev_dbg(dev, "event %s sufficient resources (%ux%u)\n", - sufficient ? "" : "not", ev_data->width, ev_data->height); + VDBGH("event: %s sufficient resources (%ux%u)\n", + sufficient ? "" : "not", ev_data->width, ev_data->height); + + if (ev_data->buf_count) + VDBGH("event: buf_count: %u, old: %u\n", + ev_data->buf_count, inst->num_output_bufs); if (sufficient) { hfi_session_continue(inst); @@ -1344,7 +1395,7 @@ static void vdec_event_change(struct venus_inst *inst, ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, false); if (ret) - dev_dbg(dev, "flush output error %d\n", ret); + VDBGH("flush output error (%d)\n", ret); } inst->reconfig = true; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index feed648550d1..c591d00ee0a7 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1074,6 +1074,10 @@ static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, } v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); + + VDBGH("done: %s, idx: %02u, flen: %08u, flags: hfi: %08x, v4l2: %08x\n", + V4L2_TYPE_IS_OUTPUT(type) ? "out" : "cap", + vbuf->vb2_buf.index, bytesused, hfi_flags, vbuf->flags); } static void venc_event_notify(struct venus_inst *inst, u32 event, From patchwork Tue Jun 9 10:46:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11595183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B77C6913 for ; Tue, 9 Jun 2020 10:48:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97757207C3 for ; Tue, 9 Jun 2020 10:48:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iITZQzep" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgFIKs4 (ORCPT ); Tue, 9 Jun 2020 06:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728915AbgFIKsK (ORCPT ); Tue, 9 Jun 2020 06:48:10 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E1CDC0085C5 for ; Tue, 9 Jun 2020 03:47:49 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id n24so21826067ejd.0 for ; Tue, 09 Jun 2020 03:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Oemz0y6Halgxd9K+njjbf/y07mF1lR81JfjGGt4j8Io=; b=iITZQzepYu0FYulcuAhfuDWi/16M56AofW8Jkk4EXje7LbpCfGgXUXt4mVAD9S9GAw P+KF91qsLae1yBZk64Eg+7MySqXAxm70J5T+GDaXmvB6yqpm1YwWgnx0eILvxCZQa4MO X2ZWDcSlKGJFb11dXXX6js7YuCRCGcjtoaxJFWBRsMondULfk44oem6UjT7ztiVd3pyU szY/KiRL3JZp7Io/US70tlqqcMRIAEfqU8yow87c1sn10HkU9ATAn19ec8IL4Jx1OUil GB2SP9aX8K7qOmh+/5PsYzLi1cxu80fu6P2jMFuHf47QqwLcm+UOIaNkIVo62p22r1QP dvVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Oemz0y6Halgxd9K+njjbf/y07mF1lR81JfjGGt4j8Io=; b=HUOdCDbj6CIyP3U7B2WJUd+qmfb/XEZexARxaziYEHSnXqJh1POoxqeF+MHeuwmgUM u+eFtG+msEoqNYWZNv/Q32XkKHrTbXi9n1XW3pqvDlbJUk616FuYIyeJxx+6nKn4gfeE lBv8fB9jO9/IzBU/2AEzGrrjMdP7enfqBFyk3VRxfbgO1W8H/hnDbrV2BDEoTij9vSqL pZDztBLtFCQb2sci26Pol9qGSRfL5xcnF7YRMW/U8cjYWzFZoqwMAwoMj2SCxFG2evA9 d7AqaPtNwhsKiqZo3hGt+tMQX3DBj1corddXxQa2uvVUY6Y1r2C8RDJcJfOpVzGGEIOc 7IOQ== X-Gm-Message-State: AOAM530bicBwpRyz3gAIO1b+kbC0mkcdIiRdQ66oDii34B7yb3A3CiIJ 5fzGA79HMi1Ihz+iIaOZF8vvCQ== X-Google-Smtp-Source: ABdhPJwmQrjonfoCvhtTfzguHCYRItN0w74Xgjx0CUyTWFohneAUdPJcTlC7X6PECCEadzOmV1lOkw== X-Received: by 2002:a17:906:b097:: with SMTP id x23mr24627789ejy.227.1591699667897; Tue, 09 Jun 2020 03:47:47 -0700 (PDT) Received: from localhost.localdomain (hst-221-69.medicom.bg. [84.238.221.69]) by smtp.gmail.com with ESMTPSA id qt19sm12267763ejb.14.2020.06.09.03.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 03:47:47 -0700 (PDT) From: Stanimir Varbanov To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Joe Perches , Greg Kroah-Hartman , Jason Baron , Stanimir Varbanov Subject: [PATCH v3 7/7] venus: Add a debugfs file for SSR trigger Date: Tue, 9 Jun 2020 13:46:04 +0300 Message-Id: <20200609104604.1594-8-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609104604.1594-1-stanimir.varbanov@linaro.org> References: <20200609104604.1594-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The SSR (SubSystem Restart) is used to simulate an error on FW side of Venus. We support following type of triggers - fatal error, div by zero and watchdog IRQ. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/dbgfs.c | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/media/platform/qcom/venus/dbgfs.c b/drivers/media/platform/qcom/venus/dbgfs.c index a2465fe8e20b..59d52e5af64a 100644 --- a/drivers/media/platform/qcom/venus/dbgfs.c +++ b/drivers/media/platform/qcom/venus/dbgfs.c @@ -9,6 +9,35 @@ extern int venus_fw_debug; +static int trigger_ssr_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +static ssize_t trigger_ssr_write(struct file *filp, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct venus_core *core = filp->private_data; + u32 ssr_type; + int ret; + + ret = kstrtou32_from_user(buf, count, 4, &ssr_type); + if (ret) + return ret; + + ret = hfi_core_trigger_ssr(core, ssr_type); + if (ret < 0) + return ret; + + return count; +} + +static const struct file_operations ssr_fops = { + .open = trigger_ssr_open, + .write = trigger_ssr_write, +}; + int venus_dbgfs_init(struct venus_core *core) { core->root = debugfs_create_dir("venus", NULL); @@ -17,6 +46,8 @@ int venus_dbgfs_init(struct venus_core *core) debugfs_create_x32("fw_level", 0644, core->root, &venus_fw_debug); + debugfs_create_file("trigger_ssr", 0200, core->root, core, &ssr_fops); + return 0; }