• Vineeth Vijayan's avatar
    s390/cio: introduce locking for register/unregister functions · 0c6924c2
    Vineeth Vijayan authored
    Unbinding an I/O subchannel with a child-CCW device in disconnected
    state sometimes causes a kernel-panic. The race condition was seen
    mostly during testing, when setting all the CHPIDs of a device to
    offline and at the same time, the unbinding the I/O subchannel driver.
    
    The kernel-panic occurs because of double delete, the I/O subchannel
    driver calls device_del on the CCW device while another device_del
    invocation for the same device is in-flight.  For instance, disabling
    all the CHPIDs will trigger the ccw_device_remove function, which will
    call a ccw_device_unregister(), which ends up calling the device_del()
    which is asynchronous via cdev's todo workqueue. And unbinding the I/O
    subchannel driver calls io_subchannel_remove() function which calls the
    ccw_device_unregister() and device_del().
    
    This double delete can be prevented by serializing all CCW device
    registration/unregistration calls into the driver core. This patch
    introduces a mutex which will be used for this purpose.
    Signed-off-by: default avatarVineeth Vijayan <vneethv@linux.ibm.com>
    Reported-by: default avatarBoris Fiuczynski <fiuczy@linux.ibm.com>
    Reviewed-by: default avatarPeter Oberparleiter <oberpar@linux.ibm.com>
    Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
    0c6924c2
device.c 48.2 KB