Merge "soc: qcom: Add snapshot of SSR, PIL, Sysmon, and PDR drivers"

This commit is contained in:
qctecmdr 2019-08-20 11:28:12 -07:00 • committed by Gerrit - the friendly Code Review server
commit 2f4e024c0e
22 changed files with 9607 additions and 0 deletions

View file

@ -0,0 +1,52 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2011-2014, 2017-2019, The Linux Foundation. All rights reserved.
*/
#ifndef _RAMDUMP_HEADER
#define _RAMDUMP_HEADER
struct device;
struct ramdump_segment {
char *name;
unsigned long address;
void *v_address;
unsigned long size;
};
#if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
extern void *create_ramdump_device(const char *dev_name, struct device *parent);
extern void destroy_ramdump_device(void *dev);
extern int do_ramdump(void *handle, struct ramdump_segment *segments,
int nsegments);
extern int do_elf_ramdump(void *handle, struct ramdump_segment *segments,
int nsegments);
extern int do_minidump(void *handle, struct ramdump_segment *segments,
int nsegments);
#else
static inline void *create_ramdump_device(const char *dev_name,
struct device *parent)
{
return NULL;
}
static inline void destroy_ramdump_device(void *dev)
{
}
static inline int do_ramdump(void *handle, struct ramdump_segment *segments,
int nsegments)
{
return -ENODEV;
}
static inline int do_elf_ramdump(void *handle, struct ramdump_segment *segments,
int nsegments)
{
return -ENODEV;
}
#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */
#endif

View file

@ -0,0 +1,89 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2015-2016, 2018-2019, The Linux Foundation. All rights reserved.
*/
/*
* Process Domain Service Locator API header
*
*/
#ifndef _SERVICE_LOCATOR_H
#define _SERVICE_LOCATOR_H
#define QMI_SERVREG_LOC_NAME_LENGTH_V01 64
#define QMI_SERVREG_LOC_LIST_LENGTH_V01 32
/*
* @name: The full process domain path for a process domain which provides
* a particular service
* @instance_id: The QMI instance id corresponding to the root process
* domain which is responsible for notifications for this
* process domain
* @service_data_valid: Indicates if service_data field has valid data
* @service_data: Optional service data provided by the service locator
*/
struct servreg_loc_entry_v01 {
char name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1];
uint32_t instance_id;
uint8_t service_data_valid;
uint32_t service_data;
};
/*
* @client_name: Name of the client calling the api
* @service_name: Name of the service for which the list of process domains
* is requested
* @total_domains: Length of the process domain list
* @db_rev_count: Process domain list database revision number
* @domain_list: List of process domains providing the service
*/
struct pd_qmi_client_data {
char client_name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1];
char service_name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1];
int total_domains;
int db_rev_count;
struct servreg_loc_entry_v01 *domain_list;
};
enum service_locator_state {
LOCATOR_DOWN = 0x0F,
LOCATOR_UP = 0x1F,
};
#if IS_ENABLED(CONFIG_MSM_SERVICE_LOCATOR)
/*
* Use this api to request information regarding the process domains on
* which a particular service runs. The client name, the service name
* and notifier block pointer need to be provided by client calling the api.
* The total domains, db revision and the domain list will be filled in
* by the service locator.
* Returns 0 on success; otherwise a value < 0 if no valid subsystem is found.
*/
int get_service_location(char *client_name, char *service_name,
struct notifier_block *locator_nb);
/*
* Use this api to request information regarding the subsystem the process
* domain runs on.
* @pd_path: The name field from inside the servreg_loc_entry that one
* gets back using the get_processdomains api.
* Returns 0 on success; otherwise a value < 0 if no valid subsystem is found.
*/
int find_subsys(const char *pd_path, char *subsys);
#else
static inline int get_service_location(char *client_name,
char *service_name, struct notifier_block *locator_nb)
{
return -ENODEV;
}
static inline int find_subsys(const char *pd_path, const char *subsys)
{
return 0;
}
#endif /* CONFIG_MSM_SERVICE_LOCATOR */
#endif

View file

@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
*/
/*
* Process Domain Service Notifier API header
*
*/
#ifndef _SERVICE_NOTIFIER_H
#define _SERVICE_NOTIFIER_H
enum qmi_servreg_notif_service_state_enum_type_v01 {
QMI_SERVREG_NOTIF_SERVICE_STATE_ENUM_TYPE_MIN_VAL_V01 = INT_MIN,
QMI_SERVREG_NOTIF_SERVICE_STATE_ENUM_TYPE_MAX_VAL_V01 = INT_MAX,
SERVREG_NOTIF_SERVICE_STATE_DOWN_V01 = 0x0FFFFFFF,
SERVREG_NOTIF_SERVICE_STATE_UP_V01 = 0x1FFFFFFF,
SERVREG_NOTIF_SERVICE_STATE_EARLY_DOWN_V01 = 0x2FFFFFFF,
SERVREG_NOTIF_SERVICE_STATE_UNINIT_V01 = 0x7FFFFFFF,
};
enum pd_subsys_state {
ROOT_PD_DOWN,
ROOT_PD_UP,
ROOT_PD_ERR_FATAL,
ROOT_PD_WDOG_BITE,
ROOT_PD_SHUTDOWN,
USER_PD_STATE_CHANGE,
};
#if IS_ENABLED(CONFIG_MSM_SERVICE_NOTIFIER)
/* service_notif_register_notifier() - Register a notifier for a service
* On success, it returns back a handle. It takes the following arguments:
* service_path: Individual service identifier path for which a client
* registers for notifications.
* instance_id: Instance id specific to a subsystem.
* current_state: Current state of service returned by the registration
* process.
* notifier block: notifier callback for service events.
*/
void *service_notif_register_notifier(const char *service_path, int instance_id,
struct notifier_block *nb, int *curr_state);
/* service_notif_unregister_notifier() - Unregister a notifier for a service.
* service_notif_handle - The notifier handler that was provided by the
* service_notif_register_notifier function when the
* client registered for notifications.
* nb - The notifier block that was previously used during the registration.
*/
int service_notif_unregister_notifier(void *service_notif_handle,
struct notifier_block *nb);
int service_notif_pd_restart(const char *service_path, int instance_id);
#else
static inline void *service_notif_register_notifier(const char *service_path,
int instance_id, struct notifier_block *nb,
int *curr_state)
{
return ERR_PTR(-ENODEV);
}
static inline int service_notif_unregister_notifier(void *service_notif_handle,
struct notifier_block *nb)
{
return -ENODEV;
}
static inline int service_notif_pd_restart(const char *service_path,
int instance_id)
{
return -ENODEV;
}
#endif /* CONFIG_MSM_SERVICE_NOTIFIER */
#endif

View file

@ -0,0 +1,118 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2011, 2013-2014, 2018-2019, The Linux Foundation. All rights reserved.
*/
/*
* Subsystem restart notifier API header
*
*/
#ifndef _SUBSYS_NOTIFIER_H
#define _SUBSYS_NOTIFIER_H
#include <linux/notifier.h>
enum subsys_notif_type {
SUBSYS_BEFORE_SHUTDOWN,
SUBSYS_AFTER_SHUTDOWN,
SUBSYS_BEFORE_POWERUP,
SUBSYS_AFTER_POWERUP,
SUBSYS_BEFORE_AUTH_AND_RESET,
SUBSYS_RAMDUMP_NOTIFICATION,
SUBSYS_POWERUP_FAILURE,
SUBSYS_PROXY_VOTE,
SUBSYS_PROXY_UNVOTE,
SUBSYS_SOC_RESET,
SUBSYS_NOTIF_TYPE_COUNT
};
enum early_subsys_notif_type {
XPORT_LAYER_NOTIF,
NUM_EARLY_NOTIFS
};
#if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
/* Use the subsys_notif_register_notifier API to register for notifications for
* a particular subsystem. This API will return a handle that can be used to
* un-reg for notifications using the subsys_notif_unregister_notifier API by
* passing in that handle as an argument.
*
* On receiving a notification, the second (unsigned long) argument of the
* notifier callback will contain the notification type, and the third (void *)
* argument will contain the handle that was returned by
* subsys_notif_register_notifier.
*/
void *subsys_notif_register_notifier(
const char *subsys_name, struct notifier_block *nb);
int subsys_notif_unregister_notifier(void *subsys_handle,
struct notifier_block *nb);
/* Use the subsys_notif_init_subsys API to initialize the notifier chains form
* a particular subsystem. This API will return a handle that can be used to
* queue notifications using the subsys_notif_queue_notification API by passing
* in that handle as an argument.
*/
void *subsys_notif_add_subsys(const char *subsys_name);
int subsys_notif_queue_notification(void *subsys_handle,
enum subsys_notif_type notif_type,
void *data);
void *subsys_get_early_notif_info(const char *subsys_name);
int subsys_register_early_notifier(const char *subsys_name,
enum early_subsys_notif_type notif_type,
void (*early_notif_cb)(void *),
void *data);
int subsys_unregister_early_notifier(const char *subsys_name, enum
early_subsys_notif_type notif_type);
void subsys_send_early_notifications(void *early_notif_handle);
#else
static inline void *subsys_notif_register_notifier(
const char *subsys_name, struct notifier_block *nb)
{
return NULL;
}
static inline int subsys_notif_unregister_notifier(void *subsys_handle,
struct notifier_block *nb)
{
return 0;
}
static inline void *subsys_notif_add_subsys(const char *subsys_name)
{
return NULL;
}
static inline int subsys_notif_queue_notification(void *subsys_handle,
enum subsys_notif_type notif_type,
void *data)
{
return 0;
}
static inline void *subsys_get_early_notif_info(const char *subsys_name)
{
return NULL;
}
static inline int subsys_register_early_notifier(const char *subsys_name,
enum early_subsys_notif_type notif_type,
void (*early_notif_cb)(void *),
void *data)
{
return -ENOTSUPP;
}
static inline int subsys_unregister_early_notifier(const char *subsys_name,
enum early_subsys_notif_type
notif_type)
{
return -ENOTSUPP;
}
static inline void subsys_send_early_notifications(void *early_notif_handle)
{
}
#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */
#endif

View file

@ -0,0 +1,236 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
*/
#ifndef __SUBSYS_RESTART_H
#define __SUBSYS_RESTART_H
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/device.h>
struct subsys_device;
extern struct bus_type subsys_bus_type;
enum {
RESET_SOC = 0,
RESET_SUBSYS_COUPLED,
RESET_LEVEL_MAX
};
enum crash_status {
CRASH_STATUS_NO_CRASH = 0,
CRASH_STATUS_ERR_FATAL,
CRASH_STATUS_WDOG_BITE,
};
struct device;
struct module;
enum ssr_comm {
SUBSYS_TO_SUBSYS_SYSMON,
SUBSYS_TO_HLOS,
HLOS_TO_SUBSYS_SYSMON_SHUTDOWN,
NUM_SSR_COMMS,
};
/**
* struct subsys_notif_timeout - timeout data used by notification timeout hdlr
* @comm_type: Specifies if the type of communication being tracked is
* through sysmon between two subsystems, subsystem notifier call chain, or
* sysmon shutdown.
* @dest_name: subsystem to which sysmon notification is being sent to
* @source_name: subsystem which generated event that notification is being sent
* for
* @timer: timer for scheduling timeout
*/
struct subsys_notif_timeout {
enum ssr_comm comm_type;
const char *dest_name;
const char *source_name;
struct timer_list timer;
};
/**
* struct subsys_desc - subsystem descriptor
* @name: name of subsystem
* @fw_name: firmware name
* @pon_depends_on: subsystem this subsystem wants to power-on first. If the
* dependednt subsystem is already powered-on, the framework won't try to power
* it back up again.
* @poff_depends_on: subsystem this subsystem wants to power-off first. If the
* dependednt subsystem is already powered-off, the framework won't try to power
* it off again.
* @dev: parent device
* @owner: module the descriptor belongs to
* @shutdown: Stop a subsystem
* @powerup: Start a subsystem
* @crash_shutdown: Shutdown a subsystem when the system crashes (can't sleep)
* @ramdump: Collect a ramdump of the subsystem
* @free_memory: Free the memory associated with this subsystem
* @is_not_loadable: Indicate if subsystem firmware is not loadable via pil
* framework
* @no_auth: Set if subsystem does not rely on PIL to authenticate and bring
* it out of reset
* @ssctl_instance_id: Instance id used to connect with SSCTL service
* @sysmon_pid: pdev id that sysmon is probed with for the subsystem
* @sysmon_shutdown_ret: Return value for the call to sysmon_send_shutdown
* @system_debug: If "set", triggers a device restart when the
* subsystem's wdog bite handler is invoked.
* @ignore_ssr_failure: SSR failures are usually fatal and results in panic. If
* set will ignore failure.
* @edge: GLINK logical name of the subsystem
*/
struct subsys_desc {
const char *name;
char fw_name[256];
const char *pon_depends_on;
const char *poff_depends_on;
struct device *dev;
struct module *owner;
int (*shutdown)(const struct subsys_desc *desc, bool force_stop);
int (*powerup)(const struct subsys_desc *desc);
void (*crash_shutdown)(const struct subsys_desc *desc);
int (*ramdump)(int need_dumps, const struct subsys_desc *desc);
void (*free_memory)(const struct subsys_desc *desc);
irqreturn_t (*err_fatal_handler)(int irq, void *dev_id);
irqreturn_t (*stop_ack_handler)(int irq, void *dev_id);
irqreturn_t (*shutdown_ack_handler)(int irq, void *dev_id);
irqreturn_t (*ramdump_disable_handler)(int irq, void *dev_id);
irqreturn_t (*wdog_bite_handler)(int irq, void *dev_id);
irqreturn_t (*generic_handler)(int irq, void *dev_id);
struct completion shutdown_ack;
int is_not_loadable;
int err_fatal_gpio;
unsigned int err_fatal_irq;
unsigned int err_ready_irq;
unsigned int stop_ack_irq;
unsigned int wdog_bite_irq;
unsigned int generic_irq;
int force_stop_bit;
int ramdump_disable_irq;
int shutdown_ack_irq;
int ramdump_disable;
bool no_auth;
bool pil_mss_memsetup;
int ssctl_instance_id;
u32 sysmon_pid;
int sysmon_shutdown_ret;
bool system_debug;
bool ignore_ssr_failure;
const char *edge;
struct qcom_smem_state *state;
#ifdef CONFIG_SETUP_SSR_NOTIF_TIMEOUTS
struct subsys_notif_timeout timeout_data;
#endif /* CONFIG_SETUP_SSR_NOTIF_TIMEOUTS */
};
/**
* struct notif_data - additional notif information
* @crashed: indicates if subsystem has crashed due to wdog bite or err fatal
* @enable_ramdump: ramdumps disabled if set to 0
* @enable_mini_ramdumps: enable flag for minimized critical-memory-only
* ramdumps
* @no_auth: set if subsystem does not use PIL to bring it out of reset
* @pdev: subsystem platform device pointer
*/
struct notif_data {
enum crash_status crashed;
int enable_ramdump;
int enable_mini_ramdumps;
bool no_auth;
struct platform_device *pdev;
};
#if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
extern int subsystem_restart_dev(struct subsys_device *dev);
extern int subsystem_restart(const char *name);
extern int subsystem_crashed(const char *name);
extern void *subsystem_get(const char *name);
extern void *subsystem_get_with_fwname(const char *name, const char *fw_name);
extern int subsystem_set_fwname(const char *name, const char *fw_name);
extern void subsystem_put(void *subsystem);
extern struct subsys_device *subsys_register(struct subsys_desc *desc);
extern void subsys_unregister(struct subsys_device *dev);
extern void subsys_set_crash_status(struct subsys_device *dev,
enum crash_status crashed);
extern enum crash_status subsys_get_crash_status(struct subsys_device *dev);
void notify_proxy_vote(struct device *device);
void notify_proxy_unvote(struct device *device);
void notify_before_auth_and_reset(struct device *device);
void complete_err_ready(struct subsys_device *subsys);
static inline void complete_shutdown_ack(struct subsys_desc *desc)
{
complete(&desc->shutdown_ack);
}
#else
static inline int subsystem_restart_dev(struct subsys_device *dev)
{
return 0;
}
static inline int subsystem_restart(const char *name)
{
return 0;
}
static inline int subsystem_crashed(const char *name)
{
return 0;
}
static inline void *subsystem_get(const char *name)
{
return NULL;
}
static inline void *subsystem_get_with_fwname(const char *name,
const char *fw_name) {
return NULL;
}
static inline int subsystem_set_fwname(const char *name,
const char *fw_name) {
return 0;
}
static inline void subsystem_put(void *subsystem) { }
static inline
struct subsys_device *subsys_register(struct subsys_desc *desc)
{
return NULL;
}
static inline void subsys_unregister(struct subsys_device *dev) { }
static inline void subsys_set_crash_status(struct subsys_device *dev,
enum crash_status crashed) { }
static inline
enum crash_status subsys_get_crash_status(struct subsys_device *dev)
{
return false;
}
static inline void notify_proxy_vote(struct device *device) { }
static inline void notify_proxy_unvote(struct device *device) { }
static inline void notify_before_auth_and_reset(struct device *device) { }
#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */
/* Helper wrappers */
static inline void wakeup_source_trash(struct wakeup_source *ws)
{
if (!ws)
return;
wakeup_source_remove(ws);
__pm_relax(ws);
}
#endif

102
include/soc/qcom/sysmon.h Normal file
View file

@ -0,0 +1,102 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
*/
#ifndef __MSM_SYSMON_H
#define __MSM_SYSMON_H
#include <soc/qcom/subsystem_notif.h>
#include <soc/qcom/subsystem_restart.h>
/**
* enum ssctl_ssr_event_enum_type - Subsystem notification type.
*/
enum ssctl_ssr_event_enum_type {
SSCTL_SSR_EVENT_ENUM_TYPE_MIN_ENUM_VAL = -2147483647,
SSCTL_SSR_EVENT_INVALID = -1,
SSCTL_SSR_EVENT_BEFORE_POWERUP = 0,
SSCTL_SSR_EVENT_AFTER_POWERUP = 1,
SSCTL_SSR_EVENT_BEFORE_SHUTDOWN = 2,
SSCTL_SSR_EVENT_AFTER_SHUTDOWN = 3,
SSCTL_SSR_EVENT_ENUM_TYPE_MAX_ENUM_VAL = 2147483647
};
/**
* enum ssctl_ssr_event_driven_enum_type - Subsystem shutdown type.
*/
enum ssctl_ssr_event_driven_enum_type {
SSCTL_SSR_EVENT_DRIVEN_ENUM_TYPE_MIN_ENUM_VAL = -2147483647,
SSCTL_SSR_EVENT_FORCED = 0,
SSCTL_SSR_EVENT_GRACEFUL = 1,
SSCTL_SSR_EVENT_DRIVEN_ENUM_TYPE_MAX_ENUM_VAL = 2147483647
};
#if IS_ENABLED(CONFIG_MSM_SUBSYSTEM_RESTART)
extern int sysmon_send_event(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif);
extern int sysmon_get_reason(struct subsys_desc *dest_desc, char *buf,
size_t len);
extern int sysmon_send_shutdown(struct subsys_desc *dest_desc);
extern int sysmon_notifier_register(struct subsys_desc *desc);
extern void sysmon_notifier_unregister(struct subsys_desc *desc);
#else
static inline int sysmon_send_event(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif)
{
return 0;
}
static inline int sysmon_get_reason(struct subsys_desc *dest_desc,
char *buf, size_t len)
{
return 0;
}
static inline int sysmon_send_shutdown(struct subsys_desc *dest_desc)
{
return 0;
}
static inline int sysmon_notifier_register(struct subsys_desc *desc)
{
return 0;
}
static inline void sysmon_notifier_unregister(struct subsys_desc *desc)
{
}
#endif
#if defined(CONFIG_MSM_SYSMON_GLINK_COMM)
extern int sysmon_glink_register(struct subsys_desc *desc);
extern void sysmon_glink_unregister(struct subsys_desc *desc);
extern int sysmon_send_shutdown_no_qmi(struct subsys_desc *dest_desc);
extern int sysmon_get_reason_no_qmi(struct subsys_desc *dest_desc,
char *buf, size_t len);
extern int sysmon_send_event_no_qmi(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif);
#else
static inline int sysmon_get_reason_no_qmi(struct subsys_desc *dest_desc,
char *buf, size_t len)
{
return 0;
}
static inline int sysmon_send_shutdown_no_qmi(struct subsys_desc *dest_desc)
{
return 0;
}
static inline int sysmon_glink_register(struct subsys_desc *desc)
{
return 0;
}
static inline void sysmon_glink_unregister(struct subsys_desc *desc)
{
}
static inline int sysmon_send_event_no_qmi(struct subsys_desc *dest_desc,
struct subsys_desc *event_desc,
enum subsys_notif_type notif)
{
return 0;
}
#endif
#endif