Skip to content

Commit d1b3dad

Browse files
nicolincjgunthorpe
authored andcommitted
iommufd: Move struct iommufd_object to public iommufd header
Prepare for an embedded structure design for driver-level iommufd_viommu objects: // include/linux/iommufd.h struct iommufd_viommu { struct iommufd_object obj; .... }; // Some IOMMU driver struct iommu_driver_viommu { struct iommufd_viommu core; .... }; It has to expose struct iommufd_object and enum iommufd_object_type from the core-level private header to the public iommufd header. Link: https://patch.msgid.link/r/54a43b0768089d690104530754f499ca05ce0074.1730836219.git.nicolinc@nvidia.com Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent c9d6ee6 commit d1b3dad

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

drivers/iommu/iommufd/iommufd_private.h

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#define __IOMMUFD_PRIVATE_H
66

77
#include <linux/iommu.h>
8+
#include <linux/iommufd.h>
89
#include <linux/iova_bitmap.h>
9-
#include <linux/refcount.h>
1010
#include <linux/rwsem.h>
1111
#include <linux/uaccess.h>
1212
#include <linux/xarray.h>
@@ -126,29 +126,6 @@ static inline int iommufd_ucmd_respond(struct iommufd_ucmd *ucmd,
126126
return 0;
127127
}
128128

129-
enum iommufd_object_type {
130-
IOMMUFD_OBJ_NONE,
131-
IOMMUFD_OBJ_ANY = IOMMUFD_OBJ_NONE,
132-
IOMMUFD_OBJ_DEVICE,
133-
IOMMUFD_OBJ_HWPT_PAGING,
134-
IOMMUFD_OBJ_HWPT_NESTED,
135-
IOMMUFD_OBJ_IOAS,
136-
IOMMUFD_OBJ_ACCESS,
137-
IOMMUFD_OBJ_FAULT,
138-
#ifdef CONFIG_IOMMUFD_TEST
139-
IOMMUFD_OBJ_SELFTEST,
140-
#endif
141-
IOMMUFD_OBJ_MAX,
142-
};
143-
144-
/* Base struct for all objects with a userspace ID handle. */
145-
struct iommufd_object {
146-
refcount_t shortterm_users;
147-
refcount_t users;
148-
enum iommufd_object_type type;
149-
unsigned int id;
150-
};
151-
152129
static inline bool iommufd_lock_obj(struct iommufd_object *obj)
153130
{
154131
if (!refcount_inc_not_zero(&obj->users))

include/linux/iommufd.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/err.h>
1010
#include <linux/errno.h>
11+
#include <linux/refcount.h>
1112
#include <linux/types.h>
1213

1314
struct device;
@@ -18,6 +19,29 @@ struct iommufd_ctx;
1819
struct iommufd_device;
1920
struct page;
2021

22+
enum iommufd_object_type {
23+
IOMMUFD_OBJ_NONE,
24+
IOMMUFD_OBJ_ANY = IOMMUFD_OBJ_NONE,
25+
IOMMUFD_OBJ_DEVICE,
26+
IOMMUFD_OBJ_HWPT_PAGING,
27+
IOMMUFD_OBJ_HWPT_NESTED,
28+
IOMMUFD_OBJ_IOAS,
29+
IOMMUFD_OBJ_ACCESS,
30+
IOMMUFD_OBJ_FAULT,
31+
#ifdef CONFIG_IOMMUFD_TEST
32+
IOMMUFD_OBJ_SELFTEST,
33+
#endif
34+
IOMMUFD_OBJ_MAX,
35+
};
36+
37+
/* Base struct for all objects with a userspace ID handle. */
38+
struct iommufd_object {
39+
refcount_t shortterm_users;
40+
refcount_t users;
41+
enum iommufd_object_type type;
42+
unsigned int id;
43+
};
44+
2145
struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
2246
struct device *dev, u32 *id);
2347
void iommufd_device_unbind(struct iommufd_device *idev);

0 commit comments

Comments
 (0)