linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
@ 2019-02-20  4:58 Vaishali Thakkar
  2019-02-21 12:18 ` Laurent Pinchart
  0 siblings, 1 reply; 8+ messages in thread
From: Vaishali Thakkar @ 2019-02-20  4:58 UTC (permalink / raw)
  To: andy.gross
  Cc: david.brown, gregkh, linux-arm-msm, linux-kernel, rafael,
	bjorn.andersson, vkoul, Vaishali Thakkar

The Qualcomm socinfo provides a number of additional attributes,
add these to the socinfo driver and expose them via debugfs
functionality.

Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org>
---
Changes since v1:
	- Remove unnecessary debugfs dir creation check
	- Align ifdefs to left
	- Fix function signatures for debugfs init/exit
---
 drivers/soc/qcom/socinfo.c | 198 +++++++++++++++++++++++++++++++++++++
 1 file changed, 198 insertions(+)

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index 02078049fac7..5f4bef216ae1 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -4,6 +4,7 @@
  * Copyright (c) 2017-2019, Linaro Ltd.
  */
 
+#include <linux/debugfs.h>
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -29,6 +30,28 @@
  */
 #define SMEM_HW_SW_BUILD_ID            137
 
+#ifdef CONFIG_DEBUG_FS
+/* pmic model info */
+static const char *const pmic_model[] = {
+	[0]  = "Unknown PMIC model",
+	[9]  = "PM8994",
+	[11] = "PM8916",
+	[13] = "PM8058",
+	[14] = "PM8028",
+	[15] = "PM8901",
+	[16] = "PM8027",
+	[17] = "ISL9519",
+	[18] = "PM8921",
+	[19] = "PM8018",
+	[20] = "PM8015",
+	[21] = "PM8014",
+	[22] = "PM8821",
+	[23] = "PM8038",
+	[24] = "PM8922",
+	[25] = "PM8917",
+};
+#endif /* CONFIG_DEBUG_FS */
+
 /* Socinfo SMEM item structure */
 struct socinfo {
 	__le32 fmt;
@@ -70,6 +93,10 @@ struct socinfo {
 struct qcom_socinfo {
 	struct soc_device *soc_dev;
 	struct soc_device_attribute attr;
+#ifdef CONFIG_DEBUG_FS
+	struct dentry *dbg_root;
+#endif /* CONFIG_DEBUG_FS */
+	struct socinfo *socinfo;
 };
 
 struct soc_of_id {
@@ -133,6 +160,171 @@ static const char *socinfo_machine(struct device *dev, unsigned int id)
 	return NULL;
 }
 
+#ifdef CONFIG_DEBUG_FS
+
+#define UINT_SHOW(name, attr)						\
+static int qcom_show_##name(struct seq_file *seq, void *p)		\
+{									\
+	struct socinfo *socinfo = seq->private;				\
+	seq_printf(seq, "%u\n", le32_to_cpu(socinfo->attr));		\
+	return 0;							\
+}									\
+static int qcom_open_##name(struct inode *inode, struct file *file)	\
+{									\
+	return single_open(file, qcom_show_##name, inode->i_private);	\
+}									\
+									\
+static const struct file_operations qcom_ ##name## _ops = {		\
+	.open = qcom_open_##name,					\
+	.read = seq_read,						\
+	.llseek = seq_lseek,						\
+	.release = single_release,					\
+}
+
+#define DEBUGFS_UINT_ADD(name)						\
+	debugfs_create_file(__stringify(name), 0400,			\
+			    qcom_socinfo->dbg_root,			\
+			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
+
+#define HEX_SHOW(name, attr)						\
+static int qcom_show_##name(struct seq_file *seq, void *p)		\
+{									\
+	struct socinfo *socinfo = seq->private;				\
+	seq_printf(seq, "0x%x\n", le32_to_cpu(socinfo->attr));		\
+	return 0;							\
+}									\
+static int qcom_open_##name(struct inode *inode, struct file *file)	\
+{									\
+	return single_open(file, qcom_show_##name, inode->i_private);	\
+}									\
+									\
+static const struct file_operations qcom_ ##name## _ops = {		\
+	.open = qcom_open_##name,					\
+	.read = seq_read,						\
+	.llseek = seq_lseek,						\
+	.release = single_release,					\
+}
+
+#define DEBUGFS_HEX_ADD(name)						\
+	debugfs_create_file(__stringify(name), 0400,			\
+			    qcom_socinfo->dbg_root,			\
+			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
+
+
+#define QCOM_OPEN(name, _func)						\
+static int qcom_open_##name(struct inode *inode, struct file *file)	\
+{									\
+	return single_open(file, _func, inode->i_private);		\
+}									\
+									\
+static const struct file_operations qcom_ ##name## _ops = {		\
+	.open = qcom_open_##name,					\
+	.read = seq_read,						\
+	.llseek = seq_lseek,						\
+	.release = single_release,					\
+}
+
+#define DEBUGFS_ADD(name)						\
+	debugfs_create_file(__stringify(name), 0400,			\
+			    qcom_socinfo->dbg_root,			\
+			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
+
+
+static int qcom_show_build_id(struct seq_file *seq, void *p)
+{
+	struct socinfo *socinfo = seq->private;
+
+	seq_printf(seq, "%s\n", socinfo->build_id);
+
+	return 0;
+}
+
+static int qcom_show_accessory_chip(struct seq_file *seq, void *p)
+{
+	struct socinfo *socinfo = seq->private;
+
+	seq_printf(seq, "%d\n", le32_to_cpu(socinfo->accessory_chip));
+
+	return 0;
+}
+
+static int qcom_show_platform_subtype(struct seq_file *seq, void *p)
+{
+	struct socinfo *socinfo = seq->private;
+	int subtype = le32_to_cpu(socinfo->hw_plat_subtype);
+
+	if (subtype < 0)
+		return -EINVAL;
+
+	seq_printf(seq, "%u\n", subtype);
+
+	return 0;
+}
+
+static int qcom_show_pmic_model(struct seq_file *seq, void *p)
+{
+	struct socinfo *socinfo = seq->private;
+	int model = SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_model));
+
+	if (model < 0)
+		return -EINVAL;
+
+	seq_printf(seq, "%s\n", pmic_model[model]);
+
+	return 0;
+}
+
+static int qcom_show_pmic_die_revision(struct seq_file *seq, void *p)
+{
+	struct socinfo *socinfo = seq->private;
+
+	seq_printf(seq, "%u.%u\n",
+		   SOCINFO_MAJOR(le32_to_cpu(socinfo->pmic_die_rev)),
+		   SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_die_rev)));
+
+	return 0;
+}
+
+UINT_SHOW(raw_version, raw_ver);
+UINT_SHOW(hardware_platform, hw_plat);
+UINT_SHOW(platform_version, plat_ver);
+UINT_SHOW(foundry_id, foundry_id);
+HEX_SHOW(chip_family, chip_family);
+HEX_SHOW(raw_device_family, raw_device_family);
+HEX_SHOW(raw_device_number, raw_device_num);
+QCOM_OPEN(build_id, qcom_show_build_id);
+QCOM_OPEN(accessory_chip, qcom_show_accessory_chip);
+QCOM_OPEN(pmic_model, qcom_show_pmic_model);
+QCOM_OPEN(platform_subtype, qcom_show_platform_subtype);
+QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision);
+
+static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)
+{
+	qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);
+
+	DEBUGFS_UINT_ADD(raw_version);
+	DEBUGFS_UINT_ADD(hardware_platform);
+	DEBUGFS_UINT_ADD(platform_version);
+	DEBUGFS_UINT_ADD(foundry_id);
+	DEBUGFS_HEX_ADD(chip_family);
+	DEBUGFS_HEX_ADD(raw_device_family);
+	DEBUGFS_HEX_ADD(raw_device_number);
+	DEBUGFS_ADD(build_id);
+	DEBUGFS_ADD(accessory_chip);
+	DEBUGFS_ADD(pmic_model);
+	DEBUGFS_ADD(platform_subtype);
+	DEBUGFS_ADD(pmic_die_revision);
+}
+
+static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)
+{
+	debugfs_remove_recursive(qcom_socinfo->dbg_root);
+}
+#else
+static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { return 0; }
+static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) {  }
+#endif /* CONFIG_DEBUG_FS */
+
 static int qcom_socinfo_probe(struct platform_device *pdev)
 {
 	struct qcom_socinfo *qs;
@@ -165,6 +357,10 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
 	if (IS_ERR(qs->soc_dev))
 		return PTR_ERR(qs->soc_dev);
 
+	qs->socinfo = info;
+
+	socinfo_debugfs_init(qs);
+
 	/* Feed the soc specific unique data into entropy pool */
 	add_device_randomness(info, item_size);
 
@@ -179,6 +375,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev)
 
 	soc_device_unregister(qs->soc_dev);
 
+	socinfo_debugfs_exit(qs);
+
 	return 0;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-20  4:58 [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes Vaishali Thakkar
@ 2019-02-21 12:18 ` Laurent Pinchart
  2019-02-21 15:57   ` Bjorn Andersson
  0 siblings, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2019-02-21 12:18 UTC (permalink / raw)
  To: Vaishali Thakkar
  Cc: andy.gross, david.brown, gregkh, linux-arm-msm, linux-kernel,
	rafael, bjorn.andersson, vkoul

Hi Vaishali,

Thank you for the patch.

On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
> The Qualcomm socinfo provides a number of additional attributes,
> add these to the socinfo driver and expose them via debugfs
> functionality.

What is the use case for these attributes ? I fear they will be used in
production systems, and that would require debugfs in production, which
isn't a good idea. If you need to expose those attributes for anything
else than debugging then we need a proper API, likely sysfs-based.

> Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org>
> ---
> Changes since v1:
> 	- Remove unnecessary debugfs dir creation check
> 	- Align ifdefs to left
> 	- Fix function signatures for debugfs init/exit
> ---
>  drivers/soc/qcom/socinfo.c | 198 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 198 insertions(+)
> 
> diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
> index 02078049fac7..5f4bef216ae1 100644
> --- a/drivers/soc/qcom/socinfo.c
> +++ b/drivers/soc/qcom/socinfo.c
> @@ -4,6 +4,7 @@
>   * Copyright (c) 2017-2019, Linaro Ltd.
>   */
>  
> +#include <linux/debugfs.h>
>  #include <linux/err.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> @@ -29,6 +30,28 @@
>   */
>  #define SMEM_HW_SW_BUILD_ID            137
>  
> +#ifdef CONFIG_DEBUG_FS
> +/* pmic model info */
> +static const char *const pmic_model[] = {
> +	[0]  = "Unknown PMIC model",
> +	[9]  = "PM8994",
> +	[11] = "PM8916",
> +	[13] = "PM8058",
> +	[14] = "PM8028",
> +	[15] = "PM8901",
> +	[16] = "PM8027",
> +	[17] = "ISL9519",
> +	[18] = "PM8921",
> +	[19] = "PM8018",
> +	[20] = "PM8015",
> +	[21] = "PM8014",
> +	[22] = "PM8821",
> +	[23] = "PM8038",
> +	[24] = "PM8922",
> +	[25] = "PM8917",
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  /* Socinfo SMEM item structure */
>  struct socinfo {
>  	__le32 fmt;
> @@ -70,6 +93,10 @@ struct socinfo {
>  struct qcom_socinfo {
>  	struct soc_device *soc_dev;
>  	struct soc_device_attribute attr;
> +#ifdef CONFIG_DEBUG_FS
> +	struct dentry *dbg_root;
> +#endif /* CONFIG_DEBUG_FS */
> +	struct socinfo *socinfo;
>  };
>  
>  struct soc_of_id {
> @@ -133,6 +160,171 @@ static const char *socinfo_machine(struct device *dev, unsigned int id)
>  	return NULL;
>  }
>  
> +#ifdef CONFIG_DEBUG_FS
> +
> +#define UINT_SHOW(name, attr)						\
> +static int qcom_show_##name(struct seq_file *seq, void *p)		\
> +{									\
> +	struct socinfo *socinfo = seq->private;				\
> +	seq_printf(seq, "%u\n", le32_to_cpu(socinfo->attr));		\
> +	return 0;							\
> +}									\
> +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> +{									\
> +	return single_open(file, qcom_show_##name, inode->i_private);	\
> +}									\
> +									\
> +static const struct file_operations qcom_ ##name## _ops = {		\
> +	.open = qcom_open_##name,					\
> +	.read = seq_read,						\
> +	.llseek = seq_lseek,						\
> +	.release = single_release,					\
> +}
> +
> +#define DEBUGFS_UINT_ADD(name)						\
> +	debugfs_create_file(__stringify(name), 0400,			\
> +			    qcom_socinfo->dbg_root,			\
> +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> +
> +#define HEX_SHOW(name, attr)						\
> +static int qcom_show_##name(struct seq_file *seq, void *p)		\
> +{									\
> +	struct socinfo *socinfo = seq->private;				\
> +	seq_printf(seq, "0x%x\n", le32_to_cpu(socinfo->attr));		\
> +	return 0;							\
> +}									\
> +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> +{									\
> +	return single_open(file, qcom_show_##name, inode->i_private);	\
> +}									\
> +									\
> +static const struct file_operations qcom_ ##name## _ops = {		\
> +	.open = qcom_open_##name,					\
> +	.read = seq_read,						\
> +	.llseek = seq_lseek,						\
> +	.release = single_release,					\
> +}
> +
> +#define DEBUGFS_HEX_ADD(name)						\
> +	debugfs_create_file(__stringify(name), 0400,			\
> +			    qcom_socinfo->dbg_root,			\
> +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> +
> +
> +#define QCOM_OPEN(name, _func)						\
> +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> +{									\
> +	return single_open(file, _func, inode->i_private);		\
> +}									\
> +									\
> +static const struct file_operations qcom_ ##name## _ops = {		\
> +	.open = qcom_open_##name,					\
> +	.read = seq_read,						\
> +	.llseek = seq_lseek,						\
> +	.release = single_release,					\
> +}
> +
> +#define DEBUGFS_ADD(name)						\
> +	debugfs_create_file(__stringify(name), 0400,			\
> +			    qcom_socinfo->dbg_root,			\
> +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> +
> +
> +static int qcom_show_build_id(struct seq_file *seq, void *p)
> +{
> +	struct socinfo *socinfo = seq->private;
> +
> +	seq_printf(seq, "%s\n", socinfo->build_id);
> +
> +	return 0;
> +}
> +
> +static int qcom_show_accessory_chip(struct seq_file *seq, void *p)
> +{
> +	struct socinfo *socinfo = seq->private;
> +
> +	seq_printf(seq, "%d\n", le32_to_cpu(socinfo->accessory_chip));
> +
> +	return 0;
> +}
> +
> +static int qcom_show_platform_subtype(struct seq_file *seq, void *p)
> +{
> +	struct socinfo *socinfo = seq->private;
> +	int subtype = le32_to_cpu(socinfo->hw_plat_subtype);
> +
> +	if (subtype < 0)
> +		return -EINVAL;
> +
> +	seq_printf(seq, "%u\n", subtype);
> +
> +	return 0;
> +}
> +
> +static int qcom_show_pmic_model(struct seq_file *seq, void *p)
> +{
> +	struct socinfo *socinfo = seq->private;
> +	int model = SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_model));
> +
> +	if (model < 0)
> +		return -EINVAL;
> +
> +	seq_printf(seq, "%s\n", pmic_model[model]);
> +
> +	return 0;
> +}
> +
> +static int qcom_show_pmic_die_revision(struct seq_file *seq, void *p)
> +{
> +	struct socinfo *socinfo = seq->private;
> +
> +	seq_printf(seq, "%u.%u\n",
> +		   SOCINFO_MAJOR(le32_to_cpu(socinfo->pmic_die_rev)),
> +		   SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_die_rev)));
> +
> +	return 0;
> +}
> +
> +UINT_SHOW(raw_version, raw_ver);
> +UINT_SHOW(hardware_platform, hw_plat);
> +UINT_SHOW(platform_version, plat_ver);
> +UINT_SHOW(foundry_id, foundry_id);
> +HEX_SHOW(chip_family, chip_family);
> +HEX_SHOW(raw_device_family, raw_device_family);
> +HEX_SHOW(raw_device_number, raw_device_num);
> +QCOM_OPEN(build_id, qcom_show_build_id);
> +QCOM_OPEN(accessory_chip, qcom_show_accessory_chip);
> +QCOM_OPEN(pmic_model, qcom_show_pmic_model);
> +QCOM_OPEN(platform_subtype, qcom_show_platform_subtype);
> +QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision);
> +
> +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)
> +{
> +	qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);
> +
> +	DEBUGFS_UINT_ADD(raw_version);
> +	DEBUGFS_UINT_ADD(hardware_platform);
> +	DEBUGFS_UINT_ADD(platform_version);
> +	DEBUGFS_UINT_ADD(foundry_id);
> +	DEBUGFS_HEX_ADD(chip_family);
> +	DEBUGFS_HEX_ADD(raw_device_family);
> +	DEBUGFS_HEX_ADD(raw_device_number);
> +	DEBUGFS_ADD(build_id);
> +	DEBUGFS_ADD(accessory_chip);
> +	DEBUGFS_ADD(pmic_model);
> +	DEBUGFS_ADD(platform_subtype);
> +	DEBUGFS_ADD(pmic_die_revision);
> +}
> +
> +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)
> +{
> +	debugfs_remove_recursive(qcom_socinfo->dbg_root);
> +}
> +#else
> +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { return 0; }
> +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) {  }
> +#endif /* CONFIG_DEBUG_FS */
> +
>  static int qcom_socinfo_probe(struct platform_device *pdev)
>  {
>  	struct qcom_socinfo *qs;
> @@ -165,6 +357,10 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
>  	if (IS_ERR(qs->soc_dev))
>  		return PTR_ERR(qs->soc_dev);
>  
> +	qs->socinfo = info;
> +
> +	socinfo_debugfs_init(qs);
> +
>  	/* Feed the soc specific unique data into entropy pool */
>  	add_device_randomness(info, item_size);
>  
> @@ -179,6 +375,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev)
>  
>  	soc_device_unregister(qs->soc_dev);
>  
> +	socinfo_debugfs_exit(qs);
> +
>  	return 0;
>  }
> 

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-21 12:18 ` Laurent Pinchart
@ 2019-02-21 15:57   ` Bjorn Andersson
  2019-02-21 22:13     ` Laurent Pinchart
  2019-02-22 11:54     ` Marc Gonzalez
  0 siblings, 2 replies; 8+ messages in thread
From: Bjorn Andersson @ 2019-02-21 15:57 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Vaishali Thakkar, andy.gross, david.brown, gregkh, linux-arm-msm,
	linux-kernel, rafael, vkoul

On Thu 21 Feb 04:18 PST 2019, Laurent Pinchart wrote:

> Hi Vaishali,
> 
> Thank you for the patch.
> 
> On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
> > The Qualcomm socinfo provides a number of additional attributes,
> > add these to the socinfo driver and expose them via debugfs
> > functionality.
> 
> What is the use case for these attributes ? I fear they will be used in
> production systems, and that would require debugfs in production, which
> isn't a good idea. If you need to expose those attributes for anything
> else than debugging then we need a proper API, likely sysfs-based.
> 

The use case of these attributes, beyond development/debugging, are
unfortunately somewhat unknown and is the reason why they where moved to
debugfs from the earlier attempts to upstream this.

I think the production requirements at hand prohibits debugfs to be
present, so attributes that are required beyond development/debugging
purposes would have to be migrated out to sysfs - but the idea here is
that such migration would have come with the missing motivation to add
them there today.

Regards,
Bjorn

> > Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org>
> > ---
> > Changes since v1:
> > 	- Remove unnecessary debugfs dir creation check
> > 	- Align ifdefs to left
> > 	- Fix function signatures for debugfs init/exit
> > ---
> >  drivers/soc/qcom/socinfo.c | 198 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 198 insertions(+)
> > 
> > diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
> > index 02078049fac7..5f4bef216ae1 100644
> > --- a/drivers/soc/qcom/socinfo.c
> > +++ b/drivers/soc/qcom/socinfo.c
> > @@ -4,6 +4,7 @@
> >   * Copyright (c) 2017-2019, Linaro Ltd.
> >   */
> >  
> > +#include <linux/debugfs.h>
> >  #include <linux/err.h>
> >  #include <linux/module.h>
> >  #include <linux/platform_device.h>
> > @@ -29,6 +30,28 @@
> >   */
> >  #define SMEM_HW_SW_BUILD_ID            137
> >  
> > +#ifdef CONFIG_DEBUG_FS
> > +/* pmic model info */
> > +static const char *const pmic_model[] = {
> > +	[0]  = "Unknown PMIC model",
> > +	[9]  = "PM8994",
> > +	[11] = "PM8916",
> > +	[13] = "PM8058",
> > +	[14] = "PM8028",
> > +	[15] = "PM8901",
> > +	[16] = "PM8027",
> > +	[17] = "ISL9519",
> > +	[18] = "PM8921",
> > +	[19] = "PM8018",
> > +	[20] = "PM8015",
> > +	[21] = "PM8014",
> > +	[22] = "PM8821",
> > +	[23] = "PM8038",
> > +	[24] = "PM8922",
> > +	[25] = "PM8917",
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >  /* Socinfo SMEM item structure */
> >  struct socinfo {
> >  	__le32 fmt;
> > @@ -70,6 +93,10 @@ struct socinfo {
> >  struct qcom_socinfo {
> >  	struct soc_device *soc_dev;
> >  	struct soc_device_attribute attr;
> > +#ifdef CONFIG_DEBUG_FS
> > +	struct dentry *dbg_root;
> > +#endif /* CONFIG_DEBUG_FS */
> > +	struct socinfo *socinfo;
> >  };
> >  
> >  struct soc_of_id {
> > @@ -133,6 +160,171 @@ static const char *socinfo_machine(struct device *dev, unsigned int id)
> >  	return NULL;
> >  }
> >  
> > +#ifdef CONFIG_DEBUG_FS
> > +
> > +#define UINT_SHOW(name, attr)						\
> > +static int qcom_show_##name(struct seq_file *seq, void *p)		\
> > +{									\
> > +	struct socinfo *socinfo = seq->private;				\
> > +	seq_printf(seq, "%u\n", le32_to_cpu(socinfo->attr));		\
> > +	return 0;							\
> > +}									\
> > +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> > +{									\
> > +	return single_open(file, qcom_show_##name, inode->i_private);	\
> > +}									\
> > +									\
> > +static const struct file_operations qcom_ ##name## _ops = {		\
> > +	.open = qcom_open_##name,					\
> > +	.read = seq_read,						\
> > +	.llseek = seq_lseek,						\
> > +	.release = single_release,					\
> > +}
> > +
> > +#define DEBUGFS_UINT_ADD(name)						\
> > +	debugfs_create_file(__stringify(name), 0400,			\
> > +			    qcom_socinfo->dbg_root,			\
> > +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> > +
> > +#define HEX_SHOW(name, attr)						\
> > +static int qcom_show_##name(struct seq_file *seq, void *p)		\
> > +{									\
> > +	struct socinfo *socinfo = seq->private;				\
> > +	seq_printf(seq, "0x%x\n", le32_to_cpu(socinfo->attr));		\
> > +	return 0;							\
> > +}									\
> > +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> > +{									\
> > +	return single_open(file, qcom_show_##name, inode->i_private);	\
> > +}									\
> > +									\
> > +static const struct file_operations qcom_ ##name## _ops = {		\
> > +	.open = qcom_open_##name,					\
> > +	.read = seq_read,						\
> > +	.llseek = seq_lseek,						\
> > +	.release = single_release,					\
> > +}
> > +
> > +#define DEBUGFS_HEX_ADD(name)						\
> > +	debugfs_create_file(__stringify(name), 0400,			\
> > +			    qcom_socinfo->dbg_root,			\
> > +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> > +
> > +
> > +#define QCOM_OPEN(name, _func)						\
> > +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> > +{									\
> > +	return single_open(file, _func, inode->i_private);		\
> > +}									\
> > +									\
> > +static const struct file_operations qcom_ ##name## _ops = {		\
> > +	.open = qcom_open_##name,					\
> > +	.read = seq_read,						\
> > +	.llseek = seq_lseek,						\
> > +	.release = single_release,					\
> > +}
> > +
> > +#define DEBUGFS_ADD(name)						\
> > +	debugfs_create_file(__stringify(name), 0400,			\
> > +			    qcom_socinfo->dbg_root,			\
> > +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> > +
> > +
> > +static int qcom_show_build_id(struct seq_file *seq, void *p)
> > +{
> > +	struct socinfo *socinfo = seq->private;
> > +
> > +	seq_printf(seq, "%s\n", socinfo->build_id);
> > +
> > +	return 0;
> > +}
> > +
> > +static int qcom_show_accessory_chip(struct seq_file *seq, void *p)
> > +{
> > +	struct socinfo *socinfo = seq->private;
> > +
> > +	seq_printf(seq, "%d\n", le32_to_cpu(socinfo->accessory_chip));
> > +
> > +	return 0;
> > +}
> > +
> > +static int qcom_show_platform_subtype(struct seq_file *seq, void *p)
> > +{
> > +	struct socinfo *socinfo = seq->private;
> > +	int subtype = le32_to_cpu(socinfo->hw_plat_subtype);
> > +
> > +	if (subtype < 0)
> > +		return -EINVAL;
> > +
> > +	seq_printf(seq, "%u\n", subtype);
> > +
> > +	return 0;
> > +}
> > +
> > +static int qcom_show_pmic_model(struct seq_file *seq, void *p)
> > +{
> > +	struct socinfo *socinfo = seq->private;
> > +	int model = SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_model));
> > +
> > +	if (model < 0)
> > +		return -EINVAL;
> > +
> > +	seq_printf(seq, "%s\n", pmic_model[model]);
> > +
> > +	return 0;
> > +}
> > +
> > +static int qcom_show_pmic_die_revision(struct seq_file *seq, void *p)
> > +{
> > +	struct socinfo *socinfo = seq->private;
> > +
> > +	seq_printf(seq, "%u.%u\n",
> > +		   SOCINFO_MAJOR(le32_to_cpu(socinfo->pmic_die_rev)),
> > +		   SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_die_rev)));
> > +
> > +	return 0;
> > +}
> > +
> > +UINT_SHOW(raw_version, raw_ver);
> > +UINT_SHOW(hardware_platform, hw_plat);
> > +UINT_SHOW(platform_version, plat_ver);
> > +UINT_SHOW(foundry_id, foundry_id);
> > +HEX_SHOW(chip_family, chip_family);
> > +HEX_SHOW(raw_device_family, raw_device_family);
> > +HEX_SHOW(raw_device_number, raw_device_num);
> > +QCOM_OPEN(build_id, qcom_show_build_id);
> > +QCOM_OPEN(accessory_chip, qcom_show_accessory_chip);
> > +QCOM_OPEN(pmic_model, qcom_show_pmic_model);
> > +QCOM_OPEN(platform_subtype, qcom_show_platform_subtype);
> > +QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision);
> > +
> > +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)
> > +{
> > +	qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);
> > +
> > +	DEBUGFS_UINT_ADD(raw_version);
> > +	DEBUGFS_UINT_ADD(hardware_platform);
> > +	DEBUGFS_UINT_ADD(platform_version);
> > +	DEBUGFS_UINT_ADD(foundry_id);
> > +	DEBUGFS_HEX_ADD(chip_family);
> > +	DEBUGFS_HEX_ADD(raw_device_family);
> > +	DEBUGFS_HEX_ADD(raw_device_number);
> > +	DEBUGFS_ADD(build_id);
> > +	DEBUGFS_ADD(accessory_chip);
> > +	DEBUGFS_ADD(pmic_model);
> > +	DEBUGFS_ADD(platform_subtype);
> > +	DEBUGFS_ADD(pmic_die_revision);
> > +}
> > +
> > +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)
> > +{
> > +	debugfs_remove_recursive(qcom_socinfo->dbg_root);
> > +}
> > +#else
> > +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { return 0; }
> > +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) {  }
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >  static int qcom_socinfo_probe(struct platform_device *pdev)
> >  {
> >  	struct qcom_socinfo *qs;
> > @@ -165,6 +357,10 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
> >  	if (IS_ERR(qs->soc_dev))
> >  		return PTR_ERR(qs->soc_dev);
> >  
> > +	qs->socinfo = info;
> > +
> > +	socinfo_debugfs_init(qs);
> > +
> >  	/* Feed the soc specific unique data into entropy pool */
> >  	add_device_randomness(info, item_size);
> >  
> > @@ -179,6 +375,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev)
> >  
> >  	soc_device_unregister(qs->soc_dev);
> >  
> > +	socinfo_debugfs_exit(qs);
> > +
> >  	return 0;
> >  }
> > 
> 
> -- 
> Regards,
> 
> Laurent Pinchart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-21 15:57   ` Bjorn Andersson
@ 2019-02-21 22:13     ` Laurent Pinchart
  2019-02-22  7:16       ` Greg KH
  2019-02-22 11:54     ` Marc Gonzalez
  1 sibling, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2019-02-21 22:13 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Vaishali Thakkar, andy.gross, david.brown, gregkh, linux-arm-msm,
	linux-kernel, rafael, vkoul

Hi Bjorn,

On Thu, Feb 21, 2019 at 07:57:42AM -0800, Bjorn Andersson wrote:
> On Thu 21 Feb 04:18 PST 2019, Laurent Pinchart wrote:
> 
> > Hi Vaishali,
> > 
> > Thank you for the patch.
> > 
> > On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
> > > The Qualcomm socinfo provides a number of additional attributes,
> > > add these to the socinfo driver and expose them via debugfs
> > > functionality.
> > 
> > What is the use case for these attributes ? I fear they will be used in
> > production systems, and that would require debugfs in production, which
> > isn't a good idea. If you need to expose those attributes for anything
> > else than debugging then we need a proper API, likely sysfs-based.
> 
> The use case of these attributes, beyond development/debugging, are
> unfortunately somewhat unknown and is the reason why they where moved to
> debugfs from the earlier attempts to upstream this.
> 
> I think the production requirements at hand prohibits debugfs to be
> present, so attributes that are required beyond development/debugging
> purposes would have to be migrated out to sysfs - but the idea here is
> that such migration would have come with the missing motivation to add
> them there today.

If the use case is just debug/development, would it be enough to print
this information in the kernel log at boot time ? I may be a bit
paranoid, but I always worry about API abuse :-(

> > > Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org>
> > > ---
> > > Changes since v1:
> > > 	- Remove unnecessary debugfs dir creation check
> > > 	- Align ifdefs to left
> > > 	- Fix function signatures for debugfs init/exit
> > > ---
> > >  drivers/soc/qcom/socinfo.c | 198 +++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 198 insertions(+)
> > > 
> > > diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
> > > index 02078049fac7..5f4bef216ae1 100644
> > > --- a/drivers/soc/qcom/socinfo.c
> > > +++ b/drivers/soc/qcom/socinfo.c
> > > @@ -4,6 +4,7 @@
> > >   * Copyright (c) 2017-2019, Linaro Ltd.
> > >   */
> > >  
> > > +#include <linux/debugfs.h>
> > >  #include <linux/err.h>
> > >  #include <linux/module.h>
> > >  #include <linux/platform_device.h>
> > > @@ -29,6 +30,28 @@
> > >   */
> > >  #define SMEM_HW_SW_BUILD_ID            137
> > >  
> > > +#ifdef CONFIG_DEBUG_FS
> > > +/* pmic model info */
> > > +static const char *const pmic_model[] = {
> > > +	[0]  = "Unknown PMIC model",
> > > +	[9]  = "PM8994",
> > > +	[11] = "PM8916",
> > > +	[13] = "PM8058",
> > > +	[14] = "PM8028",
> > > +	[15] = "PM8901",
> > > +	[16] = "PM8027",
> > > +	[17] = "ISL9519",
> > > +	[18] = "PM8921",
> > > +	[19] = "PM8018",
> > > +	[20] = "PM8015",
> > > +	[21] = "PM8014",
> > > +	[22] = "PM8821",
> > > +	[23] = "PM8038",
> > > +	[24] = "PM8922",
> > > +	[25] = "PM8917",
> > > +};
> > > +#endif /* CONFIG_DEBUG_FS */
> > > +
> > >  /* Socinfo SMEM item structure */
> > >  struct socinfo {
> > >  	__le32 fmt;
> > > @@ -70,6 +93,10 @@ struct socinfo {
> > >  struct qcom_socinfo {
> > >  	struct soc_device *soc_dev;
> > >  	struct soc_device_attribute attr;
> > > +#ifdef CONFIG_DEBUG_FS
> > > +	struct dentry *dbg_root;
> > > +#endif /* CONFIG_DEBUG_FS */
> > > +	struct socinfo *socinfo;
> > >  };
> > >  
> > >  struct soc_of_id {
> > > @@ -133,6 +160,171 @@ static const char *socinfo_machine(struct device *dev, unsigned int id)
> > >  	return NULL;
> > >  }
> > >  
> > > +#ifdef CONFIG_DEBUG_FS
> > > +
> > > +#define UINT_SHOW(name, attr)						\
> > > +static int qcom_show_##name(struct seq_file *seq, void *p)		\
> > > +{									\
> > > +	struct socinfo *socinfo = seq->private;				\
> > > +	seq_printf(seq, "%u\n", le32_to_cpu(socinfo->attr));		\
> > > +	return 0;							\
> > > +}									\
> > > +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> > > +{									\
> > > +	return single_open(file, qcom_show_##name, inode->i_private);	\
> > > +}									\
> > > +									\
> > > +static const struct file_operations qcom_ ##name## _ops = {		\
> > > +	.open = qcom_open_##name,					\
> > > +	.read = seq_read,						\
> > > +	.llseek = seq_lseek,						\
> > > +	.release = single_release,					\
> > > +}
> > > +
> > > +#define DEBUGFS_UINT_ADD(name)						\
> > > +	debugfs_create_file(__stringify(name), 0400,			\
> > > +			    qcom_socinfo->dbg_root,			\
> > > +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> > > +
> > > +#define HEX_SHOW(name, attr)						\
> > > +static int qcom_show_##name(struct seq_file *seq, void *p)		\
> > > +{									\
> > > +	struct socinfo *socinfo = seq->private;				\
> > > +	seq_printf(seq, "0x%x\n", le32_to_cpu(socinfo->attr));		\
> > > +	return 0;							\
> > > +}									\
> > > +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> > > +{									\
> > > +	return single_open(file, qcom_show_##name, inode->i_private);	\
> > > +}									\
> > > +									\
> > > +static const struct file_operations qcom_ ##name## _ops = {		\
> > > +	.open = qcom_open_##name,					\
> > > +	.read = seq_read,						\
> > > +	.llseek = seq_lseek,						\
> > > +	.release = single_release,					\
> > > +}
> > > +
> > > +#define DEBUGFS_HEX_ADD(name)						\
> > > +	debugfs_create_file(__stringify(name), 0400,			\
> > > +			    qcom_socinfo->dbg_root,			\
> > > +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> > > +
> > > +
> > > +#define QCOM_OPEN(name, _func)						\
> > > +static int qcom_open_##name(struct inode *inode, struct file *file)	\
> > > +{									\
> > > +	return single_open(file, _func, inode->i_private);		\
> > > +}									\
> > > +									\
> > > +static const struct file_operations qcom_ ##name## _ops = {		\
> > > +	.open = qcom_open_##name,					\
> > > +	.read = seq_read,						\
> > > +	.llseek = seq_lseek,						\
> > > +	.release = single_release,					\
> > > +}
> > > +
> > > +#define DEBUGFS_ADD(name)						\
> > > +	debugfs_create_file(__stringify(name), 0400,			\
> > > +			    qcom_socinfo->dbg_root,			\
> > > +			    qcom_socinfo->socinfo, &qcom_ ##name## _ops)
> > > +
> > > +
> > > +static int qcom_show_build_id(struct seq_file *seq, void *p)
> > > +{
> > > +	struct socinfo *socinfo = seq->private;
> > > +
> > > +	seq_printf(seq, "%s\n", socinfo->build_id);
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static int qcom_show_accessory_chip(struct seq_file *seq, void *p)
> > > +{
> > > +	struct socinfo *socinfo = seq->private;
> > > +
> > > +	seq_printf(seq, "%d\n", le32_to_cpu(socinfo->accessory_chip));
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static int qcom_show_platform_subtype(struct seq_file *seq, void *p)
> > > +{
> > > +	struct socinfo *socinfo = seq->private;
> > > +	int subtype = le32_to_cpu(socinfo->hw_plat_subtype);
> > > +
> > > +	if (subtype < 0)
> > > +		return -EINVAL;
> > > +
> > > +	seq_printf(seq, "%u\n", subtype);
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static int qcom_show_pmic_model(struct seq_file *seq, void *p)
> > > +{
> > > +	struct socinfo *socinfo = seq->private;
> > > +	int model = SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_model));
> > > +
> > > +	if (model < 0)
> > > +		return -EINVAL;
> > > +
> > > +	seq_printf(seq, "%s\n", pmic_model[model]);
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static int qcom_show_pmic_die_revision(struct seq_file *seq, void *p)
> > > +{
> > > +	struct socinfo *socinfo = seq->private;
> > > +
> > > +	seq_printf(seq, "%u.%u\n",
> > > +		   SOCINFO_MAJOR(le32_to_cpu(socinfo->pmic_die_rev)),
> > > +		   SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_die_rev)));
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +UINT_SHOW(raw_version, raw_ver);
> > > +UINT_SHOW(hardware_platform, hw_plat);
> > > +UINT_SHOW(platform_version, plat_ver);
> > > +UINT_SHOW(foundry_id, foundry_id);
> > > +HEX_SHOW(chip_family, chip_family);
> > > +HEX_SHOW(raw_device_family, raw_device_family);
> > > +HEX_SHOW(raw_device_number, raw_device_num);
> > > +QCOM_OPEN(build_id, qcom_show_build_id);
> > > +QCOM_OPEN(accessory_chip, qcom_show_accessory_chip);
> > > +QCOM_OPEN(pmic_model, qcom_show_pmic_model);
> > > +QCOM_OPEN(platform_subtype, qcom_show_platform_subtype);
> > > +QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision);
> > > +
> > > +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo)
> > > +{
> > > +	qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL);
> > > +
> > > +	DEBUGFS_UINT_ADD(raw_version);
> > > +	DEBUGFS_UINT_ADD(hardware_platform);
> > > +	DEBUGFS_UINT_ADD(platform_version);
> > > +	DEBUGFS_UINT_ADD(foundry_id);
> > > +	DEBUGFS_HEX_ADD(chip_family);
> > > +	DEBUGFS_HEX_ADD(raw_device_family);
> > > +	DEBUGFS_HEX_ADD(raw_device_number);
> > > +	DEBUGFS_ADD(build_id);
> > > +	DEBUGFS_ADD(accessory_chip);
> > > +	DEBUGFS_ADD(pmic_model);
> > > +	DEBUGFS_ADD(platform_subtype);
> > > +	DEBUGFS_ADD(pmic_die_revision);
> > > +}
> > > +
> > > +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)
> > > +{
> > > +	debugfs_remove_recursive(qcom_socinfo->dbg_root);
> > > +}
> > > +#else
> > > +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { return 0; }
> > > +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) {  }
> > > +#endif /* CONFIG_DEBUG_FS */
> > > +
> > >  static int qcom_socinfo_probe(struct platform_device *pdev)
> > >  {
> > >  	struct qcom_socinfo *qs;
> > > @@ -165,6 +357,10 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
> > >  	if (IS_ERR(qs->soc_dev))
> > >  		return PTR_ERR(qs->soc_dev);
> > >  
> > > +	qs->socinfo = info;
> > > +
> > > +	socinfo_debugfs_init(qs);
> > > +
> > >  	/* Feed the soc specific unique data into entropy pool */
> > >  	add_device_randomness(info, item_size);
> > >  
> > > @@ -179,6 +375,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev)
> > >  
> > >  	soc_device_unregister(qs->soc_dev);
> > >  
> > > +	socinfo_debugfs_exit(qs);
> > > +
> > >  	return 0;
> > >  }
> > > 

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-21 22:13     ` Laurent Pinchart
@ 2019-02-22  7:16       ` Greg KH
  2019-02-22  9:51         ` Laurent Pinchart
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2019-02-22  7:16 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Bjorn Andersson, Vaishali Thakkar, andy.gross, david.brown,
	linux-arm-msm, linux-kernel, rafael, vkoul

On Fri, Feb 22, 2019 at 12:13:59AM +0200, Laurent Pinchart wrote:
> Hi Bjorn,
> 
> On Thu, Feb 21, 2019 at 07:57:42AM -0800, Bjorn Andersson wrote:
> > On Thu 21 Feb 04:18 PST 2019, Laurent Pinchart wrote:
> > 
> > > Hi Vaishali,
> > > 
> > > Thank you for the patch.
> > > 
> > > On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
> > > > The Qualcomm socinfo provides a number of additional attributes,
> > > > add these to the socinfo driver and expose them via debugfs
> > > > functionality.
> > > 
> > > What is the use case for these attributes ? I fear they will be used in
> > > production systems, and that would require debugfs in production, which
> > > isn't a good idea. If you need to expose those attributes for anything
> > > else than debugging then we need a proper API, likely sysfs-based.
> > 
> > The use case of these attributes, beyond development/debugging, are
> > unfortunately somewhat unknown and is the reason why they where moved to
> > debugfs from the earlier attempts to upstream this.
> > 
> > I think the production requirements at hand prohibits debugfs to be
> > present, so attributes that are required beyond development/debugging
> > purposes would have to be migrated out to sysfs - but the idea here is
> > that such migration would have come with the missing motivation to add
> > them there today.
> 
> If the use case is just debug/development, would it be enough to print
> this information in the kernel log at boot time ? I may be a bit
> paranoid, but I always worry about API abuse :-(

Putting stuff in debugfs should be fine.  No system should ever rely on
debugfs for a properly running system as it is being disabled on almost
all "sane" systems (Android included).  If a vendor relies on this
information for a properly working system, then it does not belong in
debugfs.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-22  7:16       ` Greg KH
@ 2019-02-22  9:51         ` Laurent Pinchart
  2019-02-22 10:52           ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2019-02-22  9:51 UTC (permalink / raw)
  To: Greg KH
  Cc: Bjorn Andersson, Vaishali Thakkar, andy.gross, david.brown,
	linux-arm-msm, linux-kernel, rafael, vkoul

Hi Greg,

On Fri, Feb 22, 2019 at 08:16:16AM +0100, Greg KH wrote:
> On Fri, Feb 22, 2019 at 12:13:59AM +0200, Laurent Pinchart wrote:
> > On Thu, Feb 21, 2019 at 07:57:42AM -0800, Bjorn Andersson wrote:
> > > On Thu 21 Feb 04:18 PST 2019, Laurent Pinchart wrote:
> > > > On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
> > > > > The Qualcomm socinfo provides a number of additional attributes,
> > > > > add these to the socinfo driver and expose them via debugfs
> > > > > functionality.
> > > > 
> > > > What is the use case for these attributes ? I fear they will be used in
> > > > production systems, and that would require debugfs in production, which
> > > > isn't a good idea. If you need to expose those attributes for anything
> > > > else than debugging then we need a proper API, likely sysfs-based.
> > > 
> > > The use case of these attributes, beyond development/debugging, are
> > > unfortunately somewhat unknown and is the reason why they where moved to
> > > debugfs from the earlier attempts to upstream this.
> > > 
> > > I think the production requirements at hand prohibits debugfs to be
> > > present, so attributes that are required beyond development/debugging
> > > purposes would have to be migrated out to sysfs - but the idea here is
> > > that such migration would have come with the missing motivation to add
> > > them there today.
> > 
> > If the use case is just debug/development, would it be enough to print
> > this information in the kernel log at boot time ? I may be a bit
> > paranoid, but I always worry about API abuse :-(
> 
> Putting stuff in debugfs should be fine.  No system should ever rely on
> debugfs for a properly running system as it is being disabled on almost
> all "sane" systems (Android included).  If a vendor relies on this
> information for a properly working system, then it does not belong in
> debugfs.

There's certainly no disagreement about that, my concern is about
vendors who will enable debugfs to access information they need just
because it's there. Do I assume correctly we can "break the debugfs ABI"
in mainline by changing the format of the information if needed ?

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-22  9:51         ` Laurent Pinchart
@ 2019-02-22 10:52           ` Greg KH
  0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2019-02-22 10:52 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Bjorn Andersson, Vaishali Thakkar, andy.gross, david.brown,
	linux-arm-msm, linux-kernel, rafael, vkoul

On Fri, Feb 22, 2019 at 11:51:45AM +0200, Laurent Pinchart wrote:
> Hi Greg,
> 
> On Fri, Feb 22, 2019 at 08:16:16AM +0100, Greg KH wrote:
> > On Fri, Feb 22, 2019 at 12:13:59AM +0200, Laurent Pinchart wrote:
> > > On Thu, Feb 21, 2019 at 07:57:42AM -0800, Bjorn Andersson wrote:
> > > > On Thu 21 Feb 04:18 PST 2019, Laurent Pinchart wrote:
> > > > > On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
> > > > > > The Qualcomm socinfo provides a number of additional attributes,
> > > > > > add these to the socinfo driver and expose them via debugfs
> > > > > > functionality.
> > > > > 
> > > > > What is the use case for these attributes ? I fear they will be used in
> > > > > production systems, and that would require debugfs in production, which
> > > > > isn't a good idea. If you need to expose those attributes for anything
> > > > > else than debugging then we need a proper API, likely sysfs-based.
> > > > 
> > > > The use case of these attributes, beyond development/debugging, are
> > > > unfortunately somewhat unknown and is the reason why they where moved to
> > > > debugfs from the earlier attempts to upstream this.
> > > > 
> > > > I think the production requirements at hand prohibits debugfs to be
> > > > present, so attributes that are required beyond development/debugging
> > > > purposes would have to be migrated out to sysfs - but the idea here is
> > > > that such migration would have come with the missing motivation to add
> > > > them there today.
> > > 
> > > If the use case is just debug/development, would it be enough to print
> > > this information in the kernel log at boot time ? I may be a bit
> > > paranoid, but I always worry about API abuse :-(
> > 
> > Putting stuff in debugfs should be fine.  No system should ever rely on
> > debugfs for a properly running system as it is being disabled on almost
> > all "sane" systems (Android included).  If a vendor relies on this
> > information for a properly working system, then it does not belong in
> > debugfs.
> 
> There's certainly no disagreement about that, my concern is about
> vendors who will enable debugfs to access information they need just
> because it's there.

Then they run a huge risk of relying on it.

> Do I assume correctly we can "break the debugfs ABI" in mainline by
> changing the format of the information if needed ?

Yes.  The only "rule" of debugfs is that there is no rule :)

Please, break it every-other release if you want, no userspace tools
_should_ be relying on it.[1]

thanks,

greg k-h

[1] Yes, I know Android currently relies on debugfs for a number of
    crash-dump type of things in ion and binder, but there is active
    work upstream in AOSP to remove that dependancy as no Android device
    should ever have debugfs mounted on a "normal" system for the
    security reasons alone.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes
  2019-02-21 15:57   ` Bjorn Andersson
  2019-02-21 22:13     ` Laurent Pinchart
@ 2019-02-22 11:54     ` Marc Gonzalez
  1 sibling, 0 replies; 8+ messages in thread
From: Marc Gonzalez @ 2019-02-22 11:54 UTC (permalink / raw)
  To: Bjorn Andersson, Laurent Pinchart
  Cc: Vaishali Thakkar, Andy Gross, David Brown, Greg Kroah-Hartman,
	MSM, LKML, Vinod Koul

On 21/02/2019 16:57, Bjorn Andersson wrote:

> On Thu 21 Feb 04:18 PST 2019, Laurent Pinchart wrote:
> 
>> On Wed, Feb 20, 2019 at 10:28:29AM +0530, Vaishali Thakkar wrote:
>> 
>>> The Qualcomm socinfo provides a number of additional attributes,
>>> add these to the socinfo driver and expose them via debugfs
>>> functionality.
>> 
>> What is the use case for these attributes ? I fear they will be used in
>> production systems, and that would require debugfs in production, which
>> isn't a good idea. If you need to expose those attributes for anything
>> else than debugging then we need a proper API, likely sysfs-based.
> 
> The use case of these attributes, beyond development/debugging, are
> unfortunately somewhat unknown and is the reason why they where moved to
> debugfs from the earlier attempts to upstream this.
> 
> I think the production requirements at hand prohibits debugfs to be
> present, so attributes that are required beyond development/debugging
> purposes would have to be migrated out to sysfs - but the idea here is
> that such migration would have come with the missing motivation to add
> them there today.

On a tangential note, I saw the following message when using PCIe:

atl1c 0000:01:00.0: vpd r/w failed.  This is likely a firmware bug on this device.  Contact the card vendor for a firmware update
pcilib: sysfs_read_vpd: read failed: Connection timed out

Is this in any way related to custom attributes?

Regards.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-22 11:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20  4:58 [PATCH v2 3/5] soc: qcom: socinfo: Expose custom attributes Vaishali Thakkar
2019-02-21 12:18 ` Laurent Pinchart
2019-02-21 15:57   ` Bjorn Andersson
2019-02-21 22:13     ` Laurent Pinchart
2019-02-22  7:16       ` Greg KH
2019-02-22  9:51         ` Laurent Pinchart
2019-02-22 10:52           ` Greg KH
2019-02-22 11:54     ` Marc Gonzalez

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).