]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ida: Add ida_find_first_range()
authorYi Liu <yi.l.liu@intel.com>
Fri, 21 Mar 2025 18:01:39 +0000 (11:01 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 25 Mar 2025 13:18:31 +0000 (10:18 -0300)
commit7fe6b987166b901efc5c6fce5fe853c9ebb835be
tree534d7fe14e5d1a11e8daea77c1e42f6504e596ec
parentd57a1fb3425513ec0b02acb9a9f81e5da99b4b85
ida: Add ida_find_first_range()

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);
}

Link: https://patch.msgid.link/r/20250321180143.8468-2-yi.l.liu@intel.com
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
include/linux/idr.h
lib/idr.c
lib/test_ida.c