Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fcd37a4 authored by Raghavendra Rao Ananta's avatar Raghavendra Rao Ananta
Browse files

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



Add snapshot for Subsystem Restart (SSR), Peripheral Image
Loader framework (PIL), Secure PIL driver, System Monitor
(sysmon), and Protection Domain Restart (PDR) drivers from
msm-4.19 as of commit <61502d56cb5f9b1> (Merge "drivers:
llcc_perfmon: support for dual memory controller added").

Change-Id: Id06c338121486705dfd716567244650b4dd1742c
[rananta@codeaurora.org: Make changes to make the drivers modular]
Signed-off-by: default avatarRaghavendra Rao Ananta <rananta@codeaurora.org>
parent dce2fd46
Loading
Loading
Loading
Loading
+96 −0
Original line number Diff line number Diff line
@@ -104,6 +104,102 @@ config QCOM_PM
	  modes. It interface with various system drivers to put the cores in
	  low power modes.

config MSM_PIL
	tristate "Peripheral image loader"
	select FW_LOADER
	help
	  Some peripherals' firmware need to be loaded into memory before
	  they can be brought out of reset. The Peripheral Image Loader (PIL)
	  framework is used to achive this. The driver relays the lower-level
	  functionalities such as, authenticating the images, performing the
	  reset of the peripheral, and so on to the drivers that are registered
	  with it.

	  Say 'y' or 'm' to support these devices.

config MSM_SUBSYSTEM_RESTART
	tristate "MSM Subsystem Restart"
	depends on MSM_PIL
	select QCOM_QMI_HELPERS
	help
	  This option enables the MSM subsystem restart framework.

	  The MSM subsystem restart framework provides support to boot,
	  shutdown, and restart subsystems with a reference counted API.
	  It also extends the APIs to add support for MSM System Monitor
	  using the QMI layer. These APIs may be used for sending events
	  or passing commands.
	  Moreover, the framework also notifies userspace of transitions
	  between these states via sysfs.

config SETUP_SSR_NOTIF_TIMEOUTS
	bool "Set timeouts on SSR sysmon notifications and notifier callbacks"
	help
	  Setup timers prior to initiating communication between
	  subsystems through sysmon, and prior to sending notifications
	  to drivers in the kernel that have registered callbacks with the
	  subsystem notifier framework for a particular subsystem. This
	  is a debugging feature.

config SSR_SYSMON_NOTIF_TIMEOUT
	depends on SETUP_SSR_NOTIF_TIMEOUTS
	int "SSR Sysmon notifications timeout in ms"
	default 10000
	help
	  The amount of time, in milliseconds, that should elapse between
	  the start and end of sysmon SSR notifications, before a warning
	  is emitted.

config SSR_SUBSYS_NOTIF_TIMEOUT
	depends on SETUP_SSR_NOTIF_TIMEOUTS
	int "SSR Subsystem notifier timeout in ms"
	default 10000
	help
	  The amount of time, in milliseconds, that should elapse between
	  the start and end of SSR notifications through the subsystem
	  notifier, before a warning is emitted.

config PANIC_ON_SSR_NOTIF_TIMEOUT
	bool "Trigger kernel panic when notification timeout expires"
	depends on SETUP_SSR_NOTIF_TIMEOUTS
	help
	  This is a debug feature where a kernel panic is triggered when
	  communication between subsystems through sysmon is taking too
	  long. This scneario can happen if the peripheral has died and
	  is no longer responsive.
	  Also trigger a kernel panic if invoking the callbacks registered
	  with a particular subsystem's notifications by the subsystem
	  notifier framework is taking too long.

config MSM_PIL_SSR_GENERIC
	tristate "MSM Subsystem Boot Support"
	depends on MSM_PIL && MSM_SUBSYSTEM_RESTART
	help
	  Support for booting and shutting down MSM Subsystem processors.
	  This driver also monitors the SMSM status bits and the watchdog
	  interrupt for the subsystem and restarts it on a watchdog bite
	  or a fatal error. Subsystems include LPASS, Venus, VPU, WCNSS and
	  BCSS.

config MSM_SERVICE_LOCATOR
	tristate "Service Locator"
	select QCOM_QMI_HELPERS
	help
	  The Service Locator provides a library to retrieve location
	  information given a service identifier. Location here translates
	  to what process domain exports the service, and which subsystem
	  that process domain will execute in.

config MSM_SERVICE_NOTIFIER
	tristate "Service Notifier"
	depends on MSM_SERVICE_LOCATOR && MSM_SUBSYSTEM_RESTART
	help
	  The Service Notifier provides a library for a kernel client to
	  register for state change notifications regarding a remote service.
	  A remote service here refers to a process providing certain services
	  like audio, the identifier for which is provided by the service
	  locator.

config QCOM_QMI_HELPERS
	tristate
	depends on ARCH_QCOM || COMPILE_TEST
+6 −0
Original line number Diff line number Diff line
@@ -7,6 +7,12 @@ obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o
obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
obj-$(CONFIG_QCOM_MDT_LOADER)	+= mdt_loader.o
obj-$(CONFIG_QCOM_PM)	+=	spm.o
obj-$(CONFIG_MSM_PIL)   +=      peripheral-loader.o
obj-$(CONFIG_MSM_SUBSYSTEM_RESTART) += ssr.o
ssr-y := subsystem_restart.o subsystem_notif.o ramdump.o sysmon-qmi.o
obj-$(CONFIG_MSM_PIL_SSR_GENERIC) += subsys-pil-tz.o
obj-$(CONFIG_MSM_SERVICE_NOTIFIER) += service-notifier.o
obj-$(CONFIG_MSM_SERVICE_LOCATOR) += service-locator.o
obj-$(CONFIG_QCOM_QMI_HELPERS)	+= qmi_helpers.o
qmi_helpers-y	+= qmi_encdec.o qmi_interface.o
obj-$(CONFIG_QCOM_RMTFS_MEM)	+= rmtfs_mem.o
+79 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 */

#ifndef __MINIDUMP_PRIVATE_H
#define __MINIDUMP_PRIVATE_H

#define MD_REVISION		1
#define SBL_MINIDUMP_SMEM_ID	602
#define MAX_NUM_OF_SS		10
#define MD_SS_HLOS_ID		0
#define SMEM_ENTRY_SIZE		40

/* Bootloader has 16 byte support, 4 bytes reserved for itself */
#define MAX_REGION_NAME_LENGTH	16

#define MD_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
#define MD_REGION_INVALID	('I' << 24 | 'N' << 16 | 'V' << 8 | 'A' << 0)
#define MD_REGION_INIT		('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' << 0)
#define MD_REGION_NOINIT	0

#define MD_SS_ENCR_REQ		(0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0)
#define MD_SS_ENCR_NOTREQ	(0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0)
#define MD_SS_ENCR_NONE		('N' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
#define MD_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
#define MD_SS_ENCR_START	('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 0)
#define MD_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
#define MD_SS_DISABLED		('D' << 24 | 'S' << 16 | 'B' << 8 | 'L' << 0)

/**
 * md_ss_region - Minidump region
 * @name		: Name of the region to be dumped
 * @seq_num:		: Use to differentiate regions with same name.
 * @md_valid		: This entry to be dumped (if set to 1)
 * @region_base_address	: Physical address of region to be dumped
 * @region_size		: Size of the region
 */
struct md_ss_region {
	char	name[MAX_REGION_NAME_LENGTH];
	u32	seq_num;
	u32	md_valid;
	u64	region_base_address;
	u64	region_size;
};

/**
 * md_ss_toc: Sub system SMEM Table of content
 * @md_ss_toc_init : SS toc init status
 * @md_ss_enable_status : if set to 1, Bootloader would dump this SS regions
 * @encryption_status: Encryption status for this subsystem
 * @encryption_required : Decides to encrypt the SS regions or not
 * @ss_region_count : Number of regions added in this SS toc
 * @md_ss_smem_regions_baseptr : regions base pointer of the Subsystem
 */
struct md_ss_toc {
	u32			md_ss_toc_init;
	u32			md_ss_enable_status;
	u32			encryption_status;
	u32			encryption_required;
	u32			ss_region_count;
	u64			md_ss_smem_regions_baseptr;
};

/**
 * md_global_toc: Global Table of Content
 * @md_toc_init : Global Minidump init status
 * @md_revision : Minidump revision
 * @md_enable_status : Minidump enable status
 * @md_ss_toc : Array of subsystems toc
 */
struct md_global_toc {
	u32			md_toc_init;
	u32			md_revision;
	u32			md_enable_status;
	struct md_ss_toc	md_ss_toc[MAX_NUM_OF_SS];
};

#endif
+1678 −0

File added.

Preview size limit exceeded, changes collapsed.

+160 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
 */
#ifndef __MSM_PERIPHERAL_LOADER_H
#define __MSM_PERIPHERAL_LOADER_H

#include <linux/mailbox_client.h>
#include <linux/mailbox/qmp.h>
#include "minidump_private.h"

struct device;
struct module;
struct pil_priv;

/**
 * struct pil_desc - PIL descriptor
 * @name: string used for pil_get()
 * @fw_name: firmware name
 * @dev: parent device
 * @ops: callback functions
 * @owner: module the descriptor belongs to
 * @proxy_timeout: delay in ms until proxy vote is removed
 * @flags: bitfield for image flags
 * @priv: DON'T USE - internal only
 * @attrs: DMA attributes to be used during dma allocation.
 * @proxy_unvote_irq: IRQ to trigger a proxy unvote. proxy_timeout
 * is ignored if this is set.
 * @map_fw_mem: Custom function used to map physical address space to virtual.
 * This defaults to ioremap if not specified.
 * @unmap_fw_mem: Custom function used to undo mapping by map_fw_mem.
 * This defaults to iounmap if not specified.
 * @shutdown_fail: Set if PIL op for shutting down subsystem fails.
 * @modem_ssr: true if modem is restarting, false if booting for first time.
 * @clear_fw_region: Clear fw region on failure in loading.
 * @subsys_vmid: memprot id for the subsystem.
 */
struct pil_desc {
	const char *name;
	const char *fw_name;
	struct device *dev;
	const struct pil_reset_ops *ops;
	struct module *owner;
	unsigned long proxy_timeout;
	unsigned long flags;
#define PIL_SKIP_ENTRY_CHECK	BIT(0)
	struct pil_priv *priv;
	unsigned long attrs;
	unsigned int proxy_unvote_irq;
	void __iomem * (*map_fw_mem)(phys_addr_t phys, size_t size, void *data);
	void (*unmap_fw_mem)(void __iomem *virt, size_t size, void *data);
	void *map_data;
	bool shutdown_fail;
	bool modem_ssr;
	bool clear_fw_region;
	u32 subsys_vmid;
	bool signal_aop;
	struct mbox_client cl;
	struct mbox_chan *mbox;
	struct md_ss_toc *minidump_ss;
	struct md_ss_toc **aux_minidump;
	int minidump_id;
	int *aux_minidump_ids;
	int num_aux_minidump_ids;
};

/**
 * struct pil_image_info - info in IMEM about image and where it is loaded
 * @name: name of image (may or may not be NULL terminated)
 * @start: indicates physical address where image starts (little endian)
 * @size: size of image (little endian)
 */
struct pil_image_info {
	char name[8];
	__le64 start;
	__le32 size;
} __attribute__((__packed__));

/**
 * struct pil_reset_ops - PIL operations
 * @init_image: prepare an image for authentication
 * @mem_setup: prepare the image memory region
 * @verify_blob: authenticate a program segment, called once for each loadable
 *		 program segment (optional)
 * @proxy_vote: make proxy votes before auth_and_reset (optional)
 * @auth_and_reset: boot the processor
 * @proxy_unvote: remove any proxy votes (optional)
 * @deinit_image: restore actions performed in init_image if necessary
 * @shutdown: shutdown the processor
 */
struct pil_reset_ops {
	int (*init_image)(struct pil_desc *pil, const u8 *metadata,
			  size_t size);
	int (*mem_setup)(struct pil_desc *pil, phys_addr_t addr, size_t size);
	int (*verify_blob)(struct pil_desc *pil, phys_addr_t phy_addr,
			   size_t size);
	int (*proxy_vote)(struct pil_desc *pil);
	int (*auth_and_reset)(struct pil_desc *pil);
	void (*proxy_unvote)(struct pil_desc *pil);
	int (*deinit_image)(struct pil_desc *pil);
	int (*shutdown)(struct pil_desc *pil);
};

#if IS_ENABLED(CONFIG_MSM_PIL)
extern int pil_desc_init(struct pil_desc *desc);
extern int pil_boot(struct pil_desc *desc);
extern void pil_shutdown(struct pil_desc *desc);
extern void pil_free_memory(struct pil_desc *desc);
extern void pil_desc_release(struct pil_desc *desc);
extern phys_addr_t pil_get_entry_addr(struct pil_desc *desc);
extern int pil_do_ramdump(struct pil_desc *desc, void *ramdump_dev,
			  void *minidump_dev);
extern int pil_assign_mem_to_subsys(struct pil_desc *desc, phys_addr_t addr,
						size_t size);
extern int pil_assign_mem_to_linux(struct pil_desc *desc, phys_addr_t addr,
						size_t size);
extern int pil_assign_mem_to_subsys_and_linux(struct pil_desc *desc,
						phys_addr_t addr, size_t size);
extern int pil_reclaim_mem(struct pil_desc *desc, phys_addr_t addr, size_t size,
						int VMid);
extern bool pil_is_timeout_disabled(void);
#else
static inline int pil_desc_init(struct pil_desc *desc) { return 0; }
static inline int pil_boot(struct pil_desc *desc) { return 0; }
static inline void pil_shutdown(struct pil_desc *desc) { }
static inline void pil_free_memory(struct pil_desc *desc) { }
static inline void pil_desc_release(struct pil_desc *desc) { }
static inline phys_addr_t pil_get_entry_addr(struct pil_desc *desc)
{
	return 0;
}
static inline int pil_do_ramdump(struct pil_desc *desc,
		void *ramdump_dev, void *minidump_dev)
{
	return 0;
}
static inline int pil_assign_mem_to_subsys(struct pil_desc *desc,
						phys_addr_t addr, size_t size)
{
	return 0;
}
static inline int pil_assign_mem_to_linux(struct pil_desc *desc,
						phys_addr_t addr, size_t size)
{
	return 0;
}
static inline int pil_assign_mem_to_subsys_and_linux(struct pil_desc *desc,
						phys_addr_t addr, size_t size)
{
	return 0;
}
static inline int pil_reclaim_mem(struct pil_desc *desc, phys_addr_t addr,
					size_t size, int VMid)
{
	return 0;
}
static inline bool pil_is_timeout_disabled(void) { return false; }
#endif

#endif
Loading