watchdogtest: add module to test watchdog

Convert the watchdog test to a lkm.

Change-Id: Ifa83ce4790a52865ed82d67f1a304b8804c9bf64
Signed-off-by: Ryan Lattrel <ryanl@motorola.com>
Reviewed-on: https://gerrit.mot.com/1111988
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Kenneth Kessler <kennykessler@motorola.com>
Reviewed-by: Dong-Hua Yan <a18317@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Ryan Lattrel 2018-01-04 10:12:05 -06:00
parent f02bccf2de
commit 975e0fc2ca
4 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,8 @@
DLKM_DIR := motorola/kernel/modules
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := watchdogtest.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
include $(DLKM_DIR)/AndroidKernelModule.mk

View file

@ -0,0 +1,5 @@
# add -Wall to try to catch everything we can.
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include
obj-m += watchdogtest.o

View file

@ -0,0 +1,10 @@
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
all:
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean

View file

@ -0,0 +1,85 @@
/*
* Simple softlockup watchdog regression test module
*
* Copyright (C) 2012 Motorola Mobility LLC.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* of the License.
*/
#include <linux/completion.h>
#include <linux/workqueue.h>
#include <linux/irq.h>
#include <linux/preempt.h>
#include <linux/module.h>
#include <linux/debugfs.h>
#include <soc/qcom/watchdog.h>
static struct dentry *dbgfs_fire_softlockup;
static struct dentry *dbgfs_fire_watchdog;
#ifndef CONFIG_QCOM_WATCHDOG_V2
struct completion wdt_timeout_complete;
static void wdt_timeout_work(struct work_struct *work)
{
local_irq_disable();
while (1)
;
local_irq_enable();
complete(&wdt_timeout_complete);
}
static DECLARE_WORK(wdt_timeout_work_struct, wdt_timeout_work);
#endif
static int fire_watchdog_reset_set(void *data, u64 val)
{
printk(KERN_WARNING "Fire hardware watchdog reset.\n");
printk(KERN_WARNING "Please wait ...\n");
#ifdef CONFIG_QCOM_WATCHDOG_V2
msm_trigger_wdog_bite();
#else
init_completion(&wdt_timeout_complete);
schedule_work_on(0, &wdt_timeout_work_struct);
wait_for_completion(&wdt_timeout_complete);
#endif
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fire_watchdog_reset_fops,
NULL, fire_watchdog_reset_set, "%llu\n");
static int fire_softlockup_reset_set(void *data, u64 val)
{
printk(KERN_WARNING "Fire softlockup watchdog reset.\n");
printk(KERN_WARNING "Please wait ...\n");
preempt_disable();
while (1)
;
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fire_softlockup_reset_fops,
NULL, fire_softlockup_reset_set, "%llu\n");
static int watchdog_test_init(void)
{
dbgfs_fire_softlockup = debugfs_create_file("fire_softlockup_reset",
0200, NULL, NULL, &fire_softlockup_reset_fops);
dbgfs_fire_watchdog = debugfs_create_file("fire_watchdog_reset",
0200, NULL, NULL, &fire_watchdog_reset_fops);
return 0;
}
static void watchdog_test_exit(void)
{
if(dbgfs_fire_softlockup)
debugfs_remove(dbgfs_fire_softlockup);
if(dbgfs_fire_watchdog)
debugfs_remove(dbgfs_fire_watchdog);
}
module_init(watchdog_test_init);
module_exit(watchdog_test_exit);
MODULE_LICENSE("GPL");