From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80590C636CA for ; Fri, 16 Jul 2021 16:28:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 46809613CC for ; Fri, 16 Jul 2021 16:28:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46809613CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=511LkYuMf8hBHKHEijBdFgXGn9Lhjr0k/8WvOkoizyI=; b=Omfw1Qy4J46U0K LFy+zlfi8iD3KlVPKMurewmIKrrm6K24au7Kkf2s9vv5485XRtolyfhUY+8mJa4onzvUZpZRRCPgi RwzbcnRJ1+PDCwvbvactGN8lcvOWL49kdaYiL5EcLr0DTTsX4OwE/GxtzYzJyTdGI/WnIZMEqBZWN MzrXtsCjMSfbkiZjNXbjI/NNnQRzhaqMbu835i+1NXUdsSxVambbHEhHdCdDQXHpjiuU/+h3S/Z9P 6LglJ5TSzTPg2C3VBrtHH2bf98AP9xE+twKVUs3q734XCdUEvZRgTl6XY6DhejPwjIImStjVg5uW/ 9yTcQSncpmnpu1Xrmt1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4Qfa-004rDr-Nn; Fri, 16 Jul 2021 16:26:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4QfV-004rBx-Lv for linux-arm-kernel@lists.infradead.org; Fri, 16 Jul 2021 16:26:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D80A31B; Fri, 16 Jul 2021 09:26:26 -0700 (PDT) Received: from lpieralisi (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B94F23F7D7; Fri, 16 Jul 2021 09:26:23 -0700 (PDT) Date: Fri, 16 Jul 2021 17:26:17 +0100 From: Lorenzo Pieralisi To: Ard Biesheuvel Cc: Robin Murphy , Catalin Marinas , ACPI Devel Maling List , Veronika Kabatova , Will Deacon , CKI Project , Mark Rutland , Memory Management , skt-results-master@redhat.com, Jeff Bastian , Jan Stancek , Linux ARM , "Rafael J. Wysocki" , Len Brown , Hanjun Guo , Sudeep Holla , lv.zheng@intel.com, Tony Luck , James Morse Subject: Re: =?utf-8?B?4p2MIEZBSUw=?= =?utf-8?Q?=3A?= Test report for kernel 5.13.0-rc7 (arm-next, 8ab9b1a9) Message-ID: <20210716162617.GA1403@lpieralisi> References: <20210629144415.GA28457@lpieralisi> <14ca6f72-9b0f-ebd7-9cf8-a5d6190c8e5d@arm.com> <20210629163543.GA12361@arm.com> <20210630103715.GA12089@lpieralisi> <20210630154923.GA16215@lpieralisi> <20210705161715.GA19877@lpieralisi> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210716_092629_865983_E0A83EC5 X-CRM114-Status: GOOD ( 42.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 16, 2021 at 06:16:01PM +0200, Ard Biesheuvel wrote: > On Mon, 5 Jul 2021 at 18:17, Lorenzo Pieralisi > 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 > > --- > > 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 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel