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.

drivers: hv: vmbus: replace deprecated mmap hook with mmap_prepare

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

This updates all callbacks which referenced the function pointer
hv_mmap_ring_buffer to instead reference hv_mmap_prepare_ring_buffer,
utilising the newly introduced compat_set_desc_from_vma() and
__compat_vma_mmap() to be able to implement this change.

The UIO HV generic driver is the only user of hv_create_ring_sysfs(),
which is the only function which references
vmbus_channel->mmap_prepare_ring_buffer which, in turn, is the only
external interface to hv_mmap_prepare_ring_buffer.

This patch therefore updates this caller to use mmap_prepare instead,
which also previously used vm_iomap_memory(), so this change replaces it
with its mmap_prepare equivalent, mmap_action_simple_ioremap().

[akpm@linux-foundation.org: restore struct vmbus_channel comment, per Michael Kelley]
Link: https://lkml.kernel.org/r/05467cb62267d750e5c770147517d4df0246cda6.1774045440.git.ljs@kernel.org
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Michael Kelley <mhklinux@outlook.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: Suren Baghdasaryan <surenb@google.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
f98cb7ca 668937b7

+29 -21
+2 -2
drivers/hv/hyperv_vmbus.h
··· 545 545 546 546 /* Create and remove sysfs entry for memory mapped ring buffers for a channel */ 547 547 int hv_create_ring_sysfs(struct vmbus_channel *channel, 548 - int (*hv_mmap_ring_buffer)(struct vmbus_channel *channel, 549 - struct vm_area_struct *vma)); 548 + int (*hv_mmap_prepare_ring_buffer)(struct vmbus_channel *channel, 549 + struct vm_area_desc *desc)); 550 550 int hv_remove_ring_sysfs(struct vmbus_channel *channel); 551 551 552 552 #endif /* _HYPERV_VMBUS_H */
+19 -12
drivers/hv/vmbus_drv.c
··· 1951 1951 struct vm_area_struct *vma) 1952 1952 { 1953 1953 struct vmbus_channel *channel = container_of(kobj, struct vmbus_channel, kobj); 1954 + struct vm_area_desc desc; 1955 + int err; 1954 1956 1955 1957 /* 1956 - * hv_(create|remove)_ring_sysfs implementation ensures that mmap_ring_buffer 1957 - * is not NULL. 1958 + * hv_(create|remove)_ring_sysfs implementation ensures that 1959 + * mmap_prepare_ring_buffer is not NULL. 1958 1960 */ 1959 - return channel->mmap_ring_buffer(channel, vma); 1961 + compat_set_desc_from_vma(&desc, filp, vma); 1962 + err = channel->mmap_prepare_ring_buffer(channel, &desc); 1963 + if (err) 1964 + return err; 1965 + 1966 + return __compat_vma_mmap(&desc, vma); 1960 1967 } 1961 1968 1962 1969 static struct bin_attribute chan_attr_ring_buffer = { ··· 2055 2048 /** 2056 2049 * hv_create_ring_sysfs() - create "ring" sysfs entry corresponding to ring buffers for a channel. 2057 2050 * @channel: Pointer to vmbus_channel structure 2058 - * @hv_mmap_ring_buffer: function pointer for initializing the function to be called on mmap of 2051 + * @hv_mmap_prepare_ring_buffer: function pointer for initializing the function to be called on mmap 2059 2052 * channel's "ring" sysfs node, which is for the ring buffer of that channel. 2060 2053 * Function pointer is of below type: 2061 - * int (*hv_mmap_ring_buffer)(struct vmbus_channel *channel, 2062 - * struct vm_area_struct *vma)) 2063 - * This has a pointer to the channel and a pointer to vm_area_struct, 2064 - * used for mmap, as arguments. 2054 + * int (*hv_mmap_prepare_ring_buffer)(struct vmbus_channel *channel, 2055 + * struct vm_area_desc *desc)) 2056 + * This has a pointer to the channel and a pointer to vm_area_desc, 2057 + * used for mmap_prepare, as arguments. 2065 2058 * 2066 2059 * Sysfs node for ring buffer of a channel is created along with other fields, however its 2067 2060 * visibility is disabled by default. Sysfs creation needs to be controlled when the use-case ··· 2078 2071 * Returns 0 on success or error code on failure. 2079 2072 */ 2080 2073 int hv_create_ring_sysfs(struct vmbus_channel *channel, 2081 - int (*hv_mmap_ring_buffer)(struct vmbus_channel *channel, 2082 - struct vm_area_struct *vma)) 2074 + int (*hv_mmap_prepare_ring_buffer)(struct vmbus_channel *channel, 2075 + struct vm_area_desc *desc)) 2083 2076 { 2084 2077 struct kobject *kobj = &channel->kobj; 2085 2078 2086 - channel->mmap_ring_buffer = hv_mmap_ring_buffer; 2079 + channel->mmap_prepare_ring_buffer = hv_mmap_prepare_ring_buffer; 2087 2080 channel->ring_sysfs_visible = true; 2088 2081 2089 2082 return sysfs_update_group(kobj, &vmbus_chan_group); ··· 2105 2098 2106 2099 channel->ring_sysfs_visible = false; 2107 2100 ret = sysfs_update_group(kobj, &vmbus_chan_group); 2108 - channel->mmap_ring_buffer = NULL; 2101 + channel->mmap_prepare_ring_buffer = NULL; 2109 2102 return ret; 2110 2103 } 2111 2104 EXPORT_SYMBOL_GPL(hv_remove_ring_sysfs);
+6 -5
drivers/uio/uio_hv_generic.c
··· 154 154 * The ring buffer is allocated as contiguous memory by vmbus_open 155 155 */ 156 156 static int 157 - hv_uio_ring_mmap(struct vmbus_channel *channel, struct vm_area_struct *vma) 157 + hv_uio_ring_mmap_prepare(struct vmbus_channel *channel, struct vm_area_desc *desc) 158 158 { 159 159 void *ring_buffer = page_address(channel->ringbuffer_page); 160 160 161 161 if (channel->state != CHANNEL_OPENED_STATE) 162 162 return -ENODEV; 163 163 164 - return vm_iomap_memory(vma, virt_to_phys(ring_buffer), 165 - channel->ringbuffer_pagecount << PAGE_SHIFT); 164 + mmap_action_simple_ioremap(desc, virt_to_phys(ring_buffer), 165 + channel->ringbuffer_pagecount << PAGE_SHIFT); 166 + return 0; 166 167 } 167 168 168 169 /* Callback from VMBUS subsystem when new channel created. */ ··· 184 183 } 185 184 186 185 set_channel_read_mode(new_sc, HV_CALL_ISR); 187 - ret = hv_create_ring_sysfs(new_sc, hv_uio_ring_mmap); 186 + ret = hv_create_ring_sysfs(new_sc, hv_uio_ring_mmap_prepare); 188 187 if (ret) { 189 188 dev_err(device, "sysfs create ring bin file failed; %d\n", ret); 190 189 vmbus_close(new_sc); ··· 367 366 * or decoupled from uio_hv_generic probe. Userspace programs can make use of inotify 368 367 * APIs to make sure that ring is created. 369 368 */ 370 - hv_create_ring_sysfs(channel, hv_uio_ring_mmap); 369 + hv_create_ring_sysfs(channel, hv_uio_ring_mmap_prepare); 371 370 372 371 hv_set_drvdata(dev, pdata); 373 372
+2 -2
include/linux/hyperv.h
··· 1015 1015 /* The max size of a packet on this channel */ 1016 1016 u32 max_pkt_size; 1017 1017 1018 - /* function to mmap ring buffer memory to the channel's sysfs ring attribute */ 1019 - int (*mmap_ring_buffer)(struct vmbus_channel *channel, struct vm_area_struct *vma); 1018 + /* function to mmap ring buffer memory to the channel's sysfs ring attribute */ 1019 + int (*mmap_prepare_ring_buffer)(struct vmbus_channel *channel, struct vm_area_desc *desc); 1020 1020 1021 1021 /* boolean to control visibility of sysfs for ring buffer */ 1022 1022 bool ring_sysfs_visible;