// SPDX-License-Identifier: GPL-2.0-only /* * Coredump functionality for Remoteproc framework. * * Copyright (c) 2020, The Linux Foundation. All rights reserved. */ #include <linux/completion.h> #include <linux/devcoredump.h> #include <linux/device.h> #include <linux/kernel.h> #include <linux/remoteproc.h> #include "remoteproc_internal.h" #include "remoteproc_elf_helpers.h" struct rproc_coredump_state { … }; /** * rproc_coredump_cleanup() - clean up dump_segments list * @rproc: the remote processor handle */ void rproc_coredump_cleanup(struct rproc *rproc) { … } EXPORT_SYMBOL_GPL(…); /** * rproc_coredump_add_segment() - add segment of device memory to coredump * @rproc: handle of a remote processor * @da: device address * @size: size of segment * * Add device memory to the list of segments to be included in a coredump for * the remoteproc. * * Return: 0 on success, negative errno on error. */ int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size) { … } EXPORT_SYMBOL(…); /** * rproc_coredump_add_custom_segment() - add custom coredump segment * @rproc: handle of a remote processor * @da: device address * @size: size of segment * @dumpfn: custom dump function called for each segment during coredump * @priv: private data * * Add device memory to the list of segments to be included in the coredump * and associate the segment with the given custom dump function and private * data. * * Return: 0 on success, negative errno on error. */ int rproc_coredump_add_custom_segment(struct rproc *rproc, dma_addr_t da, size_t size, void (*dumpfn)(struct rproc *rproc, struct rproc_dump_segment *segment, void *dest, size_t offset, size_t size), void *priv) { … } EXPORT_SYMBOL(…); /** * rproc_coredump_set_elf_info() - set coredump elf information * @rproc: handle of a remote processor * @class: elf class for coredump elf file * @machine: elf machine for coredump elf file * * Set elf information which will be used for coredump elf file. * * Return: 0 on success, negative errno on error. */ int rproc_coredump_set_elf_info(struct rproc *rproc, u8 class, u16 machine) { … } EXPORT_SYMBOL(…); static void rproc_coredump_free(void *data) { … } static void *rproc_coredump_find_segment(loff_t user_offset, struct list_head *segments, size_t *data_left) { … } static void rproc_copy_segment(struct rproc *rproc, void *dest, struct rproc_dump_segment *segment, size_t offset, size_t size) { … } static ssize_t rproc_coredump_read(char *buffer, loff_t offset, size_t count, void *data, size_t header_sz) { … } /** * rproc_coredump() - perform coredump * @rproc: rproc handle * * This function will generate an ELF header for the registered segments * and create a devcoredump device associated with rproc. Based on the * coredump configuration this function will directly copy the segments * from device memory to userspace or copy segments from device memory to * a separate buffer, which can then be read by userspace. * The first approach avoids using extra vmalloc memory. But it will stall * recovery flow until dump is read by userspace. */ void rproc_coredump(struct rproc *rproc) { … } EXPORT_SYMBOL_GPL(…); /** * rproc_coredump_using_sections() - perform coredump using section headers * @rproc: rproc handle * * This function will generate an ELF header for the registered sections of * segments and create a devcoredump device associated with rproc. Based on * the coredump configuration this function will directly copy the segments * from device memory to userspace or copy segments from device memory to * a separate buffer, which can then be read by userspace. * The first approach avoids using extra vmalloc memory. But it will stall * recovery flow until dump is read by userspace. */ void rproc_coredump_using_sections(struct rproc *rproc) { … } EXPORT_SYMBOL(…);