M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
BOARD_PLATFORM_LIST := msm8974
BOARD_PLATFORM_LIST += msm8226
BOARD_PLATFORM_LIST += msm8610
ifeq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true)
LOCAL_PATH := $(call my-dir)
# the dlkm
include $(CLEAR_VARS)
DLKM_DIR := device/qcom/common/dlkm
LOCAL_MODULE := msm_watchdog_test_module.ko
LOCAL_MODULE_TAGS := debug
include $(DLKM_DIR)/AndroidKernelModule.mk
# the test script
include $(CLEAR_VARS)
LOCAL_MODULE := msm_watchdog_test.sh
LOCAL_SRC_FILES := msm_watchdog_test.sh
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/kernel-tests
include $(BUILD_PREBUILT)
endif

View File

@@ -0,0 +1 @@
obj-m := msm_watchdog_test_module.o

View File

@@ -0,0 +1,24 @@
watchdogdir = $(prefix)/watchdog
KERNEL_FLAGS ?= ARCH=arm
dist_watchdog_SCRIPTS = msm_watchdog_test.sh run.sh
module = msm_watchdog_test_module.ko
kmake = $(MAKE) $(KERNEL_FLAGS) -C $(KERNEL_DIR) M=$(CURDIR)
$(module):
$(kmake) modules
all-local: $(module)
install-exec-local: $(module)
$(kmake) INSTALL_MOD_PATH=$(DESTDIR)$(prefix)/modules modules_install
dist_watchdog_DATA = README.txt
# "make distclean" will always run clean-local in this directory,
# regardless of the KERNELMODULES conditional. Therefore, ensure
# KERNEL_DIR exists before running clean. Further, don't fail even
# if there is a problem.
clean-local:
-test ! -d "$(KERNEL_DIR)" || $(kmake) clean

View File

@@ -0,0 +1,52 @@
Watchdog Testing Documentation
Usage: msm_watchdog_test.sh TEST
Runs the basic watchdog test
TEST can be one of: apps_wdog_bite, sec_wdog_bite,
sec_wdog_scm, apps_wdog_bark
OPTIONS:
The module knows about the following parameters
- apps_wdog_bite
- sec_wdog_bite
- sec_wdog_scm
- apps_wdog_bark
Setting any of these to 1 at insmod time will cause the
corresponding test to be executed. For example, the following will
run the apps watchdog bark test:
# insmod msm_watchdog_test_module.ko apps_wdog_bark=1
However, rather than inserting the module directly and worrying
about supplying the correct parameters, you should use the wrapper
script: msm_watchdog_test.sh.
TEST BEHAVIOR:
* Test will force a watchdog timeout, which will reboot the system.
After obtaining rampdumps from debug mode, the ramdump parser
will produce the following results:
| Test | Outcome |
|----------------+---------------------------------------------------------|
| sec_wdog_scm | No watchdog (FIQ) message should be present. |
| | The CPU context should be dumped as part of |
| | the debug image output. |
|----------------+---------------------------------------------------------|
| sec_wdog_bite | Same as sec_wdog_scm. |
|----------------+---------------------------------------------------------|
| apps_wdog_bark | No watchdog (FIQ) message should be present. |
|----------------+---------------------------------------------------------|
| apps_wdog_bite | Watchdog/FIQ message should be present. The CPU context |
| | should be dumped as part of the debug image output. |
TARGETS:
* 8974
NOTES:
If the script successfully returns and gives you back a shell prompt, the
test failed.

View File

@@ -0,0 +1,56 @@
# Copyright (c) 2012, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of The Linux Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if [ -d /system/lib/modules/ ]; then
modpath=/system/lib/modules
else
modpath=/kernel-tests/modules/lib/modules/$(uname -r)/extra
fi
watchdog_test_mod=${modpath}/msm_watchdog_test_module.ko
case "$1" in
apps_wdog_bite|apps_wdog_bark|sec_wdog_bite|sec_wdog_scm)
thetest="$1"
echo "Running test $thetest"
;;
*)
echo "Unkown test: $1"
echo "Supported tests: apps_wdog_bite apps_wdog_bark sec_wdog_bite sec_wdog_scm"
exit 1
;;
esac
if [ -e $watchdog_test_mod ]; then
insmod $watchdog_test_mod ${thetest}=1
else
echo "watchdog test module not found (${watchdog_test_mod})"
fi
echo "Test failed"
exit 1

View File

@@ -0,0 +1,215 @@
/* Copyright (c) 2012-2013, Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only 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.
*/
#include <linux/completion.h>
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/preempt.h>
#include <linux/irq.h>
#include <linux/smp.h>
#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <asm/barrier.h>
#include <asm/io.h>
#include <asm-generic/sizes.h>
#include <mach/scm.h>
#define REG_MPM2_WDOG_BASE 0xFC4AA000
#define REG_OFFSET_MPM2_WDOG_RESET 0x0
#define REG_OFFSET_MPM2_WDOG_BITE_VAL 0x10
#define REG_VAL_WDOG_RESET_DO_RESET 0x1
#define REG_VAL_WDOG_BITE_VAL 0x400
#define SCM_SVC_SEC_WDOG_TRIG 0x8
#define MDELAY_TIME 15000
static int apps_wdog_bite;
static int sec_wdog_bite;
static int sec_wdog_scm;
static int apps_wdog_bark;
static int apps_wdog_bite_set(const char *val, struct kernel_param *kp);
module_param_call(apps_wdog_bite, apps_wdog_bite_set, param_get_int,
&apps_wdog_bite, 0644);
static int sec_wdog_bite_set(const char *val, struct kernel_param *kp);
module_param_call(sec_wdog_bite, sec_wdog_bite_set, param_get_int,
&sec_wdog_bite, 0644);
static int sec_wdog_scm_set(const char *val, struct kernel_param *kp);
module_param_call(sec_wdog_scm, sec_wdog_scm_set, param_get_int,
&sec_wdog_scm, 0644);
static int apps_wdog_bark_set(const char *val, struct kernel_param *kp);
module_param_call(apps_wdog_bark, apps_wdog_bark_set, param_get_int,
&apps_wdog_bark, 0644);
struct completion timeout_complete;
static void timeout_work(struct work_struct *work)
{
pr_info("apps watchdog bark\n");
preempt_disable();
mdelay(MDELAY_TIME);
preempt_enable();
complete(&timeout_complete);
}
#ifdef CONFIG_HOTPLUG_CPU
static void bring_other_cpus_down(void)
{
int cpu;
for_each_online_cpu(cpu) {
if (cpu == 0)
continue;
cpu_down(cpu);
}
}
#else
static void bring_other_cpus_down(void)
{
}
#endif
static void apps_bite_work(struct work_struct *work)
{
bring_other_cpus_down();
pr_info("apps watchdog bite\n");
local_irq_disable();
mdelay(MDELAY_TIME);
local_irq_enable();
pr_err("apps watchdog bite failed\n");
complete(&timeout_complete);
}
static void sec_wdog_bite_work(struct work_struct *work)
{
static void *sec_wdog_virt;
bring_other_cpus_down();
sec_wdog_virt = ioremap(REG_MPM2_WDOG_BASE, SZ_4K);
if (!sec_wdog_virt) {
pr_info("unable to map sec wdog page\n");
goto err;
}
writel_relaxed(REG_VAL_WDOG_RESET_DO_RESET,
sec_wdog_virt + REG_OFFSET_MPM2_WDOG_RESET);
writel_relaxed(REG_VAL_WDOG_BITE_VAL,
sec_wdog_virt + REG_OFFSET_MPM2_WDOG_BITE_VAL);
mb();
mdelay(MDELAY_TIME);
err:
complete(&timeout_complete);
}
/*
* If this returns operation failed
*/
static DECLARE_WORK(apps_bite_work_struct, apps_bite_work);
static int apps_wdog_bite_set(const char *val, struct kernel_param *kp)
{
int ret;
int old_val;
old_val = apps_wdog_bite;
ret = param_set_int(val, kp);
if (ret)
return ret;
if (apps_wdog_bite == 1) {
init_completion(&timeout_complete);
schedule_work_on(0, &apps_bite_work_struct);
wait_for_completion(&timeout_complete);
}
return -EIO;
}
/*
* If this returns operation failed
*/
static DECLARE_WORK(sec_wdog_bite_work_struct, sec_wdog_bite_work);
static int sec_wdog_bite_set(const char *val, struct kernel_param *kp)
{
int ret;
int old_val;
old_val = sec_wdog_bite;
ret = param_set_int(val, kp);
if (ret)
return ret;
if (sec_wdog_bite == 1) {
init_completion(&timeout_complete);
schedule_work_on(0, &sec_wdog_bite_work_struct);
wait_for_completion(&timeout_complete);
}
return -EIO;
}
/*
* If this returns operation failed
*/
static int sec_wdog_scm_set(const char *val, struct kernel_param *kp)
{
int ret;
int old_val;
old_val = sec_wdog_scm;
ret = param_set_int(val, kp);
if (ret)
return ret;
if (sec_wdog_scm == 1) {
u8 trigger = 0;
pr_info("sec watchdog bite\n");
ret = scm_call(SCM_SVC_BOOT, SCM_SVC_SEC_WDOG_TRIG, &trigger,
sizeof(trigger), NULL, 0);
pr_err("Secure watchdog bite failed\n");
}
return ret;
}
/*
* If this returns operation failed
*/
static DECLARE_WORK(timeout_work_struct, timeout_work);
static int apps_wdog_bark_set(const char *val, struct kernel_param *kp)
{
int ret;
int old_val;
old_val = apps_wdog_bark;
ret = param_set_int(val, kp);
if (ret)
return ret;
if (apps_wdog_bark == 1) {
init_completion(&timeout_complete);
schedule_work_on(0, &timeout_work_struct);
wait_for_completion(&timeout_complete);
pr_err("Failed to trigger apps bark\n");
}
return -EIO;
}
static int msm_watchdog_test_init(void)
{
return 0;
}
static void msm_watchdog_test_exit(void)
{
return;
}
module_init(msm_watchdog_test_init);
module_exit(msm_watchdog_test_exit);
MODULE_LICENSE("GPL v2");

View File

@@ -0,0 +1,31 @@
#!/bin/sh --
# Copyright (c) 2012, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of The Linux Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e
cd `dirname $0` && exec ./msm_watchdog_test.sh apps_wdog_bark