Re: [PATCH v2 07/13] trinity: Add sysfs module

From: Greg KH
Date: Sun Sep 18 2022 - 06:32:47 EST


On Sat, Sep 17, 2022 at 04:23:50PM +0900, Jiho Chu wrote:
> This patch includes sysfs interfaces.
>
> sysfs interface provides NPU's internal statistics, status and control
> attribes.
>
> The sysfs information provided by the Trinity are:
> - IDU version
> - profiling result
> - allocated debugfs buffer
>
> The control attributes are including:
> - initialize profile operation
> - NPU control (suspend/resume/stop)
>
> Signed-off-by: Jiho Chu <jiho.chu@xxxxxxxxxxx>
> Signed-off-by: Yelin Jeong <yelini.jeong@xxxxxxxxxxx>
> Signed-off-by: Dongju Chae <dongju.chae@xxxxxxxxxxx>
> Signed-off-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>
> ---
> .../ABI/testing/sysfs-driver-trinity | 55 ++
> drivers/misc/trinity/Makefile | 1 +
> drivers/misc/trinity/trinity_sysfs.c | 667 ++++++++++++++++++
> 3 files changed, 723 insertions(+)
> create mode 100644 Documentation/ABI/testing/sysfs-driver-trinity
> create mode 100644 drivers/misc/trinity/trinity_sysfs.c
>
> diff --git a/Documentation/ABI/testing/sysfs-driver-trinity b/Documentation/ABI/testing/sysfs-driver-trinity
> new file mode 100644
> index 000000000000..754e6f36a1dc
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-driver-trinity
> @@ -0,0 +1,55 @@
> +What: /sys/devices/platform/trinity/*.triv2/debug/debugfs_max
> +Date: July 2022
> +KernelVersion: 5.19-rc8
> +Contact: Jiho Chu <jiho.chu@xxxxxxxxxxx>
> +Description: Shows current allocated debugfs entry size.
> + Note that, Writing max entry size allocates NPU's hardware
> + memory for debugfs entries.

Why are debugfs things being mentioned in sysfs entries?

That's not needed, nor is it allowed, sorry.

Please put all debugfs stuff in debugfs.

Also, sysfs is "one value per file", you violate that in lots of ways
with this patch. Please fix all of that, and use the sysfs_emit() calls
instead of snprintf() for your sysfs show calls.

thanks,

greg k-h