Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4268882pxv; Tue, 27 Jul 2021 03:10:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0CG2QYjxn6HHv0QU57w88khs/6rj78J7152PB+8c9QEGlVBpemVV4aFmO9Z9IGGtveKUW X-Received: by 2002:a92:7312:: with SMTP id o18mr15657912ilc.289.1627380657719; Tue, 27 Jul 2021 03:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627380657; cv=none; d=google.com; s=arc-20160816; b=iuPNRwJkkBjlxXAR19WZkMfNqNZSVNk9+Q5C3Wjol/YNseAvpbdwQlEtAwaniwQ/l6 19Mv87C7OU/bh38kxXUG5ODTtDVDWQyACIAeaiqY5+mkrK07deNGtKdz8Iufxr0C2Nb1 K2GdZutBC/IBSI2O9PdtkPLsjnzFzb/zivSBs8bNWyVmJ+p63sj+xNtS0mqV8KAy4cnf XTdFVZk3km2pPdjSOsSJqJ8eXBGtMaf0ce5rHtZWOFFtjGSsk0+ZF+3DpLJlcO3tZCgx gbhVHmYk2MoWSQcKAI6wULrr7mqbdu9vf/C0X27r9Ag7ZhbMQ22VT43tpyc4qwzylMjk 9vCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iXXg9t2vZMzoQy0109NABusYTCH5Szsjf361DC36aV8=; b=uGeUSb0PYfAQSn4ppEWzb0qLMpPlD8tuPKtLWqH4DnT6vnfYvZRFFBgxgsmUPammDJ 6EOGtS0W0nlROcTy1ESV14XZXL2iflRruNMbp2I8QVU+vf3Arl2lVSatvh495A6RSpYO R+HIn9bA8h0V6MkV6wRpKYaroJSNtAnq7Qe/qPrNDDxwLlVqsfni9vsA+jyeFButfEa5 Q9Ey9+YPFfmvxO67ImjMNYEOt519YA88iDM9nIXuHRXTgrztnLLcR7IkvSeXsYGKXk6L uOgdQCUV/jNno/n08yqxvJUxgrG2VdSJo53yWlHevuyEmoZofF58JVhtSAEf+1Vl9sCU aQ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7n3yPt8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si2767044ioz.87.2021.07.27.03.10.46; Tue, 27 Jul 2021 03:10:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7n3yPt8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236103AbhG0KKA (ORCPT + 99 others); Tue, 27 Jul 2021 06:10:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236046AbhG0KJ6 (ORCPT ); Tue, 27 Jul 2021 06:09:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A07261505; Tue, 27 Jul 2021 10:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627380598; bh=+zy1KVbWis0NChMBKfluyJz7JK9D515lhSdSK/ke/+I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=t7n3yPt8S7MVD8eFNaGBVI96IMsiSIydToBVixNIxf65wZC0fy7w16/GjaJvGntXu uDvbYyStDycBSmR+ddAUsBuq4fD6TxoCcpUyT4iU4jKeO0OTpcKukAERHGiG+e36j4 gqdQ2gy/o0O/L2kuA+d3Pz8yzT5csOmy1SnnogaUrtNnEAIp2WHArE2m29O1wNuD+Z wiitDNYmft04QIDypFSqKpxJWpkb7Ej5c1o2n6aYU7kNRSNc/IxXGGh2rVljAU0pYq NEpW0k5mkGzb3AmSvOKEvbHXSU8wxq9xsxnpn3gChHLHocv4btJ25CsOjVD30JKbAb HYErpTG86YZbA== Received: by mail-oi1-f173.google.com with SMTP id y18so14528072oiv.3; Tue, 27 Jul 2021 03:09:58 -0700 (PDT) X-Gm-Message-State: AOAM532NILfFf+1/Nj2w0A/SNnWtv2MiWciI4bl7CxbKl4w84ZhyW1pd HRskwqQyeneW02TImkPpwruNO+vlIRxuE+/eBuI= X-Received: by 2002:aca:5a04:: with SMTP id o4mr14216558oib.33.1627380597962; Tue, 27 Jul 2021 03:09:57 -0700 (PDT) MIME-Version: 1.0 References: <20210726100026.12538-1-lorenzo.pieralisi@arm.com> <20210727100645.GA7108@lpieralisi> In-Reply-To: <20210727100645.GA7108@lpieralisi> From: Ard Biesheuvel Date: Tue, 27 Jul 2021 12:09:47 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ACPI: Add memory semantics to acpi_os_map_memory() To: Lorenzo Pieralisi Cc: Linux Kernel Mailing List , Will Deacon , Hanjun Guo , Sudeep Holla , Catalin Marinas , "Rafael J. Wysocki" , ACPI Devel Maling List , Linux ARM , Veronika kabatova , Robin Murphy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Jul 2021 at 12:06, Lorenzo Pieralisi wrote: > > On Mon, Jul 26, 2021 at 05:55:33PM +0200, Ard Biesheuvel wrote: > > On Mon, 26 Jul 2021 at 12:00, Lorenzo Pieralisi > > wrote: > > > > > > The memory attributes attached to memory regions depend on architecture > > > specific mappings. > > > > > > For some memory regions, the attributes specified by firmware (eg > > > uncached) are not sufficient to determine how a memory region should be > > > mapped by an OS (for instance a region that is define as uncached in > > > firmware can be mapped as Normal or Device memory on arm64) and > > > therefore the OS must be given control on how to map the region to match > > > the expected mapping behaviour (eg if a mapping is requested with memory > > > semantics, it must allow unaligned accesses). > > > > > > Rework acpi_os_map_memory() and acpi_os_ioremap() back-end to split > > > them into two separate code paths: > > > > > > acpi_os_memmap() -> memory semantics > > > acpi_os_ioremap() -> MMIO semantics > > > > > > The split allows the architectural implementation back-ends to detect > > > the default memory attributes required by the mapping in question > > > (ie the mapping API defines the semantics memory vs MMIO) and map the > > > memory accordingly. > > > > > > Link: https://lore.kernel.org/linux-arm-kernel/31ffe8fc-f5ee-2858-26c5-0fd8bdd68702@arm.com > > > Signed-off-by: Lorenzo Pieralisi > > > Cc: Ard Biesheuvel > > > Cc: Will Deacon > > > Cc: Hanjun Guo > > > Cc: Sudeep Holla > > > Cc: Catalin Marinas > > > Cc: "Rafael J. Wysocki" > > > > For the patch in general > > > > Acked-by: Ard Biesheuvel > > Thanks ! > > [...] > > > > -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) > > > > I am aware that this just duplicated the prototype above, but I think > > this should be > > > > void __iomem *__ref > > > > given that the __ref comes after the * in the prototype below. > > Yes I just moved/duplicated the prototype above but I believe this is > consistent with include/acpi/acpi_io.h unless I have not understood > what you meant ? > > It is probably worth changing it in both places to > > void __iomem *__ref > > ? > > I can do that with an additional patch. > Yes, as long as they are all mutually consistent. The __ref is not part of the type at all, so it should not be between the void and the *, even if the compiler appears to allow it. > > > > > +{ > > > + 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); > > > > I think this should be (__force void *) to shut up sparse address > > space warnings. > > Yes I can add that attribute in an additional patch and rebase this one > on top of it. > > Thanks, > Lorenzo > > > > > > } > > > 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.31.0 > > >