> -----Original Message----- > From: Guo, Jia > Sent: Wednesday, July 11, 2018 6:42 PM > > When device be hotplug out, the pci resource will be released in kernel, > the uio fd will disappear, and the irq will be released. At this time, > if igb uio driver still try to access or release these resource, it will > cause kernel crash. > > On the other hand, uio_remove will be called unexpectedly before > uio_release. The uio_remove procedure will free resources which are needed > by uio_release. So there is no chance to disable interrupt which is defined > inside uio_release procedure. This will affect later usage of interrupt. > > So the case of unexpectedly removal by hot unplug should be identify and > correspondingly processed. > > This patch propose to add enum rte_udev_state in struct rte_uio_pci_dev, > that will keep the state of uio device as probed/opened/released/removed. > > This patch also checks kobject’s remove_uevent_sent state to detect the > unexpectedly removal status which means hot unplug. Once hot unplug be > detected, it will call uio_release as soon as possible and set the uio > status to be “removed”. After that, uio will check this status in > uio_release function, if uio have already been removed, it will only free > the dirty uio resource. > > Signed-off-by: Jeff Guo <jia....@intel.com>
Even though we prefer vfio than igb_uio as vfio is safer and more standard way of accessing devices, it's still good to have this bug-fixing to avoiding kernel crash and memory leak. Later on, we might further enhance igb_uio by introducing similar mechanism which vfio-pci currently uses (send event to up-layer application in the middle of pci remove process), so up-layer application can close this device more gracefully. Or, we can suggest to use vfio, and leave igb_uio as it is. Thanks, --Shaopeng Acked-by: Shaopeng He <shaopeng...@intel.com>