1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2022, Oracle and/or its affiliates.
4 * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved
6 #ifndef _IOVA_BITMAP_H_
7 #define _IOVA_BITMAP_H_
9 #include <linux/types.h>
10 #include <linux/errno.h>
14 typedef int (*iova_bitmap_fn_t)(struct iova_bitmap *bitmap,
15 unsigned long iova, size_t length,
18 #if IS_ENABLED(CONFIG_IOMMUFD_DRIVER)
19 struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length,
20 unsigned long page_size,
22 void iova_bitmap_free(struct iova_bitmap *bitmap);
23 int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque,
25 void iova_bitmap_set(struct iova_bitmap *bitmap,
26 unsigned long iova, size_t length);
28 static inline struct iova_bitmap *iova_bitmap_alloc(unsigned long iova,
30 unsigned long page_size,
36 static inline void iova_bitmap_free(struct iova_bitmap *bitmap)
40 static inline int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque,
46 static inline void iova_bitmap_set(struct iova_bitmap *bitmap,
47 unsigned long iova, size_t length)