mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 15:11:31 +00:00
s390/pci_mmio: use follow_pfnmap API
Use the new API that can understand huge pfn mappings. Link: https://lkml.kernel.org/r/20240826204353.2228736-12-peterx@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com> Cc: Niklas Schnelle <schnelle@linux.ibm.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Alex Williamson <alex.williamson@redhat.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: Gavin Shan <gshan@redhat.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will@kernel.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
5731aacd54
commit
bd8c2d18bf
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user