Extend coredump functionality
Subsystems (2)
PATCH v4 2/3 remoteproc: Add inline coredump functionality
In reply to Rishabh BhatnagarThe current coredump implementation uses vmalloc area to copy all the segments. But this might put strain on low memory targets as the firmware size sometimes is in tens of MBs. The situation becomes worse if there are multiple remote processors undergoing recovery at the same time. This patch adds inline coredump functionality that avoids extra memory usage. This requires recovery to be halted until data is read by userspace and free function is called.
--- drivers/remoteproc/qcom_q6v5_mss.c | 9 +- drivers/remoteproc/remoteproc_coredump.c | 162 +++++++++++++++++++++++++++---- include/linux/remoteproc.h | 21 +++- 3 files changed, 167 insertions(+), 25 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +5 -4
@@ -1231,12 +1231,13 @@ static int q6v5_mpss_load(struct q6v5 *qproc)static void qcom_q6v5_dump_segment (struct rproc *rproc,struct rproc_dump_segment *segment, -void *dest) +void *dest,size_t offset,size_t size) {int ret =0 ;struct q6v5 *qproc = rproc->priv;unsigned long mask =BIT ((unsigned long )segment->priv); -void *ptr =rproc_da_to_va (rproc, segment->da, segment->size); +size_t copy_size = size ? size : segment->size; +void *ptr =rproc_da_to_va (rproc, segment->da + offset, copy_size);/* Unlock mba before copying segments */ if (!qproc->dump_mba_loaded) {
@@ -1251,9 +1252,9 @@ static void qcom_q6v5_dump_segment(struct rproc *rproc, }if (!ptr || ret) -memset (dest,0xff , segment->size); +memset (dest,0xff , copy_size);else -memcpy (dest, ptr, segment->size); +memcpy (dest, ptr, copy_size); qproc->dump_segment_mask |= mask;
drivers/remoteproc/remoteproc_coredump.c +143 -19
215 lines not on this page · raw message
include/linux/remoteproc.h +19 -2
@@ -435,6 +435,20 @@ enum rproc_crash_type { };/** +* enum rproc_dump_mechanism - Coredump options for core +* @RPROC_COREDUMP_DEFAULT: Copy dump to separate buffer and carry on with +recovery +* @RPROC_COREDUMP_INLINE: Read segments directly from device memory. Stall +recovery until all segments are read +* @RPROC_COREDUMP_DISABLED: Don't perform any dump +*/ +enum rproc_dump_mechanism { +RPROC_COREDUMP_DEFAULT , +RPROC_COREDUMP_INLINE , +RPROC_COREDUMP_DISABLED , +}; + +/** * struct rproc_dump_segment - segment info from ELF header * @node: list node related to the rproc segment list * @da: device address of the segment
@@ -451,7 +465,7 @@ struct rproc_dump_segment {void *priv;void (*dump)(struct rproc *rproc,struct rproc_dump_segment *segment, -void *dest); +void *dest,size_t offset,size_t size);loff_t offset; };
@@ -466,6 +480,7 @@ struct rproc_dump_segment {* @dev: virtual device for refcounting and common remoteproc behavior * @power: refcount of users who need this rproc powered up * @state: state of the device +* @dump_conf: Currenlty selected coredump configuration * @lock: lock which protects concurrent manipulations of the rproc * @dbg_dir: debugfs directory of this rproc device * @traces: list of trace buffers
@@ -499,6 +514,7 @@ struct rproc {struct device dev;atomic_t power;unsigned int state; +enum rproc_dump_mechanism dump_conf;struct mutex lock;struct dentry *dbg_dir;struct list_head traces;
@@ -630,7 +646,8 @@ 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), +void *dest,size_t offset, +size_t size), void *priv);int rproc_coredump_set_elf_info (struct rproc *rproc,u8 class,u16 machine);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 3/3 remoteproc: Add coredump debugfs entry
In reply to Rishabh BhatnagarAdd coredump debugfs entry to configure the type of dump that will be collected during recovery. User can select between default or inline coredump functionality. Also coredump collection can be disabled through this interface.
This functionality can be configured differently for different remote processors.
--- drivers/remoteproc/remoteproc_debugfs.c | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
drivers/remoteproc/remoteproc_debugfs.c +86 -0
@@ -28,6 +28,90 @@static struct dentry *rproc_dbg;/* +* A coredump-configuration-to-string lookup table, for exposing a +* human readable configuration via debugfs. Always keep in sync with +* enum rproc_coredump_mechanism +*/ +static const char *const rproc_coredump_str[] = { + [RPROC_COREDUMP_DEFAULT ] ="default" , + [RPROC_COREDUMP_INLINE ] ="inline" , + [RPROC_COREDUMP_DISABLED ] ="disabled" , +}; + +/* Expose the current coredump configuration via debugfs */ +static ssize_t rproc_coredump_read (struct file *filp,char __user *userbuf, +size_t count,loff_t *ppos) +{ +struct rproc *rproc = filp->private_data; +const char *buf = rproc_coredump_str[rproc->dump_conf]; + +return simple_read_from_buffer (userbuf, count, ppos, buf,strlen (buf)); +} + +/* +* By writing to the 'coredump' debugfs entry, we control the behavior of the +* coredump mechanism dynamically. The default value of this entry is "default". +* +* The 'coredump' debugfs entry supports these commands: +* +* default: This is the default coredump mechanism. When the remoteproc +* crashes the entire coredump will be copied to a separate buffer +* and exposed to userspace. +* +* inline: The coredump will not be copied to a separate buffer and the +* recovery process will have to wait until data is read by +* userspace. But this avoid usage of extra memory. +* +* disabled: This will disable coredump. Recovery will proceed without +* collecting any dump. +*/ +static ssize_t rproc_coredump_write (struct file *filp, +const char __user *user_buf,size_t count, +loff_t *ppos) +{ +struct rproc *rproc = filp->private_data; +int ret, err =0 ; +char buf[20 ]; + +if (count >sizeof (buf)) +return -EINVAL ; + + ret =copy_from_user (buf, user_buf, count); +if (ret) +return -EFAULT ; + +/* remove end of line */ +if (buf[count -1 ] =='\n' ) + buf[count -1 ] ='\0' ; + +if (rproc->state ==RPROC_CRASHED ) { +dev_err (&rproc->dev,"can't change coredump configuration\n" ); + err = -EBUSY ; + goto out; + } + +if (!strncmp (buf,"disable" , count)) { + rproc->dump_conf =RPROC_COREDUMP_DISABLED ; + }else if (!strncmp (buf,"inline" , count)) { + rproc->dump_conf =RPROC_COREDUMP_INLINE ; + }else if (!strncmp (buf,"default" , count)) { + rproc->dump_conf =RPROC_COREDUMP_DEFAULT ; + }else { +dev_err (&rproc->dev,"Invalid coredump configuration\n" ); + err = -EINVAL ; + } +out: +return err ? err : count; +} + +static const struct file_operations rproc_coredump_fops = { + .read = rproc_coredump_read, + .write = rproc_coredump_write, + .open = simple_open, + .llseek = generic_file_llseek, +}; + +/* * Some remote processors may support dumping trace logs into a shared * memory buffer. We expose this trace buffer using debugfs, so users * can easily tell what's going on remotely.
@@ -337,6 +421,8 @@ void rproc_create_debug_dir(struct rproc *rproc) rproc, &rproc_rsc_table_fops);debugfs_create_file ("carveout_memories" ,0400 , rproc->dbg_dir, rproc, &rproc_carveouts_fops); +debugfs_create_file ("coredump" ,0600 , rproc->dbg_dir, + rproc, &rproc_coredump_fops); }void __init rproc_init_debugfs (void )
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 1/3 remoteproc: Move coredump functionality to a new file
In reply to Rishabh BhatnagarMove all coredump functionality to an individual file. This is being done so that the current functionality can be extended in future patchsets.
--- drivers/remoteproc/Makefile | 1 + drivers/remoteproc/remoteproc_core.c | 191 ----------------------------- drivers/remoteproc/remoteproc_coredump.c | 204 +++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 4 + 4 files changed, 209 insertions(+), 191 deletions(-) create mode 100644 drivers/remoteproc/remoteproc_coredump.c
drivers/remoteproc/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_REMOTEPROC) += remoteproc.o remoteproc-y := remoteproc_core.o +remoteproc-y += remoteproc_coredump.o remoteproc-y += remoteproc_debugfs.o remoteproc-y += remoteproc_sysfs.o remoteproc-y += remoteproc_virtio.o
drivers/remoteproc/remoteproc_core.c +0 -191
215 lines not on this page · raw message
drivers/remoteproc/remoteproc_coredump.c new file +204 -0
204 lines not on this page · raw message
drivers/remoteproc/remoteproc_internal.h +4 -0
@@ -47,6 +47,10 @@ struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,int rproc_init_sysfs (void );void rproc_exit_sysfs (void ); +/* from remoteproc_coredump.c */ +void rproc_coredump_cleanup (struct rproc *rproc); +void rproc_coredump (struct rproc *rproc); +void rproc_free_vring (struct rproc_vring *rvring);int rproc_alloc_vring (struct rproc_vdev *rvdev,int i);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
v4 cover Extend coredump functionality
This patch series moves the coredump functionality to a separate file and adds "inline" coredump feature. Inline coredump directly copies segments from device memory during coredump to userspace. This avoids extra memory usage at the cost of speed. Recovery is stalled until all data is read by userspace.
Changelog:
v4 -> v3:
- Write a helper function to copy segment memory for every dump format
- Change segment dump fn to add offset and size adn covert mss driver
v3 -> v2:
- Move entire coredump functionality to remoteproc_coredump.c
- Modify rproc_coredump to perform dump according to conf. set by userspace
- Move the userspace configuration to debugfs from sysfs.
- Keep the default coredump implementation as is
v2 -> v1:
- Introduce new file for coredump.
- Add userspace sysfs configuration for dump type.
Rishabh Bhatnagar (3):
remoteproc: Move coredump functionality to a new file
remoteproc: Add inline coredump functionality
remoteproc: Add coredump debugfs entry
drivers/remoteproc/Makefile | 1 + drivers/remoteproc/qcom_q6v5_mss.c | 9 +- drivers/remoteproc/remoteproc_core.c | 191 ------------------ drivers/remoteproc/remoteproc_coredump.c | 328 +++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_debugfs.c | 86 ++++++++ drivers/remoteproc/remoteproc_internal.h | 4 + include/linux/remoteproc.h | 21 +- 7 files changed, 443 insertions(+), 197 deletions(-) create mode 100644 drivers/remoteproc/remoteproc_coredump.c
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 8 lines · Rishabh Bhatnagar
This patch series moves the coredump functionality to a separate file and adds "inline" coredump feature. Inline coredump directly copies segments from device memory during coredump to userspace. This avoids extra memory usage at the cost of speed. Recovery is stalled until all data is read by userspace.
Changelog:
Hi Rishabh,
This looks good to me, but it doesn't apply cleanly on linux-next. Can you please take a look?
Regards,
Bjorn
Quoted 33 lines
v4 -> v3:
- Write a helper function to copy segment memory for every dump format
- Change segment dump fn to add offset and size adn covert mss driverv3 -> v2:
- Move entire coredump functionality toremoteproc_coredump.c
- Modifyrproc_coredumpto perform dump according to conf. set by userspace
- Move the userspace configuration to debugfs from sysfs.
- Keep the default coredump implementation as isv2 -> v1:
- Introduce new file for coredump.
- Add userspace sysfs configuration for dump type.Rishabh Bhatnagar (3):
remoteproc: Move coredump functionality to a new file
remoteproc: Add inline coredump functionality
remoteproc: Add coredump debugfs entrydrivers/remoteproc/Makefile | 1 + drivers/remoteproc/qcom_q6v5_mss.c | 9 +- drivers/remoteproc/remoteproc_core.c | 191 ------------------ drivers/remoteproc/remoteproc_coredump.c | 328 +++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_debugfs.c | 86 ++++++++ drivers/remoteproc/remoteproc_internal.h | 4 + include/linux/remoteproc.h | 21 +- 7 files changed, 443 insertions(+), 197 deletions(-) create mode 100644 drivers/remoteproc/remoteproc_coredump.cSignature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 11 lines · Bjorn Andersson
Quoted 8 lines · Rishabh Bhatnagar
This patch series moves the coredump functionality to a separate file and adds "inline" coredump feature. Inline coredump directly copies segments from device memory during coredump to userspace. This avoids extra memory usage at the cost of speed. Recovery is stalled until all data is read by userspace.
Changelog:
Quoted 8 lines
Hi Rishabh,
This looks good to me, but it doesn't apply cleanly on linux-next. Can you please take a look?
Regards,
Bjorn
Yes some more gerrits have been merged in the meantime. I'll rebase on top of Linux-next and send out another patchset.
Quoted 35 lines
Quoted 35 lines
v4 -> v3:
- Write a helper function to copy segment memory for every dump format
- Change segment dump fn to add offset and size adn covert mss driverv3 -> v2:
- Move entire coredump functionality toremoteproc_coredump.c
- Modifyrproc_coredumpto perform dump according to conf. set by userspace
- Move the userspace configuration to debugfs from sysfs.
- Keep the default coredump implementation as isv2 -> v1:
- Introduce new file for coredump.
- Add userspace sysfs configuration for dump type.Rishabh Bhatnagar (3):
remoteproc: Move coredump functionality to a new file
remoteproc: Add inline coredump functionality
remoteproc: Add coredump debugfs entrydrivers/remoteproc/Makefile | 1 + drivers/remoteproc/qcom_q6v5_mss.c | 9 +- drivers/remoteproc/remoteproc_core.c | 191 ------------------ drivers/remoteproc/remoteproc_coredump.c | 328 +++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_debugfs.c | 86 ++++++++ drivers/remoteproc/remoteproc_internal.h | 4 + include/linux/remoteproc.h | 21 +- 7 files changed, 443 insertions(+), 197 deletions(-) create mode 100644 drivers/remoteproc/remoteproc_coredump.c--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project