Skip to contentSkip to conversation

Add Data Capture and Compare(DCC) driver to new location

PATCH In review Souradeep Chowdhury 3 participants 11 messages Apr 14, 2023 – Apr 18, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add Data Capture and Compare(DCC) driver to new location

DCC(Data Capture and Compare) is a DMA engine designed for debugging purposes. In case of a system crash or manual software triggers by the user the DCC hardware stores the value at the register addresses which can be used for debugging purposes. The DCC driver provides the user with debugfs interface to configure the register addresses. The options that the DCC hardware provides include reading from registers, writing to registers, first reading and then writing to registers and looping through the values of the same register.

This patch series is a continuation of the previous series

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

The dcc driver is moved to a new location drivers/misc along with the binding as per discussions.

Souradeep Chowdhury (3):
dt-bindings: misc: qcom,dcc: Add the dtschema
drivers: misc: dcc: Add driver support for Data Capture and Compare
unit(DCC)
MAINTAINERS: Add the entry for DCC(Data Capture and Compare) driver
support

 .../devicetree/bindings/misc/qcom,dcc.yaml         |   44 +
 MAINTAINERS                                        |    8 +
 drivers/misc/Kconfig                               |    8 +
 drivers/misc/Makefile                              |    1 +
 drivers/misc/dcc.c                                 | 1305 ++++++++++++++++++++
 5 files changed, 1366 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/qcom,dcc.yaml
 create mode 100644 drivers/misc/dcc.c

--
2.7.4

#1 lore raw

PATCH 1/3 dt-bindings: misc: qcom,dcc: Add the dtschema

Add the device tree bindings for Data Capture and Compare(DCC).

---
 .../devicetree/bindings/misc/qcom,dcc.yaml         | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/qcom,dcc.yaml
Documentation/devicetree/bindings/misc/qcom,dcc.yaml new file +44 -0
new file mode 100644
index 0000000..055f3cb
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/misc/qcom,dcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Data Capture and Compare
+
+maintainers:
+  - Souradeep Chowdhury <[email protected]>
+
+description: |
+    DCC (Data Capture and Compare) is a DMA engine which is used to save
+    configuration data or system memory contents during catastrophic failure
+    or SW trigger. DCC is used to capture and store data for debugging purpose
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - qcom,sm8150-dcc
+          - qcom,sc7280-dcc
+          - qcom,sc7180-dcc
+          - qcom,sdm845-dcc
+      - const: qcom,dcc
+
+  reg:
+    items:
+      - description: DCC base
+      - description: DCC RAM base
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    dma@10a2000{
+        compatible = "qcom,sm8150-dcc", "qcom,dcc";
+        reg = <0x010a2000 0x1000>,
+              <0x010ad000 0x2000>;
+    };
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

In reply to Souradeep Chowdhury

The DCC is a DMA Engine designed to capture and store data during system crash or software triggers. The DCC operates based on user inputs via the debugfs interface. The user gives addresses as inputs and these addresses are stored in the dcc sram. In case of a system crash or a manual software trigger by the user through the debugfs interface, the dcc captures and stores the values at these addresses. This patch contains the driver which has all the methods pertaining to the debugfs interface, auxiliary functions to support all the four fundamental operations of dcc namely read, write, read/modify/write and loop. The probe method here instantiates all the resources necessary for dcc to operate mainly the dedicated dcc sram where it stores the values. The DCC driver can be used for debugging purposes without going for a reboot since it can perform software triggers as well based on user inputs.

Also add the documentation for debugfs entries which explains the functionalities of each debugfs file that has been created for dcc.

The following is the justification of using debugfs interface over the other alternatives like sysfs/ioctls

i) As can be seen from the debugfs attribute descriptions, some of the debugfs attribute files here contains multiple arguments which needs to be accepted from the user. This goes against the design style of sysfs.

ii) The user input patterns have been made simple and convenient in this case with the use of debugfs interface as user doesn't need to shuffle between different files to execute one instruction as was the case on using other alternatives.

---
 drivers/misc/Kconfig  |    8 +
 drivers/misc/Makefile |    1 +
 drivers/misc/dcc.c    | 1305 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1314 insertions(+)
 create mode 100644 drivers/misc/dcc.c
drivers/misc/Kconfig +8 -0
index 433aa41..e2bc652 100644
@@ -276,6 +276,14 @@ config QCOM_COINCELL
 	  to maintain PMIC register and RTC state in the absence of
 	  external power.
 
+config QCOM_DCC
+	tristate "Qualcomm Technologies, Inc. Data Capture and Compare(DCC) engine driver"
+	depends on ARCH_QCOM || COMPILE_TEST
+	help
+	  This option enables driver for Data Capture and Compare engine. DCC
+	  driver provides interface to configure DCC block and read back
+	  captured data from DCC's internal SRAM.
+
 config QCOM_FASTRPC
 	tristate "Qualcomm FastRPC"
 	depends on ARCH_QCOM || COMPILE_TEST
drivers/misc/Makefile +1 -0
index 56de439..6fa8efa 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_TIFM_CORE)       	+= tifm_core.o
 obj-$(CONFIG_TIFM_7XX1)       	+= tifm_7xx1.o
 obj-$(CONFIG_PHANTOM)		+= phantom.o
 obj-$(CONFIG_QCOM_COINCELL)	+= qcom-coincell.o
+obj-$(CONFIG_QCOM_DCC)		+= dcc.o
 obj-$(CONFIG_QCOM_FASTRPC)	+= fastrpc.o
 obj-$(CONFIG_SENSORS_BH1770)	+= bh1770glc.o
 obj-$(CONFIG_SENSORS_APDS990X)	+= apds990x.o
drivers/misc/dcc.c new file +1305 -0

1,305 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

Quoted 8 lines · Souradeep Chowdhury

The DCC is a DMA Engine designed to capture and store data during system crash or software triggers. The DCC operates based on user inputs via the debugfs interface. The user gives addresses as inputs and these addresses are stored in the dcc sram. In case of a system crash or a manual software trigger by the user through the debugfs interface, the dcc captures and stores the values at these addresses. This patch contains the driver which has all the methods

Quoted 8 lines

pertaining to the debugfs interface, auxiliary functions to support all the four fundamental operations of dcc namely read, write, read/modify/write and loop. The probe method here instantiates all the resources necessary for dcc to operate mainly the dedicated dcc sram where it stores the values. The DCC driver can be used for debugging purposes without going for a reboot since it can perform software triggers as well based on user inputs.

You have 72 columns, why not use them all please?

drivers/misc/dcc.c line 4

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.

It is now 2023 :)

Quoted 10 lines

+ */

drivers/misc/dcc.c new file +9 -0
+
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/miscdevice.h>

drivers/misc/dcc.c line 24

Quoted 10 lines
drivers/misc/dcc.c new file +10 -0
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#define STATUS_READY_TIMEOUT		5000  /* microseconds */
+
+#define DCC_SRAM_NODE "dcc_sram"

You only use this once, why is a #define needed?

drivers/misc/dcc.c line 1118

Quoted 8 lines
drivers/misc/dcc.c new file +8 -0
+static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
+{
+	int i;
+	char list_num[10];
+	struct dentry *list;
+	struct device *dev = drvdata->dev;
+
+	drvdata->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);

You are creating a directory at the root of debugfs with just your device name? While that will work, that feels very odd. Please use a subdirectory.

drivers/misc/dcc.c line 1120

Quoted 2 lines
drivers/misc/dcc.c new file +2 -0
+	if (IS_ERR(drvdata->dbg_dir)) {
+		pr_err("can't create debugfs dir\n");

There is no need to ever check the return value of a debugfs call.

Nor do you really ever even need to save off the dentry here, just look it up when you need to remove it.

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+		return;
+	}
+
+	for (i = 0; i <= drvdata->nr_link_list; i++) {

drivers/misc/dcc.c line 1134

Quoted 10 lines
drivers/misc/dcc.c new file +10 -0
+		sprintf(list_num, "%d", i);
+		list = debugfs_create_dir(list_num, drvdata->dbg_dir);
+		debugfs_create_file("enable", 0600, list, drvdata, &enable_fops);
+		debugfs_create_file("config", 0600, list, drvdata, &config_fops);
+	}
+
+	debugfs_create_file("trigger", 0200, drvdata->dbg_dir, drvdata, &trigger_fops);
+	debugfs_create_file("ready", 0400, drvdata->dbg_dir, drvdata, &ready_fops);
+	debugfs_create_file("config_reset", 0200, drvdata->dbg_dir,
+			    drvdata, &config_reset_fops);

This really looks like you are using debugfs to control the device, not just for debugging information. How are you going to be able to use the device in a system that has debugfs disabled?

thanks,

greg k-h

#4 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

Quoted 18 lines · Greg Kroah-Hartman
Quoted 8 lines · Souradeep Chowdhury

The DCC is a DMA Engine designed to capture and store data during system crash or software triggers. The DCC operates based on user inputs via the debugfs interface. The user gives addresses as inputs and these addresses are stored in the dcc sram. In case of a system crash or a manual software trigger by the user through the debugfs interface, the dcc captures and stores the values at these addresses. This patch contains the driver which has all the methods

Quoted 8 lines

pertaining to the debugfs interface, auxiliary functions to support all the four fundamental operations of dcc namely read, write, read/modify/write and loop. The probe method here instantiates all the resources necessary for dcc to operate mainly the dedicated dcc sram where it stores the values. The DCC driver can be used for debugging purposes without going for a reboot since it can perform software triggers as well based on user inputs.

Quoted 8 lines

You have 72 columns, why not use them all please?

drivers/misc/dcc.c line 4

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.

It is now 2023 :)

Ack

Quoted 18 lines
Quoted 18 lines

+ */

drivers/misc/dcc.c new file +13 -0
+
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
Quoted 8 lines

drivers/misc/dcc.c line 24

Quoted 6 lines
drivers/misc/dcc.c new file +6 -0
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#define STATUS_READY_TIMEOUT		5000  /* microseconds */
+
+#define DCC_SRAM_NODE "dcc_sram"

You only use this once, why is a #define needed?

This is as per the comment on version 1 of the patch series on DCC

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"kzalloc + strlcpy can be replaced by kstrdup(), but that said...all this does seems to be to copy a const string to the heap and lugging it around. Use a define instead."

Quoted 13 lines

drivers/misc/dcc.c line 1118

Quoted 9 lines
drivers/misc/dcc.c new file +8 -0
+static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
+{
+	int i;
+	char list_num[10];
+	struct dentry *list;
+	struct device *dev = drvdata->dev;
+
+	drvdata->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);

You are creating a directory at the root of debugfs with just your device name? While that will work, that feels very odd. Please use a subdirectory.

This is as per the comment on v17 of the patch series on DCC

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"You never remove this dcc_dbg directory. Why not?

And since you don't, dcc_dbg could just be a local variable here rather than being a global. But it seems to me this is the root directory you want to remove when you're done."

Quoted 8 lines

drivers/misc/dcc.c line 1120

Quoted 3 lines
drivers/misc/dcc.c new file +2 -0
+	if (IS_ERR(drvdata->dbg_dir)) {
+		pr_err("can't create debugfs dir\n");

There is no need to ever check the return value of a debugfs call.

Nor do you really ever even need to save off the dentry here, just look it up when you need to remove it.

Ack

Quoted 11 lines
Quoted 11 lines
drivers/misc/dcc.c new file +10 -0
+		return;
+	}
+
+	for (i = 0; i <= drvdata->nr_link_list; i++) {
+		sprintf(list_num, "%d", i);
+		list = debugfs_create_dir(list_num, drvdata->dbg_dir);
+		debugfs_create_file("enable", 0600, list, drvdata, &enable_fops);
+		debugfs_create_file("config", 0600, list, drvdata, &config_fops);
+	}
+
Quoted 8 lines

drivers/misc/dcc.c line 1134

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+	debugfs_create_file("trigger", 0200, drvdata->dbg_dir, drvdata, &trigger_fops);
+	debugfs_create_file("ready", 0400, drvdata->dbg_dir, drvdata, &ready_fops);
+	debugfs_create_file("config_reset", 0200, drvdata->dbg_dir,
+			    drvdata, &config_reset_fops);

This really looks like you are using debugfs to control the device, not just for debugging information. How are you going to be able to use the device in a system that has debugfs disabled?

As per upstream discussions it was decided that debugfs will be a suitable interface for DCC. More on this in the following link:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 4 lines

thanks,

greg k-h

#5 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

Quoted 59 lines · Souradeep Chowdhury
Quoted 18 lines · Greg Kroah-Hartman
Quoted 8 lines · Souradeep Chowdhury

The DCC is a DMA Engine designed to capture and store data during system crash or software triggers. The DCC operates based on user inputs via the debugfs interface. The user gives addresses as inputs and these addresses are stored in the dcc sram. In case of a system crash or a manual software trigger by the user through the debugfs interface, the dcc captures and stores the values at these addresses. This patch contains the driver which has all the methods

Quoted 8 lines

pertaining to the debugfs interface, auxiliary functions to support all the four fundamental operations of dcc namely read, write, read/modify/write and loop. The probe method here instantiates all the resources necessary for dcc to operate mainly the dedicated dcc sram where it stores the values. The DCC driver can be used for debugging purposes without going for a reboot since it can perform software triggers as well based on user inputs.

Quoted 8 lines

You have 72 columns, why not use them all please?

drivers/misc/dcc.c line 4

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.

It is now 2023 :)

Ack

Quoted 18 lines
Quoted 18 lines

+ */

drivers/misc/dcc.c new file +13 -0
+
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
Quoted 8 lines

drivers/misc/dcc.c line 24

Quoted 6 lines
drivers/misc/dcc.c new file +6 -0
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#define STATUS_READY_TIMEOUT		5000  /* microseconds */
+
+#define DCC_SRAM_NODE "dcc_sram"

You only use this once, why is a #define needed?

Quoted 7 lines

This is as per the comment on version 1 of the patch series on DCC

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"kzalloc + strlcpy can be replaced by kstrdup(), but that said...all this does seems to be to copy a const string to the heap and lugging it around. Use a define instead."

But as you are not doing any of that here, just using the string in the one place it is needed is the same thing :)

Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
+{
+	int i;
+	char list_num[10];
Quoted 8 lines

drivers/misc/dcc.c line 1118

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+	struct dentry *list;
+	struct device *dev = drvdata->dev;
+
+	drvdata->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);

You are creating a directory at the root of debugfs with just your device name? While that will work, that feels very odd. Please use a subdirectory.

This is as per the comment on v17 of the patch series on DCC

Quoted 8 lines

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"You never remove this dcc_dbg directory. Why not?

And since you don't, dcc_dbg could just be a local variable here rather than being a global. But it seems to me this is the root directory you want to remove when you're done."

But that's not the issue. The issue is that you are putting into /sys/kernel/debug/ a flat namespace of all of your devices. Is that really what you want? If so, why do you think this will never conflict with any other device in the system?

Quoted 30 lines
Quoted 7 lines

drivers/misc/dcc.c line 1120

Quoted 2 lines
drivers/misc/dcc.c new file +2 -0
+	if (IS_ERR(drvdata->dbg_dir)) {
+		pr_err("can't create debugfs dir\n");

There is no need to ever check the return value of a debugfs call.

Nor do you really ever even need to save off the dentry here, just look it up when you need to remove it.

Ack

Quoted 11 lines
Quoted 11 lines
drivers/misc/dcc.c new file +10 -0
+		return;
+	}
+
+	for (i = 0; i <= drvdata->nr_link_list; i++) {
+		sprintf(list_num, "%d", i);
+		list = debugfs_create_dir(list_num, drvdata->dbg_dir);
+		debugfs_create_file("enable", 0600, list, drvdata, &enable_fops);
+		debugfs_create_file("config", 0600, list, drvdata, &config_fops);
+	}
+
Quoted 8 lines

drivers/misc/dcc.c line 1134

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+	debugfs_create_file("trigger", 0200, drvdata->dbg_dir, drvdata, &trigger_fops);
+	debugfs_create_file("ready", 0400, drvdata->dbg_dir, drvdata, &ready_fops);
+	debugfs_create_file("config_reset", 0200, drvdata->dbg_dir,
+			    drvdata, &config_reset_fops);

This really looks like you are using debugfs to control the device, not just for debugging information. How are you going to be able to use the device in a system that has debugfs disabled?

Quoted 4 lines

As per upstream discussions it was decided that debugfs will be a suitable interface for DCC. More on this in the following link:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/

debugfs is not a suitable interface for anything that is "real" as that's not what it is there for. Most systems disable debugfs entirely (i.e. Android), or prevent any normal user from accessing it, so this api you are creating will not be able to be used by anyone.

debugfs is for debugging, not for anything that the system functionality relies on to work properly.

Also, that was a v21 of the patch series, why did the numbering start over here at v1?

thanks,

greg k-h

#6 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

Quoted 62 lines · Greg Kroah-Hartman
Quoted 61 lines · Souradeep Chowdhury
Quoted 18 lines · Greg Kroah-Hartman
Quoted 8 lines · Souradeep Chowdhury

The DCC is a DMA Engine designed to capture and store data during system crash or software triggers. The DCC operates based on user inputs via the debugfs interface. The user gives addresses as inputs and these addresses are stored in the dcc sram. In case of a system crash or a manual software trigger by the user through the debugfs interface, the dcc captures and stores the values at these addresses. This patch contains the driver which has all the methods

Quoted 8 lines

pertaining to the debugfs interface, auxiliary functions to support all the four fundamental operations of dcc namely read, write, read/modify/write and loop. The probe method here instantiates all the resources necessary for dcc to operate mainly the dedicated dcc sram where it stores the values. The DCC driver can be used for debugging purposes without going for a reboot since it can perform software triggers as well based on user inputs.

Quoted 8 lines

You have 72 columns, why not use them all please?

drivers/misc/dcc.c line 4

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.

It is now 2023 :)

Ack

Quoted 18 lines
Quoted 18 lines

+ */

drivers/misc/dcc.c new file +13 -0
+
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
Quoted 8 lines

drivers/misc/dcc.c line 24

Quoted 6 lines
drivers/misc/dcc.c new file +6 -0
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#define STATUS_READY_TIMEOUT		5000  /* microseconds */
+
+#define DCC_SRAM_NODE "dcc_sram"

You only use this once, why is a #define needed?

This is as per the comment on version 1 of the patch series on DCC

Quoted 8 lines
Quoted 5 lines

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"kzalloc + strlcpy can be replaced by kstrdup(), but that said...all this does seems to be to copy a const string to the heap and lugging it around. Use a define instead."

But as you are not doing any of that here, just using the string in the one place it is needed is the same thing :)

Ack

Quoted 25 lines
Quoted 16 lines
Quoted 13 lines

drivers/misc/dcc.c line 1118

Quoted 9 lines
drivers/misc/dcc.c new file +8 -0
+static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
+{
+	int i;
+	char list_num[10];
+	struct dentry *list;
+	struct device *dev = drvdata->dev;
+
+	drvdata->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);

You are creating a directory at the root of debugfs with just your device name? While that will work, that feels very odd. Please use a subdirectory.

This is as per the comment on v17 of the patch series on DCC

Quoted 8 lines

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"You never remove this dcc_dbg directory. Why not?

And since you don't, dcc_dbg could just be a local variable here rather than being a global. But it seems to me this is the root directory you want to remove when you're done."

Quoted 4 lines

But that's not the issue. The issue is that you are putting into /sys/kernel/debug/ a flat namespace of all of your devices. Is that really what you want? If so, why do you think this will never conflict with any other device in the system?

Since we are going by the dev_name here which also contains the address
as per the example in the yaml binding, this will not conflict with other dev_names in the system.

Quoted 36 lines
Quoted 31 lines
Quoted 8 lines

drivers/misc/dcc.c line 1120

Quoted 3 lines
drivers/misc/dcc.c new file +2 -0
+	if (IS_ERR(drvdata->dbg_dir)) {
+		pr_err("can't create debugfs dir\n");

There is no need to ever check the return value of a debugfs call.

Nor do you really ever even need to save off the dentry here, just look it up when you need to remove it.

Ack

Quoted 11 lines
Quoted 11 lines
drivers/misc/dcc.c new file +10 -0
+		return;
+	}
+
+	for (i = 0; i <= drvdata->nr_link_list; i++) {
+		sprintf(list_num, "%d", i);
+		list = debugfs_create_dir(list_num, drvdata->dbg_dir);
+		debugfs_create_file("enable", 0600, list, drvdata, &enable_fops);
+		debugfs_create_file("config", 0600, list, drvdata, &config_fops);
+	}
+
Quoted 8 lines

drivers/misc/dcc.c line 1134

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+	debugfs_create_file("trigger", 0200, drvdata->dbg_dir, drvdata, &trigger_fops);
+	debugfs_create_file("ready", 0400, drvdata->dbg_dir, drvdata, &ready_fops);
+	debugfs_create_file("config_reset", 0200, drvdata->dbg_dir,
+			    drvdata, &config_reset_fops);

This really looks like you are using debugfs to control the device, not just for debugging information. How are you going to be able to use the device in a system that has debugfs disabled?

Quoted 4 lines

As per upstream discussions it was decided that debugfs will be a suitable interface for DCC. More on this in the following link:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines

debugfs is not a suitable interface for anything that is "real" as that's not what it is there for. Most systems disable debugfs entirely (i.e. Android), or prevent any normal user from accessing it, so this api you are creating will not be able to be used by anyone.

debugfs is for debugging, not for anything that the system functionality relies on to work properly.

DCC is a debugging hardware which stores the values of the configured register address on a system crash on it's dedicated sram. These register addresses are configured by the user through the debugfs interface. Also on the platforms where debugfs is disabled there is an alternative of using bootconfig suggested to configure the register values during boot-time. There is an ongoing patch series for that as follows:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

Quoted 3 lines

Also, that was a v21 of the patch series, why did the numbering start over here at v1?

Ack. It was decided prior to merge this driver under drivers/soc/qcom but after discussions it was concluded that drivers/misc will be the suitable home for this driver. Will post subsequent versions as a continuation of the previous series for convenience.

Quoted 4 lines

thanks,

greg k-h

#7 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

Quoted 27 lines · Souradeep Chowdhury
Quoted 26 lines · Greg Kroah-Hartman
Quoted 24 lines · Souradeep Chowdhury
Quoted 4 lines · Greg Kroah-Hartman
Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
+{
+	int i;
+	char list_num[10];
Quoted 8 lines

drivers/misc/dcc.c line 1118

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+	struct dentry *list;
+	struct device *dev = drvdata->dev;
+
+	drvdata->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);

You are creating a directory at the root of debugfs with just your device name? While that will work, that feels very odd. Please use a subdirectory.

This is as per the comment on v17 of the patch series on DCC

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"You never remove this dcc_dbg directory. Why not?

And since you don't, dcc_dbg could just be a local variable here rather than being a global. But it seems to me this is the root directory you want to remove when you're done."

Quoted 8 lines
Quoted 4 lines

But that's not the issue. The issue is that you are putting into /sys/kernel/debug/ a flat namespace of all of your devices. Is that really what you want? If so, why do you think this will never conflict with any other device in the system?

Since we are going by the dev_name here which also contains the address as per the example in the yaml binding, this will not conflict with other dev_names in the system.

That is not true at all. dev_names are only unique per bus type. There is nothing preventing any other bus from using the same name for their device as yours.

So please, for the sake of your own sanity, just create a directory and dump all of your devices into it. And for the sake of all of ours, as making the root of debugfs full of random device names is a mess, don't you think? What would happen if all drivers did that?

Quoted 13 lines
Quoted 5 lines
Quoted 4 lines

As per upstream discussions it was decided that debugfs will be a suitable interface for DCC. More on this in the following link:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines

debugfs is not a suitable interface for anything that is "real" as that's not what it is there for. Most systems disable debugfs entirely (i.e. Android), or prevent any normal user from accessing it, so this api you are creating will not be able to be used by anyone.

debugfs is for debugging, not for anything that the system functionality relies on to work properly.

Quoted 8 lines

DCC is a debugging hardware which stores the values of the configured register address on a system crash on it's dedicated sram. These register addresses are configured by the user through the debugfs interface. Also on the platforms where debugfs is disabled there is an alternative of using bootconfig suggested to configure the register values during boot-time. There is an ongoing patch series for that as follows:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

But again, debugfs is not even mounted in most systems, so how are they going to interact with your hardware? Restricting it to debugfs feels very odd to me, but hey, it's your code, I guess you don't want anyone to use it :)

good luck!

greg k-h

#8 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

Quoted 37 lines · Greg Kroah-Hartman
Quoted 27 lines · Souradeep Chowdhury
Quoted 26 lines · Greg Kroah-Hartman
Quoted 24 lines · Souradeep Chowdhury
Quoted 4 lines · Greg Kroah-Hartman
Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
+{
+	int i;
+	char list_num[10];
Quoted 8 lines

drivers/misc/dcc.c line 1118

Quoted 4 lines
drivers/misc/dcc.c new file +4 -0
+	struct dentry *list;
+	struct device *dev = drvdata->dev;
+
+	drvdata->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);

You are creating a directory at the root of debugfs with just your device name? While that will work, that feels very odd. Please use a subdirectory.

This is as per the comment on v17 of the patch series on DCC

https://lore.kernel.org/linux-arm-kernel/[email protected]/

"You never remove this dcc_dbg directory. Why not?

And since you don't, dcc_dbg could just be a local variable here rather than being a global. But it seems to me this is the root directory you want to remove when you're done."

Quoted 8 lines
Quoted 4 lines

But that's not the issue. The issue is that you are putting into /sys/kernel/debug/ a flat namespace of all of your devices. Is that really what you want? If so, why do you think this will never conflict with any other device in the system?

Since we are going by the dev_name here which also contains the address as per the example in the yaml binding, this will not conflict with other dev_names in the system.

Quoted 8 lines

That is not true at all. dev_names are only unique per bus type. There is nothing preventing any other bus from using the same name for their device as yours.

So please, for the sake of your own sanity, just create a directory and dump all of your devices into it. And for the sake of all of ours, as making the root of debugfs full of random device names is a mess, don't you think? What would happen if all drivers did that?

Ack

Quoted 31 lines
Quoted 14 lines
Quoted 6 lines
Quoted 5 lines

As per upstream discussions it was decided that debugfs will be a suitable interface for DCC. More on this in the following link:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/

Quoted 7 lines

debugfs is not a suitable interface for anything that is "real" as that's not what it is there for. Most systems disable debugfs entirely (i.e. Android), or prevent any normal user from accessing it, so this api you are creating will not be able to be used by anyone.

debugfs is for debugging, not for anything that the system functionality relies on to work properly.

Quoted 8 lines

DCC is a debugging hardware which stores the values of the configured register address on a system crash on it's dedicated sram. These register addresses are configured by the user through the debugfs interface. Also on the platforms where debugfs is disabled there is an alternative of using bootconfig suggested to configure the register values during boot-time. There is an ongoing patch series for that as follows:-

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

But again, debugfs is not even mounted in most systems, so how are they going to interact with your hardware? Restricting it to debugfs feels very odd to me, but hey, it's your code, I guess you don't want anyone to use it :)

good luck!

greg k-h

#9 lore raw

Re: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)

In reply to Souradeep Chowdhury
kernel test robot noticed the following build warnings:

Hi Souradeep,

kernel test robot noticed the following build warnings:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.3-rc7 next-20230417] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Souradeep-Chowdhury/dt-bindings-misc-qcom-dcc-Add-the-dtschema/20230414-220304
patch link:    https://lore.kernel.org/r/b1a9cbbcfefe133cc9047a71a2acdaa74239df29.1681480351.git.quic_schowdhu%40quicinc.com
patch subject: [PATCH V1 2/3] drivers: misc: dcc: Add driver support for Data Capture and Compare unit(DCC)
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20230418/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 9638da200e00bd069e6dd63604e14cbafede9324)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/f3f73f6008e1ebca6fba848e260b1f938d91be95
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Souradeep-Chowdhury/dt-bindings-misc-qcom-dcc-Add-the-dtschema/20230414-220304 git checkout f3f73f6008e1ebca6fba848e260b1f938d91be95
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/misc/dcc.c:217:14: warning: variable 'ret' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
           for (i = 0; i < drvdata->nr_link_list; i++) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/dcc.c:238:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/misc/dcc.c:217:14: note: remove the condition if it is always true
           for (i = 0; i < drvdata->nr_link_list; i++) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/dcc.c:190:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0

1 warning generated.

vim +217 drivers/misc/dcc.c

186
187 static int dcc_sw_trigger(struct dcc_drvdata *drvdata)
188 {
189 void __iomem *addr;
190 int ret;
191 int i;
192 u32 status;
193 u32 ll_cfg;
194 u32 tmp_ll_cfg;
195 u32 val;
196
197 mutex_lock(&drvdata->mutex);
198
199 for (i = 0; i < drvdata->nr_link_list; i++) {
200 if (!test_bit(i, drvdata->enable_bitmap))
201 continue;
202 ll_cfg = dcc_list_readl(drvdata, i, DCC_LL_CFG);
203 tmp_ll_cfg = ll_cfg & ~DCC_TRIGGER_MASK;
204 dcc_list_writel(drvdata, tmp_ll_cfg, i, DCC_LL_CFG);
205 dcc_list_writel(drvdata, 1, i, DCC_LL_SW_TRIGGER);
206 dcc_list_writel(drvdata, ll_cfg, i, DCC_LL_CFG);
207 }
208
209 addr = drvdata->base + DCC_STATUS(drvdata->mem_map_ver);
210 if (readl_poll_timeout(addr, val, !FIELD_GET(DCC_STATUS_MASK, val),
211 1, STATUS_READY_TIMEOUT)) {
212 dev_err(drvdata->dev, "DCC is busy after receiving sw trigger\n");
213 ret = -EBUSY;
214 goto out_unlock;
215 }
216

 > 217		for (i = 0; i < drvdata->nr_link_list; i++) {

218 if (!test_bit(i, drvdata->enable_bitmap))
219 continue;
220
221 status = dcc_list_readl(drvdata, i, DCC_LL_BUS_ACCESS_STATUS);
222 if (!status)
223 continue;
224
225 dev_err(drvdata->dev, "Read access error for list %d err: 0x%x\n",
226 i, status);
227 ll_cfg = dcc_list_readl(drvdata, i, DCC_LL_CFG);
228 tmp_ll_cfg = ll_cfg & ~DCC_TRIGGER_MASK;
229 dcc_list_writel(drvdata, tmp_ll_cfg, i, DCC_LL_CFG);
230 dcc_list_writel(drvdata, DCC_STATUS_MASK, i, DCC_LL_BUS_ACCESS_STATUS);
231 dcc_list_writel(drvdata, ll_cfg, i, DCC_LL_CFG);
232 ret = -ENODATA;
233 break;
234 }
235
236 out_unlock:
237 mutex_unlock(&drvdata->mutex);
238 return ret;
239 }
240

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#10 lore raw

PATCH 3/3 MAINTAINERS: Add the entry for DCC(Data Capture and Compare) driver support

In reply to Souradeep Chowdhury

Add the entries for all the files added as a part of driver support for DCC(Data Capture and Compare).

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index b4e9c5b..2071000 100644
@@ -5705,6 +5705,14 @@ W:	http://lists.twibble.org/mailman/listinfo/dc395x/
 F:	Documentation/scsi/dc395x.rst
 F:	drivers/scsi/dc395x.*
 
+DCC QTI DRIVER
+M:      Souradeep Chowdhury <[email protected]>
+L:      [email protected]
+S:      Maintained
+F:      Documentation/ABI/testing/debugfs-driver-dcc
+F:      Documentation/devicetree/bindings/misc/qcom,dcc.yaml
+F:      drivers/misc/dcc.c
+
 DCCP PROTOCOL
 L:	[email protected]
 S:	Orphan
Signature · 1 line
2.7.4