On Sat, Oct 3, 2026 at 6:39 PM Lorenzo Stoakes (ARM) <[email protected]> wrote:
>
> Use the mmap_prepare in favour of the deprecated mmap hook as part of the
> work to convert one to another.
>
> Since this is simply a refcounted kernel page that has been allocated, it
> should not be marked VM_IO and should be inserted using the kernel page
> insertion mechanism, so convert it to do this instead.
>
> Use the VMA descriptor's private data field as a scratch buffer to store
> the page in - this stays valid throughout the kernel page mapping
> operation.
>
> Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>

Reviewed-by: Suren Baghdasaryan <[email protected]>


> ---
>  drivers/hsi/clients/cmt_speech.c | 33 +++++++++------------------------
>  1 file changed, 9 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/hsi/clients/cmt_speech.c 
> b/drivers/hsi/clients/cmt_speech.c
> index 7226677ebde7..801697b74d4f 100644
> --- a/drivers/hsi/clients/cmt_speech.c
> +++ b/drivers/hsi/clients/cmt_speech.c
> @@ -1084,22 +1084,6 @@ static void cs_hsi_stop(struct cs_hsi_iface *hi)
>         kfree(hi);
>  }
>
> -static vm_fault_t cs_char_vma_fault(struct vm_fault *vmf)
> -{
> -       struct cs_char *csdata = vmf->vma->vm_private_data;
> -       struct page *page;
> -
> -       page = virt_to_page((void *)csdata->mmap_base);
> -       get_page(page);
> -       vmf->page = page;
> -
> -       return 0;
> -}
> -
> -static const struct vm_operations_struct cs_char_vm_ops = {
> -       .fault  = cs_char_vma_fault,
> -};
> -
>  static int cs_char_fasync(int fd, struct file *file, int on)
>  {
>         struct cs_char *csdata = file->private_data;
> @@ -1256,18 +1240,19 @@ static long cs_char_ioctl(struct file *file, unsigned 
> int cmd,
>         return r;
>  }
>
> -static int cs_char_mmap(struct file *file, struct vm_area_struct *vma)
> +static int cs_char_mmap_prepare(struct vm_area_desc *desc)
>  {
> -       if (vma->vm_end < vma->vm_start)
> -               return -EINVAL;
> +       struct file *file = desc->file;
> +       struct cs_char *csdata = file->private_data;
> +       struct page **pages = (struct page **)&desc->private_data;
>
> -       if (vma_pages(vma) != 1)
> +       if (vma_desc_pages(desc) != 1)
>                 return -EINVAL;
>
> -       vm_flags_set(vma, VM_IO | VM_DONTDUMP | VM_DONTEXPAND);
> -       vma->vm_ops = &cs_char_vm_ops;
> -       vma->vm_private_data = file->private_data;
> +       vma_desc_set_flags(desc, VMA_DONTDUMP_BIT, VMA_DONTEXPAND_BIT);
>
> +       *pages = virt_to_page((void *)csdata->mmap_base);
> +       mmap_action_map_kernel_pages_full(desc, pages);
>         return 0;
>  }
>
> @@ -1353,7 +1338,7 @@ static const struct file_operations cs_char_fops = {
>         .write          = cs_char_write,
>         .poll           = cs_char_poll,
>         .unlocked_ioctl = cs_char_ioctl,
> -       .mmap           = cs_char_mmap,
> +       .mmap_prepare   = cs_char_mmap_prepare,
>         .open           = cs_char_open,
>         .release        = cs_char_release,
>         .fasync         = cs_char_fasync,
>
> --
> 2.55.0
>

Reply via email to