Skip to content

Commit

Permalink
drm/i915: add interface to set buffer to be protected
Browse files Browse the repository at this point in the history
add ioctl interface to set buffer to be protected to suppport PXP
virtualization.

Tracked-On: OAM-121827
Signed-off-by: Xue, Bosheng <[email protected]>
  • Loading branch information
bosheng1 committed Sep 10, 2024
1 parent 1d82b0e commit ad6f839
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,7 @@ static const struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF_DRV(I915_QUERY, i915_query_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(I915_GEM_VM_CREATE, i915_gem_vm_create_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(I915_GEM_VM_DESTROY, i915_gem_vm_destroy_ioctl, DRM_RENDER_ALLOW),
PRELIM_DRM_IOCTL_DEF_DRV(I915_PXP_BO_OPS, i915_pxp_bo_ops_ioctl, DRM_RENDER_ALLOW),
PRELIM_DRM_IOCTL_DEF_DRV(I915_PXP_OPS, i915_pxp_ops_ioctl, DRM_RENDER_ALLOW),
};

Expand Down
19 changes: 19 additions & 0 deletions drivers/gpu/drm/i915/pxp/intel_pxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,20 @@ static bool pxp_action_needs_arb_session(u32 action)

return true;
}
int i915_pxp_bo_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile)
{
int ret = 0;
struct prelim_drm_i915_pxp_bo_ops *pxp_bo_ops = data;
struct drm_i915_private *i915 = to_i915(dev);
struct drm_i915_gem_object *obj;
if (!intel_pxp_is_enabled(i915->pxp))
return -ENODEV;

obj = i915_gem_object_lookup_rcu(drmfile, pxp_bo_ops->handle);
obj->flags |= I915_BO_PROTECTED;
intel_pxp_key_check(i915->pxp, obj, pxp_bo_ops->assign);
return 0;
}

int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile)
{
Expand Down Expand Up @@ -957,6 +971,11 @@ void intel_pxp_close(struct intel_pxp *pxp, struct drm_file *drmfile)
{
}

int i915_pxp_bo_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile)
{
return -ENODEV;
}

int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile)
{
return -ENODEV;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/pxp/intel_pxp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int intel_pxp_key_check(struct intel_pxp *pxp,

void intel_pxp_invalidate(struct intel_pxp *pxp);
int i915_pxp_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile);
int i915_pxp_bo_ops_ioctl(struct drm_device *dev, void *data, struct drm_file *drmfile);
void intel_pxp_close(struct intel_pxp *pxp, struct drm_file *drmfile);

#endif /* __INTEL_PXP_H__ */
11 changes: 11 additions & 0 deletions include/uapi/drm/i915_drm_prelim.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#define PRELIM_DRM_IOCTL_I915_PXP_OPS DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_PXP_OPS, \
struct prelim_drm_i915_pxp_ops)

#define PRELIM_DRM_I915_PXP_BO_OPS 0x53

#define PRELIM_DRM_IOCTL_I915_PXP_BO_OPS DRM_IOWR(DRM_COMMAND_BASE + PRELIM_DRM_I915_PXP_BO_OPS, \
struct prelim_drm_i915_pxp_bo_ops)

/* End PRELIM ioctl's */

/*
Expand Down Expand Up @@ -145,5 +150,11 @@ struct prelim_drm_i915_pxp_ops {
__u64 params; /* in/out - pointer to data matching the action */
} __attribute__((packed));

struct prelim_drm_i915_pxp_bo_ops {
__u32 handle;
__u32 assign;
} __attribute__((packed));


#endif /* __I915_DRM_PRELIM_H__ */

0 comments on commit ad6f839

Please sign in to comment.