From patchwork Wed Jun 15 05:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Wenhu X-Patchwork-Id: 12881848 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1335C433EF for ; Wed, 15 Jun 2022 06:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234569AbiFOF67 (ORCPT ); Wed, 15 Jun 2022 01:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243300AbiFOF66 (ORCPT ); Wed, 15 Jun 2022 01:58:58 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2019.outbound.protection.outlook.com [40.92.53.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE3733E18; Tue, 14 Jun 2022 22:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=niz950VfSqAzoSS0x6hEnvRUm5TYVppwx9X/JswCH/g910vURhOBNKKQn+OaU2MwByIxFBXIJvp51BJVTjYn9pA7QYcP88TSEUjCPdI55PQD9yyUlnMUwuj3Iy+Oeh3KUi+56vQ93S3wySqC1a1Mq7qHCtbMNPprBGjEle5Q06CO4TuJY3Ld4u52/d+fMLVNc8xgAzcvf53IEYCEU/HPeNI/Q/AFvgJUD2sJZazk3/w1AJ3Uts9pcNuxgcvC1TWRaADfaVd2fvToIK8AD41Zp03Qsa2ooD3iPuU3f2vWpW/VAB48wmgtKnueTBtt6ht1IdVThW2LBsSbjc/NbctHgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eoWTgHqQWDed18GGHbmGrw3lfbNF/TG1jvipXAb8rQU=; b=jqvEh4wr8wzc5CFRqFOMIzv2/kp6mFdPtKS8Nyn0rhjlr0ebn58fcSvkkTB8+TdmjEadWsccFwPJy79xozyy09R2haylpdQTBwGUiM0hSghTXO5Cj9OQHXvI0qQTT5szvdGwDLWfMk4zsjhjzwqGCuvX1Tq9AAjuNK4aoevrpcmD+duDbwtATXAoiRgTtr714qYCzw+aBU+d7Q/HoUAobubWQy0ncT0HQbGrJ8dNvoAiINq0VC2XCSCONkm6+x88pPaCr0Jh3YaDTiQg45SWIlri4nxw4AM1+vnpE4kWHHpYoqK8v3WoZS+fXKRFTBN15CfrYcJODmuRfCdEQ2gsyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eoWTgHqQWDed18GGHbmGrw3lfbNF/TG1jvipXAb8rQU=; b=KAmO7Udz+hiSeLytfU5w8Nysniag94+j2HwV/tREY5F/OlPeFXWwEpKM8N6dmc92w0+9DmVeRs4LhVukTEVNUCDv0txvgCQP1gLB8NYVV1DCUVShqmapPY1dMnP2jOqvWDvGGOgM4Et7aS0PdhymwDtQPLfHiTjPhUpv9Srpaqw67MLyut4FHcXVYZMpqFSLuFBynqiZ+avgPDW7fH83QdInCYh8cr3SRcNXfypF4stYTF4l8jon+mKfSWoc8EK/JGJDBRjTlnQvrp9okM2P6O3sk5esxfrv+RLelanLi2C0Uz/bawh0JICSr6zIo74X+i3pyMKgZ6VPeoofgDmziA== Received: from SG2PR01MB2951.apcprd01.prod.exchangelabs.com (2603:1096:4:76::15) by PU1PR01MB1947.apcprd01.prod.exchangelabs.com (2603:1096:803:19::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.22; Wed, 15 Jun 2022 05:58:52 +0000 Received: from SG2PR01MB2951.apcprd01.prod.exchangelabs.com ([fe80::a1f7:b32:baa1:3d12]) by SG2PR01MB2951.apcprd01.prod.exchangelabs.com ([fe80::a1f7:b32:baa1:3d12%7]) with mapi id 15.20.5332.022; Wed, 15 Jun 2022 05:58:52 +0000 From: Wang Wenhu To: gregkh@linuxfoundation.org, arnd@arndb.de, hao.wu@intel.com, trix@redhat.com, mdf@kernel.org, yilun.xu@intel.com, bhelgaas@google.com, akpm@linux-foundation.org, linux-fpga@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: christophe.leroy@csgroup.eu, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au, wenhu.wang@hotmail.com Subject: [PATCHv2 1/2] mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files Date: Tue, 14 Jun 2022 22:57:34 -0700 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220615055735.53585-1-wenhu.wang@hotmail.com> References: <20220615055735.53585-1-wenhu.wang@hotmail.com> X-TMN: [7E9NYvd8mRfjcrI2nMEDA6xwFWiiOlo1] X-ClientProxiedBy: SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) To SG2PR01MB2951.apcprd01.prod.exchangelabs.com (2603:1096:4:76::15) X-Microsoft-Original-Message-ID: <20220615055735.53585-2-wenhu.wang@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84e58221-e413-4278-e2f6-08da4e941fac X-MS-Exchange-SLBlob-MailProps: AsidyrAlbSQZHKAyKdVUDqca3EJTCy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/JtUexNbTOUtjrW2DWVwHvA4IOiuROSRqShBb8DJoy5yyIWbvsfyZPs59sl6b7xLdeswNbMNkUE/dsEZ4+CV41K6uzrBN9dK9ZlqRv7NRzw7FahlYtxJiOiEAKtm1tc6Mt87dGos/70hA6Ryp8P/ck/TcgBkOUI5WE8nRNMu5d6zmTvukhX60f+ORe+lt15p6Jpb/o3lEEzHa+QpIR2bp5HkRp22HauosTbVKTo6WIDsPlCISGAfF9xQW2bMHgl0u9Uk/IDhU1nah6ITwSyhGFXeBK9RSYL+kxcTIgWnQqordeI4BC8jFVJTPw+o+rgAyuuYjKsqk/5qF7XoEPpgUwvyPM8xoIr1DDb/ZIfi+5co6J5xLuiNlyR9/XYVpd/yeZRnCRKapzdsckI7wj/IcSVAAcZ682N+PBIl0McItARaHhaUR9AfUblWVMrRQRa3anG4t5IJXJt1y+aHoQwVFojp9LUZYj6V5Nz+/zSD6SJgQHgozXZIY/cJcKBjShNlSmV0F6ZmJwy3wRej+CuVufAacyNdYyafn5GuaSlaP+qjeHecBX0xM62oVxmmCId1IsNOoO5MiKZP/gaOt7EsEeQSv012Istnit7W0UJ3wkh5TfTTHD7+I83GMN1UwMSXxOjtMZkbRItXzX/p35TIuq+N4GAODCjjzx15B2K7seDBB8uQG9LI0e8zsrw2dDlG3o3B6Up6+OB75Gh59YCtz7aJZBoA4yL231pR8Xf6ZXFE3pXG+4nl8rgLyxCqaXpYeecb45CTektP4/nAH+JQ1tVhu2FEYwqTZX/lpq98bFQdKPKD5sHUpjGAATlNVH8S2A6kn9PC6v0q/H1uZ0znycb34MmrtDRhWxO/l/7rVOwLbDbTAq4ic8FMZgOkU= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-d8e84.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 84e58221-e413-4278-e2f6-08da4e941fac X-MS-Exchange-CrossTenant-AuthSource: SG2PR01MB2951.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2022 05:58:52.2084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1PR01MB1947 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org It is recommended in the "Conditional Compilation" chapter of kernel coding-style documentation that preprocessor conditionals should not be used in .c files wherever possible. As for the macro CONFIG_HAVE_IOREMAP_PROT, now it's a proper chance to eliminate it in .c files which are referencers. We constrict its usage only to mm/memory.c. HAVE_IOREMAP_PROT is supported by part of archectures such as powerpc and x86, but not supported by some others such as arm. So for some functions, a no-op version should be available. Currently it's generic_access_phys, which is referenced by some other modules. Signed-off-by: Wang Wenhu Reported-by: kernel test robot Reported-by: kernel test robot --- v2: - Added IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT) condition in __access_remote_vm - Added generic_access_phys() function with no-op in mm/memory.c instead of the former one of "static inline" in include/linux/mm.h Former: https://lore.kernel.org/linux-mm/YqMRtWAH5fIWsLQB@kroah.com/T/ --- drivers/char/mem.c | 2 -- drivers/fpga/dfl-afu-main.c | 2 -- drivers/pci/mmap.c | 2 -- drivers/uio/uio.c | 2 -- mm/memory.c | 13 +++++++++---- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 84ca98ed1dad..40186a441e38 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -354,9 +354,7 @@ static inline int private_mapping_ok(struct vm_area_struct *vma) #endif static const struct vm_operations_struct mmap_mem_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys -#endif }; static int mmap_mem(struct file *file, struct vm_area_struct *vma) diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c index 7f621e96d3b8..833e14806c7a 100644 --- a/drivers/fpga/dfl-afu-main.c +++ b/drivers/fpga/dfl-afu-main.c @@ -797,9 +797,7 @@ static long afu_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } static const struct vm_operations_struct afu_vma_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys, -#endif }; static int afu_mmap(struct file *filp, struct vm_area_struct *vma) diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c index b8c9011987f4..1dcfabf80453 100644 --- a/drivers/pci/mmap.c +++ b/drivers/pci/mmap.c @@ -35,9 +35,7 @@ int pci_mmap_page_range(struct pci_dev *pdev, int bar, #endif static const struct vm_operations_struct pci_phys_vm_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys, -#endif }; int pci_mmap_resource_range(struct pci_dev *pdev, int bar, diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 43afbb7c5ab9..c9205a121007 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -719,9 +719,7 @@ static int uio_mmap_logical(struct vm_area_struct *vma) } static const struct vm_operations_struct uio_physical_vm_ops = { -#ifdef CONFIG_HAVE_IOREMAP_PROT .access = generic_access_phys, -#endif }; static int uio_mmap_physical(struct vm_area_struct *vma) diff --git a/mm/memory.c b/mm/memory.c index 7a089145cad4..7c0e59085456 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5413,6 +5413,13 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, return ret; } EXPORT_SYMBOL_GPL(generic_access_phys); +#else +int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, + void *buf, int len, int write) +{ + return 0; +} +EXPORT_SYMBOL_GPL(generic_access_phys); #endif /* @@ -5437,9 +5444,8 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, ret = get_user_pages_remote(mm, addr, 1, gup_flags, &page, &vma, NULL); if (ret <= 0) { -#ifndef CONFIG_HAVE_IOREMAP_PROT - break; -#else + if (!IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT)) + break; /* * Check if this is a VM_IO | VM_PFNMAP VMA, which * we can access using slightly different code. @@ -5453,7 +5459,6 @@ int __access_remote_vm(struct mm_struct *mm, unsigned long addr, void *buf, if (ret <= 0) break; bytes = ret; -#endif } else { bytes = len; offset = addr & (PAGE_SIZE-1);