Hi Andrew, Anatoly, On Tue, Apr 4, 2017 at 4:52 PM, Burakov, Anatoly <anatoly.bura...@intel.com> wrote:
> Hi Andrew, > > > I think a key to the main problem is the same IOMMU group used for both > PCI functions. > > It tries to set IOMMU type using the same file descriptor twice. The > second set is dummy, since the same value is set, but still fails, I guess, > because it is already in use. > > See logs with debug enabled and few extra logs below: > > Yes you're right. Specifically, eal_vfio.c:vfio_setup_device() at line > 311 (where we check for number of groups) - the code always assumes that one > active group means we've just initialized a new group, which may not > necessarily be the case if there's more than one device per group. > > Yes, the code was not aware of that possibility. Being honest, I knew about that, but not in my mind when implementing the code. I have just cards where each PF even VF have their own VFIO group. This could be a problem for testing. Anatoly, do you have a system with that peculiarity? > Alejandro, please correct me if I'm wrong, but I think this raises another > issue: vfio_release_device() seems to attempt to close group fd > unconditionally, > which is probably a bad idea if there are more than one device per group. > > Yes, I think so, but not completely sure. Doing a quick look at kernel VFIO code, that seems a problem, but need more time for studying the code again. Again, not having hardware with this peculiarity will make the process harder. > Would you be so kind to come up with a patch to fix this oversight, or > should I do it? :) > > Yes, I will work on this as a priority and send a patch asap. Andrew, could you test this hotplug option in some way with your systems? Thanks > Thanks, > Anatoly >