From: Mitchel Humpherys <mitchelh-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Frank Rowand
<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"devicetree@vger.kernel.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Marek Szyprowski
<m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
"linux-kernel@vger.kernel.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] of: Check for overlap in reserved memory regions
Date: Mon, 14 Sep 2015 18:16:31 -0700 [thread overview]
Message-ID: <vnkwzj0o1nyo.fsf@codeaurora.org> (raw)
In-Reply-To: <CAL_JsqJB_EifnsgnU=ECzhoaSyeD=2652OEBnAjs-8+aKq5LZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> (Rob Herring's message of "Mon, 14 Sep 2015 14:21:04 -0500")
On Mon, Sep 14 2015 at 02:21:04 PM, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> On Fri, Sep 11, 2015 at 12:31 PM, Mitchel Humpherys
> <mitchelh-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> wrote:
>> Any overlap in the reserved memory regions (those specified in the
>> reserved-memory DT node) is a bug. These bugs might go undetected as
>> long as the contested region isn't used simultaneously by multiple
>> software agents, which makes such bugs hard to debug. Fix this by
>> printing a scary warning during boot if overlap is detected.
[...]
>> +
>> +static void __init __rmem_check_for_overlap(void)
>> +{
>> + int i;
>> +
>> + if (reserved_mem_count < 2)
>> + return;
>> +
>> + memcpy(sorted_reserved_mem, reserved_mem, sizeof(sorted_reserved_mem));
>> + sort(sorted_reserved_mem, reserved_mem_count,
>> + sizeof(sorted_reserved_mem[0]), __rmem_cmp, NULL);
>
> Why not just sort reserved_mem?
Yeah, I considered that but wasn't sure if it would break things in the
few places where the ordering of reserved_mem matters (like
__find_rmem). Looking closer I think we're safe to sort reserved_mem
array directly to avoid the memcpy. Will update in v2.
>
>> + for (i = 0; i < reserved_mem_count - 1; i++) {
>> + struct reserved_mem *this, *next;
>> +
>> + this = &sorted_reserved_mem[i];
>> + next = &sorted_reserved_mem[i + 1];
>> + if (!(this->base && next->base))
>> + continue;
>> + if (this->base + this->size > next->base) {
>> + phys_addr_t this_end, next_end;
>> +
>> + this_end = this->base + this->size;
>> + next_end = next->base + next->size;
>> + WARN(1, "Reserved mem: OVERLAP DETECTED!\n");
>> + pr_err("%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
>
> This seems overly verbose having both WARN and pr_err. I'd combine
> these. I don't think the stack trace from a WARN is too useful here
> given it is the DT file that users will need to go look at.
Yeah the reason for the WARN is to make it harder for this to slip by,
and I thought a BUG might be too heavy-handed. I should be able to
squeeze the content of the pr_err into the WARN in v2.
-Mitch
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Mitchel Humpherys <mitchelh@codeaurora.org>
To: Rob Herring <robh@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Grant Likely <grant.likely@linaro.org>,
"devicetree\@vger.kernel.org" <devicetree@vger.kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] of: Check for overlap in reserved memory regions
Date: Mon, 14 Sep 2015 18:16:31 -0700 [thread overview]
Message-ID: <vnkwzj0o1nyo.fsf@codeaurora.org> (raw)
In-Reply-To: <CAL_JsqJB_EifnsgnU=ECzhoaSyeD=2652OEBnAjs-8+aKq5LZQ@mail.gmail.com> (Rob Herring's message of "Mon, 14 Sep 2015 14:21:04 -0500")
On Mon, Sep 14 2015 at 02:21:04 PM, Rob Herring <robh@kernel.org> wrote:
> On Fri, Sep 11, 2015 at 12:31 PM, Mitchel Humpherys
> <mitchelh@codeaurora.org> wrote:
>> Any overlap in the reserved memory regions (those specified in the
>> reserved-memory DT node) is a bug. These bugs might go undetected as
>> long as the contested region isn't used simultaneously by multiple
>> software agents, which makes such bugs hard to debug. Fix this by
>> printing a scary warning during boot if overlap is detected.
[...]
>> +
>> +static void __init __rmem_check_for_overlap(void)
>> +{
>> + int i;
>> +
>> + if (reserved_mem_count < 2)
>> + return;
>> +
>> + memcpy(sorted_reserved_mem, reserved_mem, sizeof(sorted_reserved_mem));
>> + sort(sorted_reserved_mem, reserved_mem_count,
>> + sizeof(sorted_reserved_mem[0]), __rmem_cmp, NULL);
>
> Why not just sort reserved_mem?
Yeah, I considered that but wasn't sure if it would break things in the
few places where the ordering of reserved_mem matters (like
__find_rmem). Looking closer I think we're safe to sort reserved_mem
array directly to avoid the memcpy. Will update in v2.
>
>> + for (i = 0; i < reserved_mem_count - 1; i++) {
>> + struct reserved_mem *this, *next;
>> +
>> + this = &sorted_reserved_mem[i];
>> + next = &sorted_reserved_mem[i + 1];
>> + if (!(this->base && next->base))
>> + continue;
>> + if (this->base + this->size > next->base) {
>> + phys_addr_t this_end, next_end;
>> +
>> + this_end = this->base + this->size;
>> + next_end = next->base + next->size;
>> + WARN(1, "Reserved mem: OVERLAP DETECTED!\n");
>> + pr_err("%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
>
> This seems overly verbose having both WARN and pr_err. I'd combine
> these. I don't think the stack trace from a WARN is too useful here
> given it is the DT file that users will need to go look at.
Yeah the reason for the WARN is to make it harder for this to slip by,
and I thought a BUG might be too heavy-handed. I should be able to
squeeze the content of the pr_err into the WARN in v2.
-Mitch
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-09-15 1:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-14 19:21 [PATCH] of: Check for overlap in reserved memory regions Rob Herring
2015-09-14 19:21 ` Rob Herring
[not found] ` <CAL_JsqJB_EifnsgnU=ECzhoaSyeD=2652OEBnAjs-8+aKq5LZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-15 1:16 ` Mitchel Humpherys [this message]
2015-09-15 1:16 ` Mitchel Humpherys
-- strict thread matches above, loose matches on Subject: below --
2015-09-11 17:31 Mitchel Humpherys
2015-09-11 17:31 ` Mitchel Humpherys
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=vnkwzj0o1nyo.fsf@codeaurora.org \
--to=mitchelh-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.