From patchwork Tue Jun 20 13:13:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13285843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F190AEB64D7 for ; Tue, 20 Jun 2023 13:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EC548D0010; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79BBA8D000D; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68A3B8D0010; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5AA6A8D000D for ; Tue, 20 Jun 2023 09:17:32 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 024ECC0F4F for ; Tue, 20 Jun 2023 13:17:31 +0000 (UTC) X-FDA: 80923177944.01.8681B28 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id D887E140017 for ; Tue, 20 Jun 2023 13:17:29 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FSlUh4XI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687267049; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=O+pYF01GHYKFjlhfOilecO4nT8QJIsYtOQU4ovbaxBm1W/1LaTtNMUHf77YQ7tNE0keYBP Np6Hp70FjJq2q5h2Scukwdky8GstlhdmNiCEBywnEEngRkHY/Lw+Boqa5vTB6KYHMhUcJ+ pU7u7Jh1Ta+cL6stigUjAxfyp4Dg/X0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FSlUh4XI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687267049; a=rsa-sha256; cv=none; b=cucKLplKun4ip/vO3fDJ7LiMoBH2Jw75qeE0S6EkXkoVSwvOoNhbqDNoZBmryBE/3p1uBV pMwPwMcACHN02EvymKoI/RujKlj6XXknrFB0TO15bSbuQ/XC7kqHI20Np47a9gSjfzebEh 5IlSy5H/l4Ag6/rpI9roCLw/4gaXLn8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687267049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SboB+Gem+bQaB39EZZBPE5ZHPttNaa4nwbopj4kdit4=; b=FSlUh4XI2jCzLAdmiFZd5MFYh1HKg9KqdY16nPc6zrQyuBCtVfpzjabzIv1UF4OL3AFv2h a3uMql1Z/gf0m5cQxmmVRAIRweGf4BYniR8BE6SOuMjGWbb66mMKjkYiAW7iHK+DG3udcE r37r1fidhQ2gXg8q1qOFtTeOdywFSiM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-SII62w3fOlOJtOu-TAuZBw-1; Tue, 20 Jun 2023 09:17:27 -0400 X-MC-Unique: SII62w3fOlOJtOu-TAuZBw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC62A103963F; Tue, 20 Jun 2023 13:16:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47129C1ED96; Tue, 20 Jun 2023 13:16:23 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He Subject: [PATCH v7 15/19] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Tue, 20 Jun 2023 21:13:52 +0800 Message-Id: <20230620131356.25440-16-bhe@redhat.com> In-Reply-To: <20230620131356.25440-1-bhe@redhat.com> References: <20230620131356.25440-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: D887E140017 X-Rspam-User: X-Rspamd-Server: rspam04 X-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wx/EDlwfgTEqewo3R/GmYDcwABh46HFv++D3j2odfyGaHLCCRbJaG6KcvwnhVDfyADS+xFolCIeMAo6udD506G/NF6FCwoFogIBTOcp0YyZv0VG/CHOxmwBPowLVjiWRLH0Rmqh5trDyzc61juQgC9EvPPqtLK5AksDbwyH8Ij8FAbbkciavSjbt4nUyRsVinA/EMK0OQnpNqQOhs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christophe Leroy Architectures like powerpc have a dedicated space for IOREMAP mappings. If so, use it in generic_ioremap_prot(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig --- mm/ioremap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 86b82ec27d2b..68d9895144ad 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,6 +11,15 @@ #include #include +/* + * Ioremap often, but not always uses the generic vmalloc area. E.g on + * Power ARCH, it could have different ioremap space. + */ +#ifndef IOREMAP_START +#define IOREMAP_START VMALLOC_START +#define IOREMAP_END VMALLOC_END +#endif + void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot) { @@ -35,8 +44,8 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; - area = get_vm_area_caller(size, VM_IOREMAP, - __builtin_return_address(0)); + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +75,7 @@ void generic_iounmap(volatile void __iomem *addr) if (!iounmap_allowed(vaddr)) return; - if (is_vmalloc_addr(vaddr)) + if (is_ioremap_addr(vaddr)) vunmap(vaddr); }