Re: [PATCH v2 7/7] vfio: Remove calls to vfio_group_add_container_user()

Alex Williamson
2022-04-29T20:28:28Z

On Thu, 21 Apr 2022 13:28:38 -0300
Jason Gunthorpe <jgg@nvidia.com> wrote:

> When the open_device() op is called the container_users is incremented and
> held incremented until close_device(). Thus, so long as drivers call
> functions within their open_device()/close_device() region they do not
> need to worry about the container_users.
>
> These functions can all only be called between open_device() and
> close_device():
>
> vfio_pin_pages()
> vfio_unpin_pages()
> vfio_dma_rw()
> vfio_register_notifier()
> vfio_unregister_notifier()
>
> Eliminate the calls to vfio_group_add_container_user() and add
> vfio_assert_device_open() to detect driver mis-use.

A comment here explaining that decrementing open_count is pushed until
after close_device to support this feature would help to explain the
somewhat subtle change in vfio_group_get_device_fd().

Otherwise the series looks ok with fixes noted by previous reviews.
Thanks,

Alex