> From: Liu, Yi L <yi.l.liu@xxxxxxxxx> > Sent: Thursday, September 12, 2024 9:17 PM > > There is no helpers for user to check if a given ID is allocated or not, > neither a helper to loop all the allocated IDs in an IDA and do something > for cleanup. With the two needs, a helper to get the lowest allocated ID > of a range and two variants based on it. > > Caller can check if a given ID is allocated or not by: > > bool ida_exists(struct ida *ida, unsigned int id) > > Caller can iterate all allocated IDs by: > > int id; > while ((id = ida_find_first(&pasid_ida)) > 0) { > //anything to do with the allocated ID > ida_free(pasid_ida, pasid); > } > > Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> > Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > Signed-off-by: Yi Liu <yi.l.liu@xxxxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>