From patchwork Fri Aug 9 16:09:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13758936 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 AC28DC3DA4A for ; Fri, 9 Aug 2024 16:09:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C39E6B00AD; Fri, 9 Aug 2024 12:09:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 372106B00AE; Fri, 9 Aug 2024 12:09:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12AB26B00AF; Fri, 9 Aug 2024 12:09:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DF2A56B00AD for ; Fri, 9 Aug 2024 12:09:45 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8DA338118C for ; Fri, 9 Aug 2024 16:09:45 +0000 (UTC) X-FDA: 82433192730.02.5DFC523 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 764C0180003 for ; Fri, 9 Aug 2024 16:09:43 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=esEb7RxG; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@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=1723219718; 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=kaY3EfeA+k09YWgS+MfGM8qkjlv58srLyvVau/9jXnU=; b=IfD0Iv4E1v9UtZn3h+Um7k1CQPZ82okpsplopbBKWj31m62MXiMBir1SmVMyYySXUKGYin Wu9nPctYzGkdCJs1yjnXgre0jeuYso956jbbhM78JM6EZ+w2GI6b4V3tFtBTVj3hh/hAw/ VmVr87BjkLLdDDgCeOQ1LkjE75XYDbU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723219718; a=rsa-sha256; cv=none; b=d9DpXbrd15Qic/lQ7Vb69RmaDwWNAwZe1/H69Ficp/ijqmDgKQ5fAE55P4MMgwvaM8j9F0 bkiCHYuGADxoDQydYv3SKseWY7VuEO4xl2g7k8+18RYxDXH2+m4Wlk2B0qEY71mpPHj76v Uc53nKJrAnvZ6imstd4SmnKEMgWHB5I= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=esEb7RxG; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723219782; 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=kaY3EfeA+k09YWgS+MfGM8qkjlv58srLyvVau/9jXnU=; b=esEb7RxG1OyNGuXULMwbkHisXkJiTy4f7Gr1RZYOWuxPxZLfmXbbewqKJq1MGTnfMa5sEe nD4zRgC6zv0aiU9gHZ2y4KRvfU5cWwGs6wIr5pIUSotNGQZruG6lLVwmgIehOMnlncZX5y FeSpNhDEXQ2v5g5I49a2jONl8vGP9L8= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-zq2mnokHM06WzSH82zDuTQ-1; Fri, 09 Aug 2024 12:09:41 -0400 X-MC-Unique: zq2mnokHM06WzSH82zDuTQ-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-44fea369811so4530291cf.0 for ; Fri, 09 Aug 2024 09:09:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723219780; x=1723824580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kaY3EfeA+k09YWgS+MfGM8qkjlv58srLyvVau/9jXnU=; b=ezmC9ddxeZbs5e79pP2h4qKC7eZOBzKka3pvoGjuVONDStFf+vNCmeh3w1puHFX2zZ ScYcEhBcYtA8tFv6qhpT728LT4Flx6kNAjwX0yDOJSODkyYbgU7q5sKHTMaF59+5RdR3 NxTLfCw7vt4KxaZk20yKggPHxMcyEKVgYgESauHpP2Y9KWgIpZyKfJ5vO8DV6OSAWdof TVY3bzSVPouiJm40JY9TzNuEqTHXWUnTNTKfhyO+kbaBjEBmIcWYqB+sGOgmH8NxUaiF TmqHlqqhOxXErN64wp91hoCXttt2u8M1WYzIaV14NYT17gjLQehmr6/QlOQGnq0adPIS YvSg== X-Gm-Message-State: AOJu0YzH9D/MwGy5dpCAHLL8tJ4MzXfTguf9fSf4mGUbDYu4FY4UvImj XCz+uHXSKhYcjlWYuaLPLqRdKsmn+YWmA4tzcT2jVQi9wOEyO0eOKz20oZhL9xIeW0X/2xZwvQl n72xsc5Bc7QZzzEgTC44VEdws6v2CIFuSqMdJBxpMKHUOTsJVCTBH2f6rMq6bhEVg+JBO/ODMQ4 rEG9YHLYUCA3U7/Ps8CYgNTBZemeZ9ammM X-Received: by 2002:ac8:5912:0:b0:450:efd:723 with SMTP id d75a77b69052e-453125552fbmr13163501cf.4.1723219780623; Fri, 09 Aug 2024 09:09:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtbIkutydCKQHHfrahTRflQkyMYGSh3zYrObmthmw14T659Ni251Xo72HIqIFQZU+hooLp2A== X-Received: by 2002:ac8:5912:0:b0:450:efd:723 with SMTP id d75a77b69052e-453125552fbmr13162951cf.4.1723219780083; Fri, 09 Aug 2024 09:09:40 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-451c870016csm22526741cf.19.2024.08.09.09.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:09:39 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, peterx@redhat.com, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , David Hildenbrand , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , linux-s390@vger.kernel.org Subject: [PATCH 11/19] s390/pci_mmio: Use follow_pfnmap API Date: Fri, 9 Aug 2024 12:09:01 -0400 Message-ID: <20240809160909.1023470-12-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240809160909.1023470-1-peterx@redhat.com> References: <20240809160909.1023470-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimec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3/+tPhaVKBHI8usKUUq7krbf184/swmafU6rItRd25GCAq5F7Qn6IVjKzsJodGrjBY 9SCp8V0p gFSDl+IHYd6vZv+/rro4c9vIv4dzDr9+l/BOBpLnWjFPJ8r124SALPJr3ZCRey2DlBVCAAIgszU3JZQxeWkvNYcqu5Dmgcgq9bigaJzqnlcnECIoEUsw73FEu2hxlE/9srmACOPWRwm4zq9ToGpYsBSMmLBUkcH7atCwHWqAyQ1WEl+ehR6PshmJqAxq3yAQWJXRxLsU6TyMeDk/a0M7BREOBvNfRYtMLHiMAPnYZLaeru/nu9fvBdq0J3NMeEx8IV5Vfsr/DFDpCbv62CWYH1dcvhGl5FrK6ox9Wd7jYRUZcPPvvoPGroU51VW+9Eh0qGPydvpkq6Hah8Rm0oYWkCSi4yT+I/Lpfrjkj0WuctTV/9mpXr57UpTzJXyWAKuUglBgb/7Z7tnODDCpO5+/V4Pttp5nsjDOxGAvfcV5dGiEIk1EKXRHO9YBMT8MJSevaQ2J8xv0ZexoBKSAYaGEK5id8EmBXukro9d7qmDN3axAWp6elviZ4SJP6cvmh/gHcv6p8yUHZ/6GfPGCJaPiFGtReLrhabmXTOCsudbnupEPbbYS8ugh5RvCTpU55MYxZBVo7HdPBWWFZVZX443wr23AxBA== 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: List-Subscribe: List-Unsubscribe: Use the new API that can understand huge pfn mappings. 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 Signed-off-by: Peter Xu --- arch/s390/pci/pci_mmio.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/s390/pci/pci_mmio.c b/arch/s390/pci/pci_mmio.c index 5398729bfe1b..de5c0b389a3e 100644 --- a/arch/s390/pci/pci_mmio.c +++ b/arch/s390/pci/pci_mmio.c @@ -118,12 +118,11 @@ static inline int __memcpy_toio_inuser(void __iomem *dst, SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, const void __user *, user_buffer, size_t, length) { + struct follow_pfnmap_args args = { }; u8 local_buf[64]; void __iomem *io_addr; void *buf; struct vm_area_struct *vma; - pte_t *ptep; - spinlock_t *ptl; long ret; if (!zpci_is_enabled()) @@ -169,11 +168,13 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, if (!(vma->vm_flags & VM_WRITE)) goto out_unlock_mmap; - ret = follow_pte(vma, mmio_addr, &ptep, &ptl); + args.address = mmio_addr; + args.vma = vma; + ret = follow_pfnmap_start(&args); if (ret) goto out_unlock_mmap; - io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) | + io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK)); if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) @@ -181,7 +182,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, ret = zpci_memcpy_toio(io_addr, buf, length); out_unlock_pt: - pte_unmap_unlock(ptep, ptl); + follow_pfnmap_end(&args); out_unlock_mmap: mmap_read_unlock(current->mm); out_free: @@ -260,12 +261,11 @@ static inline int __memcpy_fromio_inuser(void __user *dst, SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, void __user *, user_buffer, size_t, length) { + struct follow_pfnmap_args args = { }; u8 local_buf[64]; void __iomem *io_addr; void *buf; struct vm_area_struct *vma; - pte_t *ptep; - spinlock_t *ptl; long ret; if (!zpci_is_enabled()) @@ -308,11 +308,13 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, if (!(vma->vm_flags & VM_WRITE)) goto out_unlock_mmap; - ret = follow_pte(vma, mmio_addr, &ptep, &ptl); + args.vma = vma; + args.address = mmio_addr; + ret = follow_pfnmap_start(&args); if (ret) goto out_unlock_mmap; - io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) | + io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK)); if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) { @@ -322,7 +324,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr, ret = zpci_memcpy_fromio(buf, io_addr, length); out_unlock_pt: - pte_unmap_unlock(ptep, ptl); + follow_pfnmap_end(&args); out_unlock_mmap: mmap_read_unlock(current->mm);