/* * By writing to the 'coredump' debugfs entry, we control the behavior of the * coredump mechanism dynamically. The default value of this entry is "disabled". * * The 'coredump' debugfs entry supports these commands: * * disabled: By default coredump collection is disabled. Recovery will * proceed without collecting any dump. * * enabled: 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.
*/ static ssize_t rproc_coredump_write(struct file *filp, constchar __user *user_buf, size_t count,
loff_t *ppos)
{ struct rproc *rproc = filp->private_data; int ret, err = 0; char buf[20];
if (count < 1 || 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';
/* * 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. * * We will most probably improve the rproc tracing facilities later on, * but this kind of lightweight and simple mechanism is always good to have, * as it provides very early tracing with little to no dependencies at all.
*/ static ssize_t rproc_trace_read(struct file *filp, char __user *userbuf,
size_t count, loff_t *ppos)
{ struct rproc_debug_trace *data = filp->private_data; struct rproc_mem_entry *trace = &data->trace_mem; void *va; char buf[100]; int len;
va = rproc_da_to_va(data->rproc, trace->da, trace->len, NULL);
if (!va) {
len = scnprintf(buf, sizeof(buf), "Trace %s not available\n",
trace->name);
va = buf;
} else {
len = strnlen(va, trace->len);
}
return simple_read_from_buffer(userbuf, count, ppos, va, len);
}
/* expose the name of the remote processor via debugfs */ static ssize_t rproc_name_read(struct file *filp, char __user *userbuf,
size_t count, loff_t *ppos)
{ struct rproc *rproc = filp->private_data; /* need room for the name, a newline and a terminating null */ char buf[100]; int i;
i = scnprintf(buf, sizeof(buf), "%.98s\n", rproc->name);
/* * By writing to the 'recovery' debugfs entry, we control the behavior of the * recovery mechanism dynamically. The default value of this entry is "enabled". * * The 'recovery' debugfs entry supports these commands: * * enabled: When enabled, the remote processor will be automatically * recovered whenever it crashes. Moreover, if the remote * processor crashes while recovery is disabled, it will * be automatically recovered too as soon as recovery is enabled. * * disabled: When disabled, a remote processor will remain in a crashed * state if it crashes. This is useful for debugging purposes; * without it, debugging a crash is substantially harder. * * recover: This function will trigger an immediate recovery if the * remote processor is in a crashed state, without changing * or checking the recovery state (enabled/disabled). * This is useful during debugging sessions, when one expects * additional crashes to happen after enabling recovery. In this * case, enabling recovery will make it hard to debug subsequent * crashes, so it's recommended to keep recovery disabled, and * instead use the "recover" command as needed.
*/ static ssize_t
rproc_recovery_write(struct file *filp, constchar __user *user_buf,
size_t count, loff_t *ppos)
{ struct rproc *rproc = filp->private_data; char buf[10]; int ret;
if (count < 1 || 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 (!strncmp(buf, "enabled", count)) { /* change the flag and begin the recovery process if needed */
rproc->recovery_disabled = false;
rproc_trigger_recovery(rproc);
} elseif (!strncmp(buf, "disabled", count)) {
rproc->recovery_disabled = true;
} elseif (!strncmp(buf, "recover", count)) { /* begin the recovery process without changing the flag */
rproc_trigger_recovery(rproc);
} else { return -EINVAL;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.