• Kevin Tian's avatar
    vfio/ccw: Use the new device life cycle helpers · ebb72b76
    Kevin Tian authored
    ccw is the only exception which cannot use vfio_alloc_device() because
    its private device structure is designed to serve both mdev and parent.
    Life cycle of the parent is managed by css_driver so vfio_ccw_private
    must be allocated/freed in css_driver probe/remove path instead of
    conforming to vfio core life cycle for mdev.
    
    Given that use a wait/completion scheme so the mdev remove path waits
    after vfio_put_device() until receiving a completion notification from
    @release. The completion indicates that all active references on
    vfio_device have been released.
    
    After that point although free of vfio_ccw_private is delayed to
    css_driver it's at least guaranteed to have no parallel reference on
    released vfio device part from other code paths.
    
    memset() in @probe is removed. vfio_device is either already cleared
    when probed for the first time or cleared in @release from last probe.
    
    The right fix is to introduce separate structures for mdev and parent,
    but this won't happen in short term per prior discussions.
    
    Remove vfio_init/uninit_group_dev() as no user now.
    Suggested-by: default avatarJason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: default avatarKevin Tian <kevin.tian@intel.com>
    Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
    Reviewed-by: default avatarEric Farman <farman@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220921104401.38898-14-kevin.tian@intel.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    ebb72b76
vfio_ccw_ops.c 15.3 KB