From patchwork Sat Aug 20 00:31:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 12949412 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 3550FC28D13 for ; Sat, 20 Aug 2022 00:33:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC0898D0003; Fri, 19 Aug 2022 20:33:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A70768D0002; Fri, 19 Aug 2022 20:33:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9117B8D0003; Fri, 19 Aug 2022 20:33:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 821AF8D0002 for ; Fri, 19 Aug 2022 20:33:37 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 581EC140436 for ; Sat, 20 Aug 2022 00:33:37 +0000 (UTC) X-FDA: 79818097674.26.452D1E4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 74F3B4004C for ; Sat, 20 Aug 2022 00:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660955504; 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=chLY++uUFkS8hC5VhV7WNTHSImYmuTtP4WBhSWyRYLQ=; b=MCzgxoL2Ba6GNkFY/CV+yotVqsX/lsY1vpXD5y9Qp3l6qr4vIAqfIMExEflQV7v1/cZ5cG LtvnCdQh69tSn/ZtV5DPwzGvPmTDvhI+fJK7dHprmObyrjihEk9IyP0yZ5pqyMw4IrUz2c jnxy3fdirnq6hwdSUCLWPUu2Yi2hZ9c= 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-402-6TqZY1enNd6QHQ2ZnS6eDg-1; Fri, 19 Aug 2022 20:31:42 -0400 X-MC-Unique: 6TqZY1enNd6QHQ2ZnS6eDg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F07D3185A794; Sat, 20 Aug 2022 00:31:41 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-17.pek2.redhat.com [10.72.12.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BED74010D2A; Sat, 20 Aug 2022 00:31:37 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org, Baoquan He Subject: [PATCH v2 02/11] mm: ioremap: fixup the physical address and page prot Date: Sat, 20 Aug 2022 08:31:16 +0800 Message-Id: <20220820003125.353570-3-bhe@redhat.com> In-Reply-To: <20220820003125.353570-1-bhe@redhat.com> References: <20220820003125.353570-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660955504; 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=chLY++uUFkS8hC5VhV7WNTHSImYmuTtP4WBhSWyRYLQ=; b=CVONMh621tcm6B6FEQbnXTPTIGCfdyy9YgvFkcgTNQzSruHdvDr3rmcudtj0n32rjzELlJ ahmghvDd05u8g9nzxPUR/BYD94LKCV6GxbCac5D27d1LEY7s3x/XQpwZr4/1HusNXTmXte Hj3zsL5GGqizurqRo1XaLfmCutP+Pvg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MCzgxoL2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.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=1660955504; a=rsa-sha256; cv=none; b=yyGQG12BkQXlR1nkGayhw0kDEIom+alMuJ2Y5MPRD43p0C3u2yKqnvYm0d3Y4qXMqTD5O5 YgKu+tu1vPILeJdFJbaqBIDozfqwj0COlQqCp8LsTKrpb1GtxmD9Ybqo99SFuTe0KY6OHv TOLZdoX2Swu1oJT0QqAg4Xa2IGnpmjY= X-Stat-Signature: f97eyxbughupnco614wocub7rbwnwcon X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 74F3B4004C Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MCzgxoL2; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com X-Rspam-User: X-HE-Tag: 1660955504-193744 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: On some architectures, the physical address need be fixed up before doing mapping, e.g, parisc. And on architectures, e.g arc, the parameter 'prot' passed into ioremap_prot() need be adjusted too. In oder to convert them to take GENERIC_IOREMAP method, we need wrap the address fixing up code and page prot adjusting code into arch_ioremap() and pass the new address and 'prot' out for ioremap_prot() handling. This is a preparation patch, no functionality change. Signed-off-by: Baoquan He --- arch/arm64/include/asm/io.h | 3 ++- arch/arm64/mm/ioremap.c | 5 +++-- include/asm-generic/io.h | 4 ++-- mm/ioremap.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index dd7e1c2dc86c..6a5578ddbbf6 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -139,7 +139,8 @@ extern void __memset_io(volatile void __iomem *, int, size_t); * I/O memory mapping functions. */ -void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot); +void __iomem * +arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val); #define arch_ioremap arch_ioremap #define _PAGE_IOREMAP PROT_DEVICE_nGnRE diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index b0f4cea86f0e..ef75ffef4dbc 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -3,9 +3,10 @@ #include #include -void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, unsigned long prot) +void __iomem * +arch_ioremap(phys_addr_t *paddr, size_t size, unsigned long *prot_val) { - unsigned long last_addr, offset; + unsigned long last_addr, offset, phys_addr = *paddr; offset = phys_addr & (~PAGE_MASK); phys_addr -= offset; diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 7b6bfb62ef80..fb9bda2be8ed 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1059,8 +1059,8 @@ static inline void iounmap(volatile void __iomem *addr) */ #ifndef arch_ioremap #define arch_ioremap arch_ioremap -static inline void __iomem *arch_ioremap(phys_addr_t phys_addr, size_t size, - unsigned long prot) +static inline void __iomem *arch_ioremap(phys_addr_t *paddr, size_t size, + unsigned long *prot_val) { return NULL; } diff --git a/mm/ioremap.c b/mm/ioremap.c index 99fde69becc7..7914b5cf5b78 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -19,7 +19,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, struct vm_struct *area; void __iomem *ioaddr; - ioaddr = arch_ioremap(phys_addr, size, prot); + ioaddr = arch_ioremap(&phys_addr, size, &prot); if (IS_ERR(ioaddr)) return NULL; else if (ioaddr)