Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

stm: replace deprecated mmap hook with mmap_prepare

The f_op->mmap interface is deprecated, so update driver to use its
successor, mmap_prepare.

The driver previously used vm_iomap_memory(), so this change replaces it
with its mmap_prepare equivalent, mmap_action_simple_ioremap().

Also, in order to correctly maintain reference counting, add a
vm_ops->mapped callback to increment the reference count when successfully
mapped.

Link: https://lkml.kernel.org/r/9f3d559a264a83cf45518fcf35cc7ef1d7dfd500.1774045440.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bodo Stroesser <bostroesser@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Long Li <longli@microsoft.com>
Cc: Marc Dionne <marc.dionne@auristor.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Richard Weinberger <richard@nod.at>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes (Oracle) and committed by
Andrew Morton
b0085cb9 08586537

+21 -10
+21 -10
drivers/hwtracing/stm/core.c
··· 666 666 return count; 667 667 } 668 668 669 + static int stm_mmap_mapped(unsigned long start, unsigned long end, pgoff_t pgoff, 670 + const struct file *file, void **vm_private_data) 671 + { 672 + struct stm_file *stmf = file->private_data; 673 + struct stm_device *stm = stmf->stm; 674 + 675 + pm_runtime_get_sync(&stm->dev); 676 + return 0; 677 + } 678 + 669 679 static void stm_mmap_open(struct vm_area_struct *vma) 670 680 { 671 681 struct stm_file *stmf = vma->vm_file->private_data; ··· 694 684 } 695 685 696 686 static const struct vm_operations_struct stm_mmap_vmops = { 687 + .mapped = stm_mmap_mapped, 697 688 .open = stm_mmap_open, 698 689 .close = stm_mmap_close, 699 690 }; 700 691 701 - static int stm_char_mmap(struct file *file, struct vm_area_struct *vma) 692 + static int stm_char_mmap_prepare(struct vm_area_desc *desc) 702 693 { 694 + struct file *file = desc->file; 703 695 struct stm_file *stmf = file->private_data; 704 696 struct stm_device *stm = stmf->stm; 705 697 unsigned long size, phys; ··· 709 697 if (!stm->data->mmio_addr) 710 698 return -EOPNOTSUPP; 711 699 712 - if (vma->vm_pgoff) 700 + if (desc->pgoff) 713 701 return -EINVAL; 714 702 715 - size = vma->vm_end - vma->vm_start; 703 + size = vma_desc_size(desc); 716 704 717 705 if (stmf->output.nr_chans * stm->data->sw_mmiosz != size) 718 706 return -EINVAL; ··· 724 712 if (!phys) 725 713 return -EINVAL; 726 714 727 - pm_runtime_get_sync(&stm->dev); 715 + desc->page_prot = pgprot_noncached(desc->page_prot); 716 + vma_desc_set_flags(desc, VMA_IO_BIT, VMA_DONTEXPAND_BIT, 717 + VMA_DONTDUMP_BIT); 718 + desc->vm_ops = &stm_mmap_vmops; 728 719 729 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 730 - vm_flags_set(vma, VM_IO | VM_DONTEXPAND | VM_DONTDUMP); 731 - vma->vm_ops = &stm_mmap_vmops; 732 - vm_iomap_memory(vma, phys, size); 733 - 720 + mmap_action_simple_ioremap(desc, phys, size); 734 721 return 0; 735 722 } 736 723 ··· 847 836 .open = stm_char_open, 848 837 .release = stm_char_release, 849 838 .write = stm_char_write, 850 - .mmap = stm_char_mmap, 839 + .mmap_prepare = stm_char_mmap_prepare, 851 840 .unlocked_ioctl = stm_char_ioctl, 852 841 .compat_ioctl = compat_ptr_ioctl, 853 842 };