> From: Jason Gunthorpe <jgg@xxxxxxxxxx> > Sent: Tuesday, February 7, 2023 9:27 PM > > On Tue, Feb 07, 2023 at 01:23:35PM +0000, Liu, Yi L wrote: > > > From: Jason Gunthorpe <jgg@xxxxxxxxxx> > > > Sent: Tuesday, February 7, 2023 9:20 PM > > > > > > On Tue, Feb 07, 2023 at 01:19:10PM +0000, Liu, Yi L wrote: > > > > > From: Jason Gunthorpe <jgg@xxxxxxxxxx> > > > > > Sent: Tuesday, February 7, 2023 9:13 PM > > > > > > > > > > On Tue, Feb 07, 2023 at 12:35:48AM +0000, Tian, Kevin wrote: > > > > > > > From: Liu, Yi L <yi.l.liu@xxxxxxxxx> > > > > > > > Sent: Monday, February 6, 2023 11:51 PM > > > > > > > > > > > > > > > From: Jason Gunthorpe <jgg@xxxxxxxxxx> > > > > > > > > Sent: Monday, February 6, 2023 11:11 PM > > > > > > > > > > > > > > > > On Mon, Feb 06, 2023 at 10:09:52AM +0000, Tian, Kevin wrote: > > > > > > > > > It's probably simpler if we always mark DMA owner with > > > vfio_group > > > > > > > > > for the group path, no matter vfio type1 or iommufd compat > is > > > used. > > > > > > > > > This should avoid all the tricky corner cases between the two > > > paths. > > > > > > > > > > > > > > > > Yes > > > > > > > > > > > > > > Then, we have two choices: > > > > > > > > > > > > > > 1) extend iommufd_device_bind() to allow a caller-specified > DMA > > > > > marker > > > > > > > 2) claim DMA owner before calling iommufd_device_bind(), still > > > need to > > > > > > > extend iommufd_device_bind() to accept a flag to bypass > DMA > > > > > owner > > > > > > > claim > > > > > > > > > > > > > > which one would be better? or do we have a third choice? > > > > > > > > > > > > > > > > > > > first one > > > > > > > > > > Why can't this all be handled in vfio?? > > > > > > > > Are you preferring the second one? Surely VFIO can claim DMA owner > > > > by itself. But it is the vfio iommufd compat mode, so it still needs to call > > > > iommufd_device_bind(). And it should bypass DMA owner claim since > > > > it's already done. > > > > > > No, I mean why can't vfio just call iommufd exactly once regardless of > > > what mode it is running in? > > > > This seems to be moving the DMA owner claim out of > iommufd_device_bind(). > > Is it? Then either group and cdev can claim DMA owner with their own > DMA > > marker. > > No, it has nothing to do with DMA ownership sorry, I'm a bit lost here. Back to Kevin's suggestion. He suggested below. "It's probably simpler if we always mark DMA owner with vfio_group for the group path, no matter vfio type1 or iommufd compat is used. This should avoid all the tricky corner cases between the two paths." This means to enforce the group path uses vfio_group as DMA ownership marker, while cdev path uses iommufd as DMA marker. Then there will be no possibility that the vfio iommufd compat mode group path can share the same DMA ownerhsip marker with cdev path. With this the devices within the same group can only be opened either by group path or cdev path, but no mixture. Regards, Yi Liu