linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: yhchuang@realtek.com
Cc: kvalo@codeaurora.org, johannes@sipsolutions.net,
	Larry.Finger@lwfinger.net, pkshih@realtek.com,
	tehuang@realtek.com, sgruszka@redhat.com,
	linux-wireless@vger.kernel.org
Subject: Re: [PATCH v4 08/13] rtw88: debug files
Date: Fri, 1 Feb 2019 11:49:40 -0800	[thread overview]
Message-ID: <20190201194938.GA98048@google.com> (raw)
In-Reply-To: <1548820940-15237-9-git-send-email-yhchuang@realtek.com>

Hi,

On Wed, Jan 30, 2019 at 12:02:15PM +0800, yhchuang@realtek.com wrote:
> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
> 
> debug files for Realtek 802.11ac wireless network chips
> 
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> ---
>  drivers/net/wireless/realtek/rtw88/debug.c | 631 +++++++++++++++++++++++++++++
>  drivers/net/wireless/realtek/rtw88/debug.h |  35 ++
>  2 files changed, 666 insertions(+)
>  create mode 100644 drivers/net/wireless/realtek/rtw88/debug.c
>  create mode 100644 drivers/net/wireless/realtek/rtw88/debug.h
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
> new file mode 100644
> index 0000000..d0cb9d3
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/debug.c
> @@ -0,0 +1,631 @@

...

> +#ifdef CONFIG_RTW88_DEBUG
> +
> +void __rtw_dbg(struct rtw_dev *rtwdev, const char *fmt, ...)
> +{
> +	struct va_format vaf = {
> +		.fmt = fmt,
> +	};
> +	va_list args;
> +
> +	va_start(args, fmt);
> +	vaf.va = &args;
> +
> +	if (net_ratelimit())
> +		dev_dbg(rtwdev->dev, "%pV", &vaf);

I understand some questions came up about this dbg() interface
previously, without the most constructive result, but...

...I do find one particular aspect of this interface a little weird: it
has its own separate Kconfig flag, and yet it's still implicitly
dependent on CONFIG_DYNAMIC_DEBUG. Note how dev_dbg() gets completely
stubbed out if !defined(CONFIG_DYNAMIC_DEBUG) && !defined(DEBUG).

I think some other similar loggers end up just using
dev_printk(KERN_DEBUG, ...) for this piece of the equation, so that if
somebody has bothered to enable CONFIG_RTW88_DEBUG, they can be sure
their log messages are at least compiled in.

But then, other drivers that have used dev_printk() *also* have dynamic
methods to enable/disable their dbg-level messages (e.g., with a 'mask'
module parameter, for classifying different types of messages). That
also gives us the option of compiling in the messages while leaving them
disabled for printing by default. IOW, they basically implement a
categorized version of CONFIG_DYNAMIC_DEBUG.

(Also note: my systems generally have DYNAMIC_DEBUG disabled, but we
*do* like to have a few driver-specific debug options enabled for WiFi,
so we can debug problems in the field via runtime enable/disable.)

Altogether, I think this means you should either:

 (a) alias RTW88_DEBUG with DYNAMIC_DEBUG (e.g., RTW88_DEBUG selects or
     depends on DYNAMIC_DEBUG?) or, remove your own special Kconfig
     entirely; or
 (b) implement runtime controls to enable/disable your dbg() messages,
     and do not depend on DYNAMIC_DEBUG

I kinda lean toward (b), since that's how many other WiFi drivers work,
and it prevents me from having to enable all of DYNAMIC_DEBUG (although,
it may be time to reevaluate why Chrome OS has it disabled...probably
just for mild savings on size). It also gives you the option of
classifying your debug messages even further.

Regards,
Brian

> +
> +	va_end(args);
> +}
> +EXPORT_SYMBOL(__rtw_dbg);
> +
> +#endif /* CONFIG_RTW88_DEBUG */
> diff --git a/drivers/net/wireless/realtek/rtw88/debug.h b/drivers/net/wireless/realtek/rtw88/debug.h
> new file mode 100644
> index 0000000..231e4e8
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/debug.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright(c) 2018  Realtek Corporation.
> + */
> +
> +#ifndef __RTW_DEBUG_H
> +#define __RTW_DEBUG_H
> +
> +#ifdef CONFIG_RTW88_DEBUGFS
> +
> +void rtw_debugfs_init(struct rtw_dev *rtwdev);
> +
> +#else
> +
> +static inline void rtw_debugfs_init(struct rtw_dev *rtwdev) {}
> +
> +#endif /* CONFIG_RTW88_DEBUGFS */
> +
> +#ifdef CONFIG_RTW88_DEBUG
> +
> +__printf(2, 3)
> +void __rtw_dbg(struct rtw_dev *rtwdev, const char *fmt, ...);
> +
> +#define rtw_dbg(rtwdev, a...) __rtw_dbg(rtwdev, ##a)
> +
> +#else
> +
> +static inline void rtw_dbg(struct rtw_dev *rtwdev, const char *fmt, ...) {}
> +
> +#endif /* CONFIG_RTW88_DEBUG */
> +
> +#define rtw_info(rtwdev, a...) dev_info(rtwdev->dev, ##a)
> +#define rtw_warn(rtwdev, a...) dev_warn(rtwdev->dev, ##a)
> +#define rtw_err(rtwdev, a...) dev_err(rtwdev->dev, ##a)
> +
> +#endif
> -- 
> 2.7.4
> 

  reply	other threads:[~2019-02-01 19:49 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  4:02 [PATCH v4 00/13] rtw88: mac80211 driver for Realtek 802.11ac wireless network chips yhchuang
2019-01-30  4:02 ` [PATCH v4 01/13] rtw88: main files yhchuang
2019-01-30 16:21   ` Larry Finger
2019-01-31  2:54     ` Tony Chuang
2019-01-30  4:02 ` [PATCH v4 02/13] rtw88: core files yhchuang
2019-01-30  4:02 ` [PATCH v4 03/13] rtw88: hci files yhchuang
2019-01-31 22:36   ` Brian Norris
2019-02-12  6:18     ` Tony Chuang
2019-02-12 22:04       ` Brian Norris
2019-02-13  8:08         ` Tony Chuang
2019-02-13 11:08       ` Tony Chuang
2019-02-13 19:21         ` Brian Norris
2019-02-14 23:05     ` Grant Grundler
2019-02-20 11:19       ` Tony Chuang
2019-03-22 14:36         ` Brian Norris
2019-02-08 22:28   ` Brian Norris
2019-02-11  6:15     ` Tony Chuang
2019-02-09  2:14   ` Brian Norris
2019-02-11  5:48     ` Tony Chuang
2019-02-11 17:56       ` Brian Norris
2019-01-30  4:02 ` [PATCH v4 04/13] rtw88: trx files yhchuang
2019-01-30  4:02 ` [PATCH v4 05/13] rtw88: mac files yhchuang
2019-01-30  4:02 ` [PATCH v4 06/13] rtw88: fw and efuse files yhchuang
2019-01-31 22:58   ` Brian Norris
2019-02-12  9:14     ` Tony Chuang
2019-01-30  4:02 ` [PATCH v4 07/13] rtw88: phy files yhchuang
2019-01-30  4:02 ` [PATCH v4 08/13] rtw88: debug files yhchuang
2019-02-01 19:49   ` Brian Norris [this message]
2019-02-11  5:41     ` Tony Chuang
2019-01-30  4:02 ` [PATCH v4 09/13] rtw88: chip files yhchuang
2019-01-30 19:44   ` Brian Norris
2019-01-31 11:36     ` Tony Chuang
2019-01-31 11:52       ` Kalle Valo
2019-01-31 11:55         ` Johannes Berg
2019-01-31 13:40           ` Kalle Valo
2019-01-30  4:02 ` [PATCH v4 10/13] rtw88: 8822B init table yhchuang
2019-01-30  4:02 ` [PATCH v4 11/13] rtw88: 8822C " yhchuang
2019-01-30  4:02 ` [PATCH v4 12/13] rtw88: Kconfig & Makefile yhchuang
2019-01-30  4:02 ` [PATCH v4 13/13] rtw88: add MAINTAINERS entry yhchuang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190201194938.GA98048@google.com \
    --to=briannorris@chromium.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=johannes@sipsolutions.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=sgruszka@redhat.com \
    --cc=tehuang@realtek.com \
    --cc=yhchuang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).