From: Dan Williams <dan.j.williams@intel.com>
To: D Scott Phillips <scott@os.amperecomputing.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
AKASHI Takahiro <takahiro.akashi@linaro.org>,
Alison Schofield <alison.schofield@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Baoquan He <bhe@redhat.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
<patches@amperecomputing.com>
Subject: Re: [PATCH v2] resource: limit request_free_mem_region based on arch_get_mappable_range
Date: Mon, 8 Jul 2024 18:31:15 -0700 [thread overview]
Message-ID: <668c92e35c677_102cc29475@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20240709002757.2431399-1-scott@os.amperecomputing.com>
D Scott Phillips wrote:
> On arm64 prior to commit 32697ff38287 ("arm64: vmemmap: Avoid base2 order
> of struct page size to dimension region"), the amdgpu driver could trip
> over the warning of:
>
> `WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));`
>
> in vmemmap_populate()[1]. After that commit, it becomes a translation fault
> and panic[2].
>
> The cause is that the amdgpu driver allocates some unused space from
> iomem_resource and claims it as MEMORY_DEVICE_PRIVATE and
> devm_memremap_pages() it. An address above those backed by the arm64
> vmemmap is picked.
>
> Limit request_free_mem_region() so that only addresses within the
> arch_get_mappable_range() can be chosen as device private addresses.
It seems odd that devm_request_free_mem_region() needs to be careful
about this restriction. The caller passes in the resource tree that is
the bounds of valid address ranges. This change assumes that the caller
wants to be restricted to vmemmap capable address ranges beyond the
restrictions it already requested in the passed in @base argument. That
restriction may be true with respect to request_mem_region(), but not
necessarily other users of get_free_mem_region() like
alloc_free_mem_region().
So, 2 questions / change request options:
1/ Preferred: Is there a possibility for the AMD driver to trim the
resource it is passing to be bound by arch_get_mappable_range()? For CXL
this is achieved by inserting CXL aperture windows into the resource
tree.
In the future what happens in the MEMORY_DEVICE_PUBLIC case when the
memory address is picked by a hardware aperture on the device? It occurs
to me if that aperture is communicated to the device via some platform
mechanism (to honor arch_get_mappable_range() restrictions), then maybe
the same should be done here.
I have always cringed at the request_free_mem_region() implementation
playing fast and loose with the platform memory map. Maybe this episode
is a sign that these constraints need more formal handling in the
resource tree.
I.e. IORES_DESC_DEVICE_PRIVATE_MEMORY becomes a platform communicated
aperture rather than hoping that unused portions of iomem_resource can
be repurposed like this.
2/ If option 1/ proves too difficult, can you rework the consideration
of @base to be gated by @desc?
Something like:
if (desc == IORES_DESC_DEVICE_PRIVATE_MEMORY)
base_start = max(base->start, arch_get_mappable_range().start);
base_end = min(base->end, arch_get_mappable_range().end;
else
base_start = base->start;
base_end = base->end;
...to localize the consideration of arch_get_mappable_range() only to
the places it is absolutely required?
next prev parent reply other threads:[~2024-07-09 1:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 0:27 [PATCH v2] resource: limit request_free_mem_region based on arch_get_mappable_range D Scott Phillips
2024-07-09 1:31 ` Dan Williams [this message]
2024-08-28 2:57 ` D Scott Phillips
2024-08-29 0:08 ` Dan Williams
2024-08-29 17:19 ` D Scott Phillips
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=668c92e35c677_102cc29475@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhe@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@amperecomputing.com \
--cc=scott@os.amperecomputing.com \
--cc=takahiro.akashi@linaro.org \
--cc=will@kernel.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