From nobody Mon Apr 6 13:29:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D3883FBEC0; Thu, 19 Mar 2026 18:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773944666; cv=none; b=WtwtHoOSqlbmMBoZB/9BPW4TP7mJNzD+xIUCIbTzCkyAbqqYO/3e5siF98FWW2pJ5G9hXzaVwyOhM7jR9j3EdEa7dZCAFt0UkgIEXBs8v7ZvrlaY8Csi8CdfG4PQLiYKtAcoxgRzrAx7DBd36wIgJtoLgdlnypAiP71kgcn/UvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773944666; c=relaxed/simple; bh=RbmL9EYUSm+5mPpVtsO49vrMj2KZeRXZE1ebFppsMFI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lr4bKcffB7ROYgHfoRqYvMDA/wgOOLsVkSvi706+pqwUxdd3Oa55kUFjRZKTMQ6b7deMAJTfnR45mdnYhqPfOIzMXMgInMwFBhWUf+jol3vcsoVNQpIEji93B6uXNfSXYOJRckin/JfHBgOSAXLJJUL5eYRECW2aLJ+DnH9oi6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Li3vZE+/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Li3vZE+/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BD20C19425; Thu, 19 Mar 2026 18:24:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773944666; bh=RbmL9EYUSm+5mPpVtsO49vrMj2KZeRXZE1ebFppsMFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Li3vZE+/Si/AoZBnvM4NobxMzxsIZX6Ut248bBHQWfZdKE7gPmzegajhyMNbUvdiu n0jsjkoZKX51lr5qi2zT8yNVl3HLzObVuPV3wio9zNDOXVxm4z87m+Hi5m3DLG+ib8 kOYTPardnhcl3zgOzKqikvzIY4+NZxPUN9G9f5Pocv/ragZCxVs9kk7dNkVbHq5l+J Y0Y4z1uKYhqOUm8MewoNCLIZhcrGvn42rm5lZv+JlivRIEjNdpU8E+qgSv9giYxO0w Qz5yNWwBmUGV1jhNJkc5FhMYFTuOtwdDT7EPTm/goKWFLPDRFB3nZmFdZwRvXlrCLa QMiaODDlA6kxw== From: "Lorenzo Stoakes (Oracle)" To: Andrew Morton Cc: Jonathan Corbet , Clemens Ladisch , Arnd Bergmann , Greg Kroah-Hartman , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Bodo Stroesser , "Martin K . Petersen" , David Howells , Marc Dionne , Alexander Viro , Christian Brauner , Jan Kara , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, linux-staging@lists.linux.dev, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Ryan Roberts Subject: [PATCH v3 14/16] uio: replace deprecated mmap hook with mmap_prepare in uio_info Date: Thu, 19 Mar 2026 18:23:38 +0000 Message-ID: <22866c41d2886554517f6ebd93b321ad068c8abe.1773944114.git.ljs@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The f_op->mmap interface is deprecated, so update uio_info to use its successor, mmap_prepare. Therefore, replace the uio_info->mmap hook with a new uio_info->mmap_prepare hook, and update its one user, target_core_user, to both specify this new mmap_prepare hook and also to use the new vm_ops->mapped() hook to continue to maintain a correct udev->kref refcount. Then update uio_mmap() to utilise the mmap_prepare compatibility layer to invoke this callback from the uio mmap invocation. Signed-off-by: Lorenzo Stoakes (Oracle) --- drivers/target/target_core_user.c | 26 ++++++++++++++++++-------- drivers/uio/uio.c | 10 ++++++++-- include/linux/uio_driver.h | 4 ++-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core= _user.c index af95531ddd35..edc2afd5f4ee 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1860,6 +1860,17 @@ static struct page *tcmu_try_get_data_page(struct tc= mu_dev *udev, uint32_t dpi) return NULL; } =20 +static int tcmu_vma_mapped(unsigned long start, unsigned long end, pgoff_t= pgoff, + const struct file *file, void **vm_private_data) +{ + struct tcmu_dev *udev =3D *vm_private_data; + + pr_debug("vma_mapped\n"); + + kref_get(&udev->kref); + return 0; +} + static void tcmu_vma_open(struct vm_area_struct *vma) { struct tcmu_dev *udev =3D vma->vm_private_data; @@ -1919,26 +1930,25 @@ static vm_fault_t tcmu_vma_fault(struct vm_fault *v= mf) } =20 static const struct vm_operations_struct tcmu_vm_ops =3D { + .mapped =3D tcmu_vma_mapped, .open =3D tcmu_vma_open, .close =3D tcmu_vma_close, .fault =3D tcmu_vma_fault, }; =20 -static int tcmu_mmap(struct uio_info *info, struct vm_area_struct *vma) +static int tcmu_mmap_prepare(struct uio_info *info, struct vm_area_desc *d= esc) { struct tcmu_dev *udev =3D container_of(info, struct tcmu_dev, uio_info); =20 - vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP); - vma->vm_ops =3D &tcmu_vm_ops; + vma_desc_set_flags(desc, VMA_DONTEXPAND_BIT, VMA_DONTDUMP_BIT); + desc->vm_ops =3D &tcmu_vm_ops; =20 - vma->vm_private_data =3D udev; + desc->private_data =3D udev; =20 /* Ensure the mmap is exactly the right size */ - if (vma_pages(vma) !=3D udev->mmap_pages) + if (vma_desc_pages(desc) !=3D udev->mmap_pages) return -EINVAL; =20 - tcmu_vma_open(vma); - return 0; } =20 @@ -2253,7 +2263,7 @@ static int tcmu_configure_device(struct se_device *de= v) info->irqcontrol =3D tcmu_irqcontrol; info->irq =3D UIO_IRQ_CUSTOM; =20 - info->mmap =3D tcmu_mmap; + info->mmap_prepare =3D tcmu_mmap_prepare; info->open =3D tcmu_open; info->release =3D tcmu_release; =20 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 5a4998e2caf8..1e4ade78ed84 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -850,8 +850,14 @@ static int uio_mmap(struct file *filep, struct vm_area= _struct *vma) goto out; } =20 - if (idev->info->mmap) { - ret =3D idev->info->mmap(idev->info, vma); + if (idev->info->mmap_prepare) { + struct vm_area_desc desc; + + compat_set_desc_from_vma(&desc, filep, vma); + ret =3D idev->info->mmap_prepare(idev->info, &desc); + if (ret) + goto out; + ret =3D __compat_vma_mmap(&desc, vma); goto out; } =20 diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index 334641e20fb1..02eaac47ac44 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h @@ -97,7 +97,7 @@ struct uio_device { * @irq_flags: flags for request_irq() * @priv: optional private data * @handler: the device's irq handler - * @mmap: mmap operation for this uio device + * @mmap_prepare: mmap_prepare operation for this uio device * @open: open operation for this uio device * @release: release operation for this uio device * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX @@ -112,7 +112,7 @@ struct uio_info { unsigned long irq_flags; void *priv; irqreturn_t (*handler)(int irq, struct uio_info *dev_info); - int (*mmap)(struct uio_info *info, struct vm_area_struct *vma); + int (*mmap_prepare)(struct uio_info *info, struct vm_area_desc *desc); int (*open)(struct uio_info *info, struct inode *inode); int (*release)(struct uio_info *info, struct inode *inode); int (*irqcontrol)(struct uio_info *info, s32 irq_on); --=20 2.53.0