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: 11595165 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 7224B159A for ; Tue, 9 Jun 2020 10:47:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57A2220812 for ; Tue, 9 Jun 2020 10:47:54 +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 S1728894AbgFIKrt (ORCPT ); Tue, 9 Jun 2020 06:47:49 -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 S1728299AbgFIKrh (ORCPT ); Tue, 9 Jun 2020 06:47:37 -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 71E7FC08C5C8 for ; Tue, 9 Jun 2020 03:47:36 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id g1so15936355edv.6 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=J0GW9NxFCB18tl0TVHYbePeNc/vRFDhZJMJtVuuWHp3bJkO/+y69/MrD1sDJZ0pWnn gFZr78T/MZrFDsdXrzxXTjFolRMkkb4/1oBq2enA9G7FBjkfq30xu2kBacBPmJ5xyZov 31LSmprZKr6ioqGiWVqe1Qtjusk5wWynLD8dzfft1SNw9dHnQEUtekn+PuePvG0iIqGY lAsgXeyr5FKqPO4wmUFNuZPlnvZP4cis/3SW5Ag5sW3ntCPxp3DfZSPiVF0KI8poYzBy cc3/SbE5CLct4JtaAFYoCRJlG9rtxJF/I8VqwvRk/423lnl0nyLJRbQdstikKlN20o6K 5xEw== X-Gm-Message-State: AOAM533KGiLekH3/r7pHTIIJ2gKjulWhi4ieJ0hS35lpqY0wFFnmeoda TpmfzSQhHtQoFh+KdhPHldirnw== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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: 11595215 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 241B41391 for ; Tue, 9 Jun 2020 10:50:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF14D2081A for ; Tue, 9 Jun 2020 10:50:01 +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 S1728916AbgFIKt4 (ORCPT ); Tue, 9 Jun 2020 06:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728864AbgFIKrl (ORCPT ); Tue, 9 Jun 2020 06:47:41 -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 DD42AC08C5C4 for ; Tue, 9 Jun 2020 03:47:38 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id gl26so21803735ejb.11 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=YPC0oGWvuxwkugwaEB5G/13zvJ7lciHBuwn85PEEDOCBA6MYORc/meBx3mU/Nu0TfB j9Ua0oFVuu3KXBB9qZ/UQ+Deb559I2yhjlO/dHnIHJ2CumeWR42FypHemODp4rF9JYwf Hb9zn1CNhb4BGzKqOxo7mueCBUASgaQniqBu9QZu+jNTiWq5YZOdWwNMo0ylPbKFiVR9 sa823xpbFZYDKk2ivAeUvisdWqu21Hn5ZYL9+m9WO1NmE3GMlIpF8nKLppNw3Bb48bXK 3sjuAjDxikqbLRODjjpy6+7k49lZ8aK/yP9zeIo76UHmUIgxvmOTHzZktoMViBpTvRPg laDw== X-Gm-Message-State: AOAM530YyXb9s36Wm3kJr+fIekdyIS4rBGtRChpwyeBpzumZikCpLdzl rQakbeXz1Mgf0DOpTmPGlxJ3VqJMRvs= 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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: 11595209 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 6F76F913 for ; Tue, 9 Jun 2020 10:49:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5230B207F9 for ; Tue, 9 Jun 2020 10:49:50 +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 S1728915AbgFIKtr (ORCPT ); Tue, 9 Jun 2020 06:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728314AbgFIKro (ORCPT ); Tue, 9 Jun 2020 06:47:44 -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 0B8B9C00862D for ; Tue, 9 Jun 2020 03:47:41 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id k11so21836437ejr.9 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=JiF/eLKv5xV2sM2iPTdG9FWa7r+i1IfMotmlQPbMRzZC0rhsLbLe8LVdL5ZXFSETGg jhcCY3unhsCqkGT6sy7LOI2ckhZoGW9E8ypgM7mi/b2QJcEZEn6qCbCGLEr2kYiD0EN7 W2zODrrvuc2GQCMh/ppD3SGHUh0RRfC2iFzB+FazW+/VG+xgCUaJ8W5jd6dYjhaJUGUb vovi3ibAhsDsPWENlmL6gwmSDqxQvLEhPnIRcOFdgJ4Hky92mvFprngA1s0dfYyfSgCL CrxGWb/9ofCRxnnovgy0G7n/dIBC49atE/SlTwQX6QC1ustuO2atxL5ZoYGPb3DcYmtO SJ2Q== X-Gm-Message-State: AOAM532mt9z44Ok4vSFI8FRxmpMWkyoRIVls52pcENNHzYVRDVGL4I4Y lxdLC/Q5xGF4h5hHrKQRdK4K+A== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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: 11595199 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 C94281391 for ; Tue, 9 Jun 2020 10:49:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B064B207F9 for ; Tue, 9 Jun 2020 10:49:40 +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 S1728483AbgFIKtg (ORCPT ); Tue, 9 Jun 2020 06:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728888AbgFIKrs (ORCPT ); Tue, 9 Jun 2020 06:47:48 -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 1E823C03E97C for ; Tue, 9 Jun 2020 03:47:43 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id p20so1831685ejd.13 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=TN3HafqQoGj2IWZ85hHYi5SKgkBhbaVOu/6NhE9NDKJ55ENVbXwD3oI4bA7NsZkmst df6Beg9p2ra63K2zhE9+Zu75GcXvjgQDRzp7zN+ooG5ItH/klcW5WV2ieCW11OUWNWgy 5rzy0ZtFnpOWMVJ7zGuaAUouTZVvqbgIcMHTjouKpObYGH30/R+VlYW4Gqd0BaiPYbnI pv8Sx8f6jho36VtfxcGy91dIhoW8oP01F8hx2UawB1gdBQ2MsDE4LiwGED7BeeBuZlgr P74tfVwWbI3+UDcUyYjyX/PCwH4DXBqZvtKSs6S6Vt3OYnLQYqDay5wq6kDKG0NHbSWB T95w== X-Gm-Message-State: AOAM532x75zsPWxV7r+V0V993mtsC7LomcTMNICRAZvOyIelwSGZxxbp x4ooL6/eML7NxgXbuukUo4Rjkg== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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: 11595191 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 6E35C1391 for ; Tue, 9 Jun 2020 10:49:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F7B5207C3 for ; Tue, 9 Jun 2020 10:49:26 +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 S1728524AbgFIKtT (ORCPT ); Tue, 9 Jun 2020 06:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728452AbgFIKr5 (ORCPT ); Tue, 9 Jun 2020 06:47:57 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61882C00863D for ; Tue, 9 Jun 2020 03:47:45 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id q13so15955918edi.3 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=hz1HOfGpNLP9LpAHhoHgkLYUv8jBCHpHNPAX0erUYn2Iq/IitflDrXORzIJtjcfFK9 zIOlbwhJL+/2sqxFnRHLsbwGYk46PzrPcN0GbwaJLxPA24cJt6N/c2MlqSFADnxDnHRG CvwNyA20/APi1JH0hXiLF7H8MqaNlQOzgYb/kkWcwkwzvOnV3mUyw8nQYziDBZYqi+xM ZfsxKC+dX1H8UwpFhCchl2Hl6bY6kGPa0KYkgsC9zOfAD2y2sighUkw/FpEoY4JUTK6j HdcyUShdmReuZCmwIcUsTVybxQaRKy+Jxy/V34fYpMlydQ/IkP1GYbmCQwZ3vSC7e9oa t/+Q== X-Gm-Message-State: AOAM532FSPAHWnBqdXM+q1cJU0x5g6VLQ5joAXYzls+w4WQ4qlM8hhOK ZMx0eXnkmI636NHiVj0cgYf81Q== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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: 11595177 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 48F581391 for ; Tue, 9 Jun 2020 10:48:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F36420814 for ; Tue, 9 Jun 2020 10:48:46 +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 S1728046AbgFIKsm (ORCPT ); Tue, 9 Jun 2020 06:48:42 -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 S1728237AbgFIKsD (ORCPT ); Tue, 9 Jun 2020 06:48:03 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 517D6C0085C1 for ; Tue, 9 Jun 2020 03:47:48 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id g1so15936684edv.6 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=HzL2bUVrCQgwJEVXcGDFNLOZiO6FIcsHCtSp4Xjf+KNusmdDgUATAveFJYUqP3IvRn 8LvUEPN7+TFXhX7M46HrNzVkKlqJFaecj4fQerHOFVGUD/eP08PgEsmPPYU8fS9etAdp qGOa0eZdUGci23yOQuHMEpLgM6Nknlt8jS8S+ACQbXp6C3Jr2Ud0HtEYhh2bh2HnXbOA jxT99lSNAkPwycweb7L70K4y2ggMwRQ3J7EEu6LDt+1BtL/Y2791bn1jdgS6RFFQ0L1q jwhj7jsAPQ/SMsJED3NRM/uG6MKHOnvDJ3EHcMc33e0SCsrUinaorDSL6t5yFW0v5CcL dT3Q== X-Gm-Message-State: AOAM533rcgKhN5KWYTLI5bV3FOwBReBZdRs7742Tuk26bod9pkp7qyR0 xUfHorG882107TOrOxmx1OM5RQ== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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: 11595185 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 C101C913 for ; Tue, 9 Jun 2020 10:49:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C912207C3 for ; Tue, 9 Jun 2020 10:49:03 +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 S1728753AbgFIKsz (ORCPT ); Tue, 9 Jun 2020 06:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728923AbgFIKsL (ORCPT ); Tue, 9 Jun 2020 06:48:11 -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 49F93C0085C8 for ; Tue, 9 Jun 2020 03:47:49 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id mb16so21825382ejb.4 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=Fgd9ABKZlMwqTMb534GvI+jEqdlRM+D5cAcGuFtnN8TZyrP6iXQ9l5tZd0e59cldZy jiarXUHG/tcDf2QBFUaDkyJdh6oW8+bIeupERSuJhL0r6DNOieU5Qm8u3CNLCQr/mnby TS4k+q1+puJHYa+HpX1qjLRG1ZXkeetfKbwmfZcapdOxR2Gy3Zd5lKFKOAjmaFFlkuLS YglVInGTrNfewPeYGG4PgBL8VawTLCXgW996gACkF2exexV6EwYfXTRNqdZVsCQezMC0 /0sc2M6THY4fsvQUKHf898dor0/t/D4vwhHJHHZ5Svt/0t3MwCdReQwD2CQO4ELxhd0/ plFA== X-Gm-Message-State: AOAM530xm/MDsf4XkUJh/nGMngTxD4POlX4ugg8hWgjvkJAQSLZf+8iO /h5bjaQLzkCdZ6/qWZatC4RFyA== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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; }