From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Rishabh Bhatnagar <rishabhb@codeaurora.org>
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
mathieu.poirier@linaro.org, tsoni@codeaurora.org,
psodagud@codeaurora.org, sidgup@codeaurora.org
Subject: Re: [PATCH v3 2/3] remoteproc: Add inline coredump functionality
Date: Tue, 19 May 2020 16:59:44 -0700 [thread overview]
Message-ID: <20200519235944.GF408178@builder.lan> (raw)
In-Reply-To: <1589486856-23440-3-git-send-email-rishabhb@codeaurora.org>
On Thu 14 May 13:07 PDT 2020, Rishabh Bhatnagar wrote:
> The 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.
>
Overall I think this looks really good now, but I spotted an issue with
INLINE dumps not using segment->dump().
Also there's 3 checkpatch --strict warnings, please fix those.
> Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> ---
> drivers/remoteproc/remoteproc_coredump.c | 129 +++++++++++++++++++++++++++++--
> include/linux/remoteproc.h | 15 ++++
> 2 files changed, 139 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_coredump.c b/drivers/remoteproc/remoteproc_coredump.c
[..]
> +static ssize_t rproc_coredump_read(char *buffer, loff_t offset, size_t count,
> + void *data, size_t header_sz)
> +{
> + void *device_mem;
> + size_t seg_data;
> + size_t copy_sz, bytes_left = count;
> + unsigned long addr;
> + struct rproc_coredump_state *dump_state = data;
> + struct rproc *rproc = dump_state->rproc;
> + void *elfcore = dump_state->header;
> +
> + /* Copy the vmalloc'ed header first. */
> + if (offset < header_sz) {
> + copy_sz = memory_read_from_buffer(buffer, count, &offset,
> + elfcore, header_sz);
> + if (copy_sz < 0)
> + return -EINVAL;
> +
> + return copy_sz;
> + }
> +
> + /* Find out the segment memory chunk to be copied based on offset.
> + * Keep copying data until count bytes are read.
> + */
/*
* Multiline comments start on the second line throughout
* remoteproc, please follow this.
*/
> + while (bytes_left) {
> + addr = rproc_coredump_find_segment(offset - header_sz,
> + &rproc->dump_segments,
> + &seg_data);
> + /* EOF check */
> + if (seg_data == 0) {
> + dev_info(&rproc->dev, "Ramdump done, %lld bytes read",
> + offset);
> + break;
> + }
> +
> + copy_sz = min_t(size_t, bytes_left, seg_data);
> +
> + device_mem = rproc_da_to_va(rproc, addr, copy_sz);
> + if (!device_mem) {
> + dev_err(&rproc->dev, "Coredump: %lx with size %zd out of remoteproc carveout\n",
> + addr, copy_sz);
> + return -ENOMEM;
I think it would be best to maintain the same behavior between INLINE
and DEFAULT here.
> + }
> + memcpy(buffer, device_mem, copy_sz);
This won't work for modem on e.g. SDM845, because we need to do some
special tricks to make the memory readable, that's why we invoke
segment->dump() in the DEFAULT scenario. Doing a memcpy here instead
will result in a security violation.
Perhaps this snippet can be extracted to a separate helper function,
which would allow you to avoid the next_seg goto label below.
> +
> + offset += copy_sz;
> + buffer += copy_sz;
> + bytes_left -= copy_sz;
> + }
> +
> + return count - bytes_left;
> +}
[..]
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index 0468be4..ab2b9b7 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -435,6 +435,19 @@ enum rproc_crash_type {
> };
>
> /**
> + * enum rproc_dump_mechanism - Coredump options for core
> + * @COREDUMP_DEFAULT: Copy dump to separate buffer and carry on with recovery
> + * @COREDUMP_INLINE: Read segments directly from device memory. Stall
> + recovery until all segments are read
> + * @COREDUMP_DISABLED: Don't perform any dump
> + */
> +enum rproc_dump_mechanism {
> + COREDUMP_DEFAULT,
> + COREDUMP_INLINE,
> + COREDUMP_DISABLED,
Please prefix these with RPROC_, as "coredump" has a meaning outside
remoteproc as well.
Regards,
Bjorn
next prev parent reply other threads:[~2020-05-20 0:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 20:07 [PATCH v3 0/3] Extend coredump functionality Rishabh Bhatnagar
2020-05-14 20:07 ` [PATCH v3 1/3] remoteproc: Move coredump functionality to a new file Rishabh Bhatnagar
2020-05-19 23:28 ` Bjorn Andersson
2020-05-21 21:30 ` Mathieu Poirier
2020-05-14 20:07 ` [PATCH v3 2/3] remoteproc: Add inline coredump functionality Rishabh Bhatnagar
2020-05-19 23:59 ` Bjorn Andersson [this message]
2020-05-21 21:35 ` Mathieu Poirier
2020-05-14 20:07 ` [PATCH v3 3/3] remoteproc: Add coredump debugfs entry Rishabh Bhatnagar
2020-05-20 0:02 ` Bjorn Andersson
2020-05-21 21:26 ` Mathieu Poirier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519235944.GF408178@builder.lan \
--to=bjorn.andersson@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=psodagud@codeaurora.org \
--cc=rishabhb@codeaurora.org \
--cc=sidgup@codeaurora.org \
--cc=tsoni@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).