Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1676977pxj; Wed, 19 May 2021 11:14:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjOF1v1afGcG8ZktthJ+UcsMmo5u6D0nUV0mEVXGUdTjzEgpBIKPgoUOR5sbzab0XhiAZ4 X-Received: by 2002:a17:906:c352:: with SMTP id ci18mr403498ejb.149.1621448045853; Wed, 19 May 2021 11:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448045; cv=none; d=google.com; s=arc-20160816; b=OrSIa+3W9vta/lHnzuYiRW7zl+ixcqtz/jECl7jcLSvMh0+p+OODhKzlSpQ8Nk5rmO SBGM78WyDpZPYB4lQnuzt2xJegbQO6n84MW9cuSAWfrvPYQgK5kb3v7C1OAoBQ7reAmq +SG0liuj9ckOwfEHxDaDpgM/3RDY7INyVXIZZ4uZvEovB2ea4oe359+skemL7kO8Fxc4 LgDPBjWDf/+PCh78HgB4oy1ou98H9xke0DfzDJa96iAP3uQiH90QHuTYUgu4cItGJiI4 EN3FUFzF77AJEidRfepsGzZXqZigYW7ioq4r7T6UzhcpllifUHghDdupMffO3dxnuRsV YSEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1TA4i7G1QiNoevESMePFsRd0Xd5wcridUEyvTa7cqpo=; b=GZRw+60CTTHpDXSJtAJBz+w1F09BtEb8yhOBhCT49meASvJo2/fBSn+5BKJ71i5dp1 tI2NdekAFKDCUEJzYQVFGjz8HFm4wmOGzQxp2jWzcbS6mSqj6whGYoGGgiBUHU5Lifje MtNSzVQLHFVSlifWn5WL5W4V9ENn7PFRXCodElwlhRuFIcuQ3juVUtBi8CAkz8kNCJpv HKqvR1us+KlDAV9r5QShupDVlAdlWZ7c6h083WSUaT4dTF5fCn3+llG7aZiJfTgauHgH QdY6KLVTi+2pe/mrzu2rg28gp3xwivd/5iYLPqg6ilziJZeBuZ7jgpCfIv7dzJMMVp/E MyGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dF8TbXGB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si8018508edr.335.2021.05.19.11.13.41; Wed, 19 May 2021 11:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dF8TbXGB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349656AbhERNd5 (ORCPT + 99 others); Tue, 18 May 2021 09:33:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:41622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349647AbhERNd4 (ORCPT ); Tue, 18 May 2021 09:33:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A13E610E9; Tue, 18 May 2021 13:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621344757; bh=WHo6QBmkSyx8hQ50l30tvg1a5wCD4yRDATz2V4Cn3FY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dF8TbXGB95ifSseYQ5aDTk0edBB0shWvN6ILOIiau6TFcD0k7Xlv+CCAyRYPF6AJ6 l3+XnHFQSQ17ZAIu1asOX5bPi6CTRrGP6arjuvBTUQdLsdByaF7vlzS2H++D6fNtHd 6rQNFUyNTNLPvEWChV+tEsvJs5tX1Sl2RpVnOCS4= Date: Tue, 18 May 2021 15:32:35 +0200 From: Greg Kroah-Hartman To: Badhri Jagan Sridharan Cc: Guenter Roeck , Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso Subject: Re: [PATCH v1 1/2] usb: typec: tcpm: Expose tcpm logs through a misc device Message-ID: References: <20210517233609.610248-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210517233609.610248-1-badhri@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -33,6 +34,10 @@ > > #include > > +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