Skip to content

Commit bd8c2d1

Browse files
xzpeterakpm00
authored andcommitted
s390/pci_mmio: use follow_pfnmap API
Use the new API that can understand huge pfn mappings. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Gavin Shan <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5731aac commit bd8c2d1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

arch/s390/pci/pci_mmio.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@ static inline int __memcpy_toio_inuser(void __iomem *dst,
118118
SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
119119
const void __user *, user_buffer, size_t, length)
120120
{
121+
struct follow_pfnmap_args args = { };
121122
u8 local_buf[64];
122123
void __iomem *io_addr;
123124
void *buf;
124125
struct vm_area_struct *vma;
125-
pte_t *ptep;
126-
spinlock_t *ptl;
127126
long ret;
128127

129128
if (!zpci_is_enabled())
@@ -169,19 +168,21 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
169168
if (!(vma->vm_flags & VM_WRITE))
170169
goto out_unlock_mmap;
171170

172-
ret = follow_pte(vma, mmio_addr, &ptep, &ptl);
171+
args.address = mmio_addr;
172+
args.vma = vma;
173+
ret = follow_pfnmap_start(&args);
173174
if (ret)
174175
goto out_unlock_mmap;
175176

176-
io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) |
177+
io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) |
177178
(mmio_addr & ~PAGE_MASK));
178179

179180
if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE)
180181
goto out_unlock_pt;
181182

182183
ret = zpci_memcpy_toio(io_addr, buf, length);
183184
out_unlock_pt:
184-
pte_unmap_unlock(ptep, ptl);
185+
follow_pfnmap_end(&args);
185186
out_unlock_mmap:
186187
mmap_read_unlock(current->mm);
187188
out_free:
@@ -260,12 +261,11 @@ static inline int __memcpy_fromio_inuser(void __user *dst,
260261
SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
261262
void __user *, user_buffer, size_t, length)
262263
{
264+
struct follow_pfnmap_args args = { };
263265
u8 local_buf[64];
264266
void __iomem *io_addr;
265267
void *buf;
266268
struct vm_area_struct *vma;
267-
pte_t *ptep;
268-
spinlock_t *ptl;
269269
long ret;
270270

271271
if (!zpci_is_enabled())
@@ -308,11 +308,13 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
308308
if (!(vma->vm_flags & VM_WRITE))
309309
goto out_unlock_mmap;
310310

311-
ret = follow_pte(vma, mmio_addr, &ptep, &ptl);
311+
args.vma = vma;
312+
args.address = mmio_addr;
313+
ret = follow_pfnmap_start(&args);
312314
if (ret)
313315
goto out_unlock_mmap;
314316

315-
io_addr = (void __iomem *)((pte_pfn(*ptep) << PAGE_SHIFT) |
317+
io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) |
316318
(mmio_addr & ~PAGE_MASK));
317319

318320
if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) {
@@ -322,7 +324,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
322324
ret = zpci_memcpy_fromio(buf, io_addr, length);
323325

324326
out_unlock_pt:
325-
pte_unmap_unlock(ptep, ptl);
327+
follow_pfnmap_end(&args);
326328
out_unlock_mmap:
327329
mmap_read_unlock(current->mm);
328330

0 commit comments

Comments
 (0)