Skip to content

Commit

Permalink
mad musings
Browse files Browse the repository at this point in the history
  • Loading branch information
jgunthorpe committed Feb 8, 2022
1 parent 4fcc390 commit 6b5b3f2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
21 changes: 21 additions & 0 deletions drivers/iommu/iommufd/device.c
Expand Up @@ -117,6 +117,21 @@ static bool iommufd_hw_pagetable_has_group(struct iommufd_hw_pagetable *hwpt,
return false;
}

static int iommufd_device_attach_sw(struct iommufd_device *idev, u32 *pt_id)
{
struct iommufd_ioas_pagetable *ioaspt;
struct iommufd_object *obj;

obj = iommufd_get_object(idev->ictx, *pt_id,
IOMMUFD_OBJ_IOAS_PAGETABLE);
if (IS_ERR(obj))
return PTR_ERR(obj);
ioaspt = container_of(obj, struct iommufd_ioas_pagetable, obj);
iommufd_put_object_keep_user(obj);
//idev->ioaspt = ioaspt;
return 0;
}

/**
* iommufd_device_attach - Connect a device to a page table
* @idev: device to attach
Expand All @@ -137,6 +152,12 @@ int iommufd_device_attach(struct iommufd_device *idev, u32 *pt_id)

refcount_inc(&idev->obj.users);

if (!idev->dev) {
rc = iommufd_device_attach_sw(idev, pt_id);
if (rc)
goto out_users;
}

hwpt = iommufd_hw_pagetable_from_id(idev->ictx, *pt_id, idev->dev);
if (IS_ERR(hwpt)) {
rc = PTR_ERR(hwpt);
Expand Down
55 changes: 55 additions & 0 deletions include/uapi/linux/iommufd.h
Expand Up @@ -134,4 +134,59 @@ struct iommu_vfio_ioas {
__u16 reserved;
};
#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)

// FIXME: Below here is only an example:
enum {
IOMMU_DRIVER_DATA_NONE = 0,
IOMMU_DRIVER_DATA_INTEL_xxx,
IOMMU_DRIVER_DATA_ARM_xxx,
};

struct iommu_hw_pt_alloc_arm_smmuv3_dd
{
__u32 flags;
__u32 type;
union {
struct {} type1;
struct {} type2;
};
};

struct iommu_hw_pagetable_alloc
{
__u32 size;
__u32 flags;
__u32 ioas_id;
__u32 out_hw_pt_id;
__u32 nested_hw_pt_id;
__u32 device_id;
__u32 driver_data_type; // of IOMMU_DRIVER_DATA_*
__u32 driver_data_len;
__u32 __reserved;
__aligned_u64 driver_data;
};

#define IOMMU_HW_PAGETABLE_ALLOC \
_IO(IOMMUFD_TYPE, IOMMUFD_CMD_HW_PAGETABLE_ALLOC)

struct iommu_hw_device_info_intel_xxx
{
__u32 intel_thing1;
__u32 intel_thing2;
};

struct iommu_hw_device_info
{
__u32 size;
__u32 flags;
__u32 device_id;
__u32 drvier_data_type;
__u32 driver_data_len;
__u32 __reserved;
__aligned_u64 driver_data;
__u32 general_thing1;
__u32 general_thing2;
__u32 general_thing3;
};

#endif

0 comments on commit 6b5b3f2

Please sign in to comment.