From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Veronika Kabatova <vkabatov@redhat.com>,
Will Deacon <will@kernel.org>,
CKI Project <cki-project@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Memory Management <mm-qe@redhat.com>,
skt-results-master@redhat.com, Jeff Bastian <jbastian@redhat.com>,
Jan Stancek <jstancek@redhat.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>, Hanjun Guo <guohanjun@huawei.com>,
Sudeep Holla <sudeep.holla@arm.com>,
lv.zheng@intel.com, Tony Luck <tony.luck@intel.com>,
James Morse <james.morse@arm.com>
Subject: Re: ❌ FAIL: Test report for kernel 5.13.0-rc7 (arm-next, 8ab9b1a9)
Date: Fri, 16 Jul 2021 17:26:17 +0100 [thread overview]
Message-ID: <20210716162617.GA1403@lpieralisi> (raw)
In-Reply-To: <CAMj1kXHQKKnzJUEXMMzt3D1NUodeik8FZN1OTpD9zf8ZWrp6Lw@mail.gmail.com>
On Fri, Jul 16, 2021 at 06:16:01PM +0200, Ard Biesheuvel wrote:
> On Mon, 5 Jul 2021 at 18:17, Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> >
> > On Wed, Jun 30, 2021 at 08:18:22PM +0200, Ard Biesheuvel wrote:
> >
> > [...]
> >
> > > > In current code, even if the BERT were mapped with acpi_os_map_iomem()
> > > > this would change nothing since it's acpi_os_ioremap() that runs the
> > > > rule (backed up by EFI memory map region info).
> > > >
> > >
> > > Indeed. So the fact that acpi_os_map_memory() is backed by
> > > acpi_os_ioremap() is something we should fix. So they should both
> > > consult the EFI memory map, but have different fallback defaults if
> > > the region is not annotated correctly.
> >
> > Put together patch below even though I am not really satisfied, a tad
> > intrusive and duplicate code in generic/arch backends, compile tested
> > only; overall this IO vs memory mapping distinction is a bit too fuzzy
> > for my taste - there is legacy unfortunately to consider though.
> >
>
> I'd say that this does not look unreasonable at all. Is there any way
> we could get this tested on actual hw?
Sure, I was meant to follow-up and was caught up in something else,
sorry.
I will clean up the log, push it out in a branch on Monday, CKI
should pick it up. I will also think about other possible testing
options.
Thanks for having a look !
Lorenzo
> > -- >8 --
> > Subject: [PATCH] ACPI: Add memory semantics to acpi_os_map_memory()
> >
> > Some platforms require memory semantics requested by the mapping function
> > to be translated into architectural specific memory attributes so that
> > the mapping is effectively implementing what is expected from it in
> > terms of allowed access patterns (eg unaligned access).
> >
> > Rework acpi_os_map_memory() and acpi_os_ioremap() back-end to split
> > them into two separate code paths that allow the architectural
> > back-end to detect the default memory attributes required by
> > the mapping in question.
> >
> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > ---
> > arch/arm64/include/asm/acpi.h | 3 +++
> > arch/arm64/kernel/acpi.c | 16 ++++++++++++++--
> > drivers/acpi/osl.c | 23 ++++++++++++++++-------
> > include/acpi/acpi_io.h | 8 ++++++++
> > 4 files changed, 41 insertions(+), 9 deletions(-)
> >
> > diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> > index bd68e1b7f29f..7535dc7cc5aa 100644
> > --- a/arch/arm64/include/asm/acpi.h
> > +++ b/arch/arm64/include/asm/acpi.h
> > @@ -50,6 +50,9 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
> > void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
> > #define acpi_os_ioremap acpi_os_ioremap
> >
> > +void __iomem *acpi_os_memmap(acpi_physical_address phys, acpi_size size);
> > +#define acpi_os_memmap acpi_os_memmap
> > +
> > typedef u64 phys_cpuid_t;
> > #define PHYS_CPUID_INVALID INVALID_HWID
> >
> > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> > index cada0b816c8a..4c04fb40dc86 100644
> > --- a/arch/arm64/kernel/acpi.c
> > +++ b/arch/arm64/kernel/acpi.c
> > @@ -261,7 +261,8 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
> > return __pgprot(PROT_DEVICE_nGnRnE);
> > }
> >
> > -void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
> > +static void __iomem *__acpi_os_ioremap(acpi_physical_address phys,
> > + acpi_size size, bool memory)
> > {
> > efi_memory_desc_t *md, *region = NULL;
> > pgprot_t prot;
> > @@ -289,7 +290,8 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
> > * regions that require a virtual mapping to make them accessible to
> > * the EFI runtime services.
> > */
> > - prot = __pgprot(PROT_DEVICE_nGnRnE);
> > + prot = memory ? __pgprot(PROT_NORMAL_NC) :
> > + __pgprot(PROT_DEVICE_nGnRnE);
> > if (region) {
> > switch (region->type) {
> > case EFI_LOADER_CODE:
> > @@ -349,6 +351,16 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
> > return __ioremap(phys, size, prot);
> > }
> >
> > +void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
> > +{
> > + return __acpi_os_ioremap(phys, size, false);
> > +}
> > +
> > +void __iomem *acpi_os_memmap(acpi_physical_address phys, acpi_size size)
> > +{
> > + return __acpi_os_ioremap(phys, size, true);
> > +}
> > +
> > /*
> > * Claim Synchronous External Aborts as a firmware first notification.
> > *
> > diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
> > index 327e1b4eb6b0..01dd115689bf 100644
> > --- a/drivers/acpi/osl.c
> > +++ b/drivers/acpi/osl.c
> > @@ -284,7 +284,8 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
> > #define should_use_kmap(pfn) page_is_ram(pfn)
> > #endif
> >
> > -static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
> > +static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz,
> > + bool memory)
> > {
> > unsigned long pfn;
> >
> > @@ -294,7 +295,8 @@ static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
> > return NULL;
> > return (void __iomem __force *)kmap(pfn_to_page(pfn));
> > } else
> > - return acpi_os_ioremap(pg_off, pg_sz);
> > + return memory ? acpi_os_memmap(pg_off, pg_sz) :
> > + acpi_os_ioremap(pg_off, pg_sz);
> > }
> >
> > static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
> > @@ -309,9 +311,10 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
> > }
> >
> > /**
> > - * acpi_os_map_iomem - Get a virtual address for a given physical address range.
> > + * __acpi_os_map_iomem - Get a virtual address for a given physical address range.
> > * @phys: Start of the physical address range to map.
> > * @size: Size of the physical address range to map.
> > + * @memory: true if remapping memory, false if IO
> > *
> > * Look up the given physical address range in the list of existing ACPI memory
> > * mappings. If found, get a reference to it and return a pointer to it (its
> > @@ -321,8 +324,8 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
> > * During early init (when acpi_permanent_mmap has not been set yet) this
> > * routine simply calls __acpi_map_table() to get the job done.
> > */
> > -void __iomem __ref
> > -*acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
> > +static void __iomem __ref
> > +*__acpi_os_map_iomem(acpi_physical_address phys, acpi_size size, bool memory)
> > {
> > struct acpi_ioremap *map;
> > void __iomem *virt;
> > @@ -353,7 +356,7 @@ void __iomem __ref
> >
> > pg_off = round_down(phys, PAGE_SIZE);
> > pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
> > - virt = acpi_map(phys, size);
> > + virt = acpi_map(phys, size, memory);
> > if (!virt) {
> > mutex_unlock(&acpi_ioremap_lock);
> > kfree(map);
> > @@ -372,11 +375,17 @@ void __iomem __ref
> > mutex_unlock(&acpi_ioremap_lock);
> > return map->virt + (phys - map->phys);
> > }
> > +
> > +void __iomem __ref
> > +*acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
> > +{
> > + return __acpi_os_map_iomem(phys, size, false);
> > +}
> > EXPORT_SYMBOL_GPL(acpi_os_map_iomem);
> >
> > void *__ref acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
> > {
> > - return (void *)acpi_os_map_iomem(phys, size);
> > + return (void *)__acpi_os_map_iomem(phys, size, true);
> > }
> > EXPORT_SYMBOL_GPL(acpi_os_map_memory);
> >
> > diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h
> > index 027faa8883aa..a0212e67d6f4 100644
> > --- a/include/acpi/acpi_io.h
> > +++ b/include/acpi/acpi_io.h
> > @@ -14,6 +14,14 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
> > }
> > #endif
> >
> > +#ifndef acpi_os_memmap
> > +static inline void __iomem *acpi_os_memmap(acpi_physical_address phys,
> > + acpi_size size)
> > +{
> > + return ioremap_cache(phys, size);
> > +}
> > +#endif
> > +
> > extern bool acpi_permanent_mmap;
> >
> > void __iomem __ref
> > --
> > 2.29.1
> >
next prev parent reply other threads:[~2021-07-16 16:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cki.6A65B499FE.46BPQ6DJTC@redhat.com>
[not found] ` <20210625083918.GA2736@willie-the-truck>
[not found] ` <CA+tGwn=rP_hAMLLtoy_s90ZzBjfMggu7T2Qj8HyFfGh1BGUoRA@mail.gmail.com>
[not found] ` <31ffe8fc-f5ee-2858-26c5-0fd8bdd68702@arm.com>
[not found] ` <20210625110944.GB20835@arm.com>
[not found] ` <48b23351-3dba-bec8-242f-3c918ae55708@arm.com>
2021-06-29 11:48 ` ❌ FAIL: Test report for kernel 5.13.0-rc7 (arm-next, 8ab9b1a9) Robin Murphy
2021-06-29 14:44 ` Lorenzo Pieralisi
2021-06-29 15:14 ` Robin Murphy
2021-06-29 16:35 ` Catalin Marinas
2021-06-30 10:37 ` Lorenzo Pieralisi
2021-06-30 11:17 ` Robin Murphy
2021-06-30 13:22 ` Ard Biesheuvel
2021-06-30 15:49 ` Lorenzo Pieralisi
2021-06-30 18:18 ` Ard Biesheuvel
2021-07-05 16:17 ` Lorenzo Pieralisi
2021-07-16 16:16 ` Ard Biesheuvel
2021-07-16 16:26 ` Lorenzo Pieralisi [this message]
2021-07-22 12:38 ` Veronika Kabatova
2021-07-22 13:51 ` Robin Murphy
2021-07-22 18:23 ` Veronika Kabatova
2021-06-29 17:03 ` Veronika Kabatova
2021-06-29 17:27 ` Robin Murphy
2021-06-29 17:44 ` Veronika Kabatova
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=20210716162617.GA1403@lpieralisi \
--to=lorenzo.pieralisi@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cki-project@redhat.com \
--cc=guohanjun@huawei.com \
--cc=james.morse@arm.com \
--cc=jbastian@redhat.com \
--cc=jstancek@redhat.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lv.zheng@intel.com \
--cc=mark.rutland@arm.com \
--cc=mm-qe@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=robin.murphy@arm.com \
--cc=skt-results-master@redhat.com \
--cc=sudeep.holla@arm.com \
--cc=tony.luck@intel.com \
--cc=vkabatov@redhat.com \
--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