From patchwork Thu Jul 6 15:45: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: 13303968 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 C01D7EB64D9 for ; Thu, 6 Jul 2023 15:47:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 588478D0002; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55F018D0001; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 426918D0002; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) 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 32FAA8D0001 for ; Thu, 6 Jul 2023 11:47:19 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F2F75B0701 for ; Thu, 6 Jul 2023 15:47:18 +0000 (UTC) X-FDA: 80981616156.26.21E580F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 23FB740002 for ; Thu, 6 Jul 2023 15:47:14 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KG8haOi3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.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=1688658435; a=rsa-sha256; cv=none; b=LLG0oPXJWdrtUhYGqOnz/8LcyPi14bDrdf9M9Wb1fuz8NQmLIIbHHysLauQI92Mn0Mv5GF 45pnPPrPVptTylaUMkrdUHL6WEfLX5hWKNJEJEec89dq4MP5cjzZnRwPTOY0/E5dJbhWzk mQcHeEIGMxvAHO9KudgKyMNkNt/OMyc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KG8haOi3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.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=1688658435; 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=fXmRLKyZhjK8lZnEN6ZgBD7TdWtmJLX0PHcxqK6st5o=; b=WW2UJCQesECb4G2Or6GJa/tzY8RrnGyVBKbX9JQnrtQo4IiGc4HB9cKnAyYZczkxGPEOzn IF56Fhpzr7OYdzbeB5bcGXRneE2sW74H2vkf7qGTDxS0ogNAdm7hswqp28fllyKV804tWz +NUFslWlmdOT3YnYggvvWGf4Wbc+BF0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688658434; 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=fXmRLKyZhjK8lZnEN6ZgBD7TdWtmJLX0PHcxqK6st5o=; b=KG8haOi3rDn3ImhBxO+wmTEVlj32i8v6WdZFs+f+u66FZInpeMtdRzd5T0aVYr6FgEWvEi EClF2Dj/+Ni6ywPmbLWGwyIaaUz5GwsXIUZhjE28bV1AOBtZtsCBSFwo2S2IhC+Kq7D5ol a4c3DIhTVAOVIkwJLvCIlTX6Dq5/tUI= 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-627-40rembCSN4-mVvgWCYJEdg-1; Thu, 06 Jul 2023 11:47:10 -0400 X-MC-Unique: 40rembCSN4-mVvgWCYJEdg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 183C081D9EC; Thu, 6 Jul 2023 15:47:09 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 487C1F6401; Thu, 6 Jul 2023 15:46:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-mm@kvack.org, arnd@arndb.de, hch@lst.de, christophe.leroy@csgroup.eu, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, shorne@gmail.com, David.Laight@ACULAB.COM, deller@gmx.de, nathan@kernel.org, glaubitz@physik.fu-berlin.de, Baoquan He , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH v8 10/19] s390: mm: Convert to GENERIC_IOREMAP Date: Thu, 6 Jul 2023 23:45:11 +0800 Message-Id: <20230706154520.11257-11-bhe@redhat.com> In-Reply-To: <20230706154520.11257-1-bhe@redhat.com> References: <20230706154520.11257-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 23FB740002 X-Stat-Signature: 8cp3wdqutna5se7armknwofr8p3ncn4y X-HE-Tag: 1688658434-157582 X-HE-Meta: U2FsdGVkX1/GwYL2biTqufDfzlnQC2BNLYlq85XSjm3gz4aoyPIpSo/gwxwtqS+Akw1xCBvbEZWGcxv3SZm+Oh57KxGJidd5gmxeen/A/TCEQY22opZSUn+pKfaNsqBqimoQdX1YMVbcKQRKkp0cOQOvFBbvaXxL73vOEwyDMKgb7p2TdeKcvaBIZHTgDnk2WU3JaQB4k7PZw3+/80uaeXdH4CPfXfPekf/KOeWaStfIildgdKdTG+SE5E6DjNfZEZ+T7599AlEUg7hPeB43bnU38K3q6BrSMIPBUFfltZE0FCQBymbcsWJcCrTXMdF116xWZ9GsNtNQqh2P01kAgp1Grh5gAf5zkI616/zqFSp5HAkKqori/5SRZJHfHZeGSQ4DQ5gFbM/QelWECdF/Wf4YjzXBxvTcTCxxUeGtsPAD8hTxDmbxfW+Aesyp726cvAc25y5kkuelaIz2lCtaDUzOvpIT0C40fNNYjLd2m+KTg6T850v0IJbMlYsvGy4gQmd8pxu69r1/Yvn1EwJwI7aYzhREGGYCYYYBH2TjaySlvlqzsHLr3JEdRhJDogRLOHJQnCs2A+XQLEWmtR7OlCA7O/EaQzY7+qBWc4h/w0DwPsOO+n+vWcrwYDjDYG3U6+ufnAkI0O/OcA2zKbqIrqfKBTBEF7qyQp9NhnmC6pghNl7d5mOaqdZTB9oGbmF7IMgogljewOIN90UQpzhhqDsuPSh9XlS0P0nCHo2MU2yQT85QV0+T81ONwIlxXPqeINLbYiXezLdgPsKi2aZsz3RKji9SZomlm7HLM8Kfp0hXB4URRFItqSwmlDQofTMAc3jHcssEGw2iEV6KRb6RnCKIKyypph6pD79gnPEgoZZz6aM+3Xygi9W9EvRWatWbXXPzRNSBr5aqEz6rWMXQ3xOPMqLn5T1X0Y85H8VtPCS76xTNkzeQffphshnPnJIA2RQyDNLZ3EjZ95bNRTO Jf5T0Ul6 oi2CYfEhILzgLkCsrnJbBJH6oKXbBugJVrSewQAf0NPKFcE5MZBVj5nzIiN+SrbI7flAvILH8ofnUTJK9JMCO3VRaPgQBdWU9GWg5GBqjRCKpTbFkk8R7iICB/YXOPGSzAK+h/etqAvyyOSdVNhzvWhm6vHEeKkkqMlg7/8cYq5Z6D4sxL3iD2EWmCmnLqpKlwsyxR9cH1/IvtRvZIK51Ohjle8EhKbeKOP0mZi9TpQ5YNFNiuTHK/O3vY3J41LbyxgGYlxmkA3exyMOew5srIHTWSTVZ/3UY2pPSR5jIqPYgmFBbgP20gMJChw== 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 code 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(). And also replace including with in arch/s390/kernel/perf_cpum_sf.c, otherwise building error will be seen because macro defined in can't be seen in perf_cpum_sf.c. Signed-off-by: Baoquan He Reviewed-by: Niklas Schnelle Tested-by: Niklas Schnelle Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport (IBM) Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: Christian Borntraeger Cc: Sven Schnelle Cc: linux-s390@vger.kernel.org --- arch/s390/Kconfig | 1 + arch/s390/include/asm/io.h | 21 ++++++------ arch/s390/kernel/perf_cpum_sf.c | 2 +- arch/s390/pci/pci.c | 57 ++++++--------------------------- 4 files changed, 24 insertions(+), 57 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 5b39918b7042..290b6f93b816 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -143,6 +143,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/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index 8ecfbce4ac92..dc6afc2221b4 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include /* Minimum number of sample-data-block-tables: * At least one table is required for the sampling buffer structure. diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index afc3f33788da..d34d5813d006 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);