Re: [PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-02-18 Thread Nicolin Chen
On Tue, Feb 18, 2025 at 02:08:05PM -0400, Jason Gunthorpe wrote: > On Tue, Feb 18, 2025 at 09:47:50AM -0800, Nicolin Chen wrote: > > > > +int iommufd_veventq_alloc(struct iommufd_ucmd *ucmd) > > > > +{ > > > > + struct iommu_veventq_alloc *cmd = ucmd->cmd; > > > > + struct iommufd_veven

Re: [PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-02-18 Thread Jason Gunthorpe
On Tue, Feb 18, 2025 at 09:47:50AM -0800, Nicolin Chen wrote: > I think we can do: > if (!list_empty(list)) { > struct iommufd_vevent *next; > > next = list_first_entry(list, struct iommufd_vevent, node); > if (next == &veventq->overflow) { >

Re: [PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-02-18 Thread Nicolin Chen
On Tue, Feb 18, 2025 at 05:13:47AM +, Tian, Kevin wrote: > > From: Nicolin Chen > > Sent: Saturday, January 25, 2025 8:31 AM > > + > > +/* > > + * An iommufd_veventq object represents an interface to deliver vIOMMU > > events to > > + * the user space. It is created/destroyed by the user space

Re: [PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-02-18 Thread Nicolin Chen
On Tue, Feb 18, 2025 at 11:29:59AM -0400, Jason Gunthorpe wrote: > On Fri, Jan 24, 2025 at 04:30:34PM -0800, Nicolin Chen wrote: > > + list_add_tail(&vevent->node, &eventq->deliver); > > + vevent->on_list = true; > > + vevent->header.sequence = atomic_read(&veventq->sequence); > > + if (ato

Re: [PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-02-18 Thread Jason Gunthorpe
On Fri, Jan 24, 2025 at 04:30:34PM -0800, Nicolin Chen wrote: > + list_add_tail(&vevent->node, &eventq->deliver); > + vevent->on_list = true; > + vevent->header.sequence = atomic_read(&veventq->sequence); > + if (atomic_read(&veventq->sequence) == INT_MAX) > + atomic_set

RE: [PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-02-17 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Saturday, January 25, 2025 8:31 AM > + > +/* > + * An iommufd_veventq object represents an interface to deliver vIOMMU > events to > + * the user space. It is created/destroyed by the user space and associated > with > + * vIOMMU object(s) during the allocations. s/ob

[PATCH v6 05/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-01-24 Thread Nicolin Chen
Introduce a new IOMMUFD_OBJ_VEVENTQ object for vIOMMU Event Queue that provides user space (VMM) another FD to read the vIOMMU Events. Allow a vIOMMU object to allocate vEVENTQs, with a condition that each vIOMMU can only have one single vEVENTQ per type. Add iommufd_veventq_alloc() with iommufd_