>> +EXPORT_SYMBOL_GPL(vfio_pci_memory_lock_and_enable); >> >> void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev, u16 cmd) >> { >> pci_write_config_word(vdev->pdev, PCI_COMMAND, cmd); >> up_write(&vdev->memory_lock); >> } >> +EXPORT_SYMBOL_GPL(vfio_pci_memory_unlock_and_restore); >> >> static unsigned long vma_to_pfn(struct vm_area_struct *vma) >> { > > The access is happening before the device is exposed to the user, the > above are for handling conditions while there may be races with user > access, this is totally unnecessary. Right. What I could do to reuse the code is to take out the part related to locking/unlocking as new functions and export that. The current vfio_pci_memory_lock_and_enable() would take the lock and call the new function. Same for vfio_pci_memory_unlock_and_restore(). The nvgrace module could also call that new function. Does that sound reasonable? > Does this delay even need to happen in the probe function, or could it > happen in the open_device callback? That would still be before user > access, but if we expect it to generally work, it would allow the > training to happen in the background up until the user tries to open > the device. Thanks, > > Alex The thought process is that since it is purely bare metal coming to proper state while boot, the nvgrace module should probably wait for the startup to complete during probe() instead of delaying until open() time. - Ankit Agrawal