From c153101975345676ff8f1da5290185d618ef99ad Mon Sep 17 00:00:00 2001 From: Hardik Tushar Shah Date: Mon, 24 Jun 2019 13:44:40 +0530 Subject: drivers:wdt: Add driver to handle guest WDT expiry This driver handles notification from watchdog server monitor for any of the guest WDT expiry. It propagates notification to the user through character driver user interface. Application can take appropriate action on the notification and update the driver on the action. Since this driver is running on privilege guest, it doesn't handle WDT expiry of the privilege guest. WDT expiry of the privilege guest needs to be handled outside Tegra. Bug 2565917 Change-Id: Ie32fc8aeaf0e723b3616f5efbd6bdb272aed5c62 Signed-off-by: Hardik Tushar Shah (cherry picked from commit 3c6681b534068ce3d2d51c587927e68ba6678b48) Reviewed-on: https://git-master.nvidia.com/r/2146288 Reviewed-on: https://git-master.nvidia.com/r/2142725 GVS: Gerrit_Virtual_Submit Reviewed-by: Dmitry Pervushin Reviewed-by: Phoenix Jung Reviewed-by: mobile promotions Tested-by: mobile promotions --- include/uapi/linux/nvhv_wdt_handler_ioctl.h | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 include/uapi/linux/nvhv_wdt_handler_ioctl.h (limited to 'include/uapi/linux') diff --git a/include/uapi/linux/nvhv_wdt_handler_ioctl.h b/include/uapi/linux/nvhv_wdt_handler_ioctl.h new file mode 100644 index 000000000..7b9af9681 --- /dev/null +++ b/include/uapi/linux/nvhv_wdt_handler_ioctl.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#ifndef __UAPI_LINUX_NVHV_WDT_HANDLER_IOCTL_H +#define __UAPI_LINUX_NVHV_WDT_HANDLER_IOCTL_H + +#include +#include + +#if !defined(__KERNEL__) +#define __user +#endif + +/* This matches what is defined in server, if server side + * changes, this has to be changed + */ +#define MAX_GUESTS_NUM 16 +#define HV_GUEST_IOCTL_MAGIC 'X' + + +/* Get the state of all the guest VMs */ +#define TEGRA_HV_WDT_H_GET_STATE _IOR(HV_GUEST_IOCTL_MAGIC, 0x00, \ + struct hv_wdt_h_state_array) + +/* Send command to Monitor about Guest VM action taken */ +#define TEGRA_HV_WDT_H_CMD _IOW(HV_GUEST_IOCTL_MAGIC, 0x01, \ + struct tegra_hv_wdt_h_cmd_array) + + +enum tegra_hv_wdt_h_cmd_id { + /* Application has handled the guest vm expiry synchronously */ + MESSAGE_HANDLED_SYNC, + /* Application has handled the guest vm expiry asynchronously */ + MESSAGE_HANDLED_ASYNC, +}; + +enum tegra_hv_wdt_h_state_id { + /* This is default state or monitor, This state is also reached once + * app updates driver about ASYNC or SYNC recovery triggered for Guest + */ + GUEST_STATE_INIT, + /* This is state, once monitor updates driver about GUEST WDT expiry */ + GUEST_STATE_TIMER_EXPIRED, + /* Waiting for action from Application */ + GUEST_STATE_WAIT_FOR_ACK, +}; + +struct hv_wdt_h_state_array { + /* State of each guest, use enum tegra_hv_wdt_h_state_id */ + __u32 guest_state[MAX_GUESTS_NUM]; +}; + +struct tegra_hv_wdt_h_cmd { + /* VMID for which command is expected */ + __u32 vmid; + /* Command for the VMID, use tegra_hv_wdt_h_cmd_id */ + __u32 command; +}; + +struct tegra_hv_wdt_h_cmd_array { + /* Number of vmids for which commands is to be issued */ + __u32 num_vmids; + /* VMID and command to be issued, only first num_vmids will be used from + * below array + */ + struct tegra_hv_wdt_h_cmd commands[MAX_GUESTS_NUM]; +}; +#endif -- cgit v1.2.2