From f90e79c77bf6470354ab1a527dd50ee57087ccfa Mon Sep 17 00:00:00 2001 From: Gabriel2392 Date: Thu, 19 Oct 2023 10:51:24 -0300 Subject: [PATCH] drivers: add stub kperfmon --- drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/kperfmon/Kconfig | 25 +++++++++++++ drivers/kperfmon/Makefile | 20 +++++++++++ drivers/kperfmon/kperfmon.c | 71 +++++++++++++++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 drivers/kperfmon/Kconfig create mode 100644 drivers/kperfmon/Makefile create mode 100644 drivers/kperfmon/kperfmon.c diff --git a/drivers/Kconfig b/drivers/Kconfig index a33d4a73f..3a672ffdd 100755 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -260,6 +260,7 @@ source "drivers/sti/common/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT source "drivers/input/input_boost/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT source "drivers/battery/core/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT source "drivers/kq/mesh/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT +source "drivers/kperfmon/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT source "drivers/vibrator/common/vib_info/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT source "drivers/input/sec_input/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT source "drivers/usb/common/vbus_notifier/Kconfig" # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT diff --git a/drivers/Makefile b/drivers/Makefile index 593ecd56b..756777a13 100755 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -216,6 +216,7 @@ obj-y += muic/common/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT obj-y += input/input_boost/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT obj-y += battery/core/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT obj-y += kq/mesh/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT +obj-y += kperfmon/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT obj-y += vibrator/common/vib_info/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT obj-y += input/sec_input/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT obj-y += usb/common/vbus_notifier/ # ADDED BY LEGO AUTOMATICALLY: DO NOT SUBMIT diff --git a/drivers/kperfmon/Kconfig b/drivers/kperfmon/Kconfig new file mode 100644 index 000000000..56580d665 --- /dev/null +++ b/drivers/kperfmon/Kconfig @@ -0,0 +1,25 @@ +# +# Samsung Performance Logging system +# + +menu "samsung Performace manager" + +config KPERFMON + bool "Enable performance log" + default y + help + Samsung performance log(OLOG). + Say Y here if enable performance olog driver to do logging system resources. + When some delay occurs in the kernel, native or user user space, + the logging information should be restored into the system. + +config KPERFMON_BUILD + tristate "Building tyoe of performance log" + default m + help + Samsung performance log(OLOG). + This is to set a build type for module or build-in. + Say m here if you want a module of performance olog driver. + Say y here if you want build-in object of the performance olog driver. + +endmenu diff --git a/drivers/kperfmon/Makefile b/drivers/kperfmon/Makefile new file mode 100644 index 000000000..8e394a9cd --- /dev/null +++ b/drivers/kperfmon/Makefile @@ -0,0 +1,20 @@ +# +# Makefile for the Linux kernel device drivers. +# +# Sep 2018, Binse Park +# Rewritten to use lists instead of if-statements. +# + +FLAG=1 + +ifneq ($(CONFIG_KPERFMON), y) +FLAG=0 +endif + +ifeq ($(FLAG), 1) +ifeq ($(CONFIG_KPERFMON_BUILD), y) + obj-y += kperfmon.o +else + obj-m += kperfmon.o +endif +endif diff --git a/drivers/kperfmon/kperfmon.c b/drivers/kperfmon/kperfmon.c new file mode 100644 index 000000000..54ef62cad --- /dev/null +++ b/drivers/kperfmon/kperfmon.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include + +#define BUFFER_SIZE 1024 + +#define PROC_NAME "kperfmon" +#define MESSAGE "kperfmon_version [1.0.1] kperfmon_read : 0x39b76d0, kperfmon_write : 0x39b76b8\njava_version [U14.1.0]\nnativelib_version [U14.1.0]\nperfmond_version [U14.3.0]\n[01-01 00:00:00.000 1 1181 0 ( 2)][LOG][LCDV] ON\n" + +static ssize_t proc_read(struct file *file, char *buf, size_t count, loff_t *pos); +static int proc_open(struct inode *inode, struct file *file); +static ssize_t proc_write(struct file *file, const char __user *usr_buf, size_t count, loff_t *pos); + +static struct proc_ops proc_ops = { + .proc_read = proc_read, + .proc_open = proc_open, + .proc_write = proc_write, +}; + +static int proc_init(void) { + if (proc_create(PROC_NAME, 0664, NULL, &proc_ops) == NULL) { + pr_info("%s() - Error creating entry in proc failed!!!\n", __func__); + return -ENOMEM; + } + pr_info("%s()\n", __func__); + return 0; +} + +static void proc_exit(void) { + remove_proc_entry(PROC_NAME, NULL); + pr_info("%s()\n", __func__); +} + +static ssize_t proc_read(struct file *file, char __user *usr_buf, size_t count, loff_t *pos) { + int rv; + char buffer[BUFFER_SIZE]; + + rv = snprintf(buffer, sizeof(buffer), MESSAGE); + if (rv < 0) + return rv; + + if (*pos >= rv) + return 0; + + if (count > rv - *pos) + count = rv - *pos; + + if (copy_to_user(usr_buf, buffer + *pos, count)) { + return -EFAULT; + } + + *pos += count; + return count; +} + +static int proc_open(struct inode *inode, struct file *file) { + return 0; +} + +static ssize_t proc_write(struct file *file, const char __user *usr_buf, size_t count, loff_t *pos) { + return count; +} + +module_init(proc_init); +module_exit(proc_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Binse Park "); +MODULE_DESCRIPTION("Performance Log(OLOG)");