Skip to content
  • Alex Williamson's avatar
    vfio/mdev: Check globally for duplicate devices · 8f38152f
    Alex Williamson authored
    [ Upstream commit 002fe996 ]
    
    When we create an mdev device, we check for duplicates against the
    parent device and return -EEXIST if found, but the mdev device
    namespace is global since we'll link all devices from the bus.  We do
    catch this later in sysfs_do_create_link_sd() to return -EEXIST, but
    with it comes a kernel warning and stack trace for trying to create
    duplicate sysfs links, which makes it an undesirable response.
    
    Therefore we should really be looking for duplicates across all mdev
    parent devices, or as implemented here, against our mdev device list.
    Using mdev_list to prevent duplicates means that we can remove
    mdev_parent.lock, but in order not to serialize mdev device creation
    and removal globally, we add mdev_device.active which allows UUIDs to
    be reserved such that we can drop the mdev_list_lock before the mdev
    device is fully in place.
    
    Two behavioral notes; first, mdev_parent.lock had the side-effect of
    ser...
    8f38152f