Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,32 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
obj-y += rs_trace.o
obj-y += rs_base.o
obj-y += rs_main.o
#ccflags-y += -I$(srctree)/drivers/misc/mediatek/base/power/include
ccflags-y += -I$(srctree)/drivers/gpu/mediatek/gpufreq/include/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/base/power/$(MTK_PLATFORM)/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/observer
ccflags-y += -I$(srctree)/kernel/
ccflags-y += -I$(srctree)/drivers/gpu/mediatek/mt-plat/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/perf_common/
ccflags-y += -DNR_FREQ_CPU=16
obj-y += rs_usage.o
obj-y += rs_state.o
obj-y += rs_index.o
obj-y += platform/$(MTK_PLATFORM)/
@@ -0,0 +1,13 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
obj-y += $(MTK_PLATFORM)/
@@ -0,0 +1,20 @@
#
# Copyright (C) 2018 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -Idrivers/misc/mediatek/vpu/mt6768/
ccflags-y += -Idrivers/misc/mediatek/mdla/1.0/
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
int rs_get_mdla_core_num(void)
{
return 0;
}
int rs_get_mdla_opp_max(int core)
{
return -1;
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
return -1;
}
int rs_get_mdla_ceiling_opp(int core)
{
return -1;
}
int rs_mdla_opp_to_freq(int core, int step)
{
return -1;
}
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
int rs_get_vpu_core_num(void)
{
return 0;
}
int rs_get_vpu_opp_max(int core)
{
return -1;
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
return -1;
}
int rs_get_vpu_ceiling_opp(int core)
{
return -1;
}
int rs_vpu_opp_to_freq(int core, int step)
{
return -1;
}
@@ -0,0 +1,20 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -Idrivers/misc/mediatek/vpu/mt6785/
ccflags-y += -Idrivers/misc/mediatek/mdla/1.0/
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
int rs_get_mdla_core_num(void)
{
return 0;
}
int rs_get_mdla_opp_max(int core)
{
return -1;
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
return -1;
}
int rs_get_mdla_ceiling_opp(int core)
{
return -1;
}
int rs_mdla_opp_to_freq(int core, int step)
{
return -1;
}
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#ifdef CONFIG_MTK_VPU_SUPPORT
#include "vpu_dvfs.h"
#endif
int rs_get_vpu_core_num(void)
{
#ifdef CONFIG_MTK_VPU_SUPPORT
return 2;
#else
return 0;
#endif
}
int rs_get_vpu_opp_max(int core)
{
#ifdef CONFIG_MTK_VPU_SUPPORT
return VPU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
#ifdef CONFIG_MTK_VPU_SUPPORT
return get_vpu_dspcore_opp(core);
#else
return -1;
#endif
}
int rs_get_vpu_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_VPU_SUPPORT
return get_vpu_ceiling_opp(core);
#else
return -1;
#endif
}
int rs_vpu_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_VPU_SUPPORT
return get_vpu_opp_to_freq(step);
#else
return -1;
#endif
}
@@ -0,0 +1,20 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0/$(MTK_PLATFORM)
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
int rs_get_mdla_core_num(void)
{
return 0;
}
int rs_get_mdla_opp_max(int core)
{
return -1;
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
return -1;
}
int rs_get_mdla_ceiling_opp(int core)
{
return -1;
}
int rs_mdla_opp_to_freq(int core, int step)
{
return -1;
}
@@ -0,0 +1,65 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#if defined(CONFIG_MTK_APUSYS_SUPPORT)
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_vpu_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 2;
#else
return 0;
#endif
}
int rs_get_vpu_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(VPU0);
#else
return -1;
#endif
}
int rs_get_vpu_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(VPU0);
#else
return -1;
#endif
}
int rs_vpu_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(VPU0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,20 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0/$(MTK_PLATFORM)
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
int rs_get_mdla_core_num(void)
{
return 0;
}
int rs_get_mdla_opp_max(int core)
{
return -1;
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
return -1;
}
int rs_get_mdla_ceiling_opp(int core)
{
return -1;
}
int rs_mdla_opp_to_freq(int core, int step)
{
return -1;
}
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#if defined(CONFIG_MTK_APUSYS_SUPPORT)
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_vpu_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 2;
#else
return 0;
#endif
}
int rs_get_vpu_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(VPU0);
#else
return -1;
#endif
}
int rs_get_vpu_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(VPU0);
#else
return -1;
#endif
}
int rs_vpu_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(VPU0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,20 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0/$(MTK_PLATFORM)
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#ifdef CONFIG_MTK_APUSYS_SUPPORT
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_mdla_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 1;
#else
return 0;
#endif
}
int rs_get_mdla_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(MDLA0);
#else
return -1;
#endif
}
int rs_get_mdla_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(MDLA0);
#else
return -1;
#endif
}
int rs_mdla_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(MDLA0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#if defined(CONFIG_MTK_APUSYS_SUPPORT)
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_vpu_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 2;
#else
return 0;
#endif
}
int rs_get_vpu_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(VPU0);
#else
return -1;
#endif
}
int rs_get_vpu_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(VPU0);
#else
return -1;
#endif
}
int rs_vpu_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(VPU0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,20 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0/$(MTK_PLATFORM)
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#ifdef CONFIG_MTK_APUSYS_SUPPORT
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_mdla_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 2;
#else
return 0;
#endif
}
int rs_get_mdla_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(MDLA0);
#else
return -1;
#endif
}
int rs_get_mdla_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(MDLA0);
#else
return -1;
#endif
}
int rs_mdla_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(MDLA0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#if defined(CONFIG_MTK_APUSYS_SUPPORT)
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_vpu_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 3;
#else
return 0;
#endif
}
int rs_get_vpu_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(VPU0);
#else
return -1;
#endif
}
int rs_get_vpu_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(VPU0);
#else
return -1;
#endif
}
int rs_vpu_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(VPU0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,20 @@
#
# Copyright (C) 2019 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/performance/resym
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0/$(MTK_PLATFORM)
ccflags-y += -I$(srctree)/drivers/misc/mediatek/apusys/power/2.0
obj-y += rs_vpu_pfm.o
obj-y += rs_mdla_pfm.o
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#ifdef CONFIG_MTK_APUSYS_SUPPORT
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_mdla_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 2;
#else
return 0;
#endif
}
int rs_get_mdla_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_mdla_support_idletime(void)
{
return 0;
}
int rs_get_mdla_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(MDLA0);
#else
return -1;
#endif
}
int rs_get_mdla_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(MDLA0);
#else
return -1;
#endif
}
int rs_mdla_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(MDLA0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/types.h>
#include "rs_pfm.h"
#if defined(CONFIG_MTK_APUSYS_SUPPORT)
#include <linux/platform_device.h>
#include "apusys_power.h"
#include "apu_power_table.h"
#endif
int rs_get_vpu_core_num(void)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return 3;
#else
return 0;
#endif
}
int rs_get_vpu_opp_max(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return APU_OPP_NUM - 1;
#else
return -1;
#endif
}
int rs_vpu_support_idletime(void)
{
return 0;
}
int rs_get_vpu_curr_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_opp(VPU0);
#else
return -1;
#endif
}
int rs_get_vpu_ceiling_opp(int core)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_get_ceiling_opp(VPU0);
#else
return -1;
#endif
}
int rs_vpu_opp_to_freq(int core, int step)
{
#ifdef CONFIG_MTK_APUSYS_SUPPORT
return apusys_opp_to_freq(VPU0, step);
#else
return -1;
#endif
}
@@ -0,0 +1,91 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <asm/page.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include "rs_base.h"
#define LOGSIZE 32
void *rs_alloc_atomic(int i32Size)
{
void *pvBuf;
if (i32Size <= PAGE_SIZE)
pvBuf = kmalloc(i32Size, GFP_ATOMIC);
else
pvBuf = vmalloc(i32Size);
return pvBuf;
}
void rs_free(void *pvBuf)
{
kvfree(pvBuf);
}
int rs_sysfs_create_dir(struct kobject *parent,
const char *name, struct kobject **ppsKobj)
{
struct kobject *psKobj = NULL;
if (name == NULL || ppsKobj == NULL)
return -1;
parent = (parent != NULL) ? parent : rs_kobj;
if (parent == NULL)
return -1;
psKobj = kobject_create_and_add(name, parent);
if (!psKobj)
return -1;
*ppsKobj = psKobj;
return 0;
}
void rs_sysfs_remove_dir(struct kobject **ppsKobj)
{
if (ppsKobj == NULL)
return;
kobject_put(*ppsKobj);
*ppsKobj = NULL;
}
void rs_sysfs_create_file(struct kobject *parent,
struct kobj_attribute *kobj_attr)
{
int ret;
if (kobj_attr == NULL)
return;
parent = (parent != NULL) ? parent : rs_kobj;
if (parent == NULL)
return;
ret = sysfs_create_file(parent, &(kobj_attr->attr));
if (ret)
pr_debug("Failed to create sysfs file\n");
}
void rs_sysfs_remove_file(struct kobject *parent,
struct kobj_attribute *kobj_attr)
{
if (kobj_attr == NULL)
return;
parent = (parent != NULL) ? parent : rs_kobj;
if (parent == NULL)
return;
sysfs_remove_file(parent, &(kobj_attr->attr));
}
@@ -0,0 +1,39 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _RS_BASE_H_
#define _RS_BASE_H_
#include <linux/kobject.h>
extern unsigned int mt_cpufreq_get_freq_by_idx(int id, int idx);
#define RS_CONTAINER_OF(ptr, type, member) \
((type *)(((char *)ptr) - offsetof(type, member)))
void *rs_alloc_atomic(int i32Size);
void rs_free(void *pvBuf);
/* sysfs */
#define RS_SYSFS_MAX_BUFF_SIZE 1024
extern struct kobject *rs_kobj;
#define KOBJ_ATTR_RW(_name) \
struct kobj_attribute kobj_attr_##_name = \
__ATTR(_name, 0660, \
_name##_show, _name##_store)
#define KOBJ_ATTR_RO(_name) \
struct kobj_attribute kobj_attr_##_name = \
__ATTR(_name, 0440, \
_name##_show, NULL)
int rs_sysfs_create_dir(struct kobject *parent,
const char *name, struct kobject **ppsKobj);
void rs_sysfs_remove_dir(struct kobject **ppsKobj);
void rs_sysfs_create_file(struct kobject *parent,
struct kobj_attribute *kobj_attr);
void rs_sysfs_remove_file(struct kobject *parent,
struct kobj_attribute *kobj_attr);
#endif
@@ -0,0 +1,356 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/mutex.h>
#include <linux/proc_fs.h>
#include <linux/module.h>
#include <linux/kernel_stat.h>
#include <linux/tick.h>
#include <linux/sched/stat.h>
#include <linux/sched/clock.h>
#include <linux/preempt.h>
#include <linux/slab.h>
#include <asm/div64.h>
#include <linux/sched/task.h>
//#include <trace/events/mtk_events.h>
#include <trace/events/block.h>
#include <linux/blk_types.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <mt-plat/mtk_blocktag.h>
//#include <perf_tracker_trace.h>
#include "rs_index.h"
#include "rs_trace.h"
#define TIME_5S 5000000000
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
enum {
RS_RET_SUCCESS = 0,
RS_RET_ERROR = -1,
RS_RET_INVALID = -2,
};
enum {
RS_STATE_INACTIVE = 0,
RS_STATE_ACTIVE = 1,
RS_STATE_READY = 2,
};
struct rs_io_stat {
unsigned long long dur_ns;
int io_wl;
int io_top;
int io_reqc_r;
int io_reqc_w;
int io_q_dept;
struct list_head entry;
};
static DEFINE_MUTEX(rs_loading_mutex);
static DEFINE_SPINLOCK(rs_loading_slock);
static int mask;
static int is_active;
static void wq_func(struct work_struct *data);
static DECLARE_WORK(rs_work, (void *) wq_func);
static unsigned long long last_access_ts;
static struct list_head io_stat_list;
static unsigned long long prev_ts;
#define RSL_TAG "RSL:"
#define rsi_systrace(mask, pid, val, fmt...) \
do { \
if (mask) \
__rs_systrace_c_uint64(pid, val, fmt); \
} while (0)
#define rsi_systrace_log(pid, val, fmt...) \
rsi_systrace(mask, pid, val, RSL_TAG fmt)
#define rsi_systrace_def(pid, val, fmt...) \
rsi_systrace(1, pid, val, RSL_TAG fmt)
static void rs_lockprove(const char *tag)
{
WARN_ON(!mutex_is_locked(&rs_loading_mutex));
}
static u64 rs_get_time(void)
{
unsigned long long temp;
preempt_disable();
temp = cpu_clock(smp_processor_id());
preempt_enable();
return temp;
}
static void wq_func(struct work_struct *data)
{
unsigned long long cur_ts = rs_get_time();
unsigned long long diff, last;
unsigned long flags;
spin_lock_irqsave(&rs_loading_slock, flags);
last = last_access_ts;
spin_unlock_irqrestore(&rs_loading_slock, flags);
if (cur_ts < last)
return;
diff = cur_ts - last;
if (diff <= TIME_5S)
return;
perf_rsi_switch_collect(0);
}
static void rs_reset_io_list_locked(void)
{
struct rs_io_stat *pos, *next;
list_for_each_entry_safe(pos, next, &(io_stat_list), entry) {
list_del(&pos->entry);
kfree(pos);
}
}
static void rs_get_io_stat_oneshot(struct rs_sys_data *stat)
{
#ifdef CONFIG_MTK_BLOCK_TAG
struct mtk_btag_mictx_iostat_struct iostat = {0};
if (mtk_btag_mictx_get_data(&iostat))
mtk_btag_mictx_enable(1);
stat->io_wl = iostat.wl;
stat->io_top = iostat.top;
stat->io_reqc_r = iostat.reqcnt_r;
stat->io_reqc_w = iostat.reqcnt_w;
stat->io_q_dept = iostat.q_depth;
#endif
}
static int rs_get_io_stat(struct rs_sys_data *stat)
{
int ret = 0;
struct rs_io_stat *pos, *next;
unsigned long flags;
unsigned long long io_dur = 0;
long long io_wl = 0;
long long io_top = 0;
long long io_reqc_r = 0;
long long io_reqc_w = 0;
long long io_q_dept = 0;
int cnt = 0;
spin_lock_irqsave(&rs_loading_slock, flags);
if (list_empty(&(io_stat_list))) {
spin_unlock_irqrestore(&rs_loading_slock, flags);
rs_get_io_stat_oneshot(stat);
ret = -1;
goto EXIT;
}
list_for_each_entry_safe(pos, next, &(io_stat_list), entry) {
io_dur += pos->dur_ns;
io_wl += pos->io_wl;
io_top += pos->io_top;
io_reqc_r += pos->io_reqc_r;
io_reqc_w += pos->io_reqc_w;
io_q_dept += pos->io_q_dept;
cnt++;
}
rs_reset_io_list_locked();
spin_unlock_irqrestore(&rs_loading_slock, flags);
stat->io_wl = div64_u64(io_wl, cnt);
stat->io_top = div64_u64(io_top, cnt);
stat->io_reqc_r = div64_u64(io_reqc_r, cnt);
stat->io_reqc_w = div64_u64(io_reqc_w, cnt);
stat->io_q_dept = div64_u64(io_q_dept, cnt);
EXIT:
return ret;
}
int perf_rsi_get_data(struct rs_sys_data *sysdata)
{
int ret = RS_RET_SUCCESS;
int ret_io;
u64 cur_ts;
long long dur = 0;
unsigned long flags;
rs_lockprove(__func__);
cur_ts = rs_get_time();
if (prev_ts)
dur = cur_ts - prev_ts;
prev_ts = cur_ts;
spin_lock_irqsave(&rs_loading_slock, flags);
last_access_ts = cur_ts;
if (is_active == RS_STATE_ACTIVE) {
is_active = RS_STATE_READY;
ret = RS_RET_INVALID;
}
spin_unlock_irqrestore(&rs_loading_slock, flags);
ret_io = rs_get_io_stat(sysdata);
if (ret_io)
ret = RS_RET_ERROR;
return ret;
}
static void rs_start_collect(void)
{
struct rs_sys_data sysdata = {0};
unsigned long flags;
rs_lockprove(__func__);
spin_lock_irqsave(&rs_loading_slock, flags);
if (is_active != RS_STATE_INACTIVE) {
spin_unlock_irqrestore(&rs_loading_slock, flags);
return;
}
is_active = RS_STATE_ACTIVE;
spin_unlock_irqrestore(&rs_loading_slock, flags);
//register_trace_perf_index_l(rs_update_io_stat, NULL);
perf_rsi_get_data(&sysdata);
}
static void rs_stop_collect(void)
{
unsigned long flags;
rs_lockprove(__func__);
spin_lock_irqsave(&rs_loading_slock, flags);
if (is_active == RS_STATE_INACTIVE) {
spin_unlock_irqrestore(&rs_loading_slock, flags);
return;
}
is_active = RS_STATE_INACTIVE;
rs_reset_io_list_locked();
spin_unlock_irqrestore(&rs_loading_slock, flags);
//unregister_trace_perf_index_l(rs_update_io_stat, NULL);
prev_ts = 0;
}
void perf_rsi_switch_collect(int cmd)
{
mutex_lock(&rs_loading_mutex);
if (cmd)
rs_start_collect();
else
rs_stop_collect();
mutex_unlock(&rs_loading_mutex);
}
void perf_rsi_trans_index(__s32 *data, __s32 input_size)
{
struct rs_sys_data sysdata = {0};
int limit_size;
int ret;
mutex_lock(&rs_loading_mutex);
ret = perf_rsi_get_data(&sysdata);
mutex_unlock(&rs_loading_mutex);
if (ret == RS_RET_INVALID)
return;
limit_size = MIN(input_size, sizeof(struct rs_sys_data));
memcpy(data, &sysdata, limit_size);
}
#define RS_DEBUGFS_ENTRY(name) \
static int rs_##name##_open(struct inode *i, struct file *file) \
{ \
return single_open(file, rs_##name##_show, i->i_private); \
} \
\
static const struct file_operations rs_##name##_fops = { \
.owner = THIS_MODULE, \
.open = rs_##name##_open, \
.read = seq_read, \
.write = rs_##name##_write, \
.llseek = seq_lseek, \
.release = single_release, \
}
static int rs_mask_show(struct seq_file *m, void *unused)
{
seq_printf(m, "%d\n", mask);
return 0;
}
static ssize_t rs_mask_write(struct file *flip,
const char *ubuf, size_t cnt, loff_t *data)
{
uint32_t val;
int ret;
ret = kstrtou32_from_user(ubuf, cnt, 16, &val);
if (ret)
return ret;
mask = val;
return cnt;
}
RS_DEBUGFS_ENTRY(mask);
int __init perf_rs_index_init(void)
{
INIT_LIST_HEAD(&(io_stat_list));
perf_rsi_getindex_fp = perf_rsi_trans_index;
perf_rsi_switch_collect_fp = perf_rsi_switch_collect;
return 0;
}
void rs_index_exit(void)
{
}
MODULE_AUTHOR("Chiayu Gu <chiayu.gu@mediatek.com>");
MODULE_AUTHOR("Stanley Chu <stanley.chu@mediatek.com>");
MODULE_DESCRIPTION("MediaTek Performance Index Collector");
MODULE_LICENSE("GPL v2");
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#ifndef RS_INDEX_H
#define RS_INDEX_H
struct rs_sys_data {
int io_wl;
int io_top;
int io_reqc_r;
int io_reqc_w;
int io_q_dept;
};
extern void (*perf_rsi_getindex_fp)(__s32 *data, __s32 input_size);
extern void (*perf_rsi_switch_collect_fp)(__s32 cmd);
int __init perf_rs_index_init(void);
void perf_rsi_switch_collect(int cmd);
#endif
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/module.h>
#include "rs_base.h"
#include "rs_trace.h"
#include "rs_usage.h"
#include "rs_state.h"
#include "rs_index.h"
#define RS_SYSFS_DIR_NAME "resym"
struct kobject *rs_kobj;
static int __init rs_init(void)
{
rs_kobj = kobject_create_and_add(RS_SYSFS_DIR_NAME, kernel_kobj);
perf_rs_index_init();
rs_trace_init();
rs_usage_init();
rs_state_init();
return 0;
}
static void __exit rs_exit(void)
{
rs_usage_exit();
rs_state_exit();
kobject_put(rs_kobj);
rs_kobj = NULL;
}
module_init(rs_init);
module_exit(rs_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MediaTek Resource Symphony");
MODULE_AUTHOR("MediaTek Inc.");
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __RS_PFM_H__
#define __RS_PFM_H__
/* VPU */
int rs_get_vpu_core_num(void);
int rs_get_vpu_opp_max(int core);
int rs_vpu_support_idletime(void);
int rs_get_vpu_curr_opp(int core);
int rs_get_vpu_ceiling_opp(int core);
int rs_vpu_opp_to_freq(int core, int step);
/* MDLA */
int rs_get_mdla_core_num(void);
int rs_get_mdla_opp_max(int core);
int rs_mdla_support_idletime(void);
int rs_get_mdla_curr_opp(int core);
int rs_get_mdla_ceiling_opp(int core);
int rs_mdla_opp_to_freq(int core, int step);
#endif
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/mutex.h>
#include <mt-plat/mtk_perfobserver.h>
#include "rs_state.h"
#include "rs_base.h"
static DEFINE_MUTEX(rsu_state_ntf_mutex);
static int is_throttled;
static struct kobject *rss_kobj;
void rsu_get_state(int *throttled)
{
mutex_lock(&rsu_state_ntf_mutex);
*throttled = is_throttled;
mutex_unlock(&rsu_state_ntf_mutex);
}
static int rsu_pob_eara_thrm_cb(struct notifier_block *nb,
unsigned long val, void *data)
{
switch (val) {
case POB_EARA_THRM_THROTTLED:
mutex_lock(&rsu_state_ntf_mutex);
is_throttled = 1;
mutex_unlock(&rsu_state_ntf_mutex);
break;
case POB_EARA_THRM_UNTHROTTLED:
mutex_lock(&rsu_state_ntf_mutex);
is_throttled = 0;
mutex_unlock(&rsu_state_ntf_mutex);
break;
default:
break;
}
return NOTIFY_OK;
}
static struct notifier_block rsu_pob_eara_thrm_notifier = {
.notifier_call = rsu_pob_eara_thrm_cb,
};
static ssize_t rs_state_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
{
int thrm_state = -1;
rsu_get_state(&thrm_state);
return scnprintf(buf, PAGE_SIZE, "%d\n", thrm_state);
}
KOBJ_ATTR_RO(rs_state);
int __init rs_state_init(void)
{
rsu_getstate_fp = rsu_get_state;
pob_eara_thrm_register_client(&rsu_pob_eara_thrm_notifier);
if (rs_sysfs_create_dir(NULL, "state", &rss_kobj))
return -ENODEV;
rs_sysfs_create_file(rss_kobj, &kobj_attr_rs_state);
return 0;
}
void __exit rs_state_exit(void)
{
rs_sysfs_remove_file(rss_kobj, &kobj_attr_rs_state);
rs_sysfs_remove_dir(&rss_kobj);
}
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef RS_STATE_H
#define RS_STATE_H
extern void (*rsu_getstate_fp)(int *throttled);
int __init rs_state_init(void);
void __exit rs_state_exit(void);
#endif
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#include <linux/preempt.h>
#include <linux/trace_events.h>
#include "rs_trace.h"
#define LOGSIZE 32
static unsigned long __read_mostly mark_addr;
static int rs_update_tracemark(void)
{
if (mark_addr)
return 1;
mark_addr = kallsyms_lookup_name("tracing_mark_write");
if (unlikely(!mark_addr))
return 0;
return 1;
}
void __rs_systrace_c(pid_t pid, int val, const char *fmt, ...)
{
char log[LOGSIZE];
va_list args;
int len;
if (unlikely(!rs_update_tracemark()))
return;
va_start(args, fmt);
len = vsnprintf(log, LOGSIZE, fmt, args);
va_end(args);
if (len == LOGSIZE)
log[LOGSIZE - 1] = '\0';
preempt_disable();
event_trace_printk(mark_addr, "C|%d|%s|%d\n", pid, log, val);
preempt_enable();
}
void __rs_systrace_c_uint64(pid_t pid, uint64_t val, const char *fmt, ...)
{
char log[LOGSIZE];
va_list args;
int len;
if (unlikely(!rs_update_tracemark()))
return;
va_start(args, fmt);
len = vsnprintf(log, LOGSIZE, fmt, args);
va_end(args);
if (len == LOGSIZE)
log[LOGSIZE - 1] = '\0';
preempt_disable();
event_trace_printk(mark_addr, "C|%d|%s|%llu\n", pid, log, val);
preempt_enable();
}
void __rs_systrace_b(pid_t tgid, const char *fmt, ...)
{
char log[LOGSIZE];
va_list args;
int len;
if (unlikely(!rs_update_tracemark()))
return;
va_start(args, fmt);
len = vsnprintf(log, LOGSIZE, fmt, args);
va_end(args);
if (len == LOGSIZE)
log[LOGSIZE - 1] = '\0';
preempt_disable();
event_trace_printk(mark_addr, "B|%d|%s\n", tgid, log);
preempt_enable();
}
void __rs_systrace_e(void)
{
if (unlikely(!rs_update_tracemark()))
return;
preempt_disable();
event_trace_printk(mark_addr, "E\n");
preempt_enable();
}
int rs_trace_init(void)
{
if (!rs_update_tracemark())
return -1;
return 0;
}
@@ -0,0 +1,55 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _RS_TRACE_H_
#define _RS_TRACE_H_
enum {
RS_DEBUG_MANDATORY = 1U << 0,
RS_DEBUG_MAX = 1U << 1,
};
extern uint32_t rs_systrace_mask;
int rs_trace_init(void);
void __rs_systrace_c(pid_t pid, int val, const char *fmt, ...);
void __rs_systrace_b(pid_t pid, const char *fmt, ...);
void __rs_systrace_e(void);
void __rs_systrace_c_uint64(pid_t pid, uint64_t val, const char *fmt, ...);
#define rs_systrace_c(mask, pid, val, fmt...) \
do { \
if (rs_systrace_mask & mask) \
__rs_systrace_c(pid, val, fmt); \
} while (0)
#define rs_systrace_c_uint64(mask, pid, val, fmt...) \
do { \
if (rs_systrace_mask & mask) \
__rs_systrace_c_uint64(pid, val, fmt); \
} while (0)
#define rs_systrace_b(mask, tgid, fmt, ...) \
do { \
if (rs_systrace_mask & mask) \
__rs_systrace_b(tgid, fmt); \
} while (0)
#define rs_systrace_e(mask) \
do { \
if (rs_systrace_mask & mask) \
__rs_systrace_e(); \
} while (0)
#define rs_systrace_c_log(pid, val, fmt...) \
rs_systrace_c(RS_DEBUG_MANDATORY, pid, val, fmt)
#define rs_systrace_c_uint64_log(pid, val, fmt...) \
rs_systrace_c_uint64(RS_DEBUG_MANDATORY, pid, val, fmt)
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,28 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef RS_USAGE_H
#define RS_USAGE_H
enum {
USAGE_DEVTYPE_CPU = 0,
USAGE_DEVTYPE_GPU = 1,
USAGE_DEVTYPE_APU = 2,
USAGE_DEVTYPE_MDLA = 3,
USAGE_DEVTYPE_VPU = 4,
USAGE_DEVTYPE_MAX = 5,
};
extern void (*rsu_cpufreq_notifier_fp)(int cluster_id, unsigned long freq);
extern void (*rsu_getusage_fp)(__s32 *devusage, __u32 *bwusage, __u32 pid);
int __init rs_usage_init(void);
void __exit rs_usage_exit(void);
extern unsigned int __attribute__((weak)) mt_ppm_userlimit_freq_limit_by_others(
unsigned int cluster);
#endif