public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Badhri Jagan Sridharan <badhri@google.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kyle Tso <kyletso@google.com>
Subject: Re: [PATCH v1 1/2] usb: typec: tcpm: Expose tcpm logs through a misc device
Date: Tue, 18 May 2021 15:32:35 +0200	[thread overview]
Message-ID: <YKPB81XXSVTDqMJy@kroah.com> (raw)
In-Reply-To: <20210517233609.610248-1-badhri@google.com>

On Mon, May 17, 2021 at 04:36:08PM -0700, Badhri Jagan Sridharan wrote:
> Although TCPM logs were primarily focussed to aid developers
> during bringup, TCPM logs have proved to be critical even
> post-bringup as it provides a good starting point to triage
> interoperability issues with accessories. TCPM logs
> are exposed through debugfs filesystem. For systems that
> don't mount debugfs by default, this change introduces a
> module parameter log_misc_dev which when set exports the
> tcpm logs through a misc device. This change also leaves
> the option of exporting tcpm logs through debugfs for
> backwards compatibility.
> 
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 98 +++++++++++++++++++++++++----------
>  1 file changed, 72 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index c4fdc00a3bc8..b79194919b27 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -12,6 +12,7 @@
>  #include <linux/jiffies.h>
>  #include <linux/kernel.h>
>  #include <linux/kthread.h>
> +#include <linux/miscdevice.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/power_supply.h>
> @@ -33,6 +34,10 @@
>  
>  #include <uapi/linux/sched/types.h>
>  
> +static bool modparam_log_misc_dev;
> +module_param_named(log_misc_dev, modparam_log_misc_dev, bool, 0444);
> +MODULE_PARM_DESC(log_misc_dev, "Expose tcpm logs through misc device");
> +
>  #define FOREACH_STATE(S)			\
>  	S(INVALID_STATE),			\
>  	S(TOGGLING),			\
> @@ -465,13 +470,15 @@ struct tcpm_port {
>  	 * SNK_READY for non-pd link.
>  	 */
>  	bool slow_charger_loop;
> -#ifdef CONFIG_DEBUG_FS
> +
>  	struct dentry *dentry;
>  	struct mutex logbuffer_lock;	/* log buffer access lock */
>  	int logbuffer_head;
>  	int logbuffer_tail;
>  	u8 *logbuffer[LOG_BUFFER_ENTRIES];
> -#endif
> +
> +	/* TCPM logs are exposed through misc device when modparam_log_misc_dev is set. */
> +	struct miscdevice misc;

From a technical point of view, this is not ok as now you have 2
different things controlling the lifecycle/lifespan of this structure,
making it impossible to audit and actually figure out what is happening
when.  Please do not do that.

greg k-h

      parent reply	other threads:[~2021-05-18 13:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 23:36 [PATCH v1 1/2] usb: typec: tcpm: Expose tcpm logs through a misc device Badhri Jagan Sridharan
2021-05-17 23:36 ` [PATCH v1 2/2] usb: typec: tcpm: Add module parameter to wrap around logs Badhri Jagan Sridharan
2021-05-18 13:31   ` Greg Kroah-Hartman
2021-05-18 13:00 ` [PATCH v1 1/2] usb: typec: tcpm: Expose tcpm logs through a misc device Heikki Krogerus
2021-05-18 13:31   ` Greg Kroah-Hartman
2021-05-18 13:32 ` Greg Kroah-Hartman [this message]

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=YKPB81XXSVTDqMJy@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=badhri@google.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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