From patchwork Thu Feb 16 12:34:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143027 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 C3F2AC636CC for ; Thu, 16 Feb 2023 12:34:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 666426B007B; Thu, 16 Feb 2023 07:34:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ED096B007D; Thu, 16 Feb 2023 07:34:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 467336B007E; Thu, 16 Feb 2023 07:34:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3462E6B007B for ; Thu, 16 Feb 2023 07:34:45 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0D3471605C9 for ; Thu, 16 Feb 2023 12:34:45 +0000 (UTC) X-FDA: 80473098930.01.48B9385 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 26919180004 for ; Thu, 16 Feb 2023 12:34:42 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q4+wwR00; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.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=1676550883; 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=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=541PZnYzz1SDoHyPNfa2C5hhxDzbrpa/1Zil/3ZFHkVljZSyg5IrMpi1ZjtMNUP8XtfFEq fBXdJ2uertz0eAv0Y6xTHXrd+zpZwcBkWT4vpMr6Xl7V4kRS2u/+N76oDbktCFQ/EwOWSO 5RockdQXOSe4n5l5/zQteBw4U4FX8Wo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q4+wwR00; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.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=1676550883; a=rsa-sha256; cv=none; b=pdZxBzCYkGGSEMGxsN39eqXM+9Semr4Wpk1PuyXzPfi1JpqiyiI0hUDmPfmblY3yroepnt jU9cSOCO4Zug1pq3Vs59dxoU/CJ9wzyv7G+xTumdsF3wA6T05+BHkVLYt5Zm1Trs5CNVIY FY4OMfuRRXzovloKqbkEO7cqCUds1nw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550882; 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=v0nZZRtgRBEjd1TuZoUTX3TC1k0a64a2n3jlsJishp4=; b=Q4+wwR00TdAVDVuUGm2KeVcPAdrEESx7BwiC3C7xnYoqNBizhOB2D5MuKIt0CH6ROMNCKw N+6anyMJN5c7WA+tVhVGFCGJ0agXsG6WYyCve3CuLKrEZrctsLtNNM/B0HeWzLimxwTZGz 8UZzA5TlqzdMTmni3z90xWl0x0UgY7Q= 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-630-IqQp3gjfNf6Iot1Z8qjFEQ-1; Thu, 16 Feb 2023 07:34:39 -0500 X-MC-Unique: IqQp3gjfNf6Iot1Z8qjFEQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 936D0830F82; Thu, 16 Feb 2023 12:34:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A24A492C3C; Thu, 16 Feb 2023 12:34:31 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH v4 01/16] hexagon: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:04 +0800 Message-Id: <20230216123419.461016-2-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 26919180004 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ecastrhtetge4zna47dcrbkqq1fdz55z X-HE-Tag: 1676550882-868268 X-HE-Meta: U2FsdGVkX18w/Qu7rhAiHrcMgvKxfd1F3vnYgszGFB3AcWDsellNse1ihcbrWxjprUFn091fvJFdKSBlHlpRtqIgFOjLLBsc6gr9Rs5Pzr3kWyTB4/QsZHm68bkCvoTakPaV3kKq7Iu2EMz8/oEVST8rC+GsGvZAj0lE5v2f50kIoZ/KE2Htn8tftlPe47aPnZq2sp6ETCq/yu8stsoyHm7qmoowE8yhdb3HBg0CZbIs4GxpgMwOUHG7nAoMXfl35NFptlnwPk5nJf0Is1qxCyi3blWt6wIYQn0YfoJFt03AYFROYQ6TXxmoEAxaWt2KkkO+qtH7SPy3FAxghrROnF+CrDECILPRryTQuWEWf7ZdEEsm7iJNKSS96CmkUmmhscNlIgeCVUDxQwfyckotgBi5RRvFSkDhHidpAJiGEQBYMYURx9Ke8sq0GHQ1ZocdaWf0j7wYEJ+JLxXxejkZCQ4D2xNFChs1OnlURUmmhA4sN+yfXHBSPgWbCt8WjpT4jgRuuyLWh1uXYiCBD3omMvvUf5ieXjizqH3gTt/M3s/XREpaOVgamuQRhpcEHhD0gm7XVdH6sE85uEdgZHiL3JkJMJ0p3d7zePqN0aV0o8nHySq+ZZ+NwS09hDG4DAiKHMBcCMXyU5qazBC0P83A1evvCOex43KsnhcQtRZffGH125D/tbVS8qUw7DSX+NPTxMDmuY4e7x/OVNsOch8nBcum39uaJqWo1/dP8xVQuERTnibS2Gqmsr7JPdcneZaASKg0m4C3RP3zCWrfOdDVhYxPtZMRzhFnUzT9YTUnKn9snk4rFRwxsNg9zqIgq0Fh+zic5CjmiVo3xhi8EG9mye0KYKhJl7gDzJNGp2Iy5srjYkYFmlcCm68W+GWz/7Apo1kEUmDricJXRPJM3cIC3NJMgUL994wpm5sZaX2Ghf36kcTvw48VlRmomxujCeuVj532RN90fVY0W7dWnUl CkGp5VHM yhInDDkErc5qwPDIg/BxOMs9zde06fOnkChFrwJwot2Q1imHTXM3IuErnt/C7Sc4SiqaS+1zpSChf2aNwsvWmcVHkE+tHSPFdSJGgUo/NmJBasbtFBWur7+uVa80FdKA9u826GE21lcaWGUwcz1iJxTT1TYEHqW1YluBeheR6nTYdZ6/wBgt4RKqB1hqTXcHYrJ7G6Csdxe3d3+TO9TSvr043VxTYqai3un/uhKtkvz87HNXEJbSWCpYrClwHivA7GPzhj0udQi3sjioLf/o4YMklAyy/oJVy8QU3cSmNh0Y+5HMqiHRm5+3MEqeRLkZzcO7lxAmxndryElene88n1DFlYn3u6dp6QX5SJuV8iCPwXlI= 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: By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap() are visible and available to arch. This change will simplify implementation by removing duplicated codes with generic ioremap_prot() and iounmap(), and has the equivalent functioality. For hexagon, the current ioremap() and iounmap() are the same as generic version. After taking GENERIC_IOREMAP way, the old ioremap() and iounmap() can be completely removed. Signed-off-by: Baoquan He Cc: Brian Cain Cc: linux-hexagon@vger.kernel.org --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/io.h | 9 +++++-- arch/hexagon/mm/ioremap.c | 44 ----------------------------------- 3 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 arch/hexagon/mm/ioremap.c diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 54eadf265178..17afffde1a7f 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -25,6 +25,7 @@ config HEXAGON select NEED_SG_DMA_LENGTH select NO_IOPORT_MAP select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select STACKTRACE_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h index 46a099de85b7..dcd9cbbf5934 100644 --- a/arch/hexagon/include/asm/io.h +++ b/arch/hexagon/include/asm/io.h @@ -170,8 +170,13 @@ static inline void writel(u32 data, volatile void __iomem *addr) #define writew_relaxed __raw_writew #define writel_relaxed __raw_writel -void __iomem *ioremap(unsigned long phys_addr, unsigned long size); -#define ioremap_uc(X, Y) ioremap((X), (Y)) +/* + * I/O memory mapping functions. + */ +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ + (__HEXAGON_C_DEV << 6)) + +#define ioremap_uc(addr, size) ioremap((addr), (size)) #define __raw_writel writel diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c deleted file mode 100644 index 255c5b1ee1a7..000000000000 --- a/arch/hexagon/mm/ioremap.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * I/O remap functions for Hexagon - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#include -#include -#include - -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) -{ - unsigned long last_addr, addr; - unsigned long offset = phys_addr & ~PAGE_MASK; - struct vm_struct *area; - - pgprot_t prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE - |(__HEXAGON_C_DEV << 6)); - - last_addr = phys_addr + size - 1; - - /* Wrapping not allowed */ - if (!size || (last_addr < phys_addr)) - return NULL; - - /* Rounds up to next page size, including whole-page offset */ - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr+size, phys_addr, prot)) { - vunmap((void *)addr); - return NULL; - } - - return (void __iomem *) (offset + addr); -} - -void iounmap(const volatile void __iomem *addr) -{ - vunmap((void *) ((unsigned long) addr & PAGE_MASK)); -} From patchwork Thu Feb 16 12:34:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143028 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 17797C61DA4 for ; Thu, 16 Feb 2023 12:34:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A82616B007E; Thu, 16 Feb 2023 07:34:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0C146B0080; Thu, 16 Feb 2023 07:34:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 886396B0081; Thu, 16 Feb 2023 07:34:53 -0500 (EST) 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 710C16B007E for ; Thu, 16 Feb 2023 07:34:53 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 444B11C5FFF for ; Thu, 16 Feb 2023 12:34:53 +0000 (UTC) X-FDA: 80473099266.07.ECE2107 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 6F5BB20014 for ; Thu, 16 Feb 2023 12:34:51 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V4Af0HwH; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550891; 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=jHZa8mu+sMxKIWEAwvYcXi8mFXnonAyjIbMLTnXCGN4=; b=LtjtBM9ClqUO5Pi0YWSFf7qamMnTAgPODKTaaxpy8817mry8n3kF8BoXRCNABgwM4+5JCY GBJylcyX6CxbK7Fow5NZValtL6g/Oxmsp9F/82+YShrB2tC+N/OMj4PjH4OzHTZbPBp7D9 qgsHJa07Tyg+R5XqVL20ZTPuAfPPuRo= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V4Af0HwH; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550891; a=rsa-sha256; cv=none; b=a69KlBcVSq8zPiLyLY2ImF94yqkfPBNut0mFzZ0QPdGuDmXE9Y9pkq+WqTVIdSwHL/gmqR qL0w92gu2v5G0Jg6gNnoPisVZFXHgIY6to7SqoHDOAsmxNNP76ZfFa2yQPh3wxnQqHSxOD hcaWe8SjE+2TG9zcHVFlYieUCsLIk/8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550890; 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=jHZa8mu+sMxKIWEAwvYcXi8mFXnonAyjIbMLTnXCGN4=; b=V4Af0HwHujc50s5GcEikCjDGl4by6OlV3YIFsKlBm5m/FUH6zyJVH4DtNKY2RblNxGAAQo ndHIsGUtXMmIy2mx8Xw+8/vPWYXeuD+ruyas7uA9p1ZoqHxuMKOyFIB8F36SY4UcdRtFRJ a0hKGi0Tm2alVR2C7dKOdXHhXCpQYGM= 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-29-221ga0mcOi6-Nz0bEIpEaw-1; Thu, 16 Feb 2023 07:34:47 -0500 X-MC-Unique: 221ga0mcOi6-Nz0bEIpEaw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A725A101A52E; Thu, 16 Feb 2023 12:34:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52401492C3C; Thu, 16 Feb 2023 12:34:38 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v4 02/16] openrisc: mm: remove unneeded early ioremap code Date: Thu, 16 Feb 2023 20:34:05 +0800 Message-Id: <20230216123419.461016-3-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 8qsj37s4r16jac3orwpyw9dc6rp9oa6s X-Rspamd-Queue-Id: 6F5BB20014 X-HE-Tag: 1676550891-189170 X-HE-Meta: U2FsdGVkX1/YL9zhQheVjK+84H/4tYOiGDLbfZazETeu37MRhoPK0bF5+IDvfO7DMte7OLUG1FVDGENrJtqN5zLBxp8GiC9gocLz7OGr/nHVYbH1ToyoTlIVhKX+SC502CLr5Xq92cAE/7gXft+/sT6VhRb8G4VZy2fawh2EIzZUvy6PQgpAxiyOF9/+aXDN6epzi5Iqi6joBHGyf0O1FofSLfPNP7LsQr29DqspOOzWNbgnGz6m5OS3Dza+T4fVWk8HN1TKUH1sEVXTHnKIAC9b5143py1n55FN2c2CbVlRGyF8I9Q64Y8EjK9Fj1fLPxXmjVE/ztvyQ9SIuGxScENoZXLsUTp7cRblYRG+XMDxkmGyGbS258eUsnh+X2cU0AvZTh8ZF2wTamuTtEGjj2g8sFy17eG8sp/q3dOHtxOWDcuxNilWANJ30aze3nX6br2CYwks7nzDaXo0eYncb1C93me9Te/tEHDUjO0Zyn+2fXB3WthjpxiETjDbl2/nP2Aqyi+fD2QAHOCLvERoUW89UE1YpKNriGGuutpNApjLpjAjvasqKRCWUxDZpaO6iZX2C/h2/w3UH6a2iUqbF4qEHHLTYNycqyYB7d0XwRWr3+mVwH4Ja7yDKroo7giDX41tF4I9xpoTHFY4SSuK8khYC2587BtnaLMX7Jcj90VvDfFqyOsSGOLjqXu/4rzq9XuH0EEJXBnUOQroEm7EGy4EYUTrZBws94A1ONBexPCHUrfnnrKiujs2jJudOs/ErHBKakBhL7TqbbtlVs1P2Wo0o2dXLZqMXfX78ZbE7wcltc/YH59IbiTmH98hmtPaB8r+rtPttxOLzYUFJF7to5nkZLNk7hsj91y866YdzwUz/diVE0AsRUeOaqzsbBj6ex7dks1TIiw8jaTEwxIvr1orn3zQD/m5s9elWYefWhckTmBp97QcoqYqaQbOf4lAaOOAySGUru15liwvmHd 6rOR3mc7 2J12Qyaxz6dFPv0q9Zd6SdBbaZxUBhRsvA8vObIPqOGbxQycQW5eFO0B52C61EcfYLCNxwQPzv8vHUTfs59mXiSo/qewJPuluuIz66R7P9wLJ4u5NRvBCjj/6gfbJDAJyUrSyzeh71AZ2sp9x9DL0+grnROQq7tmHrikUKRI2HF6sMw7CKAq8TuuoRxCLQodTwTNu28BHZoAYkLmSI4BRr+H3BqpTYM6RV1dSeZHgmmREHdm0njSrqA++kIPFHbg+Nz5PAIf0CiCfKGrfX8dnPkv7FUlFyYsUP9E7BKgPekHLeeRxcw4zq1z42zsV+ppEYujwCNgN4pginzI= 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: Under arch/openrisc, there isn't any place where ioremap() is called. It means that there isn't early ioremap handling needed in openrisc, So the early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is unnecessary and can be removed. Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/ Signed-off-by: Baoquan He Acked-by: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: Stafford Horne Cc: openrisc@lists.librecores.org --- arch/openrisc/mm/ioremap.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 8ec0dafecf25..90b59bc53c8c 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,8 +22,6 @@ extern int mem_init_done; -static unsigned int fixmaps_used __initdata; - /* * Remap an arbitrary physical address space into the kernel virtual * address space. Needed when the kernel wants to access high addresses @@ -52,24 +50,14 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) p = addr & PAGE_MASK; size = PAGE_ALIGN(last_addr + 1) - p; - if (likely(mem_init_done)) { - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - } else { - if ((fixmaps_used + (size >> PAGE_SHIFT)) > FIX_N_IOREMAPS) - return NULL; - v = fix_to_virt(FIX_IOREMAP_BEGIN + fixmaps_used); - fixmaps_used += (size >> PAGE_SHIFT); - } + area = get_vm_area(size, VM_IOREMAP); + if (!area) + return NULL; + v = (unsigned long)area->addr; if (ioremap_page_range(v, v + size, p, __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - if (likely(mem_init_done)) - vfree(area->addr); - else - fixmaps_used -= (size >> PAGE_SHIFT); + vfree(area->addr); return NULL; } From patchwork Thu Feb 16 12:34:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143029 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 40F0BC636CC for ; Thu, 16 Feb 2023 12:35:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D41B16B0080; Thu, 16 Feb 2023 07:35:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCAB36B0081; Thu, 16 Feb 2023 07:35:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B44916B0082; Thu, 16 Feb 2023 07:35:01 -0500 (EST) 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 A580F6B0080 for ; Thu, 16 Feb 2023 07:35:01 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 89B7C1C6917 for ; Thu, 16 Feb 2023 12:35:01 +0000 (UTC) X-FDA: 80473099602.21.661F3F5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id ABF621C000B for ; Thu, 16 Feb 2023 12:34:59 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LjMBaGij; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550899; 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=wmaPlT6qa/hIBp/Pd8+V5Z2lcUnUfL5T/RFM1vmlHuE=; b=ZOsghtx40CFJpjv/lAppqh8rhUZQ8E4BhkRGlQY0T6AcnjAC9yj/rRM4gBDfgne1QELgqh v+sQ6sdN3H3rQlKKVMmUOVSJU7o+7U1HFWL2OsgAy2/VhU3SYH7vyEC9fTCzAPpyAs7QNs uer9YPCYEvKIZbbFUYwYh56S9DSjBhY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LjMBaGij; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550899; a=rsa-sha256; cv=none; b=ZRxW75MoudxcWogyObyahTVklaRULa+jUx7D4LrFxVc1o8GKjIS5DJ1GxwhqpWIzuigU4U jdAf3EMcEqU4+G8gKEibFK6MIJle8u0YGYwF1h2xe8hg/5h8VayKxo8sjdsKNVjS9jAy7u xatRJyjnFYgDKywEXIuHE0o0mL3fzfU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550899; 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=wmaPlT6qa/hIBp/Pd8+V5Z2lcUnUfL5T/RFM1vmlHuE=; b=LjMBaGijuFViLnscz3XnqSKXLaPp8xDuWKf7GczGS3ykDtmASuZWXV3UfQLNBvEYRPpG12 8Rktr0qwYmEWq3kQkShDxRW4dQoun+AEbrydjYkuVKQS9TcnIjgiLwm15fBZ3FCuf6DXCp VU1pVFCWY6xftJRoO7HzMNV3l3AZ2Wg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-373-91IkA2bIOg-NUu3Sb4_AoA-1; Thu, 16 Feb 2023 07:34:53 -0500 X-MC-Unique: 91IkA2bIOg-NUu3Sb4_AoA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 040CD3814952; Thu, 16 Feb 2023 12:34:53 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7074B492C3C; Thu, 16 Feb 2023 12:34:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He Subject: [PATCH v4 03/16] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Date: Thu, 16 Feb 2023 20:34:06 +0800 Message-Id: <20230216123419.461016-4-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: ABF621C000B X-Stat-Signature: mbezzwmytmewosizktf4g7izy4yr5g16 X-Rspam-User: X-HE-Tag: 1676550899-649654 X-HE-Meta: U2FsdGVkX18gMhxQD/QZdPamKaDYyXl41U4Sg/fM+VO/5PZFJW7lKYcgGLnhNhJel8llY49svi0q2/+VMZsvlMu+o4TTtiKDCimMdNJX3Lc4FI9U+WdwDLdvqezu8BSQWI1H9h3Z5mEf2Tptiic/t/bq8mbyadPW/M8fwdM6BxHEA1RrJMZWOFQCFOtt8KwEhMluf/W31FB2S3LA8hp9lj7EF3pEn5CYDQ/V576p0BrRPuQbatUiwe6XgEEn2qah5VrnmgI+Ha7RjjPvfzL0HUagK9oaSap1uc8WoEgIQV5/x3nbjT5GueD/wwKmyZRDcKV/YCdMEynGJFPK/zqt+ciVBl/FS1U4IXf2iWdvBzDT4cgvyBDlh3X9wP9P2qMyuWlJEpXY/9/jdxW9weaApYyOIbHHxjnETcX9UbMCqb6Hz+bPyZuL2C6Sw7JILpD7RCwMNpS3RhsmAG5x75MIEHP7ZQzvebxgZo1hv7W1uRZW3JSPrcmD1q820DMrbdlnjQ0/5/b4TDAf885z38+SKhxS6RtgU94coQWVs/ke/u6hRfwC35iCQMndLmfKmc267nsnHOXgRK/Kbzb47y37ghy6p/hUN181bLX/MkXFIv2ldWznS5cDA/1mX2NwJH/F5WTc78Na3qzR0ggOq2ZdBuqiGp9ZWZHFMXpuN5RES76525MCsT7DmrYfjtGmDd5JesDLJ10HqZ7vx6NUeiP/SWKS7jU55SK1uSE4vXlIoU22hXptRiSGM1DfTKELGg+9PN8IQD+XDoVLgrEwoQOil1y+X9qkn+cjJsKA5JNTwqyDPSjRETSVJLhfE6OAWeGa5xM+yN/lBu/sr2gD6Lep9Uht4SM25NSf5MQElGbRkQPPkWeE4O+x2MyKvWbGrMB/XA1Ub3DGkOfVUJXeW1Aodm7H3/j82ui+ECSKeU/OSGHXhjJSrMaD4LZqnnyTk3FZSLvoJqHx4x1tSo38MeB WEkxNGJm PPEoCgR9hQWzfEfvKcmPVljB+Q3m9F0vH6zn0McTr5y9aruf5phdIkUZkjOCdXWaKR+MvOCRds0rLUFMbBe3EyEN5U8Ry7+vzGGlPVsmwwHo6o020C4IGvPy5cBpyVl91TDqw0vUKCVaSCXHXgshXZ4WsuGL6a98HGY+PmVEZD3IayDz7JCnW0/UTe3+xXSfeix6NmPax0frU6uw2cN+NGiakIYiNMUPoUB5vhqegTSoHKOz1GoLs/RX5ZpA6zhDF1In9YRoDw1vuODFsLQ+//4FGr7wr5wrqkA8eBAdtAZsU+R4= 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 Define a generic version of ioremap_prot() and iounmap() that architectures can call after they have performed the necessary alteration to parameters and/or necessary verifications. Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He --- include/asm-generic/io.h | 4 ++++ mm/ioremap.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 4c44a29b5e8e..5a9cf16ee0c2 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1073,9 +1073,13 @@ static inline bool iounmap_allowed(void *addr) } #endif +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot); + void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot); void iounmap(volatile void __iomem *addr); +void generic_iounmap(volatile void __iomem *addr); static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { diff --git a/mm/ioremap.c b/mm/ioremap.c index 8652426282cc..db6234b9db59 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -11,8 +11,8 @@ #include #include -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, - unsigned long prot) +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, + pgprot_t prot) { unsigned long offset, vaddr; phys_addr_t last_addr; @@ -28,7 +28,7 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, prot)) + if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; area = get_vm_area_caller(size, VM_IOREMAP, @@ -38,17 +38,22 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, vaddr = (unsigned long)area->addr; area->phys_addr = phys_addr; - if (ioremap_page_range(vaddr, vaddr + size, phys_addr, - __pgprot(prot))) { + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) { free_vm_area(area); return NULL; } return (void __iomem *)(vaddr + offset); } + +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) +{ + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); +} EXPORT_SYMBOL(ioremap_prot); -void iounmap(volatile void __iomem *addr) +void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); @@ -58,4 +63,9 @@ void iounmap(volatile void __iomem *addr) if (is_vmalloc_addr(vaddr)) vunmap(vaddr); } + +void iounmap(volatile void __iomem *addr) +{ + generic_iounmap(addr); +} EXPORT_SYMBOL(iounmap); From patchwork Thu Feb 16 12:34:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143030 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 B8358C61DA4 for ; Thu, 16 Feb 2023 12:35:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 504A66B0081; Thu, 16 Feb 2023 07:35:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48D366B0082; Thu, 16 Feb 2023 07:35:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 307476B0083; Thu, 16 Feb 2023 07:35:08 -0500 (EST) 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 20E286B0081 for ; Thu, 16 Feb 2023 07:35:08 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 017901C65AB for ; Thu, 16 Feb 2023 12:35:07 +0000 (UTC) X-FDA: 80473099896.13.A3997DF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 3A059C0008 for ; Thu, 16 Feb 2023 12:35:05 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dOEUfaZn; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550906; 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=5gn5xqT9XfmH8tKovLjSHCJ1d21jDbu3NIptvTi8Sio=; b=8LpXRmVGDmZm1JkRkTQb1CzzxkCu2uSCseFUMbvey8PR4MSVicMz88hqNurujXqVvxAhmT YB+jXljGzr3uxt2b8EgdsN4YgyoFoorSa99pTAr7YjVnpLiflJbZvL47POOMaMy5XdgjaW jYO2Z1N/UuhWYK70a446vr0o2KuQGnY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dOEUfaZn; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550906; a=rsa-sha256; cv=none; b=SHyk1yqpfJsBtDJYpRDyv4IOgCuCgop2XGma8x8ucRMx0aGvwjvL1qXvzLQQEEUaKfpmIG 2FVQ2QrzX8LGYqgdjSdhk83pUgPwBlR1uCz9N76VeILAnS91cQv5ohBDY1YT5rpfzHfhkf KYQEwWP+0O4YRxxN1rh0IoyRDbe8LuM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550905; 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=5gn5xqT9XfmH8tKovLjSHCJ1d21jDbu3NIptvTi8Sio=; b=dOEUfaZnW8TNmkoNpc1/E61jGcfeO0jOFCakVoPq/FP4Pi7TVOtIL3kk16Oq5yUQ5SvyRM WBEgcLldzEYWVW7Ck/1egbzsOQJp/agetQj2pjjexqYebT7v4+gGBw1wP5zbvY2WuD/NuO VpDYcfT3VQc6zTDQVUe9H8kvKm2ErwU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-2MLUCqQ5OUieeNkqxfzfVw-1; Thu, 16 Feb 2023 07:35:00 -0500 X-MC-Unique: 2MLUCqQ5OUieeNkqxfzfVw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7027B381494E; Thu, 16 Feb 2023 12:34:59 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id C55D1492C3C; Thu, 16 Feb 2023 12:34:53 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , linux-arch@vger.kernel.org Subject: [PATCH v4 04/16] mm: ioremap: allow ARCH to have its own ioremap method definition Date: Thu, 16 Feb 2023 20:34:07 +0800 Message-Id: <20230216123419.461016-5-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: huzhwrbf17hjdex1erazpo5jwz34xxrb X-Rspamd-Queue-Id: 3A059C0008 X-HE-Tag: 1676550905-557507 X-HE-Meta: U2FsdGVkX1/VE+21sdSrMgFRdtgscMsQ9qWNrjOxTzWr+r2vFb55YDshcUM8CsAiI36+zRyHwyuibTSYLIA1e7q49eYO9iuOjJPkgcCq4H5Qz0EBjR8RO8xFu2szy5dyOPuDyhAZvWhJCowovVYDF4GYsP6OtgTTaLD12CJ01SOBCm5oGewsilzQQ+baeZ5t9EF9KKNbRBIvJqKldE9yHCdIQjfNJS1m1G/+BN2JG6jxS+CwAu434hrGh81EIgzZPqRIhtq/Bp27zss6BS+sXc+LSIoeBDN2aE9OxCEd7baM39uqgzZ0MyTjIvQvNRPuMSCwP3c9a5CVSzGq5PbM6+LJzYldFpkGTU7X+ptk16bzsnPZuvs+qXDVuTmD+JcK7nzf7OMF96om/cw162+dzIljcWWkQa7Xi0AwbxdmW9bVfqgx1evk7CYUt8vLqix4d47yVpileS/t7Vyak9mOF+4JuCj1KJFL1Tk6e5GYZXjmGkDGgxg0Gd038FjOM8CLobx8pex5O6eDRv3gxpuB0w5tCclf44+8dVnIYjzpysoBi4c04LSN3WjYGrkLW55bht5wp4pthbyjvLTG6ZlXQ4pS3nT6dmAXet849I1LTGc1QGQb1Aa0U+gEM8KuCYCKIG/wmxQZvU1heYBCIKsQLPsyPJrIYyxeFZt9f1Yx4tIhSuJbyRsdxsR4MG8/sAKy26vtcfpHrJVeIG/zYEGSz4XxBxVMpeqMPr4PAmxNcG2+uEfKYoBl7jjmr0+UKLuZyH1uqevmcU+j1ah6h2RoAtDmjxLss1ZHLUQcItVyO9dgUD5eaBiCbr7yk0fed/fKW8FKe1x4d5hl93Mrh4cSGp7O6wHUeUeyu1NC/02C7A+oxjNruLW0ILC6/q2NHRHjQEgICECObznwgX9S9eIOr1sHFOe+ZWTV14iqMphKm8L0/uz3mn6h4lK540UUqTnbPP0yI3Dp/ZVcOyfHvHY c2Bm9edF JCorogQUgeNUlhIDAc1YFmazP5cRfU9Udtcbsrgkt+H8uZvCdH+naRp8XWGR2w/YFvYfrEjk+yaqyoFUy+gPpMhrV88h3+W6yLC41kUNwlu4XDnWaXKi1fTl6/cn+uISwB4y+NimfNDBsWKG2ptY/9pM5ebjQcqBXxX6dbRiYAijIsxr2m9sdhymcXmgjfm1nZuG4jyw/o9RIlk04DkXlC2vVvNiLHmwz++C/WwHUmH+hOP/k7Xmt8nblkP4qpO1joXLORqHnF/Ozbp8MfeffDaYHEA== 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: Architectures can be converted to GENERIC_IOREMAP, to take standard ioremap_xxx() and iounmap() way. But some ARCH-es could have specific handling for ioremap_prot(), ioremap() and iounmap(), than standard methods. In oder to convert these ARCH-es to take GENERIC_IOREMAP, allow these architecutres to have their own ioremap_prot(), ioremap() and iounmap() definitions. Signed-off-by: Baoquan He Cc: Arnd Bergmann Cc: Kefeng Wang Cc: linux-arch@vger.kernel.org Acked-by: Arnd Bergmann --- include/asm-generic/io.h | 3 +++ mm/ioremap.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 5a9cf16ee0c2..29ee791164ac 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1081,11 +1081,14 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, void iounmap(volatile void __iomem *addr); void generic_iounmap(volatile void __iomem *addr); +#ifndef ioremap +#define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t addr, size_t size) { /* _PAGE_IOREMAP needs to be supplied by the architecture */ return ioremap_prot(addr, size, _PAGE_IOREMAP); } +#endif #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ #ifndef ioremap_wc diff --git a/mm/ioremap.c b/mm/ioremap.c index db6234b9db59..9f34a8f90b58 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -46,12 +46,14 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, return (void __iomem *)(vaddr + offset); } +#ifndef ioremap_prot void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, unsigned long prot) { return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); +#endif void generic_iounmap(volatile void __iomem *addr) { @@ -64,8 +66,10 @@ void generic_iounmap(volatile void __iomem *addr) vunmap(vaddr); } +#ifndef iounmap void iounmap(volatile void __iomem *addr) { generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); +#endif From patchwork Thu Feb 16 12:34:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143031 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 0545EC636CC for ; Thu, 16 Feb 2023 12:35:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 970916B0078; Thu, 16 Feb 2023 07:35:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FAA66B0082; Thu, 16 Feb 2023 07:35:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 773BA6B0083; Thu, 16 Feb 2023 07:35:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 67D8D6B0078 for ; Thu, 16 Feb 2023 07:35:13 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 368AF1609E9 for ; Thu, 16 Feb 2023 12:35:13 +0000 (UTC) X-FDA: 80473100106.19.BE04914 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 6ECF1C0011 for ; Thu, 16 Feb 2023 12:35:11 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="II4/IOpQ"; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550911; 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=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=U752U5AEoevJsGMXcV1jgC79WOC9TRUFNRXWMPpFvQeYxLoRBMTjbA94+2lH0bq2qYyxBN QHYOSKqqqrGjhaXWnYKD+mlFtJsnoBVmOJSFpDfmTVy1v50JkdPjUWEVTYn5NM2fV1CdDR zx8H8JwPSnGxo+oAj04BHA+POiQTl28= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="II4/IOpQ"; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550911; a=rsa-sha256; cv=none; b=N1K26nss32Upm600fEcald8b4O9xoF6dScvOxweAtyg2BIv/zHU5Zv4Mn6dRVarDtRN3tl yD/E4Q8FkdRyiCVV0xo8X4+Lm+n5RNr2vlopOuUT0jYoSKHzIohOadcBIQ+UWfJDvA8a6o XAe1MxhyXyB4YAYy709Zzi5pWvtlRgM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550910; 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=b04gx2CEsZva7MKdHssokOo8Q5KwYfP6QKwltziak5c=; b=II4/IOpQ/8Uf1SWu/cHABf9bLStTqTST6LuPNONlxIMGtgkfIPLgJu9PJaoJNtJs92reBR SD2rOXi0fcQ2fpHXwtPn7FfLM5Cla1rEJ43VXOhxd/mR9hoHSyuj5y8VqfIICirs7XfTzF GrxM0tjpAX4VtNEzw4GI67SLDLah41k= 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-651-rRYF4ZJzMveowcX66KqSBg-1; Thu, 16 Feb 2023 07:35:07 -0500 X-MC-Unique: rRYF4ZJzMveowcX66KqSBg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0E2AE185A7A4; Thu, 16 Feb 2023 12:35:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D81A492C3C; Thu, 16 Feb 2023 12:34:59 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He Subject: [PATCH v4 05/16] mm/ioremap: add slab availability checking in ioremap_prot Date: Thu, 16 Feb 2023 20:34:08 +0800 Message-Id: <20230216123419.461016-6-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Stat-Signature: mz56hdfcfqoidbz8a349xhzjd41w1xrm X-Rspam-User: X-Rspamd-Queue-Id: 6ECF1C0011 X-Rspamd-Server: rspam06 X-HE-Tag: 1676550911-683969 X-HE-Meta: U2FsdGVkX18DFKrT7v4c1sygZc2bELmcZUksg1VmtNeU/zzzsFYjNq1/ABqor6zQXJ8/yZ0UiLEVZhlqvrVisoLsF6v9Vsh/wJIReUV6W0HsjYsncEO7iEs7X2rY5I5ELkRXF7bRZXhPPJnZNyTFr7Xgq5MD+7Rsv2qamV3Bb2q3WQb67AeWGxV+Yf1fj7gpq+9C7q2vajSJQFSyY49yZqlC5Mk6kbWjMXMCe7VC5U8M0PM3qv4e8o8cdbynnxRnZfXYxOQydMZt7psW8weRzQIlZkyt5nFuLCOrkSfWcdXWaOiGHjCmx+yWSsnZaLZTIs39pVY17Fq1o+zuNt2Bd9HUez2s3/gAyMyLk6NpY20xEBmjLIkzZhwXjoqBpI67EZxUCSa5JFgRMjuOd7dIvO1PJhlXhENfiXcJU7SvIFygkB0pFIHOoBYGz2tB0jyEcCLszbw6d/vlVwXHTAGT1GjDyXwFaynV0C0KyyLgvTaa8lj8eUFYw0p9+fXie/VD0m9lNPtVIgNigXhvfR//jJSY0MB+DCPk2oBEyiXNIVVFluVN/SytLpeOrPY5NsBptXrQso22XLFaNgqBtUeLs1/UOLpJoBwJBu0jIdauW+81SLuuZJTVGANDuzBD6140/wfQqHsv1gi/I/eFDOIWtEdejbKdllCPKK5gPvl0wejGEm4wAzWVaX8sJ50mSaRIG1OeUalqZgPGxQLVjoq+T49L96fOH2E+NrSd/GUYVdA6gB5pxJ4aUg7swzanD3i9YkDDwgmoT/yq0FjF3iZFDttSV1xiQ5zd+xsorMkT2nI2BKnXEjWmua9Nuj3OndVcff5qasbG+sZ0ekxsyZI4WFerWFfXs/EvncYdyabEREvAbLxr1QDzKhcmIKCDNck4T+29UjajgdpqBtULin9e+kNMhLeZ4bkObjIlKUunwXsLxlmpM8uRjjS9X4jepkHou4RsSKQBbvP1fE+fN9E o1RchD9C Od1lQzuVpTHRXQFKlNFXSkOFwsuipbKT5p3SbCcVcUPUqtPkVaJaxxuk+uHDVt629DD7wSyPQJf4DZMUqD92b/j1AsY7m5BREWPg+bK9a/U3fLJ3j/4Cka85yqOtI/Sd2R0KBYae909wFCKQ+dRlBMHAyysm0uRF1XcRfmF/HwzfHq6gx8vFZlopW8F3irH9xRdFg35VlJHl1BOcA0zMho3/7Itdng9gvcSwgzAlylaFrq7uMzj9GcWal7/QPpqYwwWCjzuDGoajtTKOw1eoon/PqQGE50mBZSKdcjfW94xo0EBE= 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: Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He --- mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..2fbe6b9bc50e 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (!slab_is_available()) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr) From patchwork Thu Feb 16 12:34:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143032 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 34C6CC61DA4 for ; Thu, 16 Feb 2023 12:35:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF2C16B0082; Thu, 16 Feb 2023 07:35:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C7C4F6B0083; Thu, 16 Feb 2023 07:35:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF5FD6B0085; Thu, 16 Feb 2023 07:35:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9E1706B0082 for ; Thu, 16 Feb 2023 07:35:22 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6540C1C5FFF for ; Thu, 16 Feb 2023 12:35:22 +0000 (UTC) X-FDA: 80473100484.20.2A651BB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 9A1A6140027 for ; Thu, 16 Feb 2023 12:35:19 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KwgnPW0y; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550919; 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=2hD+uQKHQP06CXA/0+ngsxXXAojl8H5mz4do0Cy/efE=; b=cNj8RZOKzFDVQRWCQqX4ge3Ck+Uf7ifFMEjdGDXtL7tDbBwVKvwlTcMVV3hoKaF38kMm2W pzD8zWjyI2YXFdeh2P9CpVJyhkRsrtwt/0pwfr4unXiaZl/l+XANcNt6G4yHudC6p3Ftd6 LUQqXj7YGSh7hwzkvCkg/KoNy/10ORU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KwgnPW0y; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550919; a=rsa-sha256; cv=none; b=e2ojLG5L7eeYSFNtoj5OxlqyvcsRdSNex/ebtnpdWy0PHkLxaENQuE5GHtKofaiBqqVZSF 4JxnKd6EKvWF3t9NjJ+Y0E1o+DUopw9KHRvontN3FxIAajB11oiB3QyQ1rrEvN3fOiShFa TliYN0G3qCFDmjsA8Va3hb2cSt2KJhM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550919; 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=2hD+uQKHQP06CXA/0+ngsxXXAojl8H5mz4do0Cy/efE=; b=KwgnPW0yXfn7vuGHnJZ1bRTUTVNLvsGW5xBy3Xw1NuEpCdJhCwZaCsH45Z4HlI+cdjqAM0 ior/GYExlZ667sYSiF2cKb20W4oxozeqitqwzcrOZCcxnDEhn44hSsXGq52FWE8l2I3vO2 LunqkRjiAvkb2mm54NYni97nL9rgW7c= 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-5-uDbkHtGuNcOUhjtY6zmuhg-1; Thu, 16 Feb 2023 07:35:15 -0500 X-MC-Unique: uDbkHtGuNcOUhjtY6zmuhg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E59D3802C16; Thu, 16 Feb 2023 12:35:14 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD6E9492C3C; Thu, 16 Feb 2023 12:35:07 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Vineet Gupta , linux-snps-arc@lists.infradead.org Subject: [PATCH v4 06/16] arc: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:09 +0800 Message-Id: <20230216123419.461016-7-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 9A1A6140027 X-Stat-Signature: j55rpx438gbjy5fgrcudtxdamgufe3ps X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1676550919-239156 X-HE-Meta: U2FsdGVkX19Okcc3uoPpO4HOnlW+wm4qxd9XubORoopHw4VmMi2qhW5ugqd92GWHpmiwC9dKXr5qO+/Ewkh16kY2ukbWA25cFnXCbsdH3F913P3UyqhQ21KM/L5o6sDce4wZG5bRTNTNr3IWr2s/fiaSVYVzCOExItU/OeMjxN+onwSF1AZwtCofEkFeQevl3p8DIPiizQQ3xq2/9Y8xbxJEqC0WchI6jOeKu85Cm+jFtcSREeKRnvuI3HvdHYNyD9W2Xzaq7GxFD3KiCPkBi/w+uc5BOiDw61S3iVSLnzN8CMERMP+X+s1bQZ/QQM1J5vFybIrZQGssyjJBEp58byV1g8LkyTYqL+ZXjJgwe95LM54ZT1ZfjTqOQ12Uvu1RCS+5lSAfIY7KB6rYDUtmRj6dOruKJ72LwOMb36KGfIvsEAEBWctfkXqqfpfnQy3fAcHxkKVwByuyRpAJfD15kT8Zm803ImYJWvNNbhdCU/621lNBQF+fe9hhyTPxgwVO3fEcJw57BfQcqwxlIZ6UnzSOQVA27EV7zWofkTztFUw9+qYoaGnvgmPEoa47KYlIaCc1xRa7DgmGGxH0RR/05Zb3yg/bQ0RkBrBBUJxTxpDfNVkF4ZDZiV4N8hLUINKcu3+u/LvZOinoGm5Ejkcz22Okcg0SFA/z9Zbi0PtvSoxvW0QfHLcLSKAhZgPFCljdmpxFMjM6cdKyzmOfMid3/JB//na16JEqrMkpo0Wb+HNpKJbD4ItdJUwlDsxjBeYbrBAZUFt/0QZE85N1/oPSE7ciCbP7vEwrGt9IyHP1X5iG84xJCr+kZEkjz6Cqh0tUcuMGhUFnNZHC1IS6hJ+JveCesrpavvxpdLW9NXF1Q3ZYzI7hVYVTlzuRaCYr+0KUOpzISTEzAy3VJIUnB7HyXBx1Ei9Obbd8QbjSysqW6UBHwRWoKD/z1UXYW+NzcsqhbUJJfV945lVYALoe0gJ cxhLncBR YXJysDTtWX1xVA+6YhNXp3YgbHMss+RkFuRPvWJV5MYJ9J4w+qbXFKTmMNBZrlyLj0oLrh8I8ehquZSF/kWa6LMo0ApE8jD2tRvWl+euVjn+AnCub6kc+hxNX/txKEi0jL7WlKcP575a2w53NECfapt9zfUvSRnH9tT/KJmbpMXIX+tvA6iBsp0CBbx0K49j/+CbjJyeDT+zfSZqWgjlZ2qBJXR4Gwqe2OUdtq2MtaA8FYTGH7b1BZAR3IvTF3AmtUstrVArl5h/kBrhVmb8su3SKS6RXJxpmyibeKzoyN50s7l0cq3z4iJ/3NMSLWWO8pNfrxPTX14BO8sZkDftQotH0sc+WKsYlJBYX+T4nhpohQZ2MkMjPZHn/u62+OviFYQz4a/asGjh7OPNMPiVPIJ8ViNLNrkdcN9I8 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for arc's special operation when ioremap_prot() and iounmap(). Signed-off-by: Baoquan He Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org Signed-off-by: Christophe Leroy --- arch/arc/Kconfig | 1 + arch/arc/include/asm/io.h | 7 +++--- arch/arc/mm/ioremap.c | 49 ++++----------------------------------- 3 files changed, 8 insertions(+), 49 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index d9a13ccf89a3..37da34ac7abf 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -26,6 +26,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD + select GENERIC_IOREMAP select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h index 80347382a380..4fdb7350636c 100644 --- a/arch/arc/include/asm/io.h +++ b/arch/arc/include/asm/io.h @@ -21,8 +21,9 @@ #endif extern void __iomem *ioremap(phys_addr_t paddr, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot +#define iounmap iounmap static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { return (void __iomem *)port; @@ -32,8 +33,6 @@ static inline void ioport_unmap(void __iomem *addr) { } -extern void iounmap(const volatile void __iomem *addr); - /* * io{read,write}{16,32}be() macros */ diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c index 712c2311daef..b07004d53267 100644 --- a/arch/arc/mm/ioremap.c +++ b/arch/arc/mm/ioremap.c @@ -8,7 +8,6 @@ #include #include #include -#include #include static inline bool arc_uncached_addr_space(phys_addr_t paddr) @@ -25,13 +24,6 @@ static inline bool arc_uncached_addr_space(phys_addr_t paddr) void __iomem *ioremap(phys_addr_t paddr, unsigned long size) { - phys_addr_t end; - - /* Don't allow wraparound or zero size */ - end = paddr + size - 1; - if (!size || (end < paddr)) - return NULL; - /* * If the region is h/w uncached, MMU mapping can be elided as optim * The cast to u32 is fine as this region can only be inside 4GB @@ -51,55 +43,22 @@ EXPORT_SYMBOL(ioremap); * ARC hardware uncached region, this one still goes thru the MMU as caller * might need finer access control (R/W/X) */ -void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, unsigned long flags) { - unsigned int off; - unsigned long vaddr; - struct vm_struct *area; - phys_addr_t end; pgprot_t prot = __pgprot(flags); - /* Don't allow wraparound, zero size */ - end = paddr + size - 1; - if ((!size) || (end < paddr)) - return NULL; - - /* An early platform driver might end up here */ - if (!slab_is_available()) - return NULL; - /* force uncached */ - prot = pgprot_noncached(prot); - - /* Mappings have to be page-aligned */ - off = paddr & ~PAGE_MASK; - paddr &= PAGE_MASK_PHYS; - size = PAGE_ALIGN(end + 1) - paddr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - area->phys_addr = paddr; - vaddr = (unsigned long)area->addr; - if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { - vunmap((void __force *)vaddr); - return NULL; - } - return (void __iomem *)(off + (char __iomem *)vaddr); + return generic_ioremap_prot(paddr, size, pgprot_noncached(prot)); } EXPORT_SYMBOL(ioremap_prot); - -void iounmap(const volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { /* weird double cast to handle phys_addr_t > 32 bits */ if (arc_uncached_addr_space((phys_addr_t)(u32)addr)) return; - vfree((void *)(PAGE_MASK & (unsigned long __force)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Feb 16 12:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143033 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 C0565C636CC for ; Thu, 16 Feb 2023 12:35:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 614FB6B0083; Thu, 16 Feb 2023 07:35:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59E6C6B0085; Thu, 16 Feb 2023 07:35:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43F396B0087; Thu, 16 Feb 2023 07:35:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3405E6B0083 for ; Thu, 16 Feb 2023 07:35:29 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0D5761A0D5F for ; Thu, 16 Feb 2023 12:35:29 +0000 (UTC) X-FDA: 80473100778.09.4B23376 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 481011C0017 for ; Thu, 16 Feb 2023 12:35:27 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A0PJuLua; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550927; 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=Q8XMgqsidsolWT+9vTShA+vg/WDVgjNUN6m5J9Drmfc=; b=UXHBsJP7nDfFqXz2hzhtszZVNMnOpQd0RE6xEIEGPSCphC7OTZgxbFjN2+w1uyrHjVMVYY SUf6ZGbraT5Z/Ye0+jmvNFxiUHxUZwvSp6ejkBQMAZ1hZ4kS9fi3c+jTsvbCBkmYGDHdDH jjwfzwhqzAjrETVpP6rktkGnb+eo/Po= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A0PJuLua; spf=pass (imf20.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550927; a=rsa-sha256; cv=none; b=P4v8vH2QHNfbT04vObpjOe5H6/uGVKa7UPYO3ccpGN3W9SlME2h3W69Hwk6sIm9acxp5kq BLcONzJEtEA7kIPUz/VOPqj9Q22KmZR6O5CIKdkWeBP1jOw0NPTz2mXY8E642jZlnrNvmE Q7to6+kNHNG4xAfN6JeE5PKkUwodNVI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550926; 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=Q8XMgqsidsolWT+9vTShA+vg/WDVgjNUN6m5J9Drmfc=; b=A0PJuLua+cTRNDUjw87jWsxMcgcVs5AsoQi5Dy3CrRiX7kQyGSFZBzUPLQRj8Ozy9TED3i uZ+aNY/hq7RkZApbDA8fRBi71lNUUMEyss1tPvNNn8QWmXopJRzj3oGFg4sJIgXL4hvGfV BeINcuZUlBywpGzskx5x4cMAw6XdfwQ= 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-255-VWr6U_S8NyGaA2SN__tblg-1; Thu, 16 Feb 2023 07:35:22 -0500 X-MC-Unique: VWr6U_S8NyGaA2SN__tblg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9393E183B3C6; Thu, 16 Feb 2023 12:35:21 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98143492C3C; Thu, 16 Feb 2023 12:35:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , linux-ia64@vger.kernel.org Subject: [PATCH v4 07/16] ia64: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:10 +0800 Message-Id: <20230216123419.461016-8-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 481011C0017 X-Stat-Signature: dz4rjh79xquk5oddk1iwxms4bu3sdosu X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1676550927-732043 X-HE-Meta: U2FsdGVkX1+UtbDrLC0/VzvWt85IbcrJatFnYJ+By6re4OK40O+MAujjy6Rnwc64ox5NZZIBCWUummtOn/g5VIL606TRNx5PqwKxTST63J89lyvL0E7LcJSx0E7ouwzzmtcpLZFboLMdSwCc2NIYCBQudaPtcyQeeQONTUDqpuRJC7BDI8HwrjJO8mD8fEpt3E7ngIvAImVvmR7dZzOKN65wGjHNiT2bqhVuHgsozxc2FN9QktS4VoHJaBndnPkVnq9LF4aLHR0XEGNY+mQIMF5jhsZwLZ/ZOtTtjmGFmnnROu9m4Z/kojqKRIYkUwlqcwOO+VW5FkLvoWvVcyB7pbIFcafMishB2q0BLvX2+EiiJVOtU1kMPMcND0kLdE8GpqdlvaxZTjhrGt67OJHBO4htVrNg1hoIQoHCkANQUTrl9tHYhZAmJZcM24/7t5onukGp2p206xM1cbWBjT6gs/UcLWqZDp1Ww/4WDyJS7k4ysB7P10SnUEh7RIhUfDYEN50En4hJmhWoCUTEYY31c0PuN6GMuieIKb4dTP3WrQNaw7Gwy+Z7b4FUDSl6imGmLAhlSTmS9bXubqofFdWcPWGsHLLrHVenIgA79w6aTdo8WWBT1ve9l3YVHWa/6ZvYGP9BfD1O9AdwJub0n0gjpqMWZqErcJ9VRlHoso5iIlUEVsC9bkkHKME+ZS0KyoReE8vvdNkr3o2kS8dGGVj/M4uPD4Xcj72zDbHRdHTfXjdz6s8jdaxjamew2z60A5igavyZ3fYS3Ko8fe6JDgKsvG1savL96QpX05tMTk++G1BLnlxWh+i8xD3zDwToEstBxu3pPeISyCmpq4fEZ/B43+moZqCHc2rGNQR/uUS2y3QkdHBMxswdZtyuz6308PNTWrPv485o4OUFInxC3RU3mURqBR82Xw0NAgghOffTkR63mfXnpE0NJwosfXnR42xT8WNR/GcgB4DUEefNgCK Ly9eRSaI jYnvMuh4/3dCvEjHse1HlqyfpuDPt62LVdIwsORbC8wNRRDAbTHpfGb4RxUEfh6VDstpcLvL7sJ2bi+ABGDqet2fA5zPO//iWyKfAbHGnPQmmt51N8piZVA8Gx3YAYRqxjKHAnB7Sob1ta2kPCl1pJchyrWKMNq/7UFp0InAiF2yo+un3xudul1gdEJfz7saYKEEhGbwH1U5IZD+Ur4v3UN6dXhs6WnRmcaSLLLhj+KvSsRGBccmKXpJYMFQIn1Qbix3lMDzAQrV0VLYUPQkrYHnRt4n2VHnVm6S8h30LYTom0BfqKRWzapi2R+81htSiIB6tjK4qsw1tqdfjDaWA/PqbbBxuK0HKQ1I9SHDC6rrJJv0= 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for ia64's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Cc: linux-ia64@vger.kernel.org Signed-off-by: Christophe Leroy --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/io.h | 13 +++++------- arch/ia64/mm/ioremap.c | 41 ++++++-------------------------------- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index d7e4a24e8644..74568cb73d87 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -45,6 +45,7 @@ config IA64 select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_IOMAP + select GENERIC_IOREMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK select ARCH_TASK_STRUCT_ALLOCATOR diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 83a492c8d298..eedc0afa8cad 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -243,15 +243,12 @@ static inline void outsl(unsigned long port, const void *src, # ifdef __KERNEL__ -extern void __iomem * ioremap(unsigned long offset, unsigned long size); +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + extern void __iomem * ioremap_uc(unsigned long offset, unsigned long size); -extern void iounmap (volatile void __iomem *addr); -static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) -{ - return ioremap(phys_addr, size); -} -#define ioremap ioremap -#define ioremap_cache ioremap_cache + +#define ioremap_prot ioremap_prot +#define ioremap_cache ioremap #define ioremap_uc ioremap_uc #define iounmap iounmap diff --git a/arch/ia64/mm/ioremap.c b/arch/ia64/mm/ioremap.c index 55fd3eb753ff..35e75e9c878b 100644 --- a/arch/ia64/mm/ioremap.c +++ b/arch/ia64/mm/ioremap.c @@ -29,13 +29,9 @@ early_ioremap (unsigned long phys_addr, unsigned long size) return __ioremap_uc(phys_addr); } -void __iomem * -ioremap (unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long flags) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset; - pgprot_t prot; u64 attr; unsigned long gran_base, gran_size; unsigned long page_base; @@ -68,36 +64,12 @@ ioremap (unsigned long phys_addr, unsigned long size) */ page_base = phys_addr & PAGE_MASK; size = PAGE_ALIGN(phys_addr + size) - page_base; - if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) { - prot = PAGE_KERNEL; - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - area->phys_addr = phys_addr; - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long) addr, - (unsigned long) addr + size, phys_addr, prot)) { - vunmap((void __force *) addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); - } + if (efi_mem_attribute(page_base, size) & EFI_MEMORY_WB) + return generic_ioremap_prot(phys_addr, size, __pgprot(flags)); return __ioremap_uc(phys_addr); } -EXPORT_SYMBOL(ioremap); +EXPORT_SYMBOL(ioremap_prot); void __iomem * ioremap_uc(unsigned long phys_addr, unsigned long size) @@ -114,8 +86,7 @@ early_iounmap (volatile void __iomem *addr, unsigned long size) { } -void -iounmap (volatile void __iomem *addr) +void iounmap(volatile void __iomem *addr) { if (REGION_NUMBER(addr) == RGN_GATE) vunmap((void *) ((unsigned long) addr & PAGE_MASK)); From patchwork Thu Feb 16 12:34:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143034 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 65571C636CC for ; Thu, 16 Feb 2023 12:35:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 049036B007E; Thu, 16 Feb 2023 07:35:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F14156B0085; Thu, 16 Feb 2023 07:35:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8E406B0087; Thu, 16 Feb 2023 07:35:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C9D156B007E for ; Thu, 16 Feb 2023 07:35:39 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A541A1203AA for ; Thu, 16 Feb 2023 12:35:39 +0000 (UTC) X-FDA: 80473101198.23.54516B2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id BE563180009 for ; Thu, 16 Feb 2023 12:35:37 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K+ZWmR0G; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550937; 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=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=6emq5KUvpyrKEqVOCzW6Wbom79OOX5qYZHXhzhaLMFdtkRJiED0vPpIZG6l2Vp6G4KyTiv bIRHCnNfLOiCbp4Sw1NhnBkssQjuUoVAZhegLTEHmzvjxXqrm9GzwFMBdA3w0ssBBddgda /hGRqnY2ZBMl7tDEBxWynfjKnB8st/U= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K+ZWmR0G; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550937; a=rsa-sha256; cv=none; b=EA8SzMqSh2QKjMKVpbof/iFVUQBaFIAlFud/H7t/aaPLZktXuLLPbuZl2N5f1zMqZXrA2E +pE5RWa5CtkBaHPbB3pz56cgJFmppgteXblbplfWAX4gBM1jE01nmQJSh+4F9PaMrBFI6g WuU6/ZSFgANnQOWhU1NXeOf7MaolSOk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550937; 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=K1VrnQks8P5H4lhuQHdk0PEcxF0GSibhsi/oBTknLWs=; b=K+ZWmR0GV3xE8IyB0W+o7WCwysdVHN0iCrc7uY+5/U2Nice6YYzNBQOrDY43kKw9mVhOnr fuZJDmvmZRoh0pTSIqivYGUU6ZShAXUvtKwLMWqvwCJSSxjG4eqR3tCamBQRtf8YHumNQG s+Gt/V4juNrD+pEBIxdHthwEBBnufW0= 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-163-G71q5-xmOVWeFL2sPqFCUA-1; Thu, 16 Feb 2023 07:35:31 -0500 X-MC-Unique: G71q5-xmOVWeFL2sPqFCUA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBBC1183B3C7; Thu, 16 Feb 2023 12:35:30 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 475B7492C3C; Thu, 16 Feb 2023 12:35:21 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v4 08/16] openrisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:11 +0800 Message-Id: <20230216123419.461016-9-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: BE563180009 X-Stat-Signature: 3t6bedu6di56pst8sys7adqyfou5id6f X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1676550937-812542 X-HE-Meta: U2FsdGVkX1+QhKvH+gUOBQO9KFzGKUaFF+B9LbMUzwJ0AgNFUq+vnQQIEAlK13GKk2m8xWOUvzUYqDjMeM+c4pHX8XJZzYRiS7SLiaEiem1Qlq6PBuIt7py2t5IzcPMOM3pdZ58wmG4P9SU9z/A8KhmnkgR+Z3PBCXLNFdIVeYkO3w/ZRz24p04ONHgSnA8qfGEpUmoQCAf4d50CH5w0+YFMThKY8Ap1IqbXIyDKaA2CREjD8/nZATPpRbJY2BGOu970HGLUMqprx4FmvPdP9gb7YY7gW0BaNZe8TmGG02O8uPOyNtH4QJlgyMl8Klr0PjaxXEzYdAzFQ3IQT+M7N3MFJEx8g+ooO8P1iQHfE48RlePkyqZAnL4WwI1EL5s70lGarQ/kyuS893CNWmS8kHO4ooZr5jjLhyRNWGE13AAFBliGmrcKRb12pChMC9mnCoIC1d43NuXmBaWZ3YhI8wrYlmBhjN5WXc8kOLuDhkmZP+3j2kuHoriYN5yOOU64v8otTH3MvPG2SgrEa/xP9kJpB2pmKhyw+lWZsga0poNJ66P9osvmyJ6RhX+hoOH/7D1WXK15qDntxulRFvOmaIGOxTdxfz7qsyz8kO7pkEgYLSfBp6wvDsKhhvL49alEVhKZlXBt6tQdib8HzGG/70rxo5vdQ9Dv2JgHHOJghuVWfbV+QkoiuRPt9BFtuC/0V9WhB9uR/fP9RsMjjI88ZyHdyZSMwmC9VbaaST4UgKbQsIEQ58qJA6CMfomgBD3D0ChhZsWQwUuMO2VpEN0B+niLK7Mkgblh52XkPbLHyQamuMjWP9iO688otgJ5WGwOn/xI5/fUnnA4jV/39EMmqqhlcHs4phfbXMv3ICqAoBHfNqvKurCdHcZMXqgU9dichjLIPX0c0UHUxSn0XPypnAZ0IJR/VXXvZHyVPad+u01ZXaI2SbGOO6Fk8iJC7i0qUQR4xzPXGA3A3Dwma20 3ZnSRB8p oq6GiZV0Uv7AsMlHMgdZG6C5OY61BsM64nW69CXyIMOhMqPaMypg9ClnCzCwKtkb7mDEiFmKqD9N1eU8toKFMgDSDMURa0KvL0J8t8xHfStZYHeXcDU4ar6g/gtUgJpYzMqRy22kEZgMAzjXM3tuDBJVAvTBKT49X2V3uLYAJeIiBcH2/seAifG87ugT6pN1l+c3a/CQJmBC8aJhebmfDbfnw/+6zN8XwJZvnCLgXO1LcHLnCN6iSdRDWuyAuiv0rrVJ63GKWMXE5Kksa96DaaF36pgNJtOWzfL4cTNMsN3RUxigWHL3Vg796gqn+OF+R8tri 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function iounmap() for openrisc's special operation when iounmap(). Signed-off-by: Baoquan He Cc: Stafford Horne Cc: Jonas Bonn Cc: Stefan Kristiansson Cc: openrisc@lists.librecores.org --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/io.h | 11 +++++--- arch/openrisc/mm/ioremap.c | 46 +--------------------------------- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index c7f282f60f64..fd9bb76a610b 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -21,6 +21,7 @@ config OPENRISC select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select GENERIC_CPU_DEVICES select HAVE_PCI select HAVE_UID16 diff --git a/arch/openrisc/include/asm/io.h b/arch/openrisc/include/asm/io.h index ee6043a03173..e640960c26c2 100644 --- a/arch/openrisc/include/asm/io.h +++ b/arch/openrisc/include/asm/io.h @@ -15,6 +15,8 @@ #define __ASM_OPENRISC_IO_H #include +#include +#include /* * PCI: We do not use IO ports in OpenRISC @@ -27,11 +29,12 @@ #define PIO_OFFSET 0 #define PIO_MASK 0 -#define ioremap ioremap -void __iomem *ioremap(phys_addr_t offset, unsigned long size); - +/* + * I/O memory mapping functions. + */ #define iounmap iounmap -extern void iounmap(volatile void __iomem *addr); + +#define _PAGE_IOREMAP (pgprot_val(PAGE_KERNEL) | _PAGE_CI) #include diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 90b59bc53c8c..9f9941df7d4c 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c @@ -22,49 +22,6 @@ extern int mem_init_done; -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) -{ - phys_addr_t p; - unsigned long v; - unsigned long offset, last_addr; - struct vm_struct *area = NULL; - - /* Don't allow wraparound or zero size */ - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - - /* - * Mappings have to be page-aligned - */ - offset = addr & ~PAGE_MASK; - p = addr & PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - p; - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - v = (unsigned long)area->addr; - - if (ioremap_page_range(v, v + size, p, - __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_CI))) { - vfree(area->addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)v); -} -EXPORT_SYMBOL(ioremap); - void iounmap(volatile void __iomem *addr) { /* If the page is from the fixmap pool then we just clear out @@ -88,9 +45,8 @@ void iounmap(volatile void __iomem *addr) return; } - return vfree((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } -EXPORT_SYMBOL(iounmap); /** * OK, this one's a bit tricky... ioremap can get called before memory is From patchwork Thu Feb 16 12:34:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143035 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 22DC3C636D6 for ; Thu, 16 Feb 2023 12:35:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBBA96B0085; Thu, 16 Feb 2023 07:35:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B43E36B0087; Thu, 16 Feb 2023 07:35:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E4646B0088; Thu, 16 Feb 2023 07:35:47 -0500 (EST) 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 8EBF66B0085 for ; Thu, 16 Feb 2023 07:35:47 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6AEE31C6165 for ; Thu, 16 Feb 2023 12:35:47 +0000 (UTC) X-FDA: 80473101534.06.53025BF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 61F0418000E for ; Thu, 16 Feb 2023 12:35:44 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P9UMOBwe; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550945; 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=uXcsodentkzmbY1cHiGh7UEV3ykeV9182iOfsbwLTn8=; b=25hGn56PwUZT48sTnJ61CBYDly5C7RkUUBN+BXfetmBjrBDJ5zrvJuwGor0U+hr+t1NKYI 1qhMex0mIMhr6XRjggDVg1y8Q+NSnpr9/lPqptmlYM+ABu5ino2QrgyMhWDK64cjj2yOGI y0f7UgfV31WP7hu0w0BT5QjVTaDW8+o= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P9UMOBwe; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550945; a=rsa-sha256; cv=none; b=0wFMgMwn6fibIcOQ2pZ6Mx4GMiJihHOiZjabh4i4QE3cQ6LR059oydqdfkNTs648Bl8F6d XXzxjz+utkHzfp334U05KxQ+LjR0DIRyWzQdPw2jIamTiJF8Rf8UaD8xPbxLrB0yQo//1G okB+QCYZCwU5G42rzqNM8tH3/4YR04w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550943; 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=uXcsodentkzmbY1cHiGh7UEV3ykeV9182iOfsbwLTn8=; b=P9UMOBwea2nfcQb9fpNgQmBioeYdxP3J0eNUb5dUFftgTKM9zU1eG/wdL4dzB0/i3oaQlr eEStfPD6ObX/NEAxswnFaNV5a4PUYpoiyktIils0NZBLmgbHzdrD/VhboObq6feCQo6+rp EnUN3FAJgQNxKE8gHex4Zw0H5rc1+SQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-94-NePEFhR7MTmjQEjJTw7qbA-1; Thu, 16 Feb 2023 07:35:39 -0500 X-MC-Unique: NePEFhR7MTmjQEjJTw7qbA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEA4438149B6; Thu, 16 Feb 2023 12:35:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 901DB492C3C; Thu, 16 Feb 2023 12:35:31 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v4 09/16] s390: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:12 +0800 Message-Id: <20230216123419.461016-10-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 61F0418000E X-Stat-Signature: houb66ns7npm7fun8rhechr8t448z99k X-Rspam-User: X-HE-Tag: 1676550944-710361 X-HE-Meta: U2FsdGVkX19YK6jKvVo52XXLX/GnNP5cvmFF4N8vN7aSNtN+ASftV90cWQDD/QD+6frq9i4Ps7q1YjiI9IHXmhOdo5uNxkHnHOmkoZ8jzdS3YbUTLDClzn3uiea0Sgy8G6iV7YX4rdwuQc+mq0y+e4/wSeodPr+z4xowMGcq0eX1BDjwL7ydophQ5ZQf5LcOk4S0HDhLrpUpqwAyBjicaeL7zUU9SH4MjJGqo0XyqFSgBIqisJvgm18SFN7Csv7uitRsT+f2DhyDTzMx2FAUMuUGNsAE0Mh4Il8PliD2VPwHTa+/cMJu/IPQp/sRoJ9/axOr0lvK/+ftErgt5N5YsYTy4D0isbhREFA1LdfkYhUhNxoTJDOOCa55LfLkUSrtA6oIKTDikdR4xlNk5othN7t9bj9+S/wjLUWG3x96ZAYy+jJi+qBwj7NJG1b2VaEe0kiCZnpyCYyPCau6awoq714g/212Co1/+Wa1Lazmd2k2X+5/2RCeRmgIY8neEyls2+V5XWlu++NvEYgvxKb8vsrmdLu85ZzWfBla5AQ9jMcRh8aqF0i+MvV2iyQsFUtwDZvX5xr7qqycp18I4xlABN4FUt3U6qaApV2GZjYFeQCtT5aDaPlHkLKzwfEyHhMo21cqc2FIyXxzbZsVAm3S35MSEB/MhKNw1n6j2PoR8fXHZuVN0ScN2EaYxvhh89fpJKKhr/WOldtKlGhQ2rS7d1iVW1/q3RjUrd9H1iDNNI1yQYDlqc1UNluTpV2pANLAgEPJ17zw1AR9BU0dFdsJE0TgwjjnCg2GtyDWeTcCh3GOiEqJwVGQB0GxWT2IiBOq78+8bCTcitYh4IPa6pPfhPKn2gbHWP2ohu6cIvo24gJNaE5wADS0gPq9xpc9rwNa6g0GzV/l4897XpfWQN1vc1shCkBrFGFMygtijDhtf4Vpja3HvXVXpixRrPmbgFYN5CDRsExDh9hw0iUBWKa A9jYLQtr 4I+g1DBnOcrdmwngC52tpJG6c2d/pp1m+PruXkrRgq1pTW+aVs30iSfxqGaQaqgEJqqBOCQpa6PF5udXlu4m+PQULFbatWoDWrp3h9cYSMI50jgPupA8ZYexVM5kzxKn0GZX95UGU9RpuZ0txgGNEoGv18AXpClbiSlW2kujoRek9pt1qKWt+xy8Y6yi5oCcEgp11eKalKShu5Rhc/WSb6uV8CdkOjXaH5l5Cb6ccmfapODE7iDKS9A+phQwFm7x8mk+M5qf5udd64+GOmRSUTr7o2PDqT+6vtVFySEbdGrZ+WPKef3/oiHRUFfdQmwSojN0+ 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for s390's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Cc: Niklas Schnelle Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle --- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++++------ arch/s390/pci/pci.c | 57 +++++++------------------------------- 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 7fd08755a1f9..be600b299328 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -141,6 +141,7 @@ config S390 select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select GENERIC_VDSO_TIME_NS + select GENERIC_IOREMAP if PCI select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h index e3882b012bfa..4453ad7c11ac 100644 --- a/arch/s390/include/asm/io.h +++ b/arch/s390/include/asm/io.h @@ -22,11 +22,18 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); #define IO_SPACE_LIMIT 0 -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); -void __iomem *ioremap(phys_addr_t addr, size_t size); -void __iomem *ioremap_wc(phys_addr_t addr, size_t size); -void __iomem *ioremap_wt(phys_addr_t addr, size_t size); -void iounmap(volatile void __iomem *addr); +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap + +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL) + +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writecombine(PAGE_KERNEL))) +#define ioremap_wt(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(pgprot_writethrough(PAGE_KERNEL))) static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) { @@ -51,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p) #define pci_iomap_wc pci_iomap_wc #define pci_iomap_wc_range pci_iomap_wc_range -#define ioremap ioremap -#define ioremap_wt ioremap_wt -#define ioremap_wc ioremap_wc - #define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count) #define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count) #define memset_io(dst, val, count) zpci_memset_io(dst, val, count) diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index ef38b1514c77..9590bf2c0d88 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -244,62 +244,25 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count) zpci_memcpy_toio(to, from, count); } -static void __iomem *__ioremap(phys_addr_t addr, size_t size, pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset, vaddr; - struct vm_struct *area; - phys_addr_t last_addr; - - last_addr = addr + size - 1; - if (!size || last_addr < addr) - return NULL; - + /* + * When PCI MIO instructions are unavailable the "physical" address + * encodes a hint for accessing the PCI memory space it represents. + * Just pass it unchanged such that ioread/iowrite can decode it. + */ if (!static_branch_unlikely(&have_mio)) - return (void __iomem *) addr; + return (void __iomem *)phys_addr; - offset = addr & ~PAGE_MASK; - addr &= PAGE_MASK; - size = PAGE_ALIGN(size + offset); - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long) area->addr; - if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) { - free_vm_area(area); - return NULL; - } - return (void __iomem *) ((unsigned long) area->addr + offset); -} - -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) -{ - return __ioremap(addr, size, __pgprot(prot)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } EXPORT_SYMBOL(ioremap_prot); -void __iomem *ioremap(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(ioremap); - -void __iomem *ioremap_wc(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writecombine(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wc); - -void __iomem *ioremap_wt(phys_addr_t addr, size_t size) -{ - return __ioremap(addr, size, pgprot_writethrough(PAGE_KERNEL)); -} -EXPORT_SYMBOL(ioremap_wt); - void iounmap(volatile void __iomem *addr) { if (static_branch_likely(&have_mio)) - vunmap((__force void *) ((unsigned long) addr & PAGE_MASK)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Feb 16 12:34:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143036 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 1E4F7C636CC for ; Thu, 16 Feb 2023 12:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B44EA6B0082; Thu, 16 Feb 2023 07:35:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A816F6B0088; Thu, 16 Feb 2023 07:35:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FA9E6B0089; Thu, 16 Feb 2023 07:35:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7B7C36B0087 for ; Thu, 16 Feb 2023 07:35:53 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 475AD1603F5 for ; Thu, 16 Feb 2023 12:35:53 +0000 (UTC) X-FDA: 80473101786.09.04B9387 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 8296D100006 for ; Thu, 16 Feb 2023 12:35:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WkxTHOpU; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550951; a=rsa-sha256; cv=none; b=5dP8L5ha+IvBruZAnrQbsE6KojYbwiekzI6nhCn7mXPPNj2bq6dtdVocOioh4w7bkwVcsd qkzZI+J7zahD5Z81knNy3kP1WA5Mwr806Rs9eqtnDEzMqvLxlYkOrvojVDskmoisChXeb0 qC/V+AglaXmgtq6GBreEx2+sK6sl3pE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WkxTHOpU; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550951; 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=QVTDIuzGqj+0AznPZIdOL0y+dZAfOPA4Q2ivFIOFZp8=; b=dYvws65im7SJiAuX9ACaxeDHhZmadID3Hv0JGrbgscLlD+jA0fMVh3dOkJLeXLxTiDqIiY zYcYSCcOQHqBBZ+J1rvVbxIFWmjv5wKCmJRcAqS2Vhx344989EbDGFLQvdmxlEy73dcxnt G2vwDKi/oy4qDF2b+ujmnLfsgye9W6A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550950; 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=QVTDIuzGqj+0AznPZIdOL0y+dZAfOPA4Q2ivFIOFZp8=; b=WkxTHOpUZZGY4EFeB6x+fE/0zdhSSdbgqIFPuNq6KDMzgv79oKs6oKHRqiI/VDECZ2IJi7 /+xctCSrVJ8MiH1xwLI+HfUc517lfcEmIb6sJ79rt9i2YGR1onP8JbCSVGZx3rtqEsFPqx fChs9JKfE7veJnP1XT1KDIfo4fAwilM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-JlR7Fil8MsSoO_Y6dmY8gQ-1; Thu, 16 Feb 2023 07:35:47 -0500 X-MC-Unique: JlR7Fil8MsSoO_Y6dmY8gQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD9AC2806043; Thu, 16 Feb 2023 12:35:46 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FF13492C3C; Thu, 16 Feb 2023 12:35:39 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH v4 10/16] sh: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:13 +0800 Message-Id: <20230216123419.461016-11-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Queue-Id: 8296D100006 X-Rspamd-Server: rspam01 X-Stat-Signature: ercbppxarutsz3afkhiwfhpwqjoqgrjd X-HE-Tag: 1676550951-199310 X-HE-Meta: U2FsdGVkX18oTQ4smpsZzZiOtpYzOyz8Vy7DJM9KmS4HYlEiE84ds2cZdRUAoN3mG12PoIKC4KSXnVTXs7WqzM9x/SVc8UnNjbGVwRPPqUusJrJAEmOa22Yca9qygalbqExGygQ1PK1XJGlT2xtrYWYMevtLWEzMNPfhNaeCWZ6JaKebJkbsnuEkCkW+yATMlvsnztjTq+nVIF4nuzvSmnTu/b10Us/tgwhLw5+y3o92pD4RsJ6kepTG/bO2oKejGo2PqZZhd6/JhwXkQZoov+TVPmvaSwmvCgM3+5EqEvHEI2NUDfYnNe42ra81wg6ay3Ga1nzAH2y4dytA8gc2ZyoJWrYWdmBtiRrZcdJ26abh4+1XjMEnsZ3vLtd405wv8/PyzfBuBMy047k6OyEAkf4qIqLm9Ph89SGHZNd5GHJOvWXJv2NIRMoiem6z4qiffXeO9pYsTZH+VKauC/4FPQA0wk6Nur3oeMoRbaWsSzsOQYKILNIaKFDcB0aC6xMipFhGA0LjxwRrc68w9uqqySKbA0zfG1M1C6adakpXZOmzcmUHSBLUvT79IJc/B7JaJJz5UvXiJY1YWmOjSYLzRjn8vt8DBGS22yvo+LtkxbAfuc4ugYfFCrJ/ipk848tth7ArWNVJ14h05NO/+aW1tV1VDN1fvCVsNuvdtHkurh4mh/AfbbzXzBHjkmVkO7ibo7kl0kAemyKWDH8MacLS26mgETT3+CqTNo+qITfb8ZC3CNQG/tKsrYekdV6wNLWvTrOmYC+G9D0lYljTGkxGX+muw7NPQmMdZ1sx7AXc014i1Eu/C6Q/XXifWSOPUR0pkLsSn1P3fPKAHH54b389fWcHy3hkVWRvqMUI0+J3BGl1FEuk/B300wA7wtysZePbyBNtTjif4zkJ4FnlGLHEpfJcNM8BsFIHf+O6j4RjhuWDRaPPio0O8/jN5OGkpFrBxkxdfnrvAuYKuRDNygO d3T5TnXE E56PvnYrQe93SRdT0k7dHiHjNXhZcSdpjmKE2M+KCdBgwEMydsYAfylNISh/msnFRIheETMBvY08II0S6u2HF+dtb5Em5/HwjGoO2N73csd3cdSWE2tRDcqnSMRekx/pfpjopLCGWmZJrvkeLTfUauJD37+71gTIdE42WHPotU5Q7xIyZw55CyzDdGMo2eG8pJzTnNhs9gPA4mWAfDc4Rd7TQwt3BScZwEzW7BlbYvsQFfZZG2WzoupA3nw+04lzuzQnH7U4YxbL0b9B3Zm4RCNcCaX+xzD+4A+IRvuBXcKv7X7/LrcD0GWcuQVMhvAQRUC7yP32hkTHbLtysbqo8rsjRTbezkAb8xYmlb0c/dcriADq+Qj9JWMxf0Q== 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for SuperH's special operation when ioremap() and iounmap(). Meanwhile, add macro definitions for port|mm io functions since SuperH has its own implementation in arch/sh/kernel/iomap.c and arch/sh/include/asm/io_noioport.h. These will conflict with the port|mm io function definitions in include/asm-generic/io.h to cause compiling errors like below: ==== CC arch/sh/kernel/asm-offsets.s In file included from ./arch/sh/include/asm/io.h:294, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/io.h:792:17: error: conflicting types for ‘ioread8’ 792 | #define ioread8 ioread8 | ^~~~~~~ ./include/asm-generic/io.h:793:18: note: in expansion of macro ‘ioread8’ 793 | static inline u8 ioread8(const volatile void __iomem *addr) | ^~~~~~~ In file included from ./arch/sh/include/asm/io.h:22, from ./include/linux/io.h:13, ...... from arch/sh/kernel/asm-offsets.c:16: ./include/asm-generic/iomap.h:29:21: note: previous declaration of ‘ioread8’ was here 29 | extern unsigned int ioread8(const void __iomem *); ==== Signed-off-by: Baoquan He Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org --- arch/sh/Kconfig | 1 + arch/sh/include/asm/io.h | 65 ++++++++++++++++--------------- arch/sh/include/asm/io_noioport.h | 7 ++++ arch/sh/mm/ioremap.c | 65 ++++++------------------------- 4 files changed, 52 insertions(+), 86 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 0665ac0add0b..9ab627f97c4a 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -25,6 +25,7 @@ config SUPERH select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD select GUP_GET_PXX_LOW_HIGH if X2TLB + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_KGDB select HAVE_ARCH_SECCOMP_FILTER diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h index fba90e670ed4..b3a26b405c8d 100644 --- a/arch/sh/include/asm/io.h +++ b/arch/sh/include/asm/io.h @@ -119,6 +119,26 @@ void __raw_readsl(const void __iomem *addr, void *data, int longlen); __BUILD_MEMORY_STRING(__raw_, q, u64) +#define ioread8 ioread8 +#define ioread16 ioread16 +#define ioread16be ioread16be +#define ioread32 ioread32 +#define ioread32be ioread32be + +#define iowrite8 iowrite8 +#define iowrite16 iowrite16 +#define iowrite16be iowrite16be +#define iowrite32 iowrite32 +#define iowrite32be iowrite32be + +#define ioread8_rep ioread8_rep +#define ioread16_rep ioread16_rep +#define ioread32_rep ioread32_rep + +#define iowrite8_rep iowrite8_rep +#define iowrite16_rep iowrite16_rep +#define iowrite32_rep iowrite32_rep + #ifdef CONFIG_HAS_IOPORT_MAP /* @@ -225,6 +245,9 @@ __BUILD_IOPORT_STRING(q, u64) #define IO_SPACE_LIMIT 0xffffffff /* We really want to try and get these to memcpy etc */ +#define memset_io memset_io +#define memcpy_fromio memcpy_fromio +#define memcpy_toio memcpy_toio void memcpy_fromio(void *, const volatile void __iomem *, unsigned long); void memcpy_toio(volatile void __iomem *, const void *, unsigned long); void memset_io(volatile void __iomem *, int, unsigned long); @@ -243,40 +266,16 @@ unsigned long long poke_real_address_q(unsigned long long addr, #endif #ifdef CONFIG_MMU -void iounmap(void __iomem *addr); -void __iomem *__ioremap_caller(phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); - -static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL_NOCACHE, - __builtin_return_address(0)); -} - -static inline void __iomem * -ioremap_cache(phys_addr_t offset, unsigned long size) -{ - return __ioremap_caller(offset, size, PAGE_KERNEL, - __builtin_return_address(0)); -} -#define ioremap_cache ioremap_cache - -#ifdef CONFIG_HAVE_IOREMAP_PROT -static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags) -{ - return __ioremap_caller(offset, size, __pgprot(flags), - __builtin_return_address(0)); -} -#endif /* CONFIG_HAVE_IOREMAP_PROT */ +/* + * I/O memory mapping functions. + */ +#define ioremap_prot ioremap_prot +#define iounmap iounmap -#else /* CONFIG_MMU */ -static inline void __iomem *ioremap(phys_addr_t offset, size_t size) -{ - return (void __iomem *)(unsigned long)offset; -} +#define _PAGE_IOREMAP pgprot_val(PAGE_KERNEL_NOCACHE) -static inline void iounmap(volatile void __iomem *addr) { } +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) #endif /* CONFIG_MMU */ #define ioremap_uc ioremap @@ -287,6 +286,8 @@ static inline void iounmap(volatile void __iomem *addr) { } */ #define xlate_dev_mem_ptr(p) __va(p) +#include + #define ARCH_HAS_VALID_PHYS_ADDR_RANGE int valid_phys_addr_range(phys_addr_t addr, size_t size); int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); diff --git a/arch/sh/include/asm/io_noioport.h b/arch/sh/include/asm/io_noioport.h index f7938fe0f911..5ba4116b4265 100644 --- a/arch/sh/include/asm/io_noioport.h +++ b/arch/sh/include/asm/io_noioport.h @@ -53,6 +53,13 @@ static inline void ioport_unmap(void __iomem *addr) #define outw_p(x, addr) outw((x), (addr)) #define outl_p(x, addr) outl((x), (addr)) +#define insb insb +#define insw insw +#define insl insl +#define outsb outsb +#define outsw outsw +#define outsl outsl + static inline void insb(unsigned long port, void *dst, unsigned long count) { BUG(); diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c index 21342581144d..c33b3daa4ad1 100644 --- a/arch/sh/mm/ioremap.c +++ b/arch/sh/mm/ioremap.c @@ -72,22 +72,11 @@ __ioremap_29bit(phys_addr_t offset, unsigned long size, pgprot_t prot) #define __ioremap_29bit(offset, size, prot) NULL #endif /* CONFIG_29BIT */ -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. Needed when the kernel wants to access high addresses - * directly. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem * __ref -__ioremap_caller(phys_addr_t phys_addr, unsigned long size, - pgprot_t pgprot, void *caller) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - struct vm_struct *area; - unsigned long offset, last_addr, addr, orig_addr; void __iomem *mapped; + pgprot_t pgprot = __pgprot(prot); mapped = __ioremap_trapped(phys_addr, size); if (mapped) @@ -97,11 +86,6 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, if (mapped) return mapped; - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * If we can't yet use the regular approach, go the fixmap route. */ @@ -112,34 +96,14 @@ __ioremap_caller(phys_addr_t phys_addr, unsigned long size, * First try to remap through the PMB. * PMB entries are all pre-faulted. */ - mapped = pmb_remap_caller(phys_addr, size, pgprot, caller); + mapped = pmb_remap_caller(phys_addr, size, pgprot, + __builtin_return_address(0)); if (mapped && !IS_ERR(mapped)) return mapped; - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr+1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (!area) - return NULL; - area->phys_addr = phys_addr; - orig_addr = addr = (unsigned long)area->addr; - - if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) { - vunmap((void *)orig_addr); - return NULL; - } - - return (void __iomem *)(offset + (char *)orig_addr); + return generic_ioremap_prot(phys_addr, size, pgprot); } -EXPORT_SYMBOL(__ioremap_caller); +EXPORT_SYMBOL(ioremap_prot); /* * Simple checks for non-translatable mappings. @@ -158,10 +122,9 @@ static inline int iomapping_nontranslatable(unsigned long offset) return 0; } -void iounmap(void __iomem *addr) +void iounmap(volatile void __iomem *addr) { unsigned long vaddr = (unsigned long __force)addr; - struct vm_struct *p; /* * Nothing to do if there is no translatable mapping. @@ -172,21 +135,15 @@ void iounmap(void __iomem *addr) /* * There's no VMA if it's from an early fixed mapping. */ - if (iounmap_fixed(addr) == 0) + if (iounmap_fixed((void __iomem *)addr) == 0) return; /* * If the PMB handled it, there's nothing else to do. */ - if (pmb_unmap(addr) == 0) + if (pmb_unmap((void __iomem *)addr) == 0) return; - p = remove_vm_area((void *)(vaddr & PAGE_MASK)); - if (!p) { - printk(KERN_ERR "%s: bad address %p\n", __func__, addr); - return; - } - - kfree(p); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); From patchwork Thu Feb 16 12:34:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143037 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 55C8DC636CC for ; Thu, 16 Feb 2023 12:36:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEE056B0078; Thu, 16 Feb 2023 07:36:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E785E6B0087; Thu, 16 Feb 2023 07:36:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF1796B0088; Thu, 16 Feb 2023 07:36:00 -0500 (EST) 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 BCB396B0078 for ; Thu, 16 Feb 2023 07:36:00 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 70248402D3 for ; Thu, 16 Feb 2023 12:36:00 +0000 (UTC) X-FDA: 80473102080.29.80314D8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id AEF524001D for ; Thu, 16 Feb 2023 12:35:58 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fkxopdkS; spf=pass (imf04.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550958; 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=gzBZFYNAI5CWgQZG4vHMuuNoYiHyiInao6WD8eF4a1Y=; b=htEe01XPR+s11lnk1lwiS4cOFtiydmAYHfd/wlcEW28lNdU+It2HyDoQ3lvLtdKEWHTeQb YnEFJfOZzOLV4idELdQ9n6vfCiSBpK5q3ooQdSNqtbHZSulhgR9XRUzSE8V17JI+N6Z982 ohWuCe3XVN7TRTpxOlHgk/Dz9c85Xfw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fkxopdkS; spf=pass (imf04.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550958; a=rsa-sha256; cv=none; b=koZIFi6l9gEsHfhCsmVIWuoZL4YQjxwwuxNQQ7APv7qFgZbqmZUjkbGU/gKRWUUSSMILj9 JjwBeW64shHRn4/SZ5vpXD3B4PsGQw0ROYYpIffSzVXqPPDKZraOTW5VZgBCwwA6/2NuJL j3SaDb+PpMRWW0K62KIgPZ+PmbSADG0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550958; 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=gzBZFYNAI5CWgQZG4vHMuuNoYiHyiInao6WD8eF4a1Y=; b=fkxopdkS9WFTciFbjl48ofcEyp9s71Fq5+kBK5HWQttsst+GcZ4H/FKFL1TvWKPi1Ldnfc fnaCdWavSrKbkKtS3NaABbXH7y67sULoNERgFLbDOFltBUn7HidpAiGLQ/OnzYwkxN2zyi uGDxyHskGJJRiwcgOFnBuC1PKIU37/E= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-ywbtoSvKM9qMPNf60mgfuQ-1; Thu, 16 Feb 2023 07:35:55 -0500 X-MC-Unique: ywbtoSvKM9qMPNf60mgfuQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2690A3C16E86; Thu, 16 Feb 2023 12:35:54 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E3B3492C3C; Thu, 16 Feb 2023 12:35:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Subject: [PATCH v4 11/16] xtensa: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:14 +0800 Message-Id: <20230216123419.461016-12-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 1b64j9nkr4ez3iq9ozkafetq8fdpo4c4 X-Rspamd-Queue-Id: AEF524001D X-HE-Tag: 1676550958-366316 X-HE-Meta: U2FsdGVkX18Dwu+b7DIRFpZSyewKvrgH14ZcIEiAwJXtIuqVJzHD/I2JyeSdmw/D/K5vv+/FE2sDgDuWJguPrzGyW2x9RtYvnBfOB5qJ7mmRhnJ5PBpNNTGIQnFzm6LkTHjjLTuRokF/KdCaIEeBEkHLTxTy7Yxj8euSg+8S9AmyNQF7lwTw16XmJM/exbY97JpHVpAB2XFmu+DOWRFxzV4KohfH66X29g825IqOY3eYxZIswf2MG4luWzfSmqKGeADcmJ+FfBRZjlMXdVxOIunSKMm0Y9Y6gazyXXqTt5TAD12xViJCwLE7imjIgHetmfYrJbfOmgjYY8bqfc0PGYX6pDzLdecV3OtbwgsuCYmYO2d/h1QTgmlUXCe+Y/PBJw3DypJWHjNYy+SVzWo9j8h5mxzDh6uDHRbmF6nLwZr4pCETYlqTLynPL7mFeT2NWYN5FjBe/RglWmqe3vrsAey4ctZtDNBoojmtcp5e6smTFoliDh81ItfWCdQneIXYIZgbB4em2+K0jvPX8nFuBsTcIeqgqR2NsJHt+AVZ/nLu79RhLd7aiuHvppUBxAKcPMpxJNnBPAiNqHM4kAbpkrch9YzftSH6e9Tj+jJ87qY5vTvzJQpdx4zuqr8BpIKWVN7HRTPT47SLmz7sazNcg+de7/pShDsTeVB2sKCDG4UyfnDtfcxywcidrOQMoTbJfnMT2oqZRYlSpuyaJJoT8ktZA7tRlEqAXEKQF5sb7h6+bPKajp7ffKtwZxByBqyfubYRkY/XDtYf7zFb8yoUSko1m9VKBtQQXc0Gwm2HJU3TOFqK0n5NMGWTg9zkrO8YUqmsVe6hzisAioak36jM4dOAoMee5CbbZfmtFLHNb/O9akKnlp0S3zPeFNvbl/H9VaNPahzQlRMWt6KYIUgmZQ0KlfyKvbYc1a7YOOSG21DcQ1EYygfgod/xgbLeP9V/gclg9gU7enuN0CqWgwf /7hGduax em8q/jYgD4F+UnrOoZMH0EqLN7Vf2+DYiBKpqZgE47X5ov3t/cPbiDzEO3U7o2Ggi3HB3GswpViUuiYLHVZlJaeeshPNcH5vTN9qDFmWQEj6vn/Mr8fwxl7+GWkFBrc+GKbEPJALjG7dpRY+D6wvnunzhYqGxnqKn9H8XLp5x571s0dtKLsEiX4KPuzzeSv61/gyvYC/tEbS0SARR1z66kzYr0XYqXBp5rY0+XDHrMyo3er+ilmupvz9Ggt07HohWpxebOJVImPvm52OlX10n1N52lffGoX9dVRgo+Gbw00enJb7nNJyE5t7hLT4piiaF3TL2RCTMjHbdmSjgEky3TiMmNsQBlu5f4CycVf9rHPRzf6m1F2W6tVSJiW540P1j8PUd 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot(), ioremap() and iounmap() for xtensa's special operation when ioremap() and iounmap(). Signed-off-by: Baoquan He Cc: Chris Zankel Cc: Max Filippov Cc: linux-xtensa@linux-xtensa.org --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/io.h | 32 ++++++++------------ arch/xtensa/mm/ioremap.c | 58 +++++++++--------------------------- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index bcb0c5d2abc2..465d5981082a 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -29,6 +29,7 @@ config XTENSA select GENERIC_LIB_UCMPDI2 select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK + select GENERIC_IOREMAP if MMU select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index a5b707e1c0f4..934e58399c8c 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -24,22 +25,24 @@ #define PCI_IOBASE ((void __iomem *)XCHAL_KIO_BYPASS_VADDR) #ifdef CONFIG_MMU - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size); -void xtensa_iounmap(volatile void __iomem *addr); - /* - * Return the virtual address for the specified bus memory. + * I/O memory mapping functions. */ +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot); +#define ioremap_prot ioremap_prot +#define iounmap iounmap + static inline void __iomem *ioremap(unsigned long offset, unsigned long size) { if (offset >= XCHAL_KIO_PADDR && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); else - return xtensa_ioremap_nocache(offset, size); + return ioremap_prot(offset, size, + pgprot_val(pgprot_noncached(PAGE_KERNEL))); } +#define ioremap ioremap static inline void __iomem *ioremap_cache(unsigned long offset, unsigned long size) @@ -48,21 +51,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset, && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); else - return xtensa_ioremap_cache(offset, size); -} -#define ioremap_cache ioremap_cache + return ioremap_prot(offset, size, pgprot_val(PAGE_KERNEL)); -static inline void iounmap(volatile void __iomem *addr) -{ - unsigned long va = (unsigned long) addr; - - if (!(va >= XCHAL_KIO_CACHED_VADDR && - va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) && - !(va >= XCHAL_KIO_BYPASS_VADDR && - va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) - xtensa_iounmap(addr); } - +#define ioremap_cache ioremap_cache #endif /* CONFIG_MMU */ #include diff --git a/arch/xtensa/mm/ioremap.c b/arch/xtensa/mm/ioremap.c index a400188c16b9..8ca660b7ab49 100644 --- a/arch/xtensa/mm/ioremap.c +++ b/arch/xtensa/mm/ioremap.c @@ -6,60 +6,30 @@ */ #include -#include #include #include #include -static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size, - pgprot_t prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - unsigned long offset = paddr & ~PAGE_MASK; - unsigned long pfn = __phys_to_pfn(paddr); - struct vm_struct *area; - unsigned long vaddr; - int err; - - paddr &= PAGE_MASK; - + unsigned long pfn = __phys_to_pfn((phys_addr)); WARN_ON(pfn_valid(pfn)); - size = PAGE_ALIGN(offset + size); - - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - vaddr = (unsigned long)area->addr; - area->phys_addr = paddr; - - err = ioremap_page_range(vaddr, vaddr + size, paddr, prot); - - if (err) { - vunmap((void *)vaddr); - return NULL; - } - - flush_cache_vmap(vaddr, vaddr + size); - return (void __iomem *)(offset + vaddr); -} - -void __iomem *xtensa_ioremap_nocache(unsigned long addr, unsigned long size) -{ - return xtensa_ioremap(addr, size, pgprot_noncached(PAGE_KERNEL)); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(xtensa_ioremap_nocache); +EXPORT_SYMBOL(ioremap_prot); -void __iomem *xtensa_ioremap_cache(unsigned long addr, unsigned long size) +void iounmap(volatile void __iomem *addr) { - return xtensa_ioremap(addr, size, PAGE_KERNEL); -} -EXPORT_SYMBOL(xtensa_ioremap_cache); + unsigned long va = (unsigned long) addr; -void xtensa_iounmap(volatile void __iomem *io_addr) -{ - void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr); + if ((va >= XCHAL_KIO_CACHED_VADDR && + va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) || + (va >= XCHAL_KIO_BYPASS_VADDR && + va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE)) + return; - vunmap(addr); + generic_iounmap(addr); } -EXPORT_SYMBOL(xtensa_iounmap); +EXPORT_SYMBOL(iounmap); From patchwork Thu Feb 16 12:34:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143038 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 C411DC61DA4 for ; Thu, 16 Feb 2023 12:36:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 617116B0083; Thu, 16 Feb 2023 07:36:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59DBB6B0087; Thu, 16 Feb 2023 07:36:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43ED86B0088; Thu, 16 Feb 2023 07:36:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3122E6B0083 for ; Thu, 16 Feb 2023 07:36:09 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0D9FE1C683C for ; Thu, 16 Feb 2023 12:36:09 +0000 (UTC) X-FDA: 80473102458.02.369F882 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 3BC5920014 for ; Thu, 16 Feb 2023 12:36:07 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WGy85Ljt; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550967; 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=jOfO7o4eolW0xpC5MhdSSAQCpax0BympL7aMQoqVjro=; b=3Yog1aB+bk1ibowtVYmpWrmo3ofM0qpLgHpv4pd2559hAAEjRnSiAEB9HGG4HEIb2ggr4N To/APOUFIFki94eKx9I1VUE+CzOah0ZzFRq/AzVqXiW0DKfTLnisYdvgIYS48oRrmea2Hn LGA4qvBVEAMl6pIPuKkZdmPZb+Ni9ZU= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WGy85Ljt; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550967; a=rsa-sha256; cv=none; b=69C1RnJ/0S72Jn6XgF2bGh5mKXottyk2ofv+1KGjNDZBlrKlrGJo7dtJRFa4FVQyxBZOf3 vD18ednAbgzUnGcevmg3oI1CWavCx2jmySRrMkjGopTJgNAArEZvNSvh9KWgwyY+CZuhPp SMmaouWG7GTQdCItC3B7e+0u95n4f1w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550966; 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=jOfO7o4eolW0xpC5MhdSSAQCpax0BympL7aMQoqVjro=; b=WGy85LjtFe0w/gQ/vKvznjAXq2D01Vp8UkIAGdrkShubZocxnksuZTvsSgyqXOl3h5HY9T lAQj6VmLiWgz57dE5zrtnnySSHJWH1axgxzhHhQY4BDzvFuV2NSYG95LYqcKFfZqYhb476 NvxWQYc4UwzSEk1jfS3nxrNXiOZnIWA= 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-118-3LacnqMIN4yVN8x9q_9VQQ-1; Thu, 16 Feb 2023 07:36:01 -0500 X-MC-Unique: 3LacnqMIN4yVN8x9q_9VQQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E5F9811E6E; Thu, 16 Feb 2023 12:36:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF29B492B0F; Thu, 16 Feb 2023 12:35:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org Subject: [PATCH v4 12/16] parisc: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:15 +0800 Message-Id: <20230216123419.461016-13-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Stat-Signature: m6qz1ngeyz55ufe5h4xwcwoz44szjdfd X-Rspam-User: X-Rspamd-Queue-Id: 3BC5920014 X-Rspamd-Server: rspam06 X-HE-Tag: 1676550967-20754 X-HE-Meta: U2FsdGVkX191PjWXX+0FL3NBI07/DUuQ1QXIxnB+YK0sCnRH1umSs8NWchwzCUjovb8tOTAi6sS1hk/PtWWUv4Gtly/H4uYLVTD5HBJqVA242W8XcJvz95sfHbCUjGOKl7lmbN0Ao4t70Ewz4QaWYD6u5orIAw1PqNe8Zsp6bqSxplChuJelqZduGPWoLSGEYLl+8s1t+uX7Fnv7uzqGAkL60sgZbvFjbDeUkO68VUzhTAQo1npmpJxY8FgxSDnpbpVVDObWaoQnoB+K6o2yZiWAk3Y+7sWf5UESxASZCEQlSX/QSOYJYmA1UdTgokg67D4NMBYHVk7Z3zFffmvsvvkSnxYiBspr+/HqX1S1hgfE2hL7vs6IkNZIfC4NlvAe745j/T8MaEFJPmcXPfj57fK/DvOYNMD2Iaw3UZopyNO6ZOdFGv/ug5lM6tI+t3WWigWcxXhi27LvbBa4DrIx/O7nLsl8guwY7Acj9bNkTYEoFAGRsMz+iWUFeEXdY8aQTX/1n8wyQpiQ9Y3htzWXcm9fdfoeCB/6OJx9kfNRLbUbhzkenSnJcmNx7+UWrFa+J3VMqVI2WnK+7ji3qncflLQXg2/6IIidKi3uvwmHeN5C9cMuyuIgx8wFWvdCXbmQJoWVBfMayBm6ZuipPEFawowIqXsTMzt7uPfNWfsP86bItXYIqioY5luRxMAnJqor566+pyoqpttGWocmDJV7xLnsbN5d0YN/HT6we+JeU2ZECudt9dDkPMxmKrNDrokYBpNfoFhPBkur2IYiUJ7uhYug8za4HagDvkF8KqYATrYuLc+XEg0QnQMqYGXQp6DjRTw0sayv9ZfMGOicZ4avYRvzVRmRn3POqEN4dI6VDp8aKZ6VQz94Hw13OO7Z++YREvwTAF+cOpTXNMRNfNXJyEAEW9xIC0jsMYKcvrIxqfpgrRFdpEYJOUiZb688wjte38IXtcVjXn8gyGEB534 EE4FxYoS j+Q0UurhaS+06S7zvC2kH1ELQzDwZ6scx/aRUC90qxzWjRQGENN1nT58hT1Yuh5HPSkljiWBbTYG8U/Xjmnn/GfxZglbpcqFlGnaVU/CyU9VL4Jc30tIinB+GFR2I0i5+LCiKNDnE0cuzImB9cOXGFPmRzcqHBzELGkLma3+CgOtBDxGYaXSptBB5g3l2cb/b6IokzJQO6J0dOitJGqKotSQhOiYfegMtdYRxeHC1EGZp1Qx/3qgrldQxvbTEy1utdF3kOH5IGK+ISCZSqahXe8p0bmsKzUS8vM9MjEShhSnXXdY878vPOHetQwh3i+MZOxe+tDsj+Ps26UJA3E1MUZUXcrpePCP8QnTJc/efg92Ctiw= 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: By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper function ioremap_prot() for parisc's special operation when iounmap(). Meanwhile, add macro ARCH_HAS_IOREMAP_WC since the added ioremap_wc() will conflict with the one in include/asm-generic/iomap.h, then an compiling error is seen: ./include/asm-generic/iomap.h:97: warning: "ioremap_wc" redefined 97 | #define ioremap_wc ioremap And benefit from the commit 437b6b35362b ("parisc: Use the generic IO helpers"), those macros don't need be added any more. Signed-off-by: Baoquan He Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/io.h | 17 +++++++--- arch/parisc/mm/ioremap.c | 62 +++--------------------------------- 3 files changed, 17 insertions(+), 63 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index a98940e64243..0ed18e673aba 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -36,6 +36,7 @@ config PARISC select GENERIC_ATOMIC64 if !64BIT select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP + select GENERIC_IOREMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_ARCH_TOPOLOGY if SMP diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h index c05e781be2f5..4c386b0cee08 100644 --- a/arch/parisc/include/asm/io.h +++ b/arch/parisc/include/asm/io.h @@ -2,6 +2,8 @@ #ifndef _ASM_IO_H #define _ASM_IO_H +#define ARCH_HAS_IOREMAP_WC + #include #include @@ -125,12 +127,17 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr) /* * The standard PCI ioremap interfaces */ -void __iomem *ioremap(unsigned long offset, unsigned long size); -#define ioremap_wc ioremap -#define ioremap_uc ioremap -#define pci_iounmap pci_iounmap +#define ioremap_prot ioremap_prot + +#define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \ + _PAGE_ACCESSED | _PAGE_NO_CACHE) -extern void iounmap(const volatile void __iomem *addr); +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) +#define ioremap_uc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP) + +#define pci_iounmap pci_iounmap void memset_io(volatile void __iomem *addr, unsigned char val, int count); void memcpy_fromio(void *dst, const volatile void __iomem *src, int count); diff --git a/arch/parisc/mm/ioremap.c b/arch/parisc/mm/ioremap.c index 345ff0b66499..fd996472dfe7 100644 --- a/arch/parisc/mm/ioremap.c +++ b/arch/parisc/mm/ioremap.c @@ -13,25 +13,9 @@ #include #include -/* - * Generic mapping function (not visible outside): - */ - -/* - * Remap an arbitrary physical address space into the kernel virtual - * address space. - * - * NOTE! We need to allow non-page-aligned mappings too: we will obviously - * have to convert them into an offset in a page-aligned mapping, but the - * caller shouldn't need to know that small detail. - */ -void __iomem *ioremap(unsigned long phys_addr, unsigned long size) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { - void __iomem *addr; - struct vm_struct *area; - unsigned long offset, last_addr; - pgprot_t pgprot; - #ifdef CONFIG_EISA unsigned long end = phys_addr + size - 1; /* Support EISA addresses */ @@ -40,11 +24,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) phys_addr |= F_EXTEND(0xfc000000); #endif - /* Don't allow wraparound or zero size */ - last_addr = phys_addr + size - 1; - if (!size || last_addr < phys_addr) - return NULL; - /* * Don't allow anybody to remap normal RAM that we're using.. */ @@ -62,39 +41,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size) } } - pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | _PAGE_NO_CACHE); - - /* - * Mappings have to be page-aligned - */ - offset = phys_addr & ~PAGE_MASK; - phys_addr &= PAGE_MASK; - size = PAGE_ALIGN(last_addr + 1) - phys_addr; - - /* - * Ok, go for it.. - */ - area = get_vm_area(size, VM_IOREMAP); - if (!area) - return NULL; - - addr = (void __iomem *) area->addr; - if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size, - phys_addr, pgprot)) { - vunmap(addr); - return NULL; - } - - return (void __iomem *) (offset + (char __iomem *)addr); -} -EXPORT_SYMBOL(ioremap); - -void iounmap(const volatile void __iomem *io_addr) -{ - unsigned long addr = (unsigned long)io_addr & PAGE_MASK; - - if (is_vmalloc_addr((void *)addr)) - vunmap((void *)addr); + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } -EXPORT_SYMBOL(iounmap); +EXPORT_SYMBOL(ioremap_prot); From patchwork Thu Feb 16 12:34:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143039 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 5B136C64ED6 for ; Thu, 16 Feb 2023 12:36:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC70D6B007E; Thu, 16 Feb 2023 07:36:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E779A6B0081; Thu, 16 Feb 2023 07:36:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF28E6B0087; Thu, 16 Feb 2023 07:36:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C0F476B007E for ; Thu, 16 Feb 2023 07:36:14 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A1359120816 for ; Thu, 16 Feb 2023 12:36:14 +0000 (UTC) X-FDA: 80473102668.06.B454223 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id E936C8000D for ; Thu, 16 Feb 2023 12:36:12 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ePYz9F0I; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1676550973; 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=Uaseq8uUQQ6QMQSRfFux0A76lTwwiGZ3GmLj5/5Y0lk=; b=Sr9JKOESlhr97F/18Rehpz4wxR+h22q8ZRCQP06oNDOYBYGMmFSRud14Q7IvubVn0j+nZK xWZjG6dZ3iMZpRm8vmpzL6sqabK7oWZ1JPsFdkHz4X5yI6ieV2ulv4yxdf8Qk6mN2DS9cD ZpIUh1UxnCGxjEjdkLmCcr0WwPAGSWA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ePYz9F0I; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1676550973; a=rsa-sha256; cv=none; b=KxyIgpETi1sSxXizH2T0y4Ni06hUaY++CJj9nMML32XUkU5IKyNdUz8Z//ZRl3+bXIYdk/ GivBQ6bvTsYOXwQxUIMy7Nr1AaBVQhP97JOy6gcCseE4CouzES2iMYUKdeEgWTlpJKYWKS OSeelTbPz2vuvRbwmyjH1a5Aj0+e424= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550971; 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=Uaseq8uUQQ6QMQSRfFux0A76lTwwiGZ3GmLj5/5Y0lk=; b=ePYz9F0I/u6odg78hhQuDR6HeeVpNS3WnMqCJVFZR6oGUR08tMEvMNoUBgquzHmpb3ehNh VpVX5YOJsU/208CEcl7VuXpyo0beub0v+NIa1fkS/Cl6wgMxGv5Kx7TrhiIKUsTgljNTZu OvS3T1uGJuliNlZuXEaHNp3/JWLdtg0= 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-192-t5oiSJVUPBaODLgfCZy8BQ-1; Thu, 16 Feb 2023 07:36:07 -0500 X-MC-Unique: t5oiSJVUPBaODLgfCZy8BQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9CA37857F40; Thu, 16 Feb 2023 12:36:06 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A108492C3C; Thu, 16 Feb 2023 12:36:00 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He Subject: [PATCH v4 13/16] mm/ioremap: Consider IOREMAP space in generic ioremap Date: Thu, 16 Feb 2023 20:34:16 +0800 Message-Id: <20230216123419.461016-14-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: E936C8000D X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: j6fk389xei6egqp1ocwkmgzd9kxbogex X-HE-Tag: 1676550972-863451 X-HE-Meta: U2FsdGVkX19/LYM8vZwCDpy5cBZB2H2R+jrnQXWylGKvy76jMjvdRcV2p1TSiuUyUfyGVtdMBy/aQ2ggGeCOIWlBaqEtmEVi7qGlFVQBKJW9XaVJ+oQ+nGvueyrq52eXh81C9SpUOWzZNa9A31RDShC8NonXUPsn7g3Wt9Og7hC8mMX9MM7rXl1mSQ7mwSUGgFeETJ/Sor6nlanetUFP+FGxoNREwhhZU08qqG95nRh45NsheBI1XM8rvtDgBrkBKH+JaM/GM66mBBxXlbhLJ6oSfuovaKKkBm0k+y50kubK4hqLL/ERnERKi5qcJGkUolUDOJpGPScbXVA6RTJR8CqgAfBJsFaDRy23r3aqGlN+fhLes+/ZJkdZxwl6qp+GV/6kD8tSeLNImeLoP1NhczwMQPW/jRrzvGFqbNaDatE/u8q7eyqXSxx7nAZpdd6etmmR30x6FzeF53H/0ChGgGS88Ym/ce7uaeodTGtGzR8015lzz28hEfgHLDgkmpj8BC37KfZtpNoQBTT9+AL4WRJdllPe4UZbsHs84W59JRZKUgglnZW5uQz3ZNXOYpm+CwMzplLlCa9BbL2d66xzPxtw700E+VKjYbpJ8Q1zwDxUcBiDKcCoClL6t2dfg2GxOelKZLhMFKfhMBpcH29L73jC48PfG9RtfrW7WAfOfBS4Gp0JqSin8wxdx2yRJRn2ZRUo6tS+HZecXPI1ZlLfyDzEu59CQbCJqEIvaGNzO1iK7xvAqXJmQYeEmwX2uB6EjjOV3erFwacGhZFpmIEkimylsk5fJNUEibgvOcTSklNl3QIFQnQovrNGKYglHKVBgnmfJU/U+G+nJJ7GUBrjXYPqkMX+GtUZDAurlBPlpL8hp5FTxYhvwcX/+Vi7A1/WuFrGCO32gWklqZ51v2MUYyPjxXCfxfqlyuy/HjSy0azoRRpEuNmzcnPrYXQ9Toyzu9GQT2B63I5mP2rdmgS Vw2U/hpY BVKSIkFWhJv0JLYEtVtLJVJsAE9nEBidKkgzuYlNqBLaFGEQ9vGmzHaURgVWd7LUMIwSBk2wjZAC0Xg2BWYAoxVYN34toM+ScTr3X1ecbrRv12mLUA5rVy/5HBtBtAZvWAIz6EFs2sE+of2fNObJn0JTuvSQRIEUlWuTIqP1QOU2ZC/3DfIcpoYkKyx6THWo+CE59u10DM1mG70WhidBfE3N08e1QVLMYcKsqoLSxTxEu4qjMx8uaWGgX+A== 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_pro(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He --- mm/ioremap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/ioremap.c b/mm/ioremap.c index 2fbe6b9bc50e..4a7749d85044 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -35,8 +35,13 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) return NULL; +#ifdef IOREMAP_START + area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, + IOREMAP_END, __builtin_return_address(0)); +#else area = get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0)); +#endif if (!area) return NULL; vaddr = (unsigned long)area->addr; @@ -66,7 +71,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); } From patchwork Thu Feb 16 12:34:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143040 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 42DDBC636CC for ; Thu, 16 Feb 2023 12:36:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB67C6B0081; Thu, 16 Feb 2023 07:36:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D40296B0085; Thu, 16 Feb 2023 07:36:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB97C6B0087; Thu, 16 Feb 2023 07:36:20 -0500 (EST) 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 AB9736B0081 for ; Thu, 16 Feb 2023 07:36:20 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8BFA8141061 for ; Thu, 16 Feb 2023 12:36:20 +0000 (UTC) X-FDA: 80473102920.14.6D4F242 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id C9A611C0021 for ; Thu, 16 Feb 2023 12:36:18 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KeVH8iHb; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550978; 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=yr5XKKSsspi4RAZHd1reswGYxPLpqfSVJwzPdgOU6W4=; b=ReOd0FCvKNvfESUEhZwfQ9A13gKstT2cNKXB1m9GfA3cQkycNgX10FtvuHm75+uYo9jLnn hGZT3NW9XiVzsY7njd+fqwV4S/Nb4ZCgA2Tt78XQDZcsItNpW4HxMepaX7IT0B4jBW6l3g uwRMNZD04VvGJ6k7WgeXqPjTQj83nx8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KeVH8iHb; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550978; a=rsa-sha256; cv=none; b=YOLByWNpdwvl7DmgUj19aY5G0sbcbdKbLTqSKeJk8paD/muyHsJ4MOvU2LkjEiMX0ZsTLO dPvzoAtTbNyp1STeTNEL1O2AGe+rmh71jcnMXunkHW04Zo50O/f6l6oEXyQjYI1hjCh+xm 5MYM33+YC3KEIrs36T5sCg6eYSvQ9+c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550978; 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=yr5XKKSsspi4RAZHd1reswGYxPLpqfSVJwzPdgOU6W4=; b=KeVH8iHbY4jdc4WejxGUw4mZ5LY97ldr4eVO2214DNu/MeqwPZJPPuQlWpV7fh7M4heTnB F1DMtsaC7qLtNKnTfY7Zx/munGU60ZdXSRJqeqeM7SzJLrgqfBvnFytR1jyE3jj+i6joE+ 83p02IPCgQMFee/JgnPUPwec8cB5Q04= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-kaG1zBrrPPyNnxQLkRzQ4Q-1; Thu, 16 Feb 2023 07:36:14 -0500 X-MC-Unique: kaG1zBrrPPyNnxQLkRzQ4Q-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1DC483C16E98; Thu, 16 Feb 2023 12:36:13 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49478492C3C; Thu, 16 Feb 2023 12:36:06 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Michael Ellerman , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v4 14/16] powerpc: mm: Convert to GENERIC_IOREMAP Date: Thu, 16 Feb 2023 20:34:17 +0800 Message-Id: <20230216123419.461016-15-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: bp9squagxwxds4xaa8cwwjtaotijkg8x X-Rspamd-Queue-Id: C9A611C0021 X-HE-Tag: 1676550978-40344 X-HE-Meta: U2FsdGVkX1+DTM7FT4WRMXrnyAlXgtuLxWQ2ZOz7RLkM2IqggfNhLJ6F4H7/lpQ7jk8ytI4diDkI/teg+mHYxXmwDA2jK2s9gUOVDLQ5CRn9wU5327FYDtBcKgD6QtEn75/myuV/vKdzAeHZIVI40tA8qRho44loXphXS2d+1M03KoxC8CkbqFlYo86sbeQDT5cY37fim5LyXNnorPOBsKFfsE2SukQRwUghUlgeL5iUKh382bUqcX3efueogVyrf78QV9UfJ9scs3ACFn56x3KZw+OcgoFdJJKCs8EvUE+jOm4RdQUeAvEdfLWHoNAz/LlmJ1xch5QvwPR/CRg/FmKxq3gV37z+9exJ0HhlX1Oej969XGqMQ5zzFc9Pin8CH7E7Lhgr3gcPibi/+0+g/zoR5vK6YJLtGZtva5DVoheqhk7DYx58umUqhnMueSuV5mfD/XUXEwVZ1JD0VCAdPEJBBxEqiUo4fu4QWS6ncrFNiRph9g6Bhpx24e+/iEvoSYzBM+mOe6a5omDhlkfbyagkM2gx9BdFi6R605cRXH8r9M5TMhM+9W3eu0CLt4DwYf1rac2e7+gGM2sV1AwK1QwYSDw6joqfEMmB4SXMcGp63V9++SlQEJSpb1sktu+5M2GrKPykbCHkFF/qEnwxpM76AQNyZGek/v/F93wLOlMdHznj/WUcIY+ADqbd4aTHJ+10SbPFtdKovcgWH6FvxxYyzCvzx6Yvci1NipAGXs/1ETGZ4C/GGHZwppvw1D7tcTa7OxFBVkWeCAH8EhKm/Aa6jpkr+i/eETkk9qOD+NDK0GXk4A30rbTziveSzIvtHSwxZl4yDpWCOo19d9YZoczIjpYhmoUoC3d/9suwmAiEnxBlgFAjBA7jsxnvjIL2w4TJKXD+JNfsEza7Qr3qFPdZcW575DcAKx7gJ71YqYZMZCsGRGWObLFd7WmxKOQIAjPzs3g1K/sr67M6znO C8w4AIKE 8gcc5sBIhstRy47w53kuWoagb6xywg6MOvE0LJ2uol2gzD8LKSCtsjaP6PlTbpGNJWV3H1IV8lYKvTl4M+1vE4bJ2+qJqvXuGCT4flwCbpTdfhTuMjslLGVC2vfTAcr2WKoPK0QoLeqpxJWoWhm93bzuMsjnA0t0ShLgmxPe+8T8j/2tfnSNmKFMtmjVgvSyJqZ/MHzuYWYdHUBOR8SvYJqf2wvMtciCy7m8RX3bmHJm+S4svZ41vSp1vvdrOfW2HS2PKjiep64KCU+QlFxprf2Ueg+ZclzJlyMMYSkCM9vWla8Di2QyySRnbi+y60DsGyoJlk9deKNe+vAKULhpJvq/5JsfvdWaV876czr1SGYCYvplUp4E7ee4zXYsir7QWo1K1 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 By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(), generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and iounmap() are all visible and available to arch. Arch needs to provide wrapper functions to override the generic versions if there's arch specific handling in its ioremap_prot(), ioremap() or iounmap(). This change will simplify implementation by removing duplicated codes with generic_ioremap_prot() and generic_iounmap(), and has the equivalent functioality as before. Here, add wrapper functions ioremap_prot() and iounmap() for powerpc's special operation when ioremap() and iounmap(). Signed-off-by: Christophe Leroy Signed-off-by: Baoquan He Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/io.h | 8 +++----- arch/powerpc/mm/ioremap.c | 26 +------------------------- arch/powerpc/mm/ioremap_32.c | 19 +++++++++---------- arch/powerpc/mm/ioremap_64.c | 12 ++---------- 5 files changed, 16 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 7a5f8dbfbdd0..02ae9e6afed6 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -181,6 +181,7 @@ config PPC select GENERIC_CPU_VULNERABILITIES if PPC_BARRIER_NOSPEC select GENERIC_EARLY_IOREMAP select GENERIC_GETTIMEOFDAY + select GENERIC_IOREMAP select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_PCI_IOMAP if PCI diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h index fc112a91d0c2..127d8300b40b 100644 --- a/arch/powerpc/include/asm/io.h +++ b/arch/powerpc/include/asm/io.h @@ -859,8 +859,8 @@ static inline void iosync(void) * */ extern void __iomem *ioremap(phys_addr_t address, unsigned long size); -extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size, - unsigned long flags); +#define ioremap ioremap +#define ioremap_prot ioremap_prot extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size); #define ioremap_wc ioremap_wc @@ -874,14 +874,12 @@ void __iomem *ioremap_coherent(phys_addr_t address, unsigned long size); #define ioremap_cache(addr, size) \ ioremap_prot((addr), (size), pgprot_val(PAGE_KERNEL)) -extern void iounmap(volatile void __iomem *addr); +#define iounmap iounmap void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size); int early_ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot); -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller); extern void __iomem *__ioremap_caller(phys_addr_t, unsigned long size, pgprot_t prot, void *caller); diff --git a/arch/powerpc/mm/ioremap.c b/arch/powerpc/mm/ioremap.c index 4f12504fb405..705e8e8ffde4 100644 --- a/arch/powerpc/mm/ioremap.c +++ b/arch/powerpc/mm/ioremap.c @@ -41,7 +41,7 @@ void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) return __ioremap_caller(addr, size, prot, caller); } -void __iomem *ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags) +void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long flags) { pte_t pte = __pte(flags); void *caller = __builtin_return_address(0); @@ -74,27 +74,3 @@ int early_ioremap_range(unsigned long ea, phys_addr_t pa, return 0; } - -void __iomem *do_ioremap(phys_addr_t pa, phys_addr_t offset, unsigned long size, - pgprot_t prot, void *caller) -{ - struct vm_struct *area; - int ret; - unsigned long va; - - area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, caller); - if (area == NULL) - return NULL; - - area->phys_addr = pa; - va = (unsigned long)area->addr; - - ret = ioremap_page_range(va, va + size, pa, prot); - if (!ret) - return (void __iomem *)area->addr + offset; - - vunmap_range(va, va + size); - free_vm_area(area); - - return NULL; -} diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 9d13143b8be4..ca5bc6be3e6f 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -21,6 +21,13 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call phys_addr_t p, offset; int err; + /* + * If the address lies within the first 16 MB, assume it's in ISA + * memory space + */ + if (addr < SZ_16M) + addr += _ISA_MEM_BASE; + /* * Choose an address to map it to. * Once the vmalloc system is running, we use it. @@ -31,13 +38,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; - /* - * If the address lies within the first 16 MB, assume it's in ISA - * memory space - */ - if (p < 16 * 1024 * 1024) - p += _ISA_MEM_BASE; - #ifndef CONFIG_CRASH_DUMP /* * Don't allow anybody to remap normal RAM that we're using. @@ -63,7 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call return (void __iomem *)v + offset; if (slab_is_available()) - return do_ioremap(p, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); /* * Should check if it is a candidate for a BAT mapping @@ -87,7 +87,6 @@ void iounmap(volatile void __iomem *addr) if (v_block_mapped((unsigned long)addr)) return; - if (addr > high_memory && (unsigned long)addr < ioremap_bot) - vunmap((void *)(PAGE_MASK & (unsigned long)addr)); + generic_iounmap(addr); } EXPORT_SYMBOL(iounmap); diff --git a/arch/powerpc/mm/ioremap_64.c b/arch/powerpc/mm/ioremap_64.c index 3acece00b33e..d24e5f166723 100644 --- a/arch/powerpc/mm/ioremap_64.c +++ b/arch/powerpc/mm/ioremap_64.c @@ -29,7 +29,7 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, return NULL; if (slab_is_available()) - return do_ioremap(paligned, offset, size, prot, caller); + return generic_ioremap_prot(addr, size, prot); pr_warn("ioremap() called early from %pS. Use early_ioremap() instead\n", caller); @@ -49,17 +49,9 @@ void __iomem *__ioremap_caller(phys_addr_t addr, unsigned long size, */ void iounmap(volatile void __iomem *token) { - void *addr; - if (!slab_is_available()) return; - addr = (void *)((unsigned long __force)PCI_FIX_ADDR(token) & PAGE_MASK); - - if ((unsigned long)addr < ioremap_bot) { - pr_warn("Attempt to iounmap early bolted mapping at 0x%p\n", addr); - return; - } - vunmap(addr); + generic_iounmap(PCI_FIX_ADDR(token)); } EXPORT_SYMBOL(iounmap); From patchwork Thu Feb 16 12:34:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143041 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 9644EC61DA4 for ; Thu, 16 Feb 2023 12:36:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 356C96B0087; Thu, 16 Feb 2023 07:36:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DED16B0088; Thu, 16 Feb 2023 07:36:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10B186B0089; Thu, 16 Feb 2023 07:36:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F2B5B6B0087 for ; Thu, 16 Feb 2023 07:36:30 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AFDE2160FBB for ; Thu, 16 Feb 2023 12:36:30 +0000 (UTC) X-FDA: 80473103340.14.73E31AC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id B01BB4001A for ; Thu, 16 Feb 2023 12:36:27 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="TWq2MTT/"; spf=pass (imf11.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676550987; 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=RNdh/TySVIGgVhyjk9AByHNitK75WMNttk6DS+DsVe0=; b=TOBj67WY+hCN+u9r9ZNFtOork32Mkz8iP5KgOAgRhvlItdK7ShrtOX1Gv56wNctLIchVUP a0B2qd9QI5kT3k+DdHsFb6rZNTZJk48pBceWkeISfSG3ooq83qJe7fnXmtt6bN54mvvWx+ TrW0JYaC+UFN5UBOQkX/sU4BTX0gv/w= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="TWq2MTT/"; spf=pass (imf11.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676550987; a=rsa-sha256; cv=none; b=F7r6/cnsWslGgLuvOXoVMODnMngVFFW2qi5hY2ZgvAnJQFvHD1S3SzDhgyFdcoE27nPMgL fufdQUZ3aWU7Bc67UaaVkliLk3EvWbxDzXfZHdab1lCpZ2W06tAnLZiFRGrybskz/SoiKl sgPOQdiAEVaLTRxIyWzly7QSI2z/GYk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676550987; 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=RNdh/TySVIGgVhyjk9AByHNitK75WMNttk6DS+DsVe0=; b=TWq2MTT/9FhKsG3DA0PNJkMVZCZoZHdKiwM00TXEWt2KrW5Z5uBgpBWpFY638hUW+07dH2 znOSS+8U/8O26oeZPvdfLSFMgyUJKeM+pcAQk9SH4WUGI/QXjWQ/V+4kSkmj/OvWWDZ0ja DIKwTNQsE1fCOShdAe/t4FytzDoQLoM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-227-T-H0c8N2PTeRxvwb_7vp5w-1; Thu, 16 Feb 2023 07:36:23 -0500 X-MC-Unique: T-H0c8N2PTeRxvwb_7vp5w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6051D1C189B5; Thu, 16 Feb 2023 12:36:22 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDAC3492C3C; Thu, 16 Feb 2023 12:36:13 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 15/16] arm64 : mm: add wrapper function ioremap_prot() Date: Thu, 16 Feb 2023 20:34:18 +0800 Message-Id: <20230216123419.461016-16-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B01BB4001A X-Rspam-User: X-Stat-Signature: 45j51e6n449r79fh9xzw3wb6cxkbr5ep X-HE-Tag: 1676550987-656647 X-HE-Meta: U2FsdGVkX1/EWEKd4gwYFP1/2IU+SfFBDpryrJwWubQ/yOOyUQRoxvT36jLVOqh4RNQ/VHyrJc8r0/X+VyfbTPFuCPCnUU2pSZzMwLRl2RA4no+SZ+eL7xofrWhpkYJOEVfdTeO6OnzF7ozFRS2c3/HogV0zWxWKPXDzer54866nN7Rchs7yAO1mXf6Mfx5UN9sU6kVTsjWnuHRGEyiJMAUgtrvLDSBPnrV0yaVT1BPV4g1Kex/qGQOu8JBlyGfXv0t/Q12/E/UF7TuxYK8YHBtas9IG3XSTuWYmNVYSowFZp2AKT80L7mdAZbcoGGBoguxvzy6YTYjqpXH+K5tQsVPMKB2o5CEKV9NEW0iE4YiZc7TP2p+JokNIei3hki2V1uYUAViwxK+ZhdhP0lvhjoD5MObMFsz5gDOiV5MkMoFGeAIZuglkohHC2TPsVhnxxxKwovauWQoODmeijxjqj172C9HX/Y4+cB8p9RKFwaQawESxUiZUPO7zgmucgZrUCEW4MexUkamKIgKY6v8sqWaGjeHATF6ZUS32h/XH0FhYf+vn37Mo94Alu5Vr/yRv1lmjiEzwiwcxn0Gvjqo7c4czeSYCn56/oKYkISGKvPpeBjPe4N+TuML28XsflrN8/o+LwUbCvy8OWwdsSeNndPJXfzTf7wcnWMMlJqS95x0CRDz2/5Jl3log5VOfm6HxpOoe6JRnctjyD+IlUpfYNTu7Xxu15M0HdTSaFY8tpWu3O43aNH+a8TyTtTholg/s45MedMPrk1aG3NQU5hIu59/sB1ffOkSF5kfm1hoRGx22+W2rcunyaMXQStSQ3Hp6cmcQLGS4OamadlleUjMOOD5RYcBa266tMwK/ZHbygKKgJUrMiDt/LhyVaJ/8IYrLTEobIq6mEY806BPiHHeJAk4XPoQcbtox/vGj69hW8Q4k6e08CsQfDEhfqNa4/yLsgc6pFdy9pT51UiC3u8Z pzxYM77m 5Q5KU4w2Rv2RO8jMzJeD7SUPHh8UD/v3WoTmRVqksQgtl4/oZ03l2CqYLSfuWRNzK2YiNQbTMOgmVm957RJboKXC09LK5igrXvEB2NbEdl9LBR99N3ECrLD5zy6IRUA4MvXbBKgNKGJ6y82dwRPoW2clb6/SyGr9OaE2hVtGPgUhAu5y1mhKn0ectBOGkRUuSytH2layIWWEK9pVRkRmP5W6QpoAo7ErQjK8j61qVf8VxkDO6BUhnlxAe8iXemh5xygORSBmdeNf5U6IexuipqOJDQYZT2H9JDix2XM1Neae4j5VsT6/herOsztSxd0sVGW09BdGwY8jAXbpckSfIFU6/ScttMwf8hllWkbkp1hgRh2KER0ScupB1KjJSS2Og7zr9+Q5zWPCDhmhC57NODQ6eMRXyhPbXTsxR 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: Since hook functions ioremap_allowed() and iounmap_allowed() will be obsoleted, add wrapper function ioremap_prot() to contain the the specific handling in addition to generic_ioremap_prot() invocation. Signed-off-by: Baoquan He Cc: Catalin Marinas Cc: Will Deacon Cc: Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 877495a0fd0c..97dd4ff1253b 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -139,8 +139,7 @@ extern void __memset_io(volatile void __iomem *, int, size_t); * I/O memory mapping functions. */ -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot); -#define ioremap_allowed ioremap_allowed +#define ioremap_prot ioremap_prot #define _PAGE_IOREMAP PROT_DEVICE_nGnRE diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index c5af103d4ad4..269f2f63ab7d 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -3,20 +3,22 @@ #include #include -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, + unsigned long prot) { unsigned long last_addr = phys_addr + size - 1; /* Don't allow outside PHYS_MASK */ if (last_addr & ~PHYS_MASK) - return false; + return NULL; /* Don't allow RAM to be mapped. */ if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr)))) - return false; + return NULL; - return true; + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); } +EXPORT_SYMBOL(ioremap_prot); /* * Must be called after early_fixmap_init From patchwork Thu Feb 16 12:34:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13143042 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 938ABC636D6 for ; Thu, 16 Feb 2023 12:36:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A32A6B0083; Thu, 16 Feb 2023 07:36:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 353DC6B0089; Thu, 16 Feb 2023 07:36:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21BBA6B008A; Thu, 16 Feb 2023 07:36:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 110C26B0083 for ; Thu, 16 Feb 2023 07:36:43 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DA2651A1067 for ; Thu, 16 Feb 2023 12:36:42 +0000 (UTC) X-FDA: 80473103844.28.3CA9BBB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 21F4A160003 for ; Thu, 16 Feb 2023 12:36:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HanqESI8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.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=1676551001; 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=sZjhNHfCq0k8rI1ELCJTN8u4w8f61XUm94YTHptLe20=; b=PCT7O9OEVILLKbf8WD49SeL9rZoVy2/NbhtjBeEfrECzFoKcvHNxdPoFxEAE29NsFQIi4x V5foInsKcKqA/u4uMJ33hhttwuA+to0Rs1lBqcn2UqLZoeuaSeZP9TBmtisppg2NJeEy2E ZEURaAQim1wEgwfb+EmACSPK0HdOyy8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HanqESI8; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676551001; a=rsa-sha256; cv=none; b=VY6sz/9jnwAhdlCYy+cOriR6vivR24hQ30+iIq6L/ZcQ7Hw81o6APXn2iRJgmMFsN9pz35 gj6Yg5dmRhDAabfBNyX2tArMWs2kxyZ3Sf582z62sVsD4/6q2WDdZ6AAr3DXrqfGi1QsnD wAS+aFgvOOVFwX0NuJUayVxTN5d/nLI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676551000; 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=sZjhNHfCq0k8rI1ELCJTN8u4w8f61XUm94YTHptLe20=; b=HanqESI8GhbZ3S4axeXtCXJGFgVWde698u5t9epuR0sgrWqgcd9Vmwyzye3XcwHk8p/9A1 kqNAbVk7iMFNSwQIZshk7W6blfZEilXCp3CUEbJN9LGQIHpoo6hep6IYn0jOqoJAaFw9HX JoRy2PwX3Oy+Crq2Nh99t3+V79JfpBI= 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-297-kAAWe3RXPKal2kOmpWdx2A-1; Thu, 16 Feb 2023 07:36:37 -0500 X-MC-Unique: kAAWe3RXPKal2kOmpWdx2A-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AEB7F85CCE0; Thu, 16 Feb 2023 12:36:36 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-99.pek2.redhat.com [10.72.12.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37CFE492C3C; Thu, 16 Feb 2023 12:36:22 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, hch@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, arnd@arndb.de, Baoquan He Subject: [PATCH v4 16/16] mm: ioremap: remove unneeded ioremap_allowed and iounmap_allowed Date: Thu, 16 Feb 2023 20:34:19 +0800 Message-Id: <20230216123419.461016-17-bhe@redhat.com> In-Reply-To: <20230216123419.461016-1-bhe@redhat.com> References: <20230216123419.461016-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 21F4A160003 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: c4etobnwtkti7n18zibd993pejgbc48p X-HE-Tag: 1676551000-337837 X-HE-Meta: U2FsdGVkX1+qoHCNvFlaLcVb9dTbAdsf3p3UlrtZVHReGIPkda/UFHkZbKdaieQ0ie0Ca6rsdwKxc9TEWw77ddfqa9bdKbkbKB5jBawNEAUvUpkl54gsFkCciHm43deJrOOFK6TapUu7g2wIdYek+WKqhQXCmvrmKUuegpV6AnKM/mNE3IldPPGk5ilz2ZEAFlQ9ANQQmNzbfshUwrx3JhLwFhMXE9YSH8L6xNiGlVYtpU2Y3O+wAZ2pYfQ7iREy66/X0sirwAARghl50em+Uv/1Vm0blHsfBK53S39LRrKPKY87fq2lgxBIaHtCcgKkHpnEl8U1NFNSJI3V5NlW4e6+21bis9jtZjiPzQnJmx1kbhJe0EtZIufQ+Qs5RRRSib61ZsG79VP/sQDlEuDYcbr9cwqJVoSc+ijzg8ECO8eRinoqfblHeW+FzhHUrkFSQ/y4SDP04oamFIL7bGoQEbdGA29ILaFJc8rbBkyjjHTbLOCmR0X4HQwb+DtYLtpVnFGAiLaP7OxrK7Re/GDlIXRbKjTxgBo8c0gwQaQwhN72+zBOJVhtekzL+8BAlGrL83R8tPWjW2RArb8+HRVuWSi1jENjkDCeDl92h9UYkGQR1VHManqfWiMzXM7zHuMXQE9sQ/UgC5k09VA7TBAlgPYCJSLJrXQLm78Oa/+NBXArvTvO86tcLxpSxc4tVVvOMh0HITkKY9RDgwW2q1c/m7+0lX1yhs2evAReLtNVFpOZZrTxpeEFkLtsDfdbNCUj7298l4oTmL78jcfD5ufw2gGMFYJefpS65UqrngZxAC+haoNH+sFxtUUwo0uujHg3f+UBdxq+DoiRYvAvLq3sXvaEvFWS5ED9p1VvnpBy5Lt2n/FH2kUOEJrnkhguBB5oqAkIceZxu8InkA6fRrY5neCG06kZ5x9cOOcskpk1YMDSJbwE9mNLFF9+6xbqQIsUCHYnKvYdWYPKddY5AEo o8lVlK5l JO2FPIAxq0D5iWRtFerl7M8S/2B+6pKMErJbT6XEnzxuvHTK6LKI3SgIaZxC5i2pcoNZIuZWcYKDfo7J/0qKoJTbLH15hKROa9QDhrLZVrGeM70p0kpswyeE7atJTwP5W9O5CE1/OflCW7GLx3FjEJ3BgBcma7J8PKQTkXglTbHKfUYeIpLmzAUuOOZVA4PWTfWmc8pCrKGCkmk3ZghKDLJcAJMk9ZqsshWLV8iXCHVZ4CZA= 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: Now there are no users of ioremap_allowed and iounmap_allowed, clean them up. Signed-off-by: Baoquan He --- include/asm-generic/io.h | 26 -------------------------- mm/ioremap.c | 6 ------ 2 files changed, 32 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 29ee791164ac..c13109d17dcb 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -1047,32 +1047,6 @@ static inline void iounmap(volatile void __iomem *addr) #elif defined(CONFIG_GENERIC_IOREMAP) #include -/* - * Arch code can implement the following two hooks when using GENERIC_IOREMAP - * ioremap_allowed() return a bool, - * - true means continue to remap - * - false means skip remap and return directly - * iounmap_allowed() return a bool, - * - true means continue to vunmap - * - false means skip vunmap and return directly - */ -#ifndef ioremap_allowed -#define ioremap_allowed ioremap_allowed -static inline bool ioremap_allowed(phys_addr_t phys_addr, size_t size, - unsigned long prot) -{ - return true; -} -#endif - -#ifndef iounmap_allowed -#define iounmap_allowed iounmap_allowed -static inline bool iounmap_allowed(void *addr) -{ - return true; -} -#endif - void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, pgprot_t prot); diff --git a/mm/ioremap.c b/mm/ioremap.c index 4a7749d85044..8cb337446bba 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -32,9 +32,6 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) - return NULL; - #ifdef IOREMAP_START area = __get_vm_area_caller(size, VM_IOREMAP, IOREMAP_START, IOREMAP_END, __builtin_return_address(0)); @@ -68,9 +65,6 @@ void generic_iounmap(volatile void __iomem *addr) { void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); - if (!iounmap_allowed(vaddr)) - return; - if (is_ioremap_addr(vaddr)) vunmap(vaddr); }